[PATCH 2/2] drm/amd/amdgpu: fix gmc bo pin count leak in SRIOV

JingWen Chen jingwech at amd.com
Tue Dec 14 04:00:20 UTC 2021


patch abandoned

On 2021/12/14 上午11:52, Jingwen Chen wrote:
> [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)


More information about the amd-gfx mailing list