]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amdgpu: Increase reset counter only on success
authorLijo Lazar <lijo.lazar@amd.com>
Mon, 14 Jul 2025 05:07:00 +0000 (10:37 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 24 Jul 2025 06:58:25 +0000 (08:58 +0200)
commit 86790e300d8b7bbadaad5024e308c52f1222128f upstream.

Increment the reset counter only if soft recovery succeeded. This is
consistent with a ring hard reset behaviour where counter gets
incremented only if hard reset succeeded.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 25c314aa3ec3d30e4ee282540e2096b5c66a2437)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c

index 59acdbfe28d871c6c394c2ceacf2efdd8063e7ff..f37afeea26e71c50cc73dc67fd9c7ebc9be7a49b 100644 (file)
@@ -463,6 +463,7 @@ bool amdgpu_ring_soft_recovery(struct amdgpu_ring *ring, unsigned int vmid,
 {
        unsigned long flags;
        ktime_t deadline;
+       bool ret;
 
        if (unlikely(ring->adev->debug_disable_soft_recovery))
                return false;
@@ -477,12 +478,16 @@ bool amdgpu_ring_soft_recovery(struct amdgpu_ring *ring, unsigned int vmid,
                dma_fence_set_error(fence, -ENODATA);
        spin_unlock_irqrestore(fence->lock, flags);
 
-       atomic_inc(&ring->adev->gpu_reset_counter);
        while (!dma_fence_is_signaled(fence) &&
               ktime_to_ns(ktime_sub(deadline, ktime_get())) > 0)
                ring->funcs->soft_recovery(ring, vmid);
 
-       return dma_fence_is_signaled(fence);
+       ret = dma_fence_is_signaled(fence);
+       /* increment the counter only if soft reset worked */
+       if (ret)
+               atomic_inc(&ring->adev->gpu_reset_counter);
+
+       return ret;
 }
 
 /*