[PATCH i-g-t 2/2] lib/amdgpu: add gfx12 shader blob for sync_dependency_test
Jesse Zhang <[email protected]>
| Newsgroups | org.freedesktop.lists.igt-dev |
|---|---|
| Message-ID | <[email protected]> |
The shader blob used by amdgpu_sync_dependency_test() is a GFX11 (RDNA3) assembly. GFX12 (RDNA4) re-encoded several of the SOP/FLAT opcodes it uses (s_endpgm, s_cbranch_scc0 and the store), so on gfx1200 the GFX11 blob decodes into different instructions: the shader neither terminates nor stores its result, and the test hangs/fails. Add a gfx1200 re-assembled copy of the same kernel and select it in get_shader_bin() by family_id, falling back to the existing GFX11 blob for everything else. Signed-off-by: Jesse Zhang <[email protected]> --- lib/amdgpu/shaders/amd_shaders.c | 35 ++++++++++++++++++++++++++++++-- lib/amdgpu/shaders/amd_shaders.h | 3 ++- tests/amdgpu/amd_basic.c | 3 ++- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/lib/amdgpu/shaders/amd_shaders.c b/lib/amdgpu/shaders/amd_shaders.c index adc4fc051..07489706e 100644 --- a/lib/amdgpu/shaders/amd_shaders.c +++ b/lib/amdgpu/shaders/amd_shaders.c @@ -109,12 +109,43 @@ uint32_t shader_bin[] = { SWAP_32(0x000070e0), SWAP_32(0x00000080), SWAP_32(0x000081bf) }; +/* + * GFX12 (RDNA4) re-encoded several of the SOP/FLAT opcodes used above + * (s_endpgm, s_cbranch_scc0, the store), so the GFX11 blob decodes into + * different instructions and the shader neither terminates nor stores its + * result. This is the same kernel re-assembled for gfx1200: + * + * s_mov_b32 s2, 0 + * .Lloop: + * s_add_co_i32 s2, s2, 1 + * s_cmp_gt_u32 s2, 0x0098967f + * s_cbranch_scc0 .Lloop + * v_mov_b32_e32 v0, 42 + * v_mov_b32_e32 v1, s0 + * v_mov_b32_e32 v2, s1 + * flat_store_b32 v[1:2], v0 + * s_endpgm + */ +static const +uint32_t shader_bin_gfx12[] = { + SWAP_32(0x800082be), SWAP_32(0x02810281), SWAP_32(0x02ff08bf), SWAP_32(0x7f969800), + SWAP_32(0xfcffa1bf), SWAP_32(0xaa02007e), SWAP_32(0x0002027e), SWAP_32(0x0102047e), + SWAP_32(0x7c8006ec), SWAP_32(0x00000000), SWAP_32(0x01000000), SWAP_32(0x0000b0bf) +}; + const uint32_t * -get_shader_bin(uint32_t *size_bytes, uint32_t *code_offset, uint32_t *data_offset) +get_shader_bin(uint32_t *size_bytes, uint32_t *code_offset, uint32_t *data_offset, + uint32_t family_id) { - *size_bytes = sizeof(shader_bin); *code_offset = CODE_OFFSET; *data_offset = DATA_OFFSET; + + if (family_id == AMDGPU_FAMILY_GC_12_0_0) { + *size_bytes = sizeof(shader_bin_gfx12); + return shader_bin_gfx12; + } + + *size_bytes = sizeof(shader_bin); return shader_bin; } diff --git a/lib/amdgpu/shaders/amd_shaders.h b/lib/amdgpu/shaders/amd_shaders.h index f7d4cab07..284c1b2f8 100644 --- a/lib/amdgpu/shaders/amd_shaders.h +++ b/lib/amdgpu/shaders/amd_shaders.h @@ -30,7 +30,8 @@ #include "amdgpu/compute_utils/amd_shared_dispatch.h" const uint32_t * -get_shader_bin(uint32_t *size_bytes, uint32_t *code_offset, uint32_t *data_offset); +get_shader_bin(uint32_t *size_bytes, uint32_t *code_offset, uint32_t *data_offset, + uint32_t family_id); int amdgpu_dispatch_load_cs_shader_hang_slow(uint32_t *ptr, uint32_t family_id); diff --git a/tests/amdgpu/amd_basic.c b/tests/amdgpu/amd_basic.c index 3ad023472..84a6d8618 100644 --- a/tests/amdgpu/amd_basic.c +++ b/tests/amdgpu/amd_basic.c @@ -553,7 +553,8 @@ amdgpu_sync_dependency_test(amdgpu_device_handle device_handle, bool user_queue) igt_assert_eq(r, 0); } - shader = get_shader_bin(&size_bytes, &code_offset, &data_offset); + shader = get_shader_bin(&size_bytes, &code_offset, &data_offset, + ip_block->funcs->family_id); /* assign cmd buffer */ base->attach_buf(base, ib_result_cpu, const_size); -- 2.49.0