drm: Branch 'master' - 4 commits
GitLab Mirror <[email protected]> Tue, 7 Jan 2020 19:39:10 +0000 (UTC)
| Newsgroups | gmane.comp.video.dri.patches |
|---|---|
| Message-ID | <[email protected]> |
tests/amdgpu/amdgpu_test.c | 30 ++-- tests/amdgpu/basic_tests.c | 2 tests/amdgpu/cs_tests.c | 1 tests/amdgpu/ras_tests.c | 285 +++++++++++++++++++++---------------------- tests/amdgpu/syncobj_tests.c | 2 5 files changed, 160 insertions(+), 160 deletions(-) New commits: commit 7fdebb02ffb885b635a3a5177cdc803516852d5f Author: Luben Tuikov <[email protected]> Date: Tue Dec 17 17:03:41 2019 -0500 tests/amdgpu: Proper format for "-l" Proper format for command line option "-l", listing the supported and unsupported tests: 1) Add an aligned column header. 2) Align all fields into columns. 3) Fixed length fields, come before the last column, which is a variable length field. 4) Variable length field, which is the name of the test, goes in the last column. 5) If a suite is disabled, do not iterate over its tests, as they'd naturally be all disabled. Now the output looks like this: $sudo ./amdgpu_test -l What: ID: Status: Name Suite: 1: ENABLED: Basic Tests Test: 1: ENABLED: Query Info Test Test: 2: ENABLED: Userptr Test Test: 3: DISABLED: bo eviction Test Test: 4: ENABLED: Command submission Test (GFX) Test: 5: ENABLED: Command submission Test (Compute) Test: 6: ENABLED: Command submission Test (Multi-Fence) Test: 7: ENABLED: Command submission Test (SDMA) Test: 8: ENABLED: SW semaphore Test Test: 9: DISABLED: Sync dependency Test Test: 10: DISABLED: Dispatch Test (Compute) Test: 11: DISABLED: Dispatch Test (GFX) Test: 12: DISABLED: Draw Test Test: 13: DISABLED: GPU reset Test Suite: 2: ENABLED: BO Tests Test: 1: ENABLED: Export/Import Test: 2: DISABLED: Metadata Test: 3: ENABLED: CPU map/unmap Test: 4: ENABLED: Memory alloc Test Test: 5: ENABLED: Memory fail alloc Test Test: 6: ENABLED: Find bo by CPU mapping Suite: 3: DISABLED: CS Tests Suite: 4: DISABLED: VCE Tests Suite: 5: ENABLED: VCN Tests Test: 1: ENABLED: VCN DEC create Test: 2: ENABLED: VCN DEC decode Test: 3: ENABLED: VCN DEC destroy Test: 4: ENABLED: VCN ENC create Test: 5: ENABLED: VCN ENC decode Test: 6: ENABLED: VCN ENC destroy Suite: 6: DISABLED: UVD ENC Tests Suite: 7: DISABLED: Deadlock Tests Suite: 8: ENABLED: VM Tests Test: 1: ENABLED: resere vmid test Test: 2: ENABLED: unaligned map Test: 3: ENABLED: vm mapping test Suite: 9: DISABLED: RAS Tests Suite: 10: ENABLED: SYNCOBJ TIMELINE Tests Test: 1: ENABLED: syncobj timeline test $_ Signed-off-by: Luben Tuikov <[email protected]> diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c index 81870b19..47e16762 100644 --- a/tests/amdgpu/amdgpu_test.c +++ b/tests/amdgpu/amdgpu_test.c @@ -202,44 +202,42 @@ static void display_test_suites(void) CU_pSuite pSuite = NULL; CU_pTest pTest = NULL; - printf("Suites\n"); + printf("%5s: %2s: %8s: %s\n", "What", "ID", "Status", "Name"); for (iSuite = 0; suites[iSuite].pName != NULL; iSuite++) { pSuite = CU_get_suite_by_index((unsigned int) iSuite + 1, - CU_get_registry()); + CU_get_registry()); if (!pSuite) { fprintf(stderr, "Invalid suite id : %d\n", iSuite + 1); continue; } - printf("Suite id = %d: Name '%s status: %s'\n", - iSuite + 1, suites[iSuite].pName, - pSuite->fActive ? "ENABLED" : "DISABLED"); - + printf("Suite: %2d: %8s: %s\n", + iSuite + 1, + pSuite->fActive ? "ENABLED" : "DISABLED", + suites[iSuite].pName); + if (!pSuite->fActive) + continue; for (iTest = 0; suites[iSuite].pTests[iTest].pName != NULL; - iTest++) { - + iTest++) { pTest = CU_get_test_by_index((unsigned int) iTest + 1, - pSuite); - + pSuite); if (!pTest) { fprintf(stderr, "Invalid test id : %d\n", iTest + 1); continue; } - - printf("Test id %d: Name: '%s status: %s'\n", iTest + 1, - suites[iSuite].pTests[iTest].pName, - pSuite->fActive && pTest->fActive ? - "ENABLED" : "DISABLED"); + printf(" Test: %2d: %8s: %s\n", + iTest + 1, + pSuite->fActive && pTest->fActive ? "ENABLED" : "DISABLED", + suites[iSuite].pTests[iTest].pName); } } } - /** Help string for command line parameters */ static const char usage[] = "Usage: %s [-hlpr] [<-s <suite id>> [-t <test id>] [-f]] " commit 680542ce086f5d0ba70331f8d350edfae20c534f Author: Luben Tuikov <[email protected]> Date: Thu Dec 5 22:02:28 2019 -0500 tests/amdgpu: Fix buffer overflow (v3) This patch fixes the following warning: -Wformat-overflow= v2: Use the correct strlcat(3). v3: Use strncat(3) and remove libbsd dependency. Signed-off-by: Luben Tuikov <[email protected]> diff --git a/tests/amdgpu/ras_tests.c b/tests/amdgpu/ras_tests.c index f745166b..810bf172 100644 --- a/tests/amdgpu/ras_tests.c +++ b/tests/amdgpu/ras_tests.c @@ -30,6 +30,9 @@ #include <fcntl.h> #include <stdio.h> #include "xf86drm.h" +#include <limits.h> + +#define PATH_SIZE PATH_MAX #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) @@ -498,7 +501,7 @@ static int get_file_contents(char *file, char *buf, int size); static int amdgpu_ras_lookup_id(drmDevicePtr device) { - char path[1024]; + char path[PATH_SIZE]; char str[128]; drmPciBusInfo info; int i; @@ -507,7 +510,7 @@ static int amdgpu_ras_lookup_id(drmDevicePtr device) for (i = 0; i < MAX_CARDS_SUPPORTED; i++) { memset(str, 0, sizeof(str)); memset(&info, 0, sizeof(info)); - sprintf(path, "/sys/kernel/debug/dri/%d/name", i); + snprintf(path, PATH_SIZE, "/sys/kernel/debug/dri/%d/name", i); if (get_file_contents(path, str, sizeof(str)) <= 0) continue; @@ -525,16 +528,16 @@ static int amdgpu_ras_lookup_id(drmDevicePtr device) //helpers static int test_card; -static char sysfs_path[1024]; -static char debugfs_path[1024]; +static char sysfs_path[PATH_SIZE]; +static char debugfs_path[PATH_SIZE]; static uint32_t ras_mask; static amdgpu_device_handle device_handle; static void set_test_card(int card) { test_card = card; - sprintf(sysfs_path, "/sys/class/drm/card%d/device/ras/", devices[card].id); - sprintf(debugfs_path, "/sys/kernel/debug/dri/%d/ras/", devices[card].id); + snprintf(sysfs_path, PATH_SIZE, "/sys/class/drm/card%d/device/ras/", devices[card].id); + snprintf(debugfs_path, PATH_SIZE, "/sys/kernel/debug/dri/%d/ras/", devices[card].id); ras_mask = devices[card].capability; device_handle = devices[card].device_handle; ras_block_mask_inject = devices[card].test_mask.inject_mask; @@ -605,10 +608,11 @@ static int amdgpu_ras_is_feature_supported(enum amdgpu_ras_block block) static int amdgpu_ras_invoke(struct ras_debug_if *data) { - char path[1024]; + char path[PATH_SIZE]; int ret; - sprintf(path, "%s%s", get_ras_debugfs_root(), "ras_ctrl"); + snprintf(path, sizeof(path), "%s", get_ras_debugfs_root()); + strncat(path, "ras_ctrl", sizeof(path) - strlen(path)); ret = set_file_contents(path, (char *)data, sizeof(*data)) - sizeof(*data); @@ -619,14 +623,16 @@ static int amdgpu_ras_query_err_count(enum amdgpu_ras_block block, unsigned long *ue, unsigned long *ce) { char buf[64]; - char name[1024]; + char name[PATH_SIZE]; *ue = *ce = 0; if (amdgpu_ras_is_feature_supported(block) <= 0) return -1; - sprintf(name, "%s%s%s", get_ras_sysfs_root(), ras_block_str(block), "_err_count"); + snprintf(name, sizeof(name), "%s", get_ras_sysfs_root()); + strncat(name, ras_block_str(block), sizeof(name) - strlen(name)); + strncat(name, "_err_count", sizeof(name) - strlen(name)); if (is_file_ok(name, O_RDONLY)) return 0; @@ -837,7 +843,7 @@ static void amdgpu_ras_basic_test(void) int i; int j; uint32_t features; - char path[1024]; + char path[PATH_SIZE]; ret = is_file_ok("/sys/module/amdgpu/parameters/ras_mask", O_RDONLY); CU_ASSERT_EQUAL(ret, 0); @@ -849,11 +855,15 @@ static void amdgpu_ras_basic_test(void) sizeof(features), &features); CU_ASSERT_EQUAL(ret, 0); - sprintf(path, "%s%s", get_ras_debugfs_root(), "ras_ctrl"); + snprintf(path, sizeof(path), "%s", get_ras_debugfs_root()); + strncat(path, "ras_ctrl", sizeof(path) - strlen(path)); + ret = is_file_ok(path, O_WRONLY); CU_ASSERT_EQUAL(ret, 0); - sprintf(path, "%s%s", get_ras_sysfs_root(), "features"); + snprintf(path, sizeof(path), "%s", get_ras_sysfs_root()); + strncat(path, "features", sizeof(path) - strlen(path)); + ret = is_file_ok(path, O_RDONLY); CU_ASSERT_EQUAL(ret, 0); @@ -865,11 +875,17 @@ static void amdgpu_ras_basic_test(void) if (!((1 << j) & ras_block_mask_basic)) continue; - sprintf(path, "%s%s%s", get_ras_sysfs_root(), ras_block_str(j), "_err_count"); + snprintf(path, sizeof(path), "%s", get_ras_sysfs_root()); + strncat(path, ras_block_str(j), sizeof(path) - strlen(path)); + strncat(path, "_err_count", sizeof(path) - strlen(path)); + ret = is_file_ok(path, O_RDONLY); CU_ASSERT_EQUAL(ret, 0); - sprintf(path, "%s%s%s", get_ras_debugfs_root(), ras_block_str(j), "_err_inject"); + snprintf(path, sizeof(path), "%s", get_ras_debugfs_root()); + strncat(path, ras_block_str(j), sizeof(path) - strlen(path)); + strncat(path, "_err_inject", sizeof(path) - strlen(path)); + ret = is_file_ok(path, O_WRONLY); CU_ASSERT_EQUAL(ret, 0); } commit 4ff499cd85f86a7b5b28f3449de2fbad1b91c795 Author: Luben Tuikov <[email protected]> Date: Thu Dec 5 22:10:43 2019 -0500 tests/amdgpu: Fix unused function warning (v2) This patch fixes: -Wunused-function v2: Always enable amdgpu_ras_test(). Signed-off-by: Luben Tuikov <[email protected]> diff --git a/tests/amdgpu/ras_tests.c b/tests/amdgpu/ras_tests.c index d714be73..f745166b 100644 --- a/tests/amdgpu/ras_tests.c +++ b/tests/amdgpu/ras_tests.c @@ -881,9 +881,7 @@ CU_TestInfo ras_tests[] = { { "ras query test", amdgpu_ras_query_test }, { "ras inject test", amdgpu_ras_inject_test }, { "ras disable test", amdgpu_ras_disable_test }, -#if 0 { "ras enable test", amdgpu_ras_enable_test }, -#endif CU_TEST_INFO_NULL, }; commit fb1634583f3ba22c67cad0df7022b6ac48a40c56 Author: Luben Tuikov <[email protected]> Date: Thu Dec 5 21:05:13 2019 -0500 tests/amdgpu: Fix various warnings This patch fixes the following warnings: -Wformat= -Wmaybe-uninitialized -Wmisleading-indentation -Wstringop-truncation -Wunused-function -Wunused-variable It also removes forward declarations and moves global functions to the bottom, keeping locals at the top, in ras_tests.c. Signed-off-by: Luben Tuikov <[email protected]> diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c index 84f3827d..1f6890e0 100644 --- a/tests/amdgpu/basic_tests.c +++ b/tests/amdgpu/basic_tests.c @@ -3306,7 +3306,7 @@ static void amdgpu_memcpy_draw(amdgpu_device_handle device_handle, int bo_cmd_size = 4096; struct amdgpu_cs_request ibs_request = {0}; struct amdgpu_cs_ib_info ib_info= {0}; - uint32_t hang_state, hangs, expired; + uint32_t expired; amdgpu_bo_list_handle bo_list; struct amdgpu_cs_fence fence_status = {0}; diff --git a/tests/amdgpu/cs_tests.c b/tests/amdgpu/cs_tests.c index 7ad0f0dc..ae4f65f5 100644 --- a/tests/amdgpu/cs_tests.c +++ b/tests/amdgpu/cs_tests.c @@ -358,6 +358,7 @@ static void amdgpu_cs_uvd_decode(void) bs_addr = fb_addr + 4*1024; dpb_addr = ALIGN(bs_addr + sizeof(uvd_bitstream), 4*1024); + ctx_addr = 0; if (family_id >= AMDGPU_FAMILY_VI) { if ((family_id == AMDGPU_FAMILY_AI) || (chip_id == chip_rev+0x50 || chip_id == chip_rev+0x5A || diff --git a/tests/amdgpu/ras_tests.c b/tests/amdgpu/ras_tests.c index c1c543c1..d714be73 100644 --- a/tests/amdgpu/ras_tests.c +++ b/tests/amdgpu/ras_tests.c @@ -522,124 +522,6 @@ static int amdgpu_ras_lookup_id(drmDevicePtr device) return -1; } -CU_BOOL suite_ras_tests_enable(void) -{ - amdgpu_device_handle device_handle; - uint32_t major_version; - uint32_t minor_version; - int i; - drmDevicePtr device; - - for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) { - if (amdgpu_device_initialize(drm_amdgpu[i], &major_version, - &minor_version, &device_handle)) - continue; - - if (drmGetDevice2(drm_amdgpu[i], - DRM_DEVICE_GET_PCI_REVISION, - &device)) - continue; - - if (device->bustype == DRM_BUS_PCI && - amdgpu_ras_lookup_capability(device_handle)) { - amdgpu_device_deinitialize(device_handle); - return CU_TRUE; - } - - if (amdgpu_device_deinitialize(device_handle)) - continue; - } - - return CU_FALSE; -} - -int suite_ras_tests_init(void) -{ - drmDevicePtr device; - amdgpu_device_handle device_handle; - uint32_t major_version; - uint32_t minor_version; - uint32_t capability; - struct ras_test_mask test_mask; - int id; - int i; - int r; - - for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) { - r = amdgpu_device_initialize(drm_amdgpu[i], &major_version, - &minor_version, &device_handle); - if (r) - continue; - - if (drmGetDevice2(drm_amdgpu[i], - DRM_DEVICE_GET_PCI_REVISION, - &device)) { - amdgpu_device_deinitialize(device_handle); - continue; - } - - if (device->bustype != DRM_BUS_PCI) { - amdgpu_device_deinitialize(device_handle); - continue; - } - - capability = amdgpu_ras_lookup_capability(device_handle); - if (capability == 0) { - amdgpu_device_deinitialize(device_handle); - continue; - - } - - id = amdgpu_ras_lookup_id(device); - if (id == -1) { - amdgpu_device_deinitialize(device_handle); - continue; - } - - test_mask = amdgpu_ras_get_test_mask(device); - - devices[devices_count++] = (struct amdgpu_ras_data) { - device_handle, id, capability, test_mask, - }; - } - - if (devices_count == 0) - return CUE_SINIT_FAILED; - - return CUE_SUCCESS; -} - -int suite_ras_tests_clean(void) -{ - int r; - int i; - int ret = CUE_SUCCESS; - - for (i = 0; i < devices_count; i++) { - r = amdgpu_device_deinitialize(devices[i].device_handle); - if (r) - ret = CUE_SCLEAN_FAILED; - } - return ret; -} - -static void amdgpu_ras_disable_test(void); -static void amdgpu_ras_enable_test(void); -static void amdgpu_ras_inject_test(void); -static void amdgpu_ras_query_test(void); -static void amdgpu_ras_basic_test(void); - -CU_TestInfo ras_tests[] = { - { "ras basic test", amdgpu_ras_basic_test }, - { "ras query test", amdgpu_ras_query_test }, - { "ras inject test", amdgpu_ras_inject_test }, - { "ras disable test", amdgpu_ras_disable_test }, -#if 0 - { "ras enable test", amdgpu_ras_enable_test }, -#endif - CU_TEST_INFO_NULL, -}; - //helpers static int test_card; @@ -648,10 +530,8 @@ static char debugfs_path[1024]; static uint32_t ras_mask; static amdgpu_device_handle device_handle; -static int set_test_card(int card) +static void set_test_card(int card) { - int i; - test_card = card; sprintf(sysfs_path, "/sys/class/drm/card%d/device/ras/", devices[card].id); sprintf(debugfs_path, "/sys/kernel/debug/dri/%d/ras/", devices[card].id); @@ -660,8 +540,6 @@ static int set_test_card(int card) ras_block_mask_inject = devices[card].test_mask.inject_mask; ras_block_mask_query = devices[card].test_mask.query_mask; ras_block_mask_basic = devices[card].test_mask.basic_mask; - - return 0; } static const char *get_ras_sysfs_root(void) @@ -742,7 +620,6 @@ static int amdgpu_ras_query_err_count(enum amdgpu_ras_block block, { char buf[64]; char name[1024]; - int ret; *ue = *ce = 0; @@ -779,7 +656,7 @@ static int amdgpu_ras_inject(enum amdgpu_ras_block block, inject->head.block = block; inject->head.type = type; inject->head.sub_block_index = sub_block; - strncpy(inject->head.name, ras_block_str(block), 32); + strncpy(inject->head.name, ras_block_str(block), sizeof(inject->head.name)-1); inject->address = address; inject->value = value; @@ -956,8 +833,6 @@ static void amdgpu_ras_query_test(void) static void amdgpu_ras_basic_test(void) { - unsigned long ue, ce; - char name[1024]; int ret; int i; int j; @@ -1000,3 +875,115 @@ static void amdgpu_ras_basic_test(void) } } } + +CU_TestInfo ras_tests[] = { + { "ras basic test", amdgpu_ras_basic_test }, + { "ras query test", amdgpu_ras_query_test }, + { "ras inject test", amdgpu_ras_inject_test }, + { "ras disable test", amdgpu_ras_disable_test }, +#if 0 + { "ras enable test", amdgpu_ras_enable_test }, +#endif + CU_TEST_INFO_NULL, +}; + +CU_BOOL suite_ras_tests_enable(void) +{ + amdgpu_device_handle device_handle; + uint32_t major_version; + uint32_t minor_version; + int i; + drmDevicePtr device; + + for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) { + if (amdgpu_device_initialize(drm_amdgpu[i], &major_version, + &minor_version, &device_handle)) + continue; + + if (drmGetDevice2(drm_amdgpu[i], + DRM_DEVICE_GET_PCI_REVISION, + &device)) + continue; + + if (device->bustype == DRM_BUS_PCI && + amdgpu_ras_lookup_capability(device_handle)) { + amdgpu_device_deinitialize(device_handle); + return CU_TRUE; + } + + if (amdgpu_device_deinitialize(device_handle)) + continue; + } + + return CU_FALSE; +} + +int suite_ras_tests_init(void) +{ + drmDevicePtr device; + amdgpu_device_handle device_handle; + uint32_t major_version; + uint32_t minor_version; + uint32_t capability; + struct ras_test_mask test_mask; + int id; + int i; + int r; + + for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) { + r = amdgpu_device_initialize(drm_amdgpu[i], &major_version, + &minor_version, &device_handle); + if (r) + continue; + + if (drmGetDevice2(drm_amdgpu[i], + DRM_DEVICE_GET_PCI_REVISION, + &device)) { + amdgpu_device_deinitialize(device_handle); + continue; + } + + if (device->bustype != DRM_BUS_PCI) { + amdgpu_device_deinitialize(device_handle); + continue; + } + + capability = amdgpu_ras_lookup_capability(device_handle); + if (capability == 0) { + amdgpu_device_deinitialize(device_handle); + continue; + + } + + id = amdgpu_ras_lookup_id(device); + if (id == -1) { + amdgpu_device_deinitialize(device_handle); + continue; + } + + test_mask = amdgpu_ras_get_test_mask(device); + + devices[devices_count++] = (struct amdgpu_ras_data) { + device_handle, id, capability, test_mask, + }; + } + + if (devices_count == 0) + return CUE_SINIT_FAILED; + + return CUE_SUCCESS; +} + +int suite_ras_tests_clean(void) +{ + int r; + int i; + int ret = CUE_SUCCESS; + + for (i = 0; i < devices_count; i++) { + r = amdgpu_device_deinitialize(devices[i].device_handle); + if (r) + ret = CUE_SCLEAN_FAILED; + } + return ret; +} diff --git a/tests/amdgpu/syncobj_tests.c b/tests/amdgpu/syncobj_tests.c index 869ed88e..3a7b38eb 100644 --- a/tests/amdgpu/syncobj_tests.c +++ b/tests/amdgpu/syncobj_tests.c @@ -96,7 +96,7 @@ static int syncobj_command_submission_helper(uint32_t syncobj_handle, bool struct amdgpu_cs_fence fence_status; amdgpu_bo_list_handle bo_list; amdgpu_va_handle va_handle; - uint32_t expired, flags; + uint32_t expired; int i, r; uint64_t seq_no; static uint32_t *ptr; --