[PATCH 2/2] drm/amd/amdgpu: fix gmc bo pin count leak in SRIOV
Jingwen Chen
Jingwen.Chen2 at amd.com
Tue Dec 14 03:52:54 UTC 2021
[Why]
gmc bo will be pinned during loading amdgpu and reset in SRIOV while
only unpinned in unload amdgpu
[How]
add amdgpu_in_reset and sriov judgement for pin bo in gart_enable
Signed-off-by: Jingwen Chen <Jingwen.Chen2 at amd.com>
---
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 8 +++++---
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 8 +++++---
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index d696c4754bea..b0f4d1ded977 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -992,9 +992,11 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
return -EINVAL;
}
- r = amdgpu_gart_table_vram_pin(adev);
- if (r)
- return r;
+ if (amdgpu_sriov_vf(adev) && !amdgpu_in_reset(adev)) {
+ r = amdgpu_gart_table_vram_pin(adev);
+ if (r)
+ return r;
+ }
r = adev->gfxhub.funcs->gart_enable(adev);
if (r)
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index db2ec84f7237..c1adb212276d 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -1717,9 +1717,11 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
return -EINVAL;
}
- r = amdgpu_gart_table_vram_pin(adev);
- if (r)
- return r;
+ if (amdgpu_sriov_vf(adev) && !amdgpu_in_reset(adev)) {
+ r = amdgpu_gart_table_vram_pin(adev);
+ if (r)
+ return r;
+ }
r = adev->gfxhub.funcs->gart_enable(adev);
if (r)
--
2.30.2
More information about the amd-gfx
mailing list