Skip to content

Commit 7d65a57

Browse files
Jack Xiaoalexdeucher
authored andcommitted
drm/amdgpu/gfx10: fix race condition for kiq
During preemption test for gfx10, it uses kiq to trigger gfx preemption, which would result in race condition with flushing TLB for kiq. Signed-off-by: Jack Xiao <[email protected]> Reviewed-by: Hawking Zhang <[email protected]> Acked-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 38794a5 commit 7d65a57

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7513,12 +7513,17 @@ static int gfx_v10_0_ring_preempt_ib(struct amdgpu_ring *ring)
75137513
struct amdgpu_device *adev = ring->adev;
75147514
struct amdgpu_kiq *kiq = &adev->gfx.kiq;
75157515
struct amdgpu_ring *kiq_ring = &kiq->ring;
7516+
unsigned long flags;
75167517

75177518
if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)
75187519
return -EINVAL;
75197520

7520-
if (amdgpu_ring_alloc(kiq_ring, kiq->pmf->unmap_queues_size))
7521+
spin_lock_irqsave(&kiq->ring_lock, flags);
7522+
7523+
if (amdgpu_ring_alloc(kiq_ring, kiq->pmf->unmap_queues_size)) {
7524+
spin_unlock_irqrestore(&kiq->ring_lock, flags);
75217525
return -ENOMEM;
7526+
}
75227527

75237528
/* assert preemption condition */
75247529
amdgpu_ring_set_preempt_cond_exec(ring, false);
@@ -7529,6 +7534,8 @@ static int gfx_v10_0_ring_preempt_ib(struct amdgpu_ring *ring)
75297534
++ring->trail_seq);
75307535
amdgpu_ring_commit(kiq_ring);
75317536

7537+
spin_unlock_irqrestore(&kiq->ring_lock, flags);
7538+
75327539
/* poll the trailing fence */
75337540
for (i = 0; i < adev->usec_timeout; i++) {
75347541
if (ring->trail_seq ==

0 commit comments

Comments
 (0)