[PATCH i-g-t] lib/amdgpu: enhance sdma test
Jesse.zhang@amd.com
jesse.zhang at amd.com
Fri Sep 27 09:09:51 UTC 2024
The sdma may have multiple rings,
each of which should be tested.
Cc: Vitaly Prosyak <vitaly.prosyak at amd.com>
Cc: Alex Deucher <alexander.deucher at amd.com>
Cc: Christian Koenig <christian.koenig at amd.com>
Signed-off-by: Jesse Zhang <jesse.zhang at amd.com>
---
lib/amdgpu/amd_deadlock_helpers.c | 45 +++++++++++++++++++++++++++----
lib/amdgpu/amd_deadlock_helpers.h | 5 ++--
tests/amdgpu/amd_deadlock.c | 18 ++++++-------
3 files changed, 51 insertions(+), 17 deletions(-)
diff --git a/lib/amdgpu/amd_deadlock_helpers.c b/lib/amdgpu/amd_deadlock_helpers.c
index c71272e58..851f096b9 100644
--- a/lib/amdgpu/amd_deadlock_helpers.c
+++ b/lib/amdgpu/amd_deadlock_helpers.c
@@ -169,8 +169,8 @@ amdgpu_wait_memory_helper(amdgpu_device_handle device_handle, unsigned int ip_ty
free_cmd_base(base_cmd);
}
-void
-bad_access_helper(amdgpu_device_handle device_handle, unsigned int cmd_error, unsigned int ip_type)
+static void
+bad_access_helper(amdgpu_device_handle device_handle, unsigned int cmd_error, unsigned int ip_type, unsigned int ring_id)
{
const struct amdgpu_ip_block_version *ip_block = NULL;
@@ -190,7 +190,7 @@ bad_access_helper(amdgpu_device_handle device_handle, unsigned int cmd_error, un
ring_context->pm4 = calloc(pm4_dw, sizeof(*ring_context->pm4));
ring_context->pm4_size = pm4_dw;
ring_context->res_cnt = 1;
- ring_context->ring_id = 0;
+ ring_context->ring_id = ring_id;
igt_assert(ring_context->pm4);
ip_block = get_ip_block(device_handle, ip_type);
r = amdgpu_bo_alloc_and_map(device_handle,
@@ -216,11 +216,27 @@ bad_access_helper(amdgpu_device_handle device_handle, unsigned int cmd_error, un
free(ring_context);
}
+void bad_access_ring_helper(amdgpu_device_handle device_handle, unsigned int cmd_error, unsigned int ip_type)
+{
+ int r;
+ struct drm_amdgpu_info_hw_ip info;
+ uint32_t ring_id;
+
+ r = amdgpu_query_hw_ip_info(device_handle, ip_type, 0, &info);
+ igt_assert_eq(r, 0);
+ if (!info.available_rings)
+ igt_info("SKIP ... as there's no ring for ip %d\n", ip_type);
+
+ for (ring_id = 0; (1 << ring_id) & info.available_rings; ring_id++) {
+ bad_access_helper(device_handle, cmd_error, ip_type, ring_id);
+ }
+}
+
#define MAX_DMABUF_COUNT 0x20000
#define MAX_DWORD_COUNT 256
-void
-amdgpu_hang_sdma_helper(amdgpu_device_handle device_handle, uint8_t hang_type)
+static void
+amdgpu_hang_sdma_helper(amdgpu_device_handle device_handle, uint8_t hang_type, unsigned int ring_id)
{
int j, r;
uint32_t *ptr, offset;
@@ -240,6 +256,7 @@ amdgpu_hang_sdma_helper(amdgpu_device_handle device_handle, uint8_t hang_type)
}
ring_context->secure = false;
ring_context->res_cnt = 2;
+ ring_context->ring_id = ring_id;
igt_assert(ring_context->pm4);
r = amdgpu_cs_ctx_create(device_handle, &ring_context->context_handle);
@@ -309,3 +326,21 @@ amdgpu_hang_sdma_helper(amdgpu_device_handle device_handle, uint8_t hang_type)
igt_assert_eq(r, 0);
free_cmd_base(base_cmd);
}
+
+void amdgpu_hang_sdma_ring_helper(amdgpu_device_handle device_handle, uint8_t hang_type)
+{
+ int r;
+ struct drm_amdgpu_info_hw_ip info;
+ uint32_t ring_id;
+
+ r = amdgpu_query_hw_ip_info(device_handle, AMDGPU_HW_IP_DMA, 0, &info);
+ igt_assert_eq(r, 0);
+ if (!info.available_rings)
+ igt_info("SKIP ... as there's no ring for the sdma\n");
+
+ for (ring_id = 0; (1 << ring_id) & info.available_rings; ring_id++) {
+ printf("%s[%d] ring_id:%d ######## \n",__func__,__LINE__,ring_id);
+ amdgpu_hang_sdma_helper(device_handle, hang_type, ring_id);
+ }
+}
+
diff --git a/lib/amdgpu/amd_deadlock_helpers.h b/lib/amdgpu/amd_deadlock_helpers.h
index 165ffb98d..7f8419280 100644
--- a/lib/amdgpu/amd_deadlock_helpers.h
+++ b/lib/amdgpu/amd_deadlock_helpers.h
@@ -26,11 +26,10 @@
void
amdgpu_wait_memory_helper(amdgpu_device_handle device_handle, unsigned int ip_type);
-
void
-bad_access_helper(amdgpu_device_handle device_handle, unsigned int cmd_error, unsigned int ip_type);
+bad_access_ring_helper(amdgpu_device_handle device_handle, unsigned int cmd_error, unsigned int ip_type);
void
-amdgpu_hang_sdma_helper(amdgpu_device_handle device_handle, uint8_t hang_type);
+amdgpu_hang_sdma_ring_helper(amdgpu_device_handle device_handle, uint8_t hang_type);
#endif
diff --git a/tests/amdgpu/amd_deadlock.c b/tests/amdgpu/amd_deadlock.c
index 696fac2eb..b5d053663 100644
--- a/tests/amdgpu/amd_deadlock.c
+++ b/tests/amdgpu/amd_deadlock.c
@@ -73,7 +73,7 @@ igt_main
igt_subtest_with_dynamic("amdgpu-gfx-illegal-reg-access") {
if (arr_cap[AMD_IP_GFX]) {
igt_dynamic_f("amdgpu-illegal-reg-access")
- bad_access_helper(device, CMD_STREAM_TRANS_BAD_REG_ADDRESS,
+ bad_access_ring_helper(device, CMD_STREAM_TRANS_BAD_REG_ADDRESS,
AMDGPU_HW_IP_GFX);
}
}
@@ -82,7 +82,7 @@ igt_main
igt_subtest_with_dynamic("amdgpu-gfx-illegal-mem-access") {
if (arr_cap[AMD_IP_GFX]) {
igt_dynamic_f("amdgpu-illegal-mem-access")
- bad_access_helper(device, CMD_STREAM_TRANS_BAD_MEM_ADDRESS,
+ bad_access_ring_helper(device, CMD_STREAM_TRANS_BAD_MEM_ADDRESS,
AMDGPU_HW_IP_GFX);
}
}
@@ -99,7 +99,7 @@ igt_main
igt_describe("Test-GPU-reset-by-access-compute-illegal-mem-addr");
igt_subtest("amdgpu-compute-illegal-mem-access") {
igt_skip_on_f(!arr_cap[AMD_IP_COMPUTE], "SKIP, compute ring don't support\n");
- bad_access_helper(device, CMD_STREAM_TRANS_BAD_MEM_ADDRESS,
+ bad_access_ring_helper(device, CMD_STREAM_TRANS_BAD_MEM_ADDRESS,
AMDGPU_HW_IP_COMPUTE);
}
@@ -115,7 +115,7 @@ igt_main
igt_subtest_with_dynamic("amdgpu-deadlock-sdma-corrupted-header-test") {
if (arr_cap[AMD_IP_DMA]) {
igt_dynamic_f("amdgpu-deadlock-sdma-corrupted-header-test")
- amdgpu_hang_sdma_helper(device, DMA_CORRUPTED_HEADER_HANG);
+ amdgpu_hang_sdma_ring_helper(device, DMA_CORRUPTED_HEADER_HANG);
}
}
@@ -123,7 +123,7 @@ igt_main
igt_subtest_with_dynamic("amdgpu-deadlock-sdma-slow-linear-copy") {
if (arr_cap[AMD_IP_DMA]) {
igt_dynamic_f("amdgpu-deadlock-sdma-slow-linear-copy")
- amdgpu_hang_sdma_helper(device, DMA_SLOW_LINEARCOPY_HANG);
+ amdgpu_hang_sdma_ring_helper(device, DMA_SLOW_LINEARCOPY_HANG);
}
}
@@ -131,7 +131,7 @@ igt_main
igt_subtest_with_dynamic("amdgpu-deadlock-sdma-badop-test") {
if (arr_cap[AMD_IP_DMA]) {
igt_dynamic_f("amdgpu-deadlock-sdma-badop-test")
- bad_access_helper(device, CMD_STREAM_EXEC_INVALID_OPCODE,
+ bad_access_ring_helper(device, CMD_STREAM_EXEC_INVALID_OPCODE,
AMDGPU_HW_IP_DMA);
}
}
@@ -140,7 +140,7 @@ igt_main
igt_subtest_with_dynamic("amdgpu-deadlock-sdma-bad-mem-test") {
if (arr_cap[AMD_IP_DMA]) {
igt_dynamic_f("amdgpu-deadlock-sdma-bad-mem-test")
- bad_access_helper(device, CMD_STREAM_TRANS_BAD_MEM_ADDRESS,
+ bad_access_ring_helper(device, CMD_STREAM_TRANS_BAD_MEM_ADDRESS,
AMDGPU_HW_IP_DMA);
}
}
@@ -149,7 +149,7 @@ igt_main
igt_subtest_with_dynamic("amdgpu-deadlock-sdma-bad-reg-test") {
if (arr_cap[AMD_IP_DMA]) {
igt_dynamic_f("amdgpu-deadlock-sdma-bad-reg-test")
- bad_access_helper(device, CMD_STREAM_TRANS_BAD_REG_ADDRESS,
+ bad_access_ring_helper(device, CMD_STREAM_TRANS_BAD_REG_ADDRESS,
AMDGPU_HW_IP_DMA);
}
}
@@ -158,7 +158,7 @@ igt_main
igt_subtest_with_dynamic("amdgpu-deadlock-sdma-bad-length-test") {
if (arr_cap[AMD_IP_DMA]) {
igt_dynamic_f("amdgpu-deadlock-sdma-bad-length-test")
- bad_access_helper(device, CMD_STREAM_EXEC_INVALID_PACKET_LENGTH,
+ bad_access_ring_helper(device, CMD_STREAM_EXEC_INVALID_PACKET_LENGTH,
AMDGPU_HW_IP_DMA);
}
}
--
2.25.1
More information about the igt-dev
mailing list