[PATCH] drm/amdgpu: skip fw pri bo alloc for SRIOV

Christian K├Ânig ckoenig.leichtzumerken at gmail.com
Thu May 16 07:24:45 UTC 2019


Am 16.05.19 um 07:11 schrieb Yintian Tao:
> PSP fw primary buffer is not used under SRIOV
> Therefore, we don't need to allocate memory for it.
>
> Signed-off-by: Yintian Tao <yttao at amd.com>
> Signed-off-by: Monk Liu <Monk.Liu at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 22 +++++++++++++---------
>   1 file changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index c567a55..d3c77d2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -905,13 +905,16 @@ static int psp_load_fw(struct amdgpu_device *adev)
>   	if (!psp->cmd)
>   		return -ENOMEM;
>   
> -	ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG,
> -					AMDGPU_GEM_DOMAIN_GTT,
> -					&psp->fw_pri_bo,
> -					&psp->fw_pri_mc_addr,
> -					&psp->fw_pri_buf);
> -	if (ret)
> -		goto failed;
> +	/* this fw pri bo is not used under SRIOV */
> +	if (!amdgpu_sriov_vf(psp->adev)) {
> +		ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG,
> +					      AMDGPU_GEM_DOMAIN_GTT,
> +					      &psp->fw_pri_bo,
> +					      &psp->fw_pri_mc_addr,
> +					      &psp->fw_pri_buf);
> +		if (ret)
> +			goto failed;
> +	}
>   
>   	ret = amdgpu_bo_create_kernel(adev, PSP_FENCE_BUFFER_SIZE, PAGE_SIZE,
>   					AMDGPU_GEM_DOMAIN_VRAM,
> @@ -1012,8 +1015,9 @@ static int psp_hw_fini(void *handle)
>   	psp_ring_destroy(psp, PSP_RING_TYPE__KM);
>   
>   	amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
> -	amdgpu_bo_free_kernel(&psp->fw_pri_bo,
> -			      &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
> +	if (!amdgpu_sriov_vf(psp->adev))
> +		amdgpu_bo_free_kernel(&psp->fw_pri_bo,
> +				      &psp->fw_pri_mc_addr, &psp->fw_pri_buf);

This is superfluous, amdgpu_bo_free_kernel() does a NULL check anyway.

Apart from that looks good to me,
Christian.

>   	amdgpu_bo_free_kernel(&psp->fence_buf_bo,
>   			      &psp->fence_buf_mc_addr, &psp->fence_buf);
>   	amdgpu_bo_free_kernel(&psp->asd_shared_bo, &psp->asd_shared_mc_addr,



More information about the amd-gfx mailing list