drm/amd/amdgpu: fix gmc bo pin count leak in SRIOV

[ Upstream commit 948e7ce01413b71395723aaf846015062aea3a43 ]

[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 to skip pin bo

v2: fix wrong judgement

Signed-off-by: Jingwen Chen <Jingwen.Chen2@amd.com>
Reviewed-by: Horace Chen <horace.chen@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Jingwen Chen 2021-12-14 11:50:39 +08:00 committed by Greg Kroah-Hartman
parent 8662d0c6a3
commit 305f07b93d
2 changed files with 8 additions and 0 deletions

View File

@ -1021,10 +1021,14 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
return -EINVAL;
}
if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
goto skip_pin_bo;
r = amdgpu_gart_table_vram_pin(adev);
if (r)
return r;
skip_pin_bo:
r = adev->gfxhub.funcs->gart_enable(adev);
if (r)
return r;

View File

@ -1708,10 +1708,14 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
return -EINVAL;
}
if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
goto skip_pin_bo;
r = amdgpu_gart_table_vram_pin(adev);
if (r)
return r;
skip_pin_bo:
r = adev->gfxhub.funcs->gart_enable(adev);
if (r)
return r;