]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amdgpu/gfx10: fix KGQ reset sequence
authorAlex Deucher <alexander.deucher@amd.com>
Thu, 26 Jun 2025 21:51:02 +0000 (17:51 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 14:38:43 +0000 (16:38 +0200)
[ Upstream commit 14b2d71a9a24727f1b9f2131ed5eb2e345840a3a ]

Need to reinit the ring before remapping it and all of
the KIQ handling needs to be within the kiq lock.

Fixes: 1741281a157f ("drm/amdgpu/gfx10: add ring reset callbacks")
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c

index 777e383d75e2578b9ef5c2b74751018d25a3c93c..e7df0487eaae3e7d9c0f2d2118a3b38ee3ddba8d 100644 (file)
@@ -9540,7 +9540,7 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
 
        spin_lock_irqsave(&kiq->ring_lock, flags);
 
-       if (amdgpu_ring_alloc(kiq_ring, 5 + 7 + 7 + kiq->pmf->map_queues_size)) {
+       if (amdgpu_ring_alloc(kiq_ring, 5 + 7 + 7)) {
                spin_unlock_irqrestore(&kiq->ring_lock, flags);
                return -ENOMEM;
        }
@@ -9560,12 +9560,9 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
                               0, 1, 0x20);
        gfx_v10_0_ring_emit_reg_wait(kiq_ring,
                                     SOC15_REG_OFFSET(GC, 0, mmCP_VMID_RESET), 0, 0xffffffff);
-       kiq->pmf->kiq_map_queues(kiq_ring, ring);
        amdgpu_ring_commit(kiq_ring);
-
-       spin_unlock_irqrestore(&kiq->ring_lock, flags);
-
        r = amdgpu_ring_test_ring(kiq_ring);
+       spin_unlock_irqrestore(&kiq->ring_lock, flags);
        if (r)
                return r;
 
@@ -9575,6 +9572,19 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
                return r;
        }
 
+       spin_lock_irqsave(&kiq->ring_lock, flags);
+
+       if (amdgpu_ring_alloc(kiq_ring, kiq->pmf->map_queues_size)) {
+               spin_unlock_irqrestore(&kiq->ring_lock, flags);
+               return -ENOMEM;
+       }
+       kiq->pmf->kiq_map_queues(kiq_ring, ring);
+       amdgpu_ring_commit(kiq_ring);
+       r = amdgpu_ring_test_ring(kiq_ring);
+       spin_unlock_irqrestore(&kiq->ring_lock, flags);
+       if (r)
+               return r;
+
        r = amdgpu_ring_test_ring(ring);
        if (r)
                return r;