Skip to contentSkip to conversation

tests/amd_dispatch: add negative test for SDMA

PATCH New Jesse Zhang 2 participants 2 messages Oct 23, 2023 – Oct 24, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/amd_dispatch: add negative test for SDMA

Issue corrupted header or slow sdma linear copy to trigger SDMA hang test.

V4:
- avoid generating warning,
and optimize logical code. (Vitaly)
- Use existing interfaces
to clean up code. (Vitaly)
- add define and additional
comments for clarification. (Vitaly)

Cc Vitaly Prosyak <[email protected]>
Cc Luben Tuikov <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian Koenig <[email protected]>
Cc Kamil Konieczny <[email protected]>
---
 lib/amdgpu/amd_command_submission.c | 46 ++++++++------
 lib/amdgpu/amd_command_submission.h |  3 +-
 lib/amdgpu/amd_deadlock_helpers.c   | 95 +++++++++++++++++++++++++++++
 lib/amdgpu/amd_deadlock_helpers.h   |  7 +++
 tests/amdgpu/amd_basic.c            |  4 +-
 tests/amdgpu/amd_deadlock.c         | 16 +++++
 tests/amdgpu/amd_security.c         |  4 +-
 7 files changed, 153 insertions(+), 22 deletions(-)
lib/amdgpu/amd_command_submission.c +29 -17
index 02cf9357b..b674ba640 100644
@@ -18,7 +18,7 @@
  */
 
 void amdgpu_test_exec_cs_helper(amdgpu_device_handle device, unsigned int ip_type,
-				struct amdgpu_ring_context *ring_context)
+				struct amdgpu_ring_context *ring_context, int expect)
 {
 	int r;
 	uint32_t expired;
@@ -31,15 +31,23 @@ void amdgpu_test_exec_cs_helper(amdgpu_device_handle device, unsigned int ip_typ
 
 	amdgpu_bo_handle *all_res = alloca(sizeof(ring_context->resources[0]) * (ring_context->res_cnt + 1));
 
+	if (expect) {
+		/* allocate IB */
+		r = amdgpu_bo_alloc_and_map(device, ring_context->write_length, 4096,
+					    AMDGPU_GEM_DOMAIN_GTT, 0,
+					    &ib_result_handle, &ib_result_cpu,
+					    &ib_result_mc_address, &va_handle);
+	} else {
+		/* prepare CS */
+		igt_assert(ring_context->pm4_dw <= 1024);
+		/* allocate IB */
+		r = amdgpu_bo_alloc_and_map(device, 4096, 4096,
+					    AMDGPU_GEM_DOMAIN_GTT, 0,
+					    &ib_result_handle, &ib_result_cpu,
+					    &ib_result_mc_address, &va_handle);
 
-	/* prepare CS */
-	igt_assert(ring_context->pm4_dw <= 1024);
 
-	/* allocate IB */
-	r = amdgpu_bo_alloc_and_map(device, 4096, 4096,
-				    AMDGPU_GEM_DOMAIN_GTT, 0,
-				    &ib_result_handle, &ib_result_cpu,
-				    &ib_result_mc_address, &va_handle);
+	}
 	igt_assert_eq(r, 0);
 
 	/* copy PM4 packet to ring from caller */
@@ -81,9 +89,13 @@ void amdgpu_test_exec_cs_helper(amdgpu_device_handle device, unsigned int ip_typ
 	r = amdgpu_cs_query_fence_status(&fence_status,
 					 AMDGPU_TIMEOUT_INFINITE,
 					 0, &expired);
-	igt_assert_eq(r, 0);
-	igt_assert_eq(expired, true);
-
+	if (expect) {
+		igt_assert_neq(r, 0);
+		igt_assert_neq(expired, true);
+	} else {
+		igt_assert_eq(r, 0);
+		igt_assert_eq(expired, true);
+	}
 	amdgpu_bo_unmap_and_free(ib_result_handle, va_handle,
 				 ib_result_mc_address, 4096);
 }
@@ -145,7 +157,7 @@ void amdgpu_command_submission_write_linear_helper(amdgpu_device_handle device,
 
 			ring_context->ring_id = ring_id;
 
-			 amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context);
+			 amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context, 0);
 
 			/* verify if SDMA test result meets with expected */
 			i = 0;
@@ -155,20 +167,20 @@ void amdgpu_command_submission_write_linear_helper(amdgpu_device_handle device,
 			} else if (ip_block->type == AMDGPU_HW_IP_GFX) {
 				ip_block->funcs->write_linear(ip_block->funcs, ring_context, &ring_context->pm4_dw);
 
-				amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context);
+				amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context, 0);
 
 			} else if (ip_block->type == AMDGPU_HW_IP_DMA) {
 				/* restore the bo_cpu to compare */
 				ring_context->bo_cpu_origin = ring_context->bo_cpu[0];
 				ip_block->funcs->write_linear(ip_block->funcs, ring_context, &ring_context->pm4_dw);
 
-				amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context);
+				amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context, 0);
 
 				/* restore again, here dest_data should be */
 				ring_context->bo_cpu_origin = ring_context->bo_cpu[0];
 				ip_block->funcs->write_linear(ip_block->funcs, ring_context, &ring_context->pm4_dw);
 
-				amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context);
+				amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context, 0);
 				/* here bo_cpu[0] should be unchanged, still is 0x12345678, otherwise failed*/
 				igt_assert_eq(ring_context->bo_cpu[0], ring_context->bo_cpu_origin);
 			}
@@ -236,7 +248,7 @@ void amdgpu_command_submission_const_fill_helper(amdgpu_device_handle device,
 			/* fulfill PM4: test DMA const fill */
 			ip_block->funcs->const_fill(ip_block->funcs, ring_context, &ring_context->pm4_dw);
 
-			amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context);
+			amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context, 0);
 
 			/* verify if SDMA test result meets with expected */
 			r = ip_block->funcs->compare(ip_block->funcs, ring_context, 4);
@@ -322,7 +334,7 @@ void amdgpu_command_submission_copy_linear_helper(amdgpu_device_handle device,
 
 				ip_block->funcs->copy_linear(ip_block->funcs, ring_context, &ring_context->pm4_dw);
 
-				amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context);
+				amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context, 0);
 
 				/* verify if SDMA test result meets with expected */
 				r = ip_block->funcs->compare_pattern(ip_block->funcs, ring_context, 4);
lib/amdgpu/amd_command_submission.h +2 -1
index 58f3221a3..44f0cc958 100644
@@ -29,7 +29,8 @@
 #include "amd_ip_blocks.h"
 
 void amdgpu_test_exec_cs_helper(amdgpu_device_handle device,
-				unsigned int ip_type, struct amdgpu_ring_context *ring_context);
+				unsigned int ip_type, struct amdgpu_ring_context *ring_context,
+				int expect);
 
 void amdgpu_command_submission_write_linear_helper(amdgpu_device_handle device,
 						   const struct amdgpu_ip_block_version *ip_block,
lib/amdgpu/amd_deadlock_helpers.c +95 -0

104 lines not on this page · raw message

lib/amdgpu/amd_deadlock_helpers.h +7 -0
index cc8eba7f7..9c0d245a9 100644
@@ -24,11 +24,18 @@
 #ifndef __AMD_DEADLOCK_HELPERS_H__
 #define __AMD_DEADLOCK_HELPERS_H__
 
+enum  hang_type {
+	DMA_CORRUPTED_HEADER_HANG,
+	DMA_SLOW_LINEARCOPY_HANG
+};
+
 void
 amdgpu_wait_memory_helper(amdgpu_device_handle device_handle, unsigned ip_type);
 
 void
 bad_access_helper(amdgpu_device_handle device_handle, int reg_access, unsigned ip_type);
 
+void
+amdgpu_hang_sdma_helper(amdgpu_device_handle device_handle, uint8_t hang_type);
 #endif
 
tests/amdgpu/amd_basic.c +2 -2
index 88fdbd980..70e45649d 100644
@@ -307,7 +307,7 @@ static void amdgpu_userptr_test(amdgpu_device_handle device)
 
 	ip_block->funcs->write_linear(ip_block->funcs, ring_context, &ring_context->pm4_dw);
 
-	 amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context);
+	 amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context, 0);
 
 	r = ip_block->funcs->compare(ip_block->funcs, ring_context, 1);
 	igt_assert_eq(r, 0);
@@ -412,7 +412,7 @@ amdgpu_bo_eviction_test(amdgpu_device_handle device_handle)
 			ring_context->resources[2] = ring_context->boa_vram[loop2];
 			ring_context->resources[3] = ring_context->boa_gtt[loop2];
 			ip_block->funcs->copy_linear(ip_block->funcs, ring_context, &ring_context->pm4_dw);
-			amdgpu_test_exec_cs_helper(device_handle, ip_block->type, ring_context);
+			amdgpu_test_exec_cs_helper(device_handle, ip_block->type, ring_context, 0);
 			/* fulfill PM4: test DMA copy linear */
 			r = ip_block->funcs->compare_pattern(ip_block->funcs, ring_context, sdma_write_length);
 			igt_assert_eq(r, 0);
tests/amdgpu/amd_deadlock.c +16 -0
index 6147b7636..dc7ec4366 100644
@@ -77,6 +77,22 @@ igt_main
 		}
 	}
 
+	igt_describe("Test-GPU-reset-by-sdma-corrupted-header-with-jobs");
+	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);
+		}
+	}
+
+	igt_describe("Test-GPU-reset-by-sdma-slow-linear-copy-with-jobs");
+	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);
+		}
+	}
+
 	igt_fixture {
 		amdgpu_device_deinitialize(device);
 		drm_close_driver(fd);
tests/amdgpu/amd_security.c +2 -2
index 46180df2e..1a7eba9eb 100644
@@ -110,7 +110,7 @@ amdgpu_bo_lcopy(amdgpu_device_handle device,
 
 	amdgpu_sdma_lcopy(ring_context->pm4, ring_context->bo_mc2,
 			ring_context->bo_mc, size, secure);
-	amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context);
+	amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context, 0);
 	free(ring_context->pm4);
 }
 
@@ -155,7 +155,7 @@ amdgpu_bo_move(amdgpu_device_handle device, int fd,
 	 * it to the desired location.
 	 */
 	amdgpu_sdma_nop(ring_context->pm4, PACKET_NOP_SIZE);
-	amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context);
+	amdgpu_test_exec_cs_helper(device, ip_block->type, ring_context, 0);
 	free(ring_context->pm4);
 }
 
Signature · 1 line
2.25.1
#1 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for tests/amd_dispatch: add negative test for SDMA (rev4)

== Series Details ==

== Series Details ==

Series: tests/amd_dispatch: add negative test for SDMA (rev4)
URL : https://patchwork.freedesktop.org/series/125215/
State : failure

== Summary ==

Series 125215 revision 4 was fully merged or fully failed: no git log