From: Jack Xiao <jack.x...@amd.com>

[ Upstream commit 55611b507fd6453d26030c0c0619fdf0c262766d ]

Check if irq_src is NULL to avoid dereferencing a NULL pointer,
for MES ring is uneccessary to recieve an interrupt notification.

Signed-off-by: Jack Xiao <jack.x...@amd.com>
Acked-by: Alex Deucher <alexander.deuc...@amd.com>
Reviewed-by: Hawking Zhang <hawking.zh...@amd.com>
Reviewed-by: Christian König <christian.koe...@amd.com>
Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 23085b352cf2d..c212d5fc665c6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -404,7 +404,9 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
                ring->fence_drv.gpu_addr = adev->uvd.inst[ring->me].gpu_addr + 
index;
        }
        amdgpu_fence_write(ring, atomic_read(&ring->fence_drv.last_seq));
-       amdgpu_irq_get(adev, irq_src, irq_type);
+
+       if (irq_src)
+               amdgpu_irq_get(adev, irq_src, irq_type);
 
        ring->fence_drv.irq_src = irq_src;
        ring->fence_drv.irq_type = irq_type;
@@ -539,8 +541,9 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev)
                        /* no need to trigger GPU reset as we are unloading */
                        amdgpu_fence_driver_force_completion(ring);
                }
-               amdgpu_irq_put(adev, ring->fence_drv.irq_src,
-                              ring->fence_drv.irq_type);
+               if (ring->fence_drv.irq_src)
+                       amdgpu_irq_put(adev, ring->fence_drv.irq_src,
+                                      ring->fence_drv.irq_type);
                drm_sched_fini(&ring->sched);
                del_timer_sync(&ring->fence_drv.fallback_timer);
                for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j)
@@ -576,8 +579,9 @@ void amdgpu_fence_driver_suspend(struct amdgpu_device *adev)
                }
 
                /* disable the interrupt */
-               amdgpu_irq_put(adev, ring->fence_drv.irq_src,
-                              ring->fence_drv.irq_type);
+               if (ring->fence_drv.irq_src)
+                       amdgpu_irq_put(adev, ring->fence_drv.irq_src,
+                                      ring->fence_drv.irq_type);
        }
 }
 
@@ -603,8 +607,9 @@ void amdgpu_fence_driver_resume(struct amdgpu_device *adev)
                        continue;
 
                /* enable the interrupt */
-               amdgpu_irq_get(adev, ring->fence_drv.irq_src,
-                              ring->fence_drv.irq_type);
+               if (ring->fence_drv.irq_src)
+                       amdgpu_irq_get(adev, ring->fence_drv.irq_src,
+                                      ring->fence_drv.irq_type);
        }
 }
 
-- 
2.25.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to