aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlora Cui <flora.cui@amd.com>2019-04-22 15:57:23 +0800
committerFlora Cui <flora.cui@amd.com>2019-07-19 16:42:28 +0800
commit3aba0f3889e88ac7d08d2e3e8b0f181893dba97a (patch)
treeeb84e5c7d6adb696249529f2daef6d27edf4dc7d
parent0247b19dc0d61408fe3a5d2954468f28e6bfe200 (diff)
downloadexternal_libdrm-3aba0f3889e88ac7d08d2e3e8b0f181893dba97a.tar.gz
external_libdrm-3aba0f3889e88ac7d08d2e3e8b0f181893dba97a.tar.bz2
external_libdrm-3aba0f3889e88ac7d08d2e3e8b0f181893dba97a.zip
tests/amdgpu: add gpu reset test
1. perform gpu reset 2. perform dispatch test to verify gpu reset to a good state Signed-off-by: Flora Cui <flora.cui@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
-rw-r--r--tests/amdgpu/amdgpu_test.c5
-rw-r--r--tests/amdgpu/basic_tests.c41
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
index 73403fb4..0c9364a6 100644
--- a/tests/amdgpu/amdgpu_test.c
+++ b/tests/amdgpu/amdgpu_test.c
@@ -472,6 +472,11 @@ static void amdgpu_disable_suites()
if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV)
if (amdgpu_set_test_active(BASIC_TESTS_STR, "Draw Test", CU_FALSE))
fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
+
+ /* This test was ran on GFX9 only */
+ if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV)
+ if (amdgpu_set_test_active(BASIC_TESTS_STR, "GPU reset Test", CU_FALSE))
+ fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
}
/* The main() function for setting up and running the tests.
diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c
index 8fa7088d..938106e8 100644
--- a/tests/amdgpu/basic_tests.c
+++ b/tests/amdgpu/basic_tests.c
@@ -24,6 +24,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sys/types.h>
+#ifdef MAJOR_IN_SYSMACROS
+#include <sys/sysmacros.h>
+#endif
+#include <sys/stat.h>
+#include <fcntl.h>
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
@@ -51,6 +57,7 @@ static void amdgpu_sync_dependency_test(void);
static void amdgpu_bo_eviction_test(void);
static void amdgpu_dispatch_test(void);
static void amdgpu_draw_test(void);
+static void amdgpu_gpu_reset_test(void);
static void amdgpu_command_submission_write_linear_helper(unsigned ip_type);
static void amdgpu_command_submission_const_fill_helper(unsigned ip_type);
@@ -74,6 +81,7 @@ CU_TestInfo basic_tests[] = {
{ "Sync dependency Test", amdgpu_sync_dependency_test },
{ "Dispatch Test", amdgpu_dispatch_test },
{ "Draw Test", amdgpu_draw_test },
+ { "GPU reset Test", amdgpu_gpu_reset_test },
CU_TEST_INFO_NULL,
};
#define BUFFER_SIZE (8 * 1024)
@@ -3131,3 +3139,36 @@ static void amdgpu_draw_test(void)
amdgpu_memcpy_draw_test(device_handle, ring_id);
}
}
+
+static void amdgpu_gpu_reset_test(void)
+{
+ int r;
+ char debugfs_path[256], tmp[10];
+ int fd;
+ struct stat sbuf;
+ amdgpu_context_handle context_handle;
+ uint32_t hang_state, hangs;
+
+ r = amdgpu_cs_ctx_create(device_handle, &context_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = fstat(drm_amdgpu[0], &sbuf);
+ CU_ASSERT_EQUAL(r, 0);
+
+ sprintf(debugfs_path, "/sys/kernel/debug/dri/%d/amdgpu_gpu_recover", minor(sbuf.st_rdev));
+ fd = open(debugfs_path, O_RDONLY);
+ CU_ASSERT(fd >= 0);
+
+ r = read(fd, tmp, sizeof(tmp)/sizeof(char));
+ CU_ASSERT(r > 0);
+
+ r = amdgpu_cs_query_reset_state(context_handle, &hang_state, &hangs);
+ CU_ASSERT_EQUAL(r, 0);
+ CU_ASSERT_EQUAL(hang_state, AMDGPU_CTX_UNKNOWN_RESET);
+
+ close(fd);
+ r = amdgpu_cs_ctx_free(context_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+ amdgpu_dispatch_test();
+}