[PATCH 2/2] drm/amdgpu/sriov:fix memory leak in psp_load_fw

Alex Deucher alexdeucher at gmail.com
Tue Sep 26 16:12:26 UTC 2017


On Fri, Sep 22, 2017 at 4:32 AM, Monk Liu <Monk.Liu at amd.com> wrote:
> when doing gpu reset this routine shouldn't do anything
> resource allocating otherwise SRIOV gpu reset will cause
> memory leak
>
> Change-Id: I25da3a5b475196c75c7e639adc40751754625968
> Signed-off-by: Monk Liu <Monk.Liu at amd.com>

A couple of comments below.  With those fixed, series is:
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index 447d446..52daabc 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -334,23 +334,26 @@ static int psp_load_fw(struct amdgpu_device *adev)
>         int ret;
>         struct psp_context *psp = &adev->psp;
>
> +       if (amdgpu_sriov_vf(adev) && adev->in_sriov_reset != 0)
> +               goto skip_memalloc;
> +
>         psp->cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
>         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);
> +                                       AMDGPU_GEM_DOMAIN_GTT,
> +                                       &psp->fw_pri_bo,
> +                                       &psp->fw_pri_mc_addr,
> +                                       &psp->fw_pri_buf);

drop whitespace change.

>         if (ret)
>                 goto failed;
>
>         ret = amdgpu_bo_create_kernel(adev, PSP_FENCE_BUFFER_SIZE, PAGE_SIZE,
> -                                     AMDGPU_GEM_DOMAIN_VRAM,
> -                                     &psp->fence_buf_bo,
> -                                     &psp->fence_buf_mc_addr,
> -                                     &psp->fence_buf);
> +                                       AMDGPU_GEM_DOMAIN_VRAM,
> +                                       &psp->fence_buf_bo,
> +                                       &psp->fence_buf_mc_addr,
> +                                       &psp->fence_buf);

Same here.

>         if (ret)
>                 goto failed_mem2;
>
> @@ -375,6 +378,7 @@ static int psp_load_fw(struct amdgpu_device *adev)
>         if (ret)
>                 goto failed_mem;
>
> +skip_memalloc:
>         ret = psp_hw_start(psp);
>         if (ret)
>                 goto failed_mem;
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list