> -----Original Message-----
> From: amd-gfx [mailto:[email protected]] On Behalf
> Of Christian König
> Sent: Thursday, July 27, 2017 11:44 AM
> To: [email protected]
> Subject: [PATCH 5/8] drm/amdgpu: improve amdgpu_bo_create_kernel
> 
> From: Christian König <[email protected]>
> 
> Make allocating the new BO optional.
> 
> Signed-off-by: Christian König <[email protected]>

Reviewed-by: Alex Deucher <[email protected]>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 22 ++++++++++++++----
> ----
>  1 file changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 8fddea4..81d40e3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -239,15 +239,20 @@ int amdgpu_bo_create_kernel(struct
> amdgpu_device *adev,
>                           u32 domain, struct amdgpu_bo **bo_ptr,
>                           u64 *gpu_addr, void **cpu_addr)
>  {
> +     bool free = false;
>       int r;
> 
> -     r = amdgpu_bo_create(adev, size, align, true, domain,
> -                          AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED
> |
> -                          AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
> -                          NULL, NULL, bo_ptr);
> -     if (r) {
> -             dev_err(adev->dev, "(%d) failed to allocate kernel bo\n", r);
> -             return r;
> +     if (!*bo_ptr) {
> +             r = amdgpu_bo_create(adev, size, align, true, domain,
> +
> AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
> +
> AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
> +                                  NULL, NULL, bo_ptr);
> +             if (r) {
> +                     dev_err(adev->dev, "(%d) failed to allocate kernel
> bo\n",
> +                             r);
> +                     return r;
> +             }
> +             free = true;
>       }
> 
>       r = amdgpu_bo_reserve(*bo_ptr, false);
> @@ -278,7 +283,8 @@ int amdgpu_bo_create_kernel(struct amdgpu_device
> *adev,
>       amdgpu_bo_unreserve(*bo_ptr);
> 
>  error_free:
> -     amdgpu_bo_unref(bo_ptr);
> +     if (free)
> +             amdgpu_bo_unref(bo_ptr);
> 
>       return r;
>  }
> --
> 2.7.4
> 
> _______________________________________________
> amd-gfx mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to