amdgpu: remove json package dependence
Except CUnit library, no additional external library should be needed when compiling amdgpu_test. This will keep this binary self containing. Suggested-by: Christian König <christian.koenig@amd.com> Acked-by: Christian König <christian.koenig@amd.com> Reviewed-by: Tao Zhou <tao.zhou1@amd.com> Signed-off-by: Guchun Chen <guchun.chen@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>main
parent
827a2a2042
commit
cb637bc17b
18
configure.ac
18
configure.ac
|
@ -430,24 +430,10 @@ if test "x$AMDGPU" != xno; then
|
||||||
AC_SUBST([CUNIT_CFLAGS])
|
AC_SUBST([CUNIT_CFLAGS])
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Detect json-c library
|
|
||||||
PKG_CHECK_MODULES([JSONC], [json-c >= 0.10.1], [have_jsonc=yes], [have_jsonc=no])
|
|
||||||
if test "x${have_jsonc}" = "xno"; then
|
|
||||||
AC_CHECK_LIB([json-c], [json_object_object_get], [have_jsonc=yes], [have_jsonc=no])
|
|
||||||
if test "x${have_jsonc}" = "xyes"; then
|
|
||||||
JSONC_LIBS="-ljson-c"
|
|
||||||
JSONC_CFLAGS=""
|
|
||||||
AC_SUBST([JSONC_LIBS])
|
|
||||||
AC_SUBST([JSONC_CFLAGS])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
have_cunit=no
|
have_cunit=no
|
||||||
have_jsonc=no
|
|
||||||
fi
|
fi
|
||||||
AM_CONDITIONAL(HAVE_CUNIT, [test "x$have_cunit" != "xno"])
|
AM_CONDITIONAL(HAVE_CUNIT, [test "x$have_cunit" != "xno"])
|
||||||
AM_CONDITIONAL(HAVE_JSONC, [test "x$have_jsonc" != "xno"])
|
|
||||||
|
|
||||||
AM_CONDITIONAL(HAVE_AMDGPU, [test "x$AMDGPU" = xyes])
|
AM_CONDITIONAL(HAVE_AMDGPU, [test "x$AMDGPU" = xyes])
|
||||||
if test "x$AMDGPU" = xyes; then
|
if test "x$AMDGPU" = xyes; then
|
||||||
|
@ -456,10 +442,6 @@ if test "x$AMDGPU" = xyes; then
|
||||||
if test "x$have_cunit" = "xno"; then
|
if test "x$have_cunit" = "xno"; then
|
||||||
AC_MSG_WARN([Could not find cunit library. Disabling amdgpu tests])
|
AC_MSG_WARN([Could not find cunit library. Disabling amdgpu tests])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$have_jsonc" = "xno"; then
|
|
||||||
AC_MSG_WARN([Could not find json-c library. Disabling amdgpu tests])
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
AC_DEFINE(HAVE_AMDGPU, 0)
|
AC_DEFINE(HAVE_AMDGPU, 0)
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -222,7 +222,6 @@ libdrm_c_args = warn_c_args + ['-fvisibility=hidden']
|
||||||
|
|
||||||
dep_pciaccess = dependency('pciaccess', version : '>= 0.10', required : with_intel)
|
dep_pciaccess = dependency('pciaccess', version : '>= 0.10', required : with_intel)
|
||||||
dep_cunit = dependency('cunit', version : '>= 2.1', required : false)
|
dep_cunit = dependency('cunit', version : '>= 2.1', required : false)
|
||||||
dep_json = dependency('json-c', version : '>= 0.10.1', required : false)
|
|
||||||
_cairo_tests = get_option('cairo-tests')
|
_cairo_tests = get_option('cairo-tests')
|
||||||
if _cairo_tests != 'false'
|
if _cairo_tests != 'false'
|
||||||
dep_cairo = dependency('cairo', required : _cairo_tests == 'true')
|
dep_cairo = dependency('cairo', required : _cairo_tests == 'true')
|
||||||
|
|
|
@ -7,8 +7,7 @@ AM_CFLAGS = \
|
||||||
|
|
||||||
LDADD = $(top_builddir)/libdrm.la \
|
LDADD = $(top_builddir)/libdrm.la \
|
||||||
$(top_builddir)/amdgpu/libdrm_amdgpu.la \
|
$(top_builddir)/amdgpu/libdrm_amdgpu.la \
|
||||||
$(CUNIT_LIBS) \
|
$(CUNIT_LIBS)
|
||||||
$(JSONC_LIBS)
|
|
||||||
|
|
||||||
if HAVE_INSTALL_TESTS
|
if HAVE_INSTALL_TESTS
|
||||||
bin_PROGRAMS = \
|
bin_PROGRAMS = \
|
||||||
|
@ -18,7 +17,7 @@ noinst_PROGRAMS = \
|
||||||
amdgpu_test
|
amdgpu_test
|
||||||
endif
|
endif
|
||||||
|
|
||||||
amdgpu_test_CPPFLAGS = $(CUNIT_CFLAGS) $(JSONC_CFLAGS)
|
amdgpu_test_CPPFLAGS = $(CUNIT_CFLAGS)
|
||||||
|
|
||||||
amdgpu_test_SOURCES = \
|
amdgpu_test_SOURCES = \
|
||||||
amdgpu_test.c \
|
amdgpu_test.c \
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
if dep_cunit.found() and dep_json.found()
|
if dep_cunit.found()
|
||||||
amdgpu_test = executable(
|
amdgpu_test = executable(
|
||||||
'amdgpu_test',
|
'amdgpu_test',
|
||||||
files(
|
files(
|
||||||
|
@ -26,19 +26,9 @@ if dep_cunit.found() and dep_json.found()
|
||||||
'vce_tests.c', 'uvd_enc_tests.c', 'vcn_tests.c', 'deadlock_tests.c',
|
'vce_tests.c', 'uvd_enc_tests.c', 'vcn_tests.c', 'deadlock_tests.c',
|
||||||
'vm_tests.c', 'ras_tests.c', 'syncobj_tests.c',
|
'vm_tests.c', 'ras_tests.c', 'syncobj_tests.c',
|
||||||
),
|
),
|
||||||
dependencies : [dep_cunit, dep_json, dep_threads],
|
dependencies : [dep_cunit, dep_threads],
|
||||||
include_directories : [inc_root, inc_drm, include_directories('../../amdgpu')],
|
include_directories : [inc_root, inc_drm, include_directories('../../amdgpu')],
|
||||||
link_with : [libdrm, libdrm_amdgpu],
|
link_with : [libdrm, libdrm_amdgpu],
|
||||||
install : with_install_tests,
|
install : with_install_tests,
|
||||||
)
|
)
|
||||||
|
|
||||||
configure_file(input : '../../data/amdgpu_ras.json',
|
|
||||||
output : 'amdgpu_ras.json',
|
|
||||||
configuration : configuration_data())
|
|
||||||
|
|
||||||
install_data(
|
|
||||||
'../../data/amdgpu_ras.json',
|
|
||||||
install_mode : 'rw-r--r--',
|
|
||||||
install_dir : datadir_amdgpu,
|
|
||||||
)
|
|
||||||
endif
|
endif
|
|
@ -30,7 +30,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "xf86drm.h"
|
#include "xf86drm.h"
|
||||||
#include "json.h"
|
#include "stdlib.h"
|
||||||
|
|
||||||
const char *ras_block_string[] = {
|
const char *ras_block_string[] = {
|
||||||
"umc",
|
"umc",
|
||||||
|
@ -775,169 +775,12 @@ static void amdgpu_ras_enable_test(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _json_get_block_id(json_object *block_obj, const char *name)
|
|
||||||
{
|
|
||||||
json_object *item_obj, *index_obj;
|
|
||||||
|
|
||||||
if (!json_object_object_get_ex(block_obj, name, &item_obj))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (!json_object_object_get_ex(item_obj, "index", &index_obj))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return json_object_get_int(index_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _json_get_subblock_id(json_object *block_obj, const char *block_name,
|
|
||||||
const char *subblock_name)
|
|
||||||
{
|
|
||||||
json_object *item_obj, *subblock_obj, *name_obj;
|
|
||||||
|
|
||||||
if (!json_object_object_get_ex(block_obj, block_name, &item_obj))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (!json_object_object_get_ex(item_obj, "subblock", &subblock_obj))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (!json_object_object_get_ex(subblock_obj, subblock_name, &name_obj))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return json_object_get_int(name_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int amdgpu_ras_get_test_items(struct ras_test_item **pitems, int *size)
|
static int amdgpu_ras_get_test_items(struct ras_test_item **pitems, int *size)
|
||||||
{
|
{
|
||||||
json_object *root_obj = NULL;
|
*pitems = NULL;
|
||||||
json_object *block_obj = NULL;
|
*size = 0;
|
||||||
json_object *type_obj = NULL;
|
|
||||||
json_object *tests_obj = NULL;
|
|
||||||
json_object *test_obj = NULL;
|
|
||||||
json_object *tmp_obj = NULL;
|
|
||||||
json_object *tmp_type_obj = NULL;
|
|
||||||
json_object *subblock_obj = NULL;
|
|
||||||
int i, length;
|
|
||||||
struct ras_test_item *items = NULL;
|
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
root_obj = json_object_from_file("./amdgpu_ras.json");
|
return 0;
|
||||||
if (!root_obj)
|
|
||||||
root_obj = json_object_from_file(
|
|
||||||
"/usr/share/libdrm/amdgpu_ras.json");
|
|
||||||
|
|
||||||
if (!root_obj) {
|
|
||||||
CU_FAIL_FATAL("Couldn't find amdgpu_ras.json");
|
|
||||||
goto pro_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check Version */
|
|
||||||
if (!json_object_object_get_ex(root_obj, "version", &tmp_obj)) {
|
|
||||||
CU_FAIL_FATAL("Wrong format of amdgpu_ras.json");
|
|
||||||
goto pro_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Block Definition */
|
|
||||||
if (!json_object_object_get_ex(root_obj, "block", &block_obj)) {
|
|
||||||
fprintf(stderr, "block isn't defined\n");
|
|
||||||
goto pro_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Type Definition */
|
|
||||||
if (!json_object_object_get_ex(root_obj, "type", &type_obj)) {
|
|
||||||
fprintf(stderr, "type isn't defined\n");
|
|
||||||
goto pro_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enumulate test items */
|
|
||||||
if (!json_object_object_get_ex(root_obj, "tests", &tests_obj)) {
|
|
||||||
fprintf(stderr, "tests are empty\n");
|
|
||||||
goto pro_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
length = json_object_array_length(tests_obj);
|
|
||||||
|
|
||||||
items = malloc(sizeof(struct ras_test_item) * length);
|
|
||||||
if (!items) {
|
|
||||||
fprintf(stderr, "malloc failed\n");
|
|
||||||
goto pro_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
|
||||||
test_obj = json_object_array_get_idx(tests_obj, i);
|
|
||||||
|
|
||||||
/* Name */
|
|
||||||
if (!json_object_object_get_ex(test_obj, "name", &tmp_obj)) {
|
|
||||||
fprintf(stderr, "Test %d has no name\n", i);
|
|
||||||
goto pro_end;
|
|
||||||
}
|
|
||||||
strncpy(items[i].name, json_object_get_string(tmp_obj), 64);
|
|
||||||
|
|
||||||
/* block */
|
|
||||||
if (!json_object_object_get_ex(test_obj, "block", &tmp_obj)) {
|
|
||||||
fprintf(stderr, "Test:%s: block isn't defined\n",
|
|
||||||
items[i].name);
|
|
||||||
goto pro_end;
|
|
||||||
}
|
|
||||||
items[i].block = _json_get_block_id(
|
|
||||||
block_obj, json_object_get_string(tmp_obj));
|
|
||||||
|
|
||||||
/* check block id */
|
|
||||||
if (items[i].block < AMDGPU_RAS_BLOCK__UMC ||
|
|
||||||
items[i].block >= AMDGPU_RAS_BLOCK__LAST) {
|
|
||||||
fprintf(stderr, "Test:%s: block id %d is invalid\n",
|
|
||||||
items[i].name, items[i].block);
|
|
||||||
goto pro_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* subblock */
|
|
||||||
if (json_object_object_get_ex(test_obj, "subblock", &tmp_obj)) {
|
|
||||||
json_object_object_get_ex(test_obj, "block",
|
|
||||||
&subblock_obj);
|
|
||||||
|
|
||||||
items[i].sub_block = _json_get_subblock_id(
|
|
||||||
block_obj,
|
|
||||||
json_object_get_string(subblock_obj),
|
|
||||||
json_object_get_string(tmp_obj));
|
|
||||||
if (items[i].sub_block < 0) {
|
|
||||||
fprintf(stderr, "Test:%s: subblock in block id %d is invalid\n",
|
|
||||||
items[i].name, items[i].block);
|
|
||||||
goto pro_end;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
items[i].sub_block = 0;
|
|
||||||
|
|
||||||
/* type */
|
|
||||||
if (json_object_object_get_ex(test_obj, "type", &tmp_obj)) {
|
|
||||||
strncpy(items[i].error_type_str,
|
|
||||||
json_object_get_string(tmp_obj), 64);
|
|
||||||
|
|
||||||
if (json_object_object_get_ex(type_obj,
|
|
||||||
json_object_get_string(tmp_obj), &tmp_type_obj))
|
|
||||||
items[i].type = json_object_get_int(tmp_type_obj);
|
|
||||||
else
|
|
||||||
items[i].type = (enum amdgpu_ras_error_type)0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* address */
|
|
||||||
if (json_object_object_get_ex(test_obj, "address", &tmp_obj))
|
|
||||||
items[i].address = json_object_get_int(tmp_obj);
|
|
||||||
else
|
|
||||||
items[i].address = 0; /* default address 0 */
|
|
||||||
|
|
||||||
/* value */
|
|
||||||
if (json_object_object_get_ex(test_obj, "value", &tmp_obj))
|
|
||||||
items[i].value = json_object_get_int(tmp_obj);
|
|
||||||
else
|
|
||||||
items[i].value = 0; /* default value 0 */
|
|
||||||
}
|
|
||||||
|
|
||||||
*pitems = items;
|
|
||||||
*size = length;
|
|
||||||
ret = 0;
|
|
||||||
pro_end:
|
|
||||||
if (root_obj)
|
|
||||||
json_object_put(root_obj);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __amdgpu_ras_inject_test(void)
|
static void __amdgpu_ras_inject_test(void)
|
||||||
|
|
Loading…
Reference in New Issue