Skip to contentSkip to conversation

drm/amdgpu: fix gart.bo pin_count leak

PATCH In review Leslie Shi 2 participants 2 messages Sep 23, 2021

Subsystems (2)
lore
Share & tools
lore

Leslie Shi

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix gart.bo pin_count leak

gmc_v{9,10}_0_gart_disable() isn't called matched with correspoding gart_enbale function in SRIOV case. This will lead to gart.bo pin_count leak on driver unload.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 3 ++-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +2 -1
index 41c3a0d70b7c..e47104a1f559 100644
@@ -1098,6 +1098,8 @@ static int gmc_v10_0_hw_fini(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+	gmc_v10_0_gart_disable(adev);
+
 	if (amdgpu_sriov_vf(adev)) {
 		/* full access mode, so don't touch any GMC register */
 		DRM_DEBUG("For SRIOV client, shouldn't do anything.\n");
@@ -1106,7 +1108,6 @@ static int gmc_v10_0_hw_fini(void *handle)
 
 	amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0);
 	amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
-	gmc_v10_0_gart_disable(adev);
 
 	return 0;
 }
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -1
index d90c16a6b2b8..5551359d5dfd 100644
@@ -1794,6 +1794,8 @@ static int gmc_v9_0_hw_fini(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+	gmc_v9_0_gart_disable(adev);
+
 	if (amdgpu_sriov_vf(adev)) {
 		/* full access mode, so don't touch any GMC register */
 		DRM_DEBUG("For SRIOV client, shouldn't do anything.\n");
@@ -1802,7 +1804,6 @@ static int gmc_v9_0_hw_fini(void *handle)
 
 	amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0);
 	amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
-	gmc_v9_0_gart_disable(adev);
 
 	return 0;
 }
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

Am 23.09.21 um 10:16 schrieb Leslie Shi:

Quoted 7 lines

gmc_v{9,10}_0_gart_disable() isn't called matched with correspoding gart_enbale function in SRIOV case. This will lead to gart.bo pin_count leak on driver unload.

Quoted 47 lines
---
  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 3 ++-
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 3 ++-
  2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +2 -1
index 41c3a0d70b7c..e47104a1f559 100644
@@ -1098,6 +1098,8 @@ static int gmc_v10_0_hw_fini(void *handle)
  {
  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+	gmc_v10_0_gart_disable(adev);
+
  	if (amdgpu_sriov_vf(adev)) {
  		/* full access mode, so don't touch any GMC register */
  		DRM_DEBUG("For SRIOV client, shouldn't do anything.\n");
@@ -1106,7 +1108,6 @@ static int gmc_v10_0_hw_fini(void *handle)
 
  	amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0);
  	amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
-	gmc_v10_0_gart_disable(adev);
 
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -1
index d90c16a6b2b8..5551359d5dfd 100644
@@ -1794,6 +1794,8 @@ static int gmc_v9_0_hw_fini(void *handle)
  {
  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+	gmc_v9_0_gart_disable(adev);
+
  	if (amdgpu_sriov_vf(adev)) {
  		/* full access mode, so don't touch any GMC register */
  		DRM_DEBUG("For SRIOV client, shouldn't do anything.\n");
@@ -1802,7 +1804,6 @@ static int gmc_v9_0_hw_fini(void *handle)
 
  	amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0);
  	amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
-	gmc_v9_0_gart_disable(adev);
 
  	return 0;
  }