]> git.ipfire.org Git - thirdparty/kernel/linux.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)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 16 Jul 2025 20:14:44 +0000 (16:14 -0400)
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>
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c

index 09d7681b7a75476d3e7b5c3abbc0cc35ef3c1707..acac646a4e4e9be317739ddeef43d29df6add6fc 100644 (file)
@@ -459,6 +459,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;
@@ -473,12 +474,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;
 }
 
 /*