drm/amdgpu: Fix map/unmap queue logic
authorLijo Lazar <lijo.lazar@amd.com>
Tue, 5 Nov 2024 05:00:20 +0000 (10:30 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 8 Nov 2024 16:10:00 +0000 (11:10 -0500)
commitfa31798582882740f2b13d19e1bd43b4ef918e2f
treeb10dcd62d5c27ff9b6d8d92298cd6debee5cc1f6
parent2bb7dced1c2f8c0e705cc74840f776406db492c3
drm/amdgpu: Fix map/unmap queue logic

In current logic, it calls ring_alloc followed by a ring_test. ring_test
in turn will call another ring_alloc. This is illegal usage as a
ring_alloc is expected to be closed properly with a ring_commit. Change
to commit the map/unmap queue packet first followed by a ring_test. Add a
comment about the usage of ring_test.

Also, reorder the current pre-condition checks of job hang or kiq ring
scheduler not ready. Without them being met, it is not useful to attempt
ring or memory allocations.

Fixes tag refers to the original patch which introduced this issue which
then got carried over into newer code.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Le Ma <le.ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Fixes: 6c10b5cc4eaa ("drm/amdgpu: Remove duplicate code in gfx_v8_0.c")
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c