Skip to contentSkip to conversation

drm/amdgpu: add missing error handling in function amdgpu_gmc_flush_gpu_tlb_pasid

PATCH In review Bob Zhou 2 participants 3 messages Jun 20, 2024 – Jun 21, 2024

Subsystems (2)
lore
Share & tools
lore

Bob Zhou

author
#0 lore raw

PATCH 1/1 drm/amdgpu: add missing error handling in function amdgpu_gmc_flush_gpu_tlb_pasid

Fix the unchecked return value warning by warning reported by Coverity, so add error handling.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +5 -1
index 322b8ff67cde..3a7622611916 100644
@@ -718,7 +718,11 @@ int amdgpu_gmc_flush_gpu_tlb_pasid(struct amdgpu_device *adev, uint16_t pasid,
 			ndw += kiq->pmf->invalidate_tlbs_size;
 
 		spin_lock(&adev->gfx.kiq[inst].ring_lock);
-		amdgpu_ring_alloc(ring, ndw);
+		r = amdgpu_ring_alloc(ring, ndw);
+		if (r) {
+			spin_unlock(&adev->gfx.kiq[inst].ring_lock);
+			goto error_unlock_reset;
+		}
 		if (adev->gmc.flush_tlb_needs_extra_type_2)
 			kiq->pmf->kiq_invalidate_tlbs(ring, pasid, 2, all_hub);
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Bob Zhou

Fix the unchecked return value warning by warning reported by Coverity, so add error handling.

Looks like there are a few other places in the driver where amdgpu_ring_alloc() is not checked. Can you fix those up too?

Quoted 24 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +5 -2
index 322b8ff67cde..3a7622611916 100644
@@ -718,7 +718,11 @@ int amdgpu_gmc_flush_gpu_tlb_pasid(struct amdgpu_device *adev, uint16_t pasid,
                        ndw += kiq->pmf->invalidate_tlbs_size;
 
                spin_lock(&adev->gfx.kiq[inst].ring_lock);
-               amdgpu_ring_alloc(ring, ndw);
+               r = amdgpu_ring_alloc(ring, ndw);
+               if (r) {
+                       spin_unlock(&adev->gfx.kiq[inst].ring_lock);
+                       goto error_unlock_reset;
+               }
                if (adev->gmc.flush_tlb_needs_extra_type_2)
                        kiq->pmf->kiq_invalidate_tlbs(ring, pasid, 2, all_hub);
 
--

2.34.1

author Reviewed-by Alex Deucher
#2 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Alex,

Thanks for your review, I will push other patch to fix those issues.

Regards,
Bob

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: 2024年6月20日 22:59
To: Zhou, Bob <[email protected]>
Cc: [email protected]; Huang, Tim <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add missing error handling in function amdgpu_gmc_flush_gpu_tlb_pasid

Quoted 5 lines · Bob Zhou

Fix the unchecked return value warning by warning reported by Coverity, so add error handling.

Looks like there are a few other places in the driver where amdgpu_ring_alloc() is not checked. Can you fix those up too?

Quoted 26 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +5 -2
index 322b8ff67cde..3a7622611916 100644
@@ -718,7 +718,11 @@ int amdgpu_gmc_flush_gpu_tlb_pasid(struct amdgpu_device *adev, uint16_t pasid,
                        ndw += kiq->pmf->invalidate_tlbs_size;
 
                spin_lock(&adev->gfx.kiq[inst].ring_lock);
-               amdgpu_ring_alloc(ring, ndw);
+               r = amdgpu_ring_alloc(ring, ndw);
+               if (r) {
+                       spin_unlock(&adev->gfx.kiq[inst].ring_lock);
+                       goto error_unlock_reset;
+               }
                if (adev->gmc.flush_tlb_needs_extra_type_2)
                        kiq->pmf->kiq_invalidate_tlbs(ring, pasid, 2,
 all_hub);
 
--

2.34.1