2 * Copyright 2017 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
31 #include "CUnit/Basic.h"
33 #include "amdgpu_test.h"
34 #include "amdgpu_drm.h"
35 #include "amdgpu_internal.h"
41 * This defines the delay in MS after which memory location designated for
42 * compression against reference value is written to, unblocking command
45 #define WRITE_MEM_ADDRESS_DELAY_MS 100
47 #define PACKET_TYPE3 3
49 #define PACKET3(op, n) ((PACKET_TYPE3 << 30) | \
50 (((op) & 0xFF) << 8) | \
53 #define PACKET3_WAIT_REG_MEM 0x3C
54 #define WAIT_REG_MEM_FUNCTION(x) ((x) << 0)
63 #define WAIT_REG_MEM_MEM_SPACE(x) ((x) << 4)
67 #define WAIT_REG_MEM_OPERATION(x) ((x) << 6)
71 #define WAIT_REG_MEM_ENGINE(x) ((x) << 8)
76 #define PACKET3_WRITE_DATA 0x37
77 #define WRITE_DATA_DST_SEL(x) ((x) << 8)
79 * 1 - memory (sync - via GRBM)
83 * 5 - memory (async - direct)
85 #define WR_ONE_ADDR (1 << 16)
86 #define WR_CONFIRM (1 << 20)
87 #define WRITE_DATA_CACHE_POLICY(x) ((x) << 25)
91 #define WRITE_DATA_ENGINE_SEL(x) ((x) << 30)
97 #define mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR 0x54f
99 #define SDMA_PKT_HEADER_OP(x) (x & 0xff)
100 #define SDMA_OP_POLL_REGMEM 8
102 static amdgpu_device_handle device_handle;
103 static uint32_t major_version;
104 static uint32_t minor_version;
106 static pthread_t stress_thread;
107 static uint32_t *ptr;
109 static uint32_t family_id;
110 static uint32_t chip_rev;
111 static uint32_t chip_id;
113 int use_uc_mtype = 0;
115 static void amdgpu_deadlock_helper(unsigned ip_type);
116 static void amdgpu_deadlock_gfx(void);
117 static void amdgpu_deadlock_compute(void);
118 static void amdgpu_illegal_reg_access();
119 static void amdgpu_illegal_mem_access();
120 static void amdgpu_deadlock_sdma(void);
121 static void amdgpu_dispatch_hang_gfx(void);
122 static void amdgpu_dispatch_hang_compute(void);
123 static void amdgpu_dispatch_hang_slow_gfx(void);
124 static void amdgpu_dispatch_hang_slow_compute(void);
125 static void amdgpu_draw_hang_gfx(void);
126 static void amdgpu_draw_hang_slow_gfx(void);
127 static void amdgpu_hang_sdma(void);
128 static void amdgpu_hang_slow_sdma(void);
130 CU_BOOL suite_deadlock_tests_enable(void)
132 CU_BOOL enable = CU_TRUE;
134 if (amdgpu_device_initialize(drm_amdgpu[0], &major_version,
135 &minor_version, &device_handle))
138 family_id = device_handle->info.family_id;
139 chip_id = device_handle->info.chip_external_rev;
140 chip_rev = device_handle->info.chip_rev;
143 * Only enable for ASICs supporting GPU reset and for which it's enabled
144 * by default (currently GFX8+ dGPUS and gfx9+ APUs). Note that Raven1
145 * did not support GPU reset, but newer variants do.
147 if (family_id == AMDGPU_FAMILY_SI ||
148 family_id == AMDGPU_FAMILY_KV ||
149 family_id == AMDGPU_FAMILY_CZ ||
150 family_id == AMDGPU_FAMILY_RV) {
151 printf("\n\nGPU reset is not enabled for the ASIC, deadlock suite disabled\n");
155 if (asic_is_gfx_pipe_removed(family_id, chip_id, chip_rev)) {
156 if (amdgpu_set_test_active("Deadlock Tests",
157 "gfx ring block test (set amdgpu.lockup_timeout=50)",
159 fprintf(stderr, "test deactivation failed - %s\n",
163 if (device_handle->info.family_id >= AMDGPU_FAMILY_AI)
166 if (amdgpu_device_deinitialize(device_handle))
172 int suite_deadlock_tests_init(void)
176 r = amdgpu_device_initialize(drm_amdgpu[0], &major_version,
177 &minor_version, &device_handle);
180 if ((r == -EACCES) && (errno == EACCES))
181 printf("\n\nError:%s. "
182 "Hint:Try to run this test program as root.",
184 return CUE_SINIT_FAILED;
190 int suite_deadlock_tests_clean(void)
192 int r = amdgpu_device_deinitialize(device_handle);
197 return CUE_SCLEAN_FAILED;
201 CU_TestInfo deadlock_tests[] = {
202 { "gfx ring block test (set amdgpu.lockup_timeout=50)", amdgpu_deadlock_gfx },
203 { "compute ring block test (set amdgpu.lockup_timeout=50)", amdgpu_deadlock_compute },
204 { "sdma ring block test (set amdgpu.lockup_timeout=50)", amdgpu_deadlock_sdma },
205 { "illegal reg access test", amdgpu_illegal_reg_access },
206 { "illegal mem access test (set amdgpu.vm_fault_stop=2)", amdgpu_illegal_mem_access },
207 { "gfx ring bad dispatch test (set amdgpu.lockup_timeout=50)", amdgpu_dispatch_hang_gfx },
208 { "compute ring bad dispatch test (set amdgpu.lockup_timeout=50,50)", amdgpu_dispatch_hang_compute },
209 { "gfx ring bad slow dispatch test (set amdgpu.lockup_timeout=50)", amdgpu_dispatch_hang_slow_gfx },
210 { "compute ring bad slow dispatch test (set amdgpu.lockup_timeout=50,50)", amdgpu_dispatch_hang_slow_compute },
211 { "gfx ring bad draw test (set amdgpu.lockup_timeout=50)", amdgpu_draw_hang_gfx },
212 { "gfx ring slow bad draw test (set amdgpu.lockup_timeout=50)", amdgpu_draw_hang_slow_gfx },
213 { "sdma ring corrupted header test (set amdgpu.lockup_timeout=50)", amdgpu_hang_sdma },
214 { "sdma ring slow linear copy test (set amdgpu.lockup_timeout=50)", amdgpu_hang_slow_sdma },
218 static void *write_mem_address(void *data)
222 /* useconds_t range is [0, 1,000,000] so use loop for waits > 1s */
223 for (i = 0; i < WRITE_MEM_ADDRESS_DELAY_MS; i++)
231 static void amdgpu_deadlock_gfx(void)
233 amdgpu_deadlock_helper(AMDGPU_HW_IP_GFX);
236 static void amdgpu_deadlock_compute(void)
238 amdgpu_deadlock_helper(AMDGPU_HW_IP_COMPUTE);
241 static void amdgpu_deadlock_helper(unsigned ip_type)
243 amdgpu_context_handle context_handle;
244 amdgpu_bo_handle ib_result_handle;
246 uint64_t ib_result_mc_address;
247 struct amdgpu_cs_request ibs_request;
248 struct amdgpu_cs_ib_info ib_info;
249 struct amdgpu_cs_fence fence_status;
252 amdgpu_bo_list_handle bo_list;
253 amdgpu_va_handle va_handle;
255 r = pthread_create(&stress_thread, NULL, write_mem_address, NULL);
256 CU_ASSERT_EQUAL(r, 0);
258 r = amdgpu_cs_ctx_create(device_handle, &context_handle);
259 CU_ASSERT_EQUAL(r, 0);
261 r = amdgpu_bo_alloc_and_map_raw(device_handle, 4096, 4096,
262 AMDGPU_GEM_DOMAIN_GTT, 0, use_uc_mtype ? AMDGPU_VM_MTYPE_UC : 0,
263 &ib_result_handle, &ib_result_cpu,
264 &ib_result_mc_address, &va_handle);
265 CU_ASSERT_EQUAL(r, 0);
267 r = amdgpu_get_bo_list(device_handle, ib_result_handle, NULL,
269 CU_ASSERT_EQUAL(r, 0);
273 ptr[0] = PACKET3(PACKET3_WAIT_REG_MEM, 5);
274 ptr[1] = (WAIT_REG_MEM_MEM_SPACE(1) | /* memory */
275 WAIT_REG_MEM_FUNCTION(4) | /* != */
276 WAIT_REG_MEM_ENGINE(0)); /* me */
277 ptr[2] = (ib_result_mc_address + 256*4) & 0xfffffffc;
278 ptr[3] = ((ib_result_mc_address + 256*4) >> 32) & 0xffffffff;
279 ptr[4] = 0x00000000; /* reference value */
280 ptr[5] = 0xffffffff; /* and mask */
281 ptr[6] = 0x00000004; /* poll interval */
283 for (i = 7; i < 16; ++i)
287 ptr[256] = 0x0; /* the memory we wait on to change */
291 memset(&ib_info, 0, sizeof(struct amdgpu_cs_ib_info));
292 ib_info.ib_mc_address = ib_result_mc_address;
295 memset(&ibs_request, 0, sizeof(struct amdgpu_cs_request));
296 ibs_request.ip_type = ip_type;
297 ibs_request.ring = 0;
298 ibs_request.number_of_ibs = 1;
299 ibs_request.ibs = &ib_info;
300 ibs_request.resources = bo_list;
301 ibs_request.fence_info.handle = NULL;
302 for (i = 0; i < 200; i++) {
303 r = amdgpu_cs_submit(context_handle, 0,&ibs_request, 1);
304 CU_ASSERT_EQUAL((r == 0 || r == -ECANCELED), 1);
308 memset(&fence_status, 0, sizeof(struct amdgpu_cs_fence));
309 fence_status.context = context_handle;
310 fence_status.ip_type = ip_type;
311 fence_status.ip_instance = 0;
312 fence_status.ring = 0;
313 fence_status.fence = ibs_request.seq_no;
315 r = amdgpu_cs_query_fence_status(&fence_status,
316 AMDGPU_TIMEOUT_INFINITE,0, &expired);
317 CU_ASSERT_EQUAL((r == 0 || r == -ECANCELED), 1);
319 pthread_join(stress_thread, NULL);
321 r = amdgpu_bo_list_destroy(bo_list);
322 CU_ASSERT_EQUAL(r, 0);
324 r = amdgpu_bo_unmap_and_free(ib_result_handle, va_handle,
325 ib_result_mc_address, 4096);
326 CU_ASSERT_EQUAL(r, 0);
328 r = amdgpu_cs_ctx_free(context_handle);
329 CU_ASSERT_EQUAL(r, 0);
332 static void amdgpu_deadlock_sdma(void)
334 amdgpu_context_handle context_handle;
335 amdgpu_bo_handle ib_result_handle;
337 uint64_t ib_result_mc_address;
338 struct amdgpu_cs_request ibs_request;
339 struct amdgpu_cs_ib_info ib_info;
340 struct amdgpu_cs_fence fence_status;
343 amdgpu_bo_list_handle bo_list;
344 amdgpu_va_handle va_handle;
345 struct drm_amdgpu_info_hw_ip info;
348 r = amdgpu_query_hw_ip_info(device_handle, AMDGPU_HW_IP_DMA, 0, &info);
349 CU_ASSERT_EQUAL(r, 0);
351 r = amdgpu_cs_ctx_create(device_handle, &context_handle);
352 CU_ASSERT_EQUAL(r, 0);
354 for (ring_id = 0; (1 << ring_id) & info.available_rings; ring_id++) {
355 r = pthread_create(&stress_thread, NULL, write_mem_address, NULL);
356 CU_ASSERT_EQUAL(r, 0);
358 r = amdgpu_bo_alloc_and_map_raw(device_handle, 4096, 4096,
359 AMDGPU_GEM_DOMAIN_GTT, 0, use_uc_mtype ? AMDGPU_VM_MTYPE_UC : 0,
360 &ib_result_handle, &ib_result_cpu,
361 &ib_result_mc_address, &va_handle);
362 CU_ASSERT_EQUAL(r, 0);
364 r = amdgpu_get_bo_list(device_handle, ib_result_handle, NULL,
366 CU_ASSERT_EQUAL(r, 0);
371 ptr[i++] = SDMA_PKT_HEADER_OP(SDMA_OP_POLL_REGMEM) |
372 (0 << 26) | /* WAIT_REG_MEM */
374 (1 << 31); /* memory */
375 ptr[i++] = (ib_result_mc_address + 256*4) & 0xfffffffc;
376 ptr[i++] = ((ib_result_mc_address + 256*4) >> 32) & 0xffffffff;
377 ptr[i++] = 0x00000000; /* reference value */
378 ptr[i++] = 0xffffffff; /* and mask */
379 ptr[i++] = 4 | /* poll interval */
380 (0xfff << 16); /* retry count */
385 ptr[256] = 0x0; /* the memory we wait on to change */
387 memset(&ib_info, 0, sizeof(struct amdgpu_cs_ib_info));
388 ib_info.ib_mc_address = ib_result_mc_address;
391 memset(&ibs_request, 0, sizeof(struct amdgpu_cs_request));
392 ibs_request.ip_type = AMDGPU_HW_IP_DMA;
393 ibs_request.ring = ring_id;
394 ibs_request.number_of_ibs = 1;
395 ibs_request.ibs = &ib_info;
396 ibs_request.resources = bo_list;
397 ibs_request.fence_info.handle = NULL;
399 for (i = 0; i < 200; i++) {
400 r = amdgpu_cs_submit(context_handle, 0,&ibs_request, 1);
401 CU_ASSERT_EQUAL((r == 0 || r == -ECANCELED), 1);
405 memset(&fence_status, 0, sizeof(struct amdgpu_cs_fence));
406 fence_status.context = context_handle;
407 fence_status.ip_type = AMDGPU_HW_IP_DMA;
408 fence_status.ip_instance = 0;
409 fence_status.ring = ring_id;
410 fence_status.fence = ibs_request.seq_no;
412 r = amdgpu_cs_query_fence_status(&fence_status,
413 AMDGPU_TIMEOUT_INFINITE,0, &expired);
414 CU_ASSERT_EQUAL((r == 0 || r == -ECANCELED), 1);
416 pthread_join(stress_thread, NULL);
418 r = amdgpu_bo_list_destroy(bo_list);
419 CU_ASSERT_EQUAL(r, 0);
421 r = amdgpu_bo_unmap_and_free(ib_result_handle, va_handle,
422 ib_result_mc_address, 4096);
423 CU_ASSERT_EQUAL(r, 0);
425 r = amdgpu_cs_ctx_free(context_handle);
426 CU_ASSERT_EQUAL(r, 0);
429 static void bad_access_helper(int reg_access)
431 amdgpu_context_handle context_handle;
432 amdgpu_bo_handle ib_result_handle;
434 uint64_t ib_result_mc_address;
435 struct amdgpu_cs_request ibs_request;
436 struct amdgpu_cs_ib_info ib_info;
437 struct amdgpu_cs_fence fence_status;
440 amdgpu_bo_list_handle bo_list;
441 amdgpu_va_handle va_handle;
443 r = amdgpu_cs_ctx_create(device_handle, &context_handle);
444 CU_ASSERT_EQUAL(r, 0);
446 r = amdgpu_bo_alloc_and_map_raw(device_handle, 4096, 4096,
447 AMDGPU_GEM_DOMAIN_GTT, 0, 0,
448 &ib_result_handle, &ib_result_cpu,
449 &ib_result_mc_address, &va_handle);
450 CU_ASSERT_EQUAL(r, 0);
452 r = amdgpu_get_bo_list(device_handle, ib_result_handle, NULL,
454 CU_ASSERT_EQUAL(r, 0);
459 ptr[i++] = PACKET3(PACKET3_WRITE_DATA, 3);
460 ptr[i++] = (reg_access ? WRITE_DATA_DST_SEL(0) : WRITE_DATA_DST_SEL(5))| WR_CONFIRM;
461 ptr[i++] = reg_access ? mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR : 0xdeadbee0;
463 ptr[i++] = 0xdeadbeef;
468 memset(&ib_info, 0, sizeof(struct amdgpu_cs_ib_info));
469 ib_info.ib_mc_address = ib_result_mc_address;
472 memset(&ibs_request, 0, sizeof(struct amdgpu_cs_request));
473 ibs_request.ip_type = AMDGPU_HW_IP_GFX;
474 ibs_request.ring = 0;
475 ibs_request.number_of_ibs = 1;
476 ibs_request.ibs = &ib_info;
477 ibs_request.resources = bo_list;
478 ibs_request.fence_info.handle = NULL;
480 r = amdgpu_cs_submit(context_handle, 0,&ibs_request, 1);
481 CU_ASSERT_EQUAL((r == 0 || r == -ECANCELED), 1);
484 memset(&fence_status, 0, sizeof(struct amdgpu_cs_fence));
485 fence_status.context = context_handle;
486 fence_status.ip_type = AMDGPU_HW_IP_GFX;
487 fence_status.ip_instance = 0;
488 fence_status.ring = 0;
489 fence_status.fence = ibs_request.seq_no;
491 r = amdgpu_cs_query_fence_status(&fence_status,
492 AMDGPU_TIMEOUT_INFINITE,0, &expired);
493 CU_ASSERT_EQUAL((r == 0 || r == -ECANCELED), 1);
495 r = amdgpu_bo_list_destroy(bo_list);
496 CU_ASSERT_EQUAL(r, 0);
498 r = amdgpu_bo_unmap_and_free(ib_result_handle, va_handle,
499 ib_result_mc_address, 4096);
500 CU_ASSERT_EQUAL(r, 0);
502 r = amdgpu_cs_ctx_free(context_handle);
503 CU_ASSERT_EQUAL(r, 0);
506 static void amdgpu_illegal_reg_access()
508 bad_access_helper(1);
511 static void amdgpu_illegal_mem_access()
513 bad_access_helper(0);
516 static void amdgpu_dispatch_hang_gfx(void)
518 amdgpu_test_dispatch_hang_helper(device_handle, AMDGPU_HW_IP_GFX);
520 static void amdgpu_dispatch_hang_compute(void)
522 amdgpu_test_dispatch_hang_helper(device_handle, AMDGPU_HW_IP_COMPUTE);
524 static void amdgpu_dispatch_hang_slow_gfx(void)
526 amdgpu_test_dispatch_hang_slow_helper(device_handle, AMDGPU_HW_IP_GFX);
528 static void amdgpu_dispatch_hang_slow_compute(void)
530 amdgpu_test_dispatch_hang_slow_helper(device_handle, AMDGPU_HW_IP_COMPUTE);
532 static void amdgpu_draw_hang_gfx(void)
534 amdgpu_test_draw_hang_helper(device_handle);
536 static void amdgpu_draw_hang_slow_gfx(void)
538 amdgpu_test_draw_hang_slow_helper(device_handle);
541 #define DMA_CORRUPTED_HEADER_HANG 1
542 #define DMA_SLOW_LINEARCOPY_HANG 2
544 static void amdgpu_hang_sdma_helper(unsigned hang_type)
546 const int sdma_write_length = 1024;
547 amdgpu_context_handle context_handle;
548 amdgpu_bo_handle ib_result_handle;
549 amdgpu_bo_handle bo1, bo2;
550 amdgpu_bo_handle resources[3];
551 amdgpu_bo_list_handle bo_list;
553 struct amdgpu_cs_ib_info ib_info;
554 struct amdgpu_cs_request ibs_request;
555 struct amdgpu_cs_fence fence_status;
556 uint64_t bo1_mc, bo2_mc;
557 uint64_t ib_result_mc_address;
558 volatile unsigned char *bo1_cpu, *bo2_cpu;
559 amdgpu_va_handle bo1_va_handle, bo2_va_handle;
560 amdgpu_va_handle va_handle;
561 struct drm_amdgpu_info_hw_ip hw_ip_info;
563 uint32_t expired, ib_size;
565 r = amdgpu_query_hw_ip_info(device_handle, AMDGPU_HW_IP_DMA, 0, &hw_ip_info);
566 CU_ASSERT_EQUAL(r, 0);
568 r = amdgpu_cs_ctx_create(device_handle, &context_handle);
569 CU_ASSERT_EQUAL(r, 0);
571 if (hang_type == DMA_CORRUPTED_HEADER_HANG)
574 ib_size = 4096 * 0x20000;
576 r = amdgpu_bo_alloc_and_map(device_handle, ib_size, 4096,
577 AMDGPU_GEM_DOMAIN_GTT, 0,
578 &ib_result_handle, &ib_result_cpu,
579 &ib_result_mc_address, &va_handle);
580 CU_ASSERT_EQUAL(r, 0);
582 r = amdgpu_bo_alloc_and_map(device_handle,
583 sdma_write_length, 4096,
584 AMDGPU_GEM_DOMAIN_GTT,
586 (void**)&bo1_cpu, &bo1_mc,
588 CU_ASSERT_EQUAL(r, 0);
591 memset((void*)bo1_cpu, 0xaa, sdma_write_length);
593 /* allocate UC bo2 for sDMA use */
594 r = amdgpu_bo_alloc_and_map(device_handle,
595 sdma_write_length, 4096,
596 AMDGPU_GEM_DOMAIN_GTT,
598 (void**)&bo2_cpu, &bo2_mc,
600 CU_ASSERT_EQUAL(r, 0);
603 memset((void*)bo2_cpu, 0, sdma_write_length);
607 resources[2] = ib_result_handle;
608 r = amdgpu_bo_list_create(device_handle, 3,
609 resources, NULL, &bo_list);
611 /* fulfill PM4: with bad copy linear header */
614 if (hang_type == DMA_CORRUPTED_HEADER_HANG) {
615 ptr[i++] = 0x23decd3d;
616 ptr[i++] = sdma_write_length - 1;
618 ptr[i++] = 0xffffffff & bo1_mc;
619 ptr[i++] = (0xffffffff00000000 & bo1_mc) >> 32;
620 ptr[i++] = 0xffffffff & bo2_mc;
621 ptr[i++] = (0xffffffff00000000 & bo2_mc) >> 32;
623 for (j = 1; j < 0x20000; j++) {
625 ptr[i++] = sdma_write_length - 1;
627 ptr[i++] = 0xffffffff & bo1_mc;
628 ptr[i++] = (0xffffffff00000000 & bo1_mc) >> 32;
629 ptr[i++] = 0xffffffff & bo2_mc;
630 ptr[i++] = (0xffffffff00000000 & bo2_mc) >> 32;
632 ptr[i++] = sdma_write_length - 1;
634 ptr[i++] = 0xffffffff & bo2_mc;
635 ptr[i++] = (0xffffffff00000000 & bo2_mc) >> 32;
636 ptr[i++] = 0xffffffff & bo1_mc;
637 ptr[i++] = (0xffffffff00000000 & bo1_mc) >> 32;
642 memset(&ib_info, 0, sizeof(struct amdgpu_cs_ib_info));
643 ib_info.ib_mc_address = ib_result_mc_address;
646 memset(&ibs_request, 0, sizeof(struct amdgpu_cs_request));
647 ibs_request.ip_type = AMDGPU_HW_IP_DMA;
648 ibs_request.ring = 0;
649 ibs_request.number_of_ibs = 1;
650 ibs_request.ibs = &ib_info;
651 ibs_request.resources = bo_list;
652 ibs_request.fence_info.handle = NULL;
654 r = amdgpu_cs_submit(context_handle, 0, &ibs_request, 1);
655 CU_ASSERT_EQUAL(r, 0);
657 memset(&fence_status, 0, sizeof(struct amdgpu_cs_fence));
658 fence_status.context = context_handle;
659 fence_status.ip_type = AMDGPU_HW_IP_DMA;
660 fence_status.ip_instance = 0;
661 fence_status.ring = 0;
662 fence_status.fence = ibs_request.seq_no;
664 r = amdgpu_cs_query_fence_status(&fence_status,
665 AMDGPU_TIMEOUT_INFINITE,
667 CU_ASSERT_EQUAL((r == 0 || r == -ECANCELED), 1);
669 r = amdgpu_bo_list_destroy(bo_list);
670 CU_ASSERT_EQUAL(r, 0);
672 r = amdgpu_bo_unmap_and_free(ib_result_handle, va_handle,
673 ib_result_mc_address, 4096);
674 CU_ASSERT_EQUAL(r, 0);
676 r = amdgpu_bo_unmap_and_free(bo1, bo1_va_handle, bo1_mc,
678 CU_ASSERT_EQUAL(r, 0);
680 r = amdgpu_bo_unmap_and_free(bo2, bo2_va_handle, bo2_mc,
682 CU_ASSERT_EQUAL(r, 0);
685 r = amdgpu_cs_ctx_free(context_handle);
686 CU_ASSERT_EQUAL(r, 0);
689 static void amdgpu_hang_sdma(void)
691 amdgpu_hang_sdma_helper(DMA_CORRUPTED_HEADER_HANG);
693 static void amdgpu_hang_slow_sdma(void)
695 amdgpu_hang_sdma_helper(DMA_SLOW_LINEARCOPY_HANG);