diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-07-29 10:46:26 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-07-29 10:46:26 +0000 |
commit | 86beed203927e3387d2baaaedcfa536ca43cd8ec (patch) | |
tree | ff6ba2e9fbd63225398e0d141dbffd5327ef5077 /sys | |
parent | 9eb47ee68c2f938aeee2e62e28957ca91ea29dab (diff) |
drm/amdgpu/gfx10: fix race condition for kiq
From Jack Xiao
d2b27b4f5b04bdce08df1b4e421b34fb2572ba97 in linux 5.7.y/5.7.11
7d65a577bb58d4f27a3398a4c0cb0b00ab7d0511 in mainline linux
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/drm/amd/amdgpu/gfx_v10_0.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/dev/pci/drm/amd/amdgpu/gfx_v10_0.c b/sys/dev/pci/drm/amd/amdgpu/gfx_v10_0.c index dd666d7084c..b558cc6ad31 100644 --- a/sys/dev/pci/drm/amd/amdgpu/gfx_v10_0.c +++ b/sys/dev/pci/drm/amd/amdgpu/gfx_v10_0.c @@ -4757,12 +4757,17 @@ static int gfx_v10_0_ring_preempt_ib(struct amdgpu_ring *ring) struct amdgpu_device *adev = ring->adev; struct amdgpu_kiq *kiq = &adev->gfx.kiq; struct amdgpu_ring *kiq_ring = &kiq->ring; + unsigned long flags; if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues) return -EINVAL; - if (amdgpu_ring_alloc(kiq_ring, kiq->pmf->unmap_queues_size)) + spin_lock_irqsave(&kiq->ring_lock, flags); + + if (amdgpu_ring_alloc(kiq_ring, kiq->pmf->unmap_queues_size)) { + spin_unlock_irqrestore(&kiq->ring_lock, flags); return -ENOMEM; + } /* assert preemption condition */ amdgpu_ring_set_preempt_cond_exec(ring, false); @@ -4773,6 +4778,8 @@ static int gfx_v10_0_ring_preempt_ib(struct amdgpu_ring *ring) ++ring->trail_seq); amdgpu_ring_commit(kiq_ring); + spin_unlock_irqrestore(&kiq->ring_lock, flags); + /* poll the trailing fence */ for (i = 0; i < adev->usec_timeout; i++) { if (ring->trail_seq == |