drm/amdgpu: Disable gfx IB preemption with gang submit
Subsystems (2)
PATCH 1/1 drm/amdgpu: Disable gfx IB preemption with gang submit
[Why]
Gang submit has conflict with IB preemption which will break the synchronization between enginees. Specifically, MCBP is enabled default under SRIOV. It will causes gang submit use case failure.
[How]
Disable gfx IB preemption when it is gang submit.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 4 +++- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 4 +++- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 3 ++- 4 files changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +3 -1
@@ -8653,7 +8653,9 @@ static void gfx_v10_0_ring_emit_ib_gfx(struct amdgpu_ring *ring, control |= ib->length_dw | (vmid <<24 ); -if (ring->adev->gfx.mcbp && (ib->flags &AMDGPU_IB_FLAG_PREEMPT )) { +if (ring->adev->gfx.mcbp && + (ib->flags &AMDGPU_IB_FLAG_PREEMPT ) && + (job->gang_submit != &job->base.s_fence->scheduled)) { control |=INDIRECT_BUFFER_PRE_ENB (1 );if (flags &AMDGPU_IB_PREEMPTED )
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +5 -3
@@ -2424,7 +2424,7 @@ static int gfx_v11_0_rlc_load_microcode(struct amdgpu_device *adev)if (version_minor ==3 )gfx_v11_0_load_rlcp_rlcv_microcode (adev); } - +return 0 ; }
@@ -3872,7 +3872,7 @@ static int gfx_v11_0_cp_compute_load_microcode(struct amdgpu_device *adev) }memcpy (fw, fw_data, fw_size); - +amdgpu_bo_kunmap (adev->gfx.mec.mec_fw_obj);amdgpu_bo_unreserve (adev->gfx.mec.mec_fw_obj);
@@ -5855,7 +5855,9 @@ static void gfx_v11_0_ring_emit_ib_gfx(struct amdgpu_ring *ring, control |= ib->length_dw | (vmid <<24 ); -if (ring->adev->gfx.mcbp && (ib->flags &AMDGPU_IB_FLAG_PREEMPT )) { +if (ring->adev->gfx.mcbp && + (ib->flags &AMDGPU_IB_FLAG_PREEMPT ) && + (job->gang_submit != &job->base.s_fence->scheduled)) { control |=INDIRECT_BUFFER_PRE_ENB (1 );if (flags &AMDGPU_IB_PREEMPTED )
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3 -1
@@ -6051,7 +6051,9 @@ static void gfx_v8_0_ring_emit_ib_gfx(struct amdgpu_ring *ring, control |= ib->length_dw | (vmid <<24 ); -if (amdgpu_sriov_vf (ring->adev) && (ib->flags &AMDGPU_IB_FLAG_PREEMPT )) { +if (ring->adev->gfx.mcbp && + (ib->flags &AMDGPU_IB_FLAG_PREEMPT ) && + (job->gang_submit != &job->base.s_fence->scheduled)) { control |=INDIRECT_BUFFER_PRE_ENB (1 );if (!(ib->flags &AMDGPU_IB_FLAG_CE ) && vmid)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -1
@@ -5420,7 +5420,8 @@ static void gfx_v9_0_ring_emit_ib_gfx(struct amdgpu_ring *ring, control |= ib->length_dw | (vmid <<24 ); -if (ib->flags &AMDGPU_IB_FLAG_PREEMPT ) { +if ((ib->flags &AMDGPU_IB_FLAG_PREEMPT ) && + (job->gang_submit != &job->base.s_fence->scheduled)) { control |=INDIRECT_BUFFER_PRE_ENB (1 );if (flags &AMDGPU_IB_PREEMPTED )
Signature · 1 line
2.43.0
Christian König
maintainerQuoted 5 lines · Yifan Zha
[Why]
Gang submit has conflict with IB preemption which will break the synchronization between enginees. Specifically, MCBP is enabled default under SRIOV. It will causes gang submit use case failure.
Gang submit is broken by design on SRIOV.
As long as nobody comes up with an idea to fix this generally I will systematically reject all patches trying to mitigate the situation.
What we could do is to return an error on gang submit under SRIOV.
Quoted 17 lines
[How]
Disable gfx IB preemption when it is gang submit.Signed-off-by Yifan Zha <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 4 +++- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 4 +++- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 3 ++- 4 files changed, 13 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static void gfx_v10_0_ring_emit_ib_gfx(struct amdgpu_ring *ring, · line 8658
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +3
-1@@ -8653,7 +8653,9 @@ static void gfx_v10_0_ring_emit_ib_gfx(struct amdgpu_ring *ring, control |= ib->length_dw | (vmid <<24 ); -if (ring->adev->gfx.mcbp && (ib->flags &AMDGPU_IB_FLAG_PREEMPT )) { +if (ring->adev->gfx.mcbp && + (ib->flags &AMDGPU_IB_FLAG_PREEMPT ) && + (job->gang_submit != &job->base.s_fence->scheduled)) {
That needs to be handled at the higher level.
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static int gfx_v11_0_rlc_load_microcode(struct amdgpu_device *adev) · line 2427
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-0control |=INDIRECT_BUFFER_PRE_ENB (1 );if (flags &AMDGPU_IB_PREEMPTED )drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1
-1@@ -2424,7 +2424,7 @@ static int gfx_v11_0_rlc_load_microcode(struct amdgpu_device *adev)if (version_minor ==3 )gfx_v11_0_load_rlcp_rlcv_microcode (adev); } - +
Unrelated white space change.
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static int gfx_v11_0_cp_compute_load_microcode(struct amdgpu_device *adev) · line 3875
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1
-1return 0 ; }@@ -3872,7 +3872,7 @@ static int gfx_v11_0_cp_compute_load_microcode(struct amdgpu_device *adev) }memcpy (fw, fw_data, fw_size); - +
Dito.
Regards,
Christian.
Quoted 43 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +3
-1amdgpu_bo_kunmap (adev->gfx.mec.mec_fw_obj);amdgpu_bo_unreserve (adev->gfx.mec.mec_fw_obj);@@ -5855,7 +5855,9 @@ static void gfx_v11_0_ring_emit_ib_gfx(struct amdgpu_ring *ring, control |= ib->length_dw | (vmid <<24 ); -if (ring->adev->gfx.mcbp && (ib->flags &AMDGPU_IB_FLAG_PREEMPT )) { +if (ring->adev->gfx.mcbp && + (ib->flags &AMDGPU_IB_FLAG_PREEMPT ) && + (job->gang_submit != &job->base.s_fence->scheduled)) { control |=INDIRECT_BUFFER_PRE_ENB (1 );if (flags &AMDGPU_IB_PREEMPTED )drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3
-1@@ -6051,7 +6051,9 @@ static void gfx_v8_0_ring_emit_ib_gfx(struct amdgpu_ring *ring, control |= ib->length_dw | (vmid <<24 ); -if (amdgpu_sriov_vf (ring->adev) && (ib->flags &AMDGPU_IB_FLAG_PREEMPT )) { +if (ring->adev->gfx.mcbp && + (ib->flags &AMDGPU_IB_FLAG_PREEMPT ) && + (job->gang_submit != &job->base.s_fence->scheduled)) { control |=INDIRECT_BUFFER_PRE_ENB (1 );if (!(ib->flags &AMDGPU_IB_FLAG_CE ) && vmid)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2
-1@@ -5420,7 +5420,8 @@ static void gfx_v9_0_ring_emit_ib_gfx(struct amdgpu_ring *ring, control |= ib->length_dw | (vmid <<24 ); -if (ib->flags &AMDGPU_IB_FLAG_PREEMPT ) { +if ((ib->flags &AMDGPU_IB_FLAG_PREEMPT ) && + (job->gang_submit != &job->base.s_fence->scheduled)) { control |=INDIRECT_BUFFER_PRE_ENB (1 );if (flags &AMDGPU_IB_PREEMPTED )