[PATCH][libdrm] amdgpu: add amdgpu_bo_dup() function.

Christian König deathsimple at vodafone.de
Fri Jun 24 09:02:40 UTC 2016


Am 24.06.2016 um 09:00 schrieb Qiang Yu:
> From: Qiang Yu <Qiang.Yu at amd.com>
>
> Change-Id: Icdc00d3e22e48120ca6f4d73ffd05ba43551ad2c
> Signed-off-by: Qiang Yu <Qiang.Yu at amd.com>
> ---
>   amdgpu/amdgpu.h    | 16 ++++++++++++++++
>   amdgpu/amdgpu_bo.c |  6 ++++++
>   2 files changed, 22 insertions(+)
>
> diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
> index 693d841..a59630a 100644
> --- a/amdgpu/amdgpu.h
> +++ b/amdgpu/amdgpu.h
> @@ -716,6 +716,22 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
>   int amdgpu_bo_free(amdgpu_bo_handle buf_handle);
>   
>   /**
> + * Increase the refence count of a memory

I think that should read "of a buffer object".

> + *
> + * \param   bo - \c [in]  Buffer handle to duplicate
> + *
> + * \return   0 on success\n
> + *          <0 - Negative POSIX Error code
> + *
> + * \note It won't really make another copy of the memory, just increase
> + *       the reference count of it
> + *
> + * \sa amdgpu_bo_alloc(), amdgpu_bo_free()
> + *
> +*/
> +int amdgpu_bo_dup(amdgpu_bo_handle bo);

I'm not sure if that this is a good name. Something like 
amdgpu_bo_inc_ref() would probably be better.

Apart from that the patch looks good to me.

Christian.

> +
> +/**
>    * Request CPU access to GPU accessable memory
>    *
>    * \param   buf_handle - \c [in] Buffer handle
> diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
> index aa0d001..086779a 100644
> --- a/amdgpu/amdgpu_bo.c
> +++ b/amdgpu/amdgpu_bo.c
> @@ -424,6 +424,12 @@ int amdgpu_bo_free(amdgpu_bo_handle buf_handle)
>   	return 0;
>   }
>   
> +int amdgpu_bo_dup(amdgpu_bo_handle bo)
> +{
> +	atomic_inc(&bo->refcount);
> +	return 0;
> +}
> +
>   int amdgpu_bo_cpu_map(amdgpu_bo_handle bo, void **cpu)
>   {
>   	union drm_amdgpu_gem_mmap args;



More information about the amd-gfx mailing list