Re: [PATCH libdrm 2/2] drm: merge and cleanup amdgpu_bo_free

2017-08-08 Thread Alex Deucher
On Tue, Aug 8, 2017 at 10:10 PM, Liu, Monk  wrote:
> I pushed it to amd-staging-upstream

that branch is long dead.  master tracks upstream now in internal git IIRC.

>
> What else branch did you refer to ?

The upstream tree on freedesktop.org:
https://cgit.freedesktop.org/mesa/drm

Alex


>
> BR Monk
>
>
> -Original Message-
> From: Alex Deucher [mailto:alexdeuc...@gmail.com]
> Sent: Wednesday, August 9, 2017 12:19 AM
> To: Christian König 
> Cc: Liu, Monk ; amd-gfx list 
> Subject: Re: [PATCH libdrm 2/2] drm: merge and cleanup amdgpu_bo_free
>
> On Tue, Aug 8, 2017 at 3:54 AM, Christian König  
> wrote:
>> Am 08.08.2017 um 09:34 schrieb Monk Liu:
>>>
>>> From: Monk Liu 
>>>
>>> since bo_reference and bo_internal_free are all only used by bo_free,
>>> so we just merge them together
>>>
>>> Change-Id: I72ebc9c8bcfcd23f4d52a1385db871a95c23859e
>>> Signed-off-by: Monk Liu 
>>
>>
>> Reviewed-by: Christian König 
>
> Pushed both upstream.  Thanks!
>
> Alex
>
>>
>>
>>> ---
>>>   amdgpu/amdgpu_bo.c   | 52
>>> +++-
>>>   amdgpu/amdgpu_internal.h | 33 --
>>>   2 files changed, 29 insertions(+), 56 deletions(-)
>>>
>>> diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index
>>> 82f38c0..901673a 100644
>>> --- a/amdgpu/amdgpu_bo.c
>>> +++ b/amdgpu/amdgpu_bo.c
>>> @@ -52,27 +52,6 @@ static void
>>> amdgpu_close_kms_handle(amdgpu_device_handle dev,
>>> drmIoctl(dev->fd, DRM_IOCTL_GEM_CLOSE, &args);
>>>   }
>>>   -void amdgpu_bo_free_internal(amdgpu_bo_handle bo) -{
>>> -   /* Remove the buffer from the hash tables. */
>>> -   util_hash_table_remove(bo->dev->bo_handles,
>>> -  (void*)(uintptr_t)bo->handle);
>>> -   if (bo->flink_name) {
>>> -   util_hash_table_remove(bo->dev->bo_flink_names,
>>> -  (void*)(uintptr_t)bo->flink_name);
>>> -   }
>>> -
>>> -   /* Release CPU access. */
>>> -   if (bo->cpu_map_count > 0) {
>>> -   bo->cpu_map_count = 1;
>>> -   amdgpu_bo_cpu_unmap(bo);
>>> -   }
>>> -
>>> -   amdgpu_close_kms_handle(bo->dev, bo->handle);
>>> -   pthread_mutex_destroy(&bo->cpu_access_mutex);
>>> -   free(bo);
>>> -}
>>> -
>>>   int amdgpu_bo_alloc(amdgpu_device_handle dev,
>>> struct amdgpu_bo_alloc_request *alloc_buffer,
>>> amdgpu_bo_handle *buf_handle) @@ -415,8 +394,35
>>> @@ int amdgpu_bo_import(amdgpu_device_handle dev,
>>> int amdgpu_bo_free(amdgpu_bo_handle buf_handle)
>>>   {
>>> -   /* Just drop the reference. */
>>> -   amdgpu_bo_reference(&buf_handle, NULL);
>>> +   struct amdgpu_device *dev;
>>> +   struct amdgpu_bo *bo = buf_handle;
>>> +
>>> +   assert(bo != NULL);
>>> +   dev = bo->dev;
>>> +   pthread_mutex_lock(&dev->bo_table_mutex);
>>> +
>>> +   if (update_references(&bo->refcount, NULL)) {
>>> +   /* Remove the buffer from the hash tables. */
>>> +   util_hash_table_remove(dev->bo_handles,
>>> +
>>> + (void*)(uintptr_t)bo->handle);
>>> +
>>> +   if (bo->flink_name) {
>>> +   util_hash_table_remove(dev->bo_flink_names,
>>> +
>>> (void*)(uintptr_t)bo->flink_name);
>>> +   }
>>> +
>>> +   /* Release CPU access. */
>>> +   if (bo->cpu_map_count > 0) {
>>> +   bo->cpu_map_count = 1;
>>> +   amdgpu_bo_cpu_unmap(bo);
>>> +   }
>>> +
>>> +   amdgpu_close_kms_handle(dev, bo->handle);
>>> +   pthread_mutex_destroy(&bo->cpu_access_mutex);
>>> +   free(bo);
>>> +   }
>>> +
>>> +   pthread_mutex_unlock(&dev->bo_table_mutex);
>>> return 0;
>>>   }
>>>   diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
>>> index 79da0e7..a6bf831 100644
>>> --- a/amdgpu/amdgpu_internal.h
>>> +++ b/amdgpu/amdgpu_internal.h
&g

RE: [PATCH libdrm 2/2] drm: merge and cleanup amdgpu_bo_free

2017-08-08 Thread Liu, Monk
I pushed it to amd-staging-upstream

What else branch did you refer to ?

BR Monk


-Original Message-
From: Alex Deucher [mailto:alexdeuc...@gmail.com] 
Sent: Wednesday, August 9, 2017 12:19 AM
To: Christian König 
Cc: Liu, Monk ; amd-gfx list 
Subject: Re: [PATCH libdrm 2/2] drm: merge and cleanup amdgpu_bo_free

On Tue, Aug 8, 2017 at 3:54 AM, Christian König  wrote:
> Am 08.08.2017 um 09:34 schrieb Monk Liu:
>>
>> From: Monk Liu 
>>
>> since bo_reference and bo_internal_free are all only used by bo_free, 
>> so we just merge them together
>>
>> Change-Id: I72ebc9c8bcfcd23f4d52a1385db871a95c23859e
>> Signed-off-by: Monk Liu 
>
>
> Reviewed-by: Christian König 

Pushed both upstream.  Thanks!

Alex

>
>
>> ---
>>   amdgpu/amdgpu_bo.c   | 52
>> +++-
>>   amdgpu/amdgpu_internal.h | 33 --
>>   2 files changed, 29 insertions(+), 56 deletions(-)
>>
>> diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index 
>> 82f38c0..901673a 100644
>> --- a/amdgpu/amdgpu_bo.c
>> +++ b/amdgpu/amdgpu_bo.c
>> @@ -52,27 +52,6 @@ static void
>> amdgpu_close_kms_handle(amdgpu_device_handle dev,
>> drmIoctl(dev->fd, DRM_IOCTL_GEM_CLOSE, &args);
>>   }
>>   -void amdgpu_bo_free_internal(amdgpu_bo_handle bo) -{
>> -   /* Remove the buffer from the hash tables. */
>> -   util_hash_table_remove(bo->dev->bo_handles,
>> -  (void*)(uintptr_t)bo->handle);
>> -   if (bo->flink_name) {
>> -   util_hash_table_remove(bo->dev->bo_flink_names,
>> -  (void*)(uintptr_t)bo->flink_name);
>> -   }
>> -
>> -   /* Release CPU access. */
>> -   if (bo->cpu_map_count > 0) {
>> -   bo->cpu_map_count = 1;
>> -   amdgpu_bo_cpu_unmap(bo);
>> -   }
>> -
>> -   amdgpu_close_kms_handle(bo->dev, bo->handle);
>> -   pthread_mutex_destroy(&bo->cpu_access_mutex);
>> -   free(bo);
>> -}
>> -
>>   int amdgpu_bo_alloc(amdgpu_device_handle dev,
>> struct amdgpu_bo_alloc_request *alloc_buffer,
>> amdgpu_bo_handle *buf_handle) @@ -415,8 +394,35 
>> @@ int amdgpu_bo_import(amdgpu_device_handle dev,
>> int amdgpu_bo_free(amdgpu_bo_handle buf_handle)
>>   {
>> -   /* Just drop the reference. */
>> -   amdgpu_bo_reference(&buf_handle, NULL);
>> +   struct amdgpu_device *dev;
>> +   struct amdgpu_bo *bo = buf_handle;
>> +
>> +   assert(bo != NULL);
>> +   dev = bo->dev;
>> +   pthread_mutex_lock(&dev->bo_table_mutex);
>> +
>> +   if (update_references(&bo->refcount, NULL)) {
>> +   /* Remove the buffer from the hash tables. */
>> +   util_hash_table_remove(dev->bo_handles,
>> +   
>> + (void*)(uintptr_t)bo->handle);
>> +
>> +   if (bo->flink_name) {
>> +   util_hash_table_remove(dev->bo_flink_names,
>> +
>> (void*)(uintptr_t)bo->flink_name);
>> +   }
>> +
>> +   /* Release CPU access. */
>> +   if (bo->cpu_map_count > 0) {
>> +   bo->cpu_map_count = 1;
>> +   amdgpu_bo_cpu_unmap(bo);
>> +   }
>> +
>> +   amdgpu_close_kms_handle(dev, bo->handle);
>> +   pthread_mutex_destroy(&bo->cpu_access_mutex);
>> +   free(bo);
>> +   }
>> +
>> +   pthread_mutex_unlock(&dev->bo_table_mutex);
>> return 0;
>>   }
>>   diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h 
>> index 79da0e7..a6bf831 100644
>> --- a/amdgpu/amdgpu_internal.h
>> +++ b/amdgpu/amdgpu_internal.h
>> @@ -133,8 +133,6 @@ struct amdgpu_semaphore {
>> void amdgpu_device_free_internal(amdgpu_device_handle dev);
>>   -void amdgpu_bo_free_internal(amdgpu_bo_handle bo);
>> -
>>   void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, uint64_t start,
>>uint64_t max, uint64_t alignment);
>>   @@ -177,37 +175,6 @@ static inline bool update_references(atomic_t 
>> *dst, atomic_t *src)
>>   }
>> /**
>> - * Assignment between two amdgpu_bo pointers with reference counting.
>> - *
>> - * Usage:
>> - *struct amdgpu

Re: [PATCH libdrm 2/2] drm: merge and cleanup amdgpu_bo_free

2017-08-08 Thread Alex Deucher
On Tue, Aug 8, 2017 at 3:54 AM, Christian König  wrote:
> Am 08.08.2017 um 09:34 schrieb Monk Liu:
>>
>> From: Monk Liu 
>>
>> since bo_reference and bo_internal_free are
>> all only used by bo_free, so we just merge them
>> together
>>
>> Change-Id: I72ebc9c8bcfcd23f4d52a1385db871a95c23859e
>> Signed-off-by: Monk Liu 
>
>
> Reviewed-by: Christian König 

Pushed both upstream.  Thanks!

Alex

>
>
>> ---
>>   amdgpu/amdgpu_bo.c   | 52
>> +++-
>>   amdgpu/amdgpu_internal.h | 33 --
>>   2 files changed, 29 insertions(+), 56 deletions(-)
>>
>> diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
>> index 82f38c0..901673a 100644
>> --- a/amdgpu/amdgpu_bo.c
>> +++ b/amdgpu/amdgpu_bo.c
>> @@ -52,27 +52,6 @@ static void
>> amdgpu_close_kms_handle(amdgpu_device_handle dev,
>> drmIoctl(dev->fd, DRM_IOCTL_GEM_CLOSE, &args);
>>   }
>>   -void amdgpu_bo_free_internal(amdgpu_bo_handle bo)
>> -{
>> -   /* Remove the buffer from the hash tables. */
>> -   util_hash_table_remove(bo->dev->bo_handles,
>> -  (void*)(uintptr_t)bo->handle);
>> -   if (bo->flink_name) {
>> -   util_hash_table_remove(bo->dev->bo_flink_names,
>> -  (void*)(uintptr_t)bo->flink_name);
>> -   }
>> -
>> -   /* Release CPU access. */
>> -   if (bo->cpu_map_count > 0) {
>> -   bo->cpu_map_count = 1;
>> -   amdgpu_bo_cpu_unmap(bo);
>> -   }
>> -
>> -   amdgpu_close_kms_handle(bo->dev, bo->handle);
>> -   pthread_mutex_destroy(&bo->cpu_access_mutex);
>> -   free(bo);
>> -}
>> -
>>   int amdgpu_bo_alloc(amdgpu_device_handle dev,
>> struct amdgpu_bo_alloc_request *alloc_buffer,
>> amdgpu_bo_handle *buf_handle)
>> @@ -415,8 +394,35 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
>> int amdgpu_bo_free(amdgpu_bo_handle buf_handle)
>>   {
>> -   /* Just drop the reference. */
>> -   amdgpu_bo_reference(&buf_handle, NULL);
>> +   struct amdgpu_device *dev;
>> +   struct amdgpu_bo *bo = buf_handle;
>> +
>> +   assert(bo != NULL);
>> +   dev = bo->dev;
>> +   pthread_mutex_lock(&dev->bo_table_mutex);
>> +
>> +   if (update_references(&bo->refcount, NULL)) {
>> +   /* Remove the buffer from the hash tables. */
>> +   util_hash_table_remove(dev->bo_handles,
>> +   (void*)(uintptr_t)bo->handle);
>> +
>> +   if (bo->flink_name) {
>> +   util_hash_table_remove(dev->bo_flink_names,
>> +
>> (void*)(uintptr_t)bo->flink_name);
>> +   }
>> +
>> +   /* Release CPU access. */
>> +   if (bo->cpu_map_count > 0) {
>> +   bo->cpu_map_count = 1;
>> +   amdgpu_bo_cpu_unmap(bo);
>> +   }
>> +
>> +   amdgpu_close_kms_handle(dev, bo->handle);
>> +   pthread_mutex_destroy(&bo->cpu_access_mutex);
>> +   free(bo);
>> +   }
>> +
>> +   pthread_mutex_unlock(&dev->bo_table_mutex);
>> return 0;
>>   }
>>   diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
>> index 79da0e7..a6bf831 100644
>> --- a/amdgpu/amdgpu_internal.h
>> +++ b/amdgpu/amdgpu_internal.h
>> @@ -133,8 +133,6 @@ struct amdgpu_semaphore {
>> void amdgpu_device_free_internal(amdgpu_device_handle dev);
>>   -void amdgpu_bo_free_internal(amdgpu_bo_handle bo);
>> -
>>   void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, uint64_t start,
>>uint64_t max, uint64_t alignment);
>>   @@ -177,37 +175,6 @@ static inline bool update_references(atomic_t *dst,
>> atomic_t *src)
>>   }
>> /**
>> - * Assignment between two amdgpu_bo pointers with reference counting.
>> - *
>> - * Usage:
>> - *struct amdgpu_bo *dst = ... , *src = ...;
>> - *
>> - *dst = src;
>> - *// No reference counting. Only use this when you need to move
>> - *// a reference from one pointer to another.
>> - *
>> - *amdgpu_bo_reference(&dst, src);
>> - *// Reference counters are updated. dst is decremented and src is
>> - *// incremented. dst is freed if its reference counter is 0.
>> - */
>> -static inline void amdgpu_bo_reference(struct amdgpu_bo **dst,
>> -   struct amdgpu_bo *src)
>> -{
>> -   pthread_mutex_t *mlock;
>> -   struct amdgpu_bo* bo = *dst;
>> -
>> -   assert(bo != NULL);
>> -   mlock = &bo->dev->bo_table_mutex;
>> -   pthread_mutex_lock(mlock);
>> -
>> -   if (update_references(&bo->refcount, src?&src->refcount:NULL))
>> -   amdgpu_bo_free_internal(bo);
>> -
>> -   pthread_mutex_unlock(mlock);
>> -   *dst = src;
>> -}
>> -
>> -/**
>>* Assignment between two amdgpu_device pointers with reference
>> counting.
>>*
>>* Usage:
>
>
>
> 

Re: [PATCH libdrm 2/2] drm: merge and cleanup amdgpu_bo_free

2017-08-08 Thread Christian König

Am 08.08.2017 um 09:34 schrieb Monk Liu:

From: Monk Liu 

since bo_reference and bo_internal_free are
all only used by bo_free, so we just merge them
together

Change-Id: I72ebc9c8bcfcd23f4d52a1385db871a95c23859e
Signed-off-by: Monk Liu 


Reviewed-by: Christian König 


---
  amdgpu/amdgpu_bo.c   | 52 +++-
  amdgpu/amdgpu_internal.h | 33 --
  2 files changed, 29 insertions(+), 56 deletions(-)

diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index 82f38c0..901673a 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -52,27 +52,6 @@ static void amdgpu_close_kms_handle(amdgpu_device_handle dev,
drmIoctl(dev->fd, DRM_IOCTL_GEM_CLOSE, &args);
  }
  
-void amdgpu_bo_free_internal(amdgpu_bo_handle bo)

-{
-   /* Remove the buffer from the hash tables. */
-   util_hash_table_remove(bo->dev->bo_handles,
-  (void*)(uintptr_t)bo->handle);
-   if (bo->flink_name) {
-   util_hash_table_remove(bo->dev->bo_flink_names,
-  (void*)(uintptr_t)bo->flink_name);
-   }
-
-   /* Release CPU access. */
-   if (bo->cpu_map_count > 0) {
-   bo->cpu_map_count = 1;
-   amdgpu_bo_cpu_unmap(bo);
-   }
-
-   amdgpu_close_kms_handle(bo->dev, bo->handle);
-   pthread_mutex_destroy(&bo->cpu_access_mutex);
-   free(bo);
-}
-
  int amdgpu_bo_alloc(amdgpu_device_handle dev,
struct amdgpu_bo_alloc_request *alloc_buffer,
amdgpu_bo_handle *buf_handle)
@@ -415,8 +394,35 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
  
  int amdgpu_bo_free(amdgpu_bo_handle buf_handle)

  {
-   /* Just drop the reference. */
-   amdgpu_bo_reference(&buf_handle, NULL);
+   struct amdgpu_device *dev;
+   struct amdgpu_bo *bo = buf_handle;
+
+   assert(bo != NULL);
+   dev = bo->dev;
+   pthread_mutex_lock(&dev->bo_table_mutex);
+
+   if (update_references(&bo->refcount, NULL)) {
+   /* Remove the buffer from the hash tables. */
+   util_hash_table_remove(dev->bo_handles,
+   (void*)(uintptr_t)bo->handle);
+
+   if (bo->flink_name) {
+   util_hash_table_remove(dev->bo_flink_names,
+   
(void*)(uintptr_t)bo->flink_name);
+   }
+
+   /* Release CPU access. */
+   if (bo->cpu_map_count > 0) {
+   bo->cpu_map_count = 1;
+   amdgpu_bo_cpu_unmap(bo);
+   }
+
+   amdgpu_close_kms_handle(dev, bo->handle);
+   pthread_mutex_destroy(&bo->cpu_access_mutex);
+   free(bo);
+   }
+
+   pthread_mutex_unlock(&dev->bo_table_mutex);
return 0;
  }
  
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h

index 79da0e7..a6bf831 100644
--- a/amdgpu/amdgpu_internal.h
+++ b/amdgpu/amdgpu_internal.h
@@ -133,8 +133,6 @@ struct amdgpu_semaphore {
  
  void amdgpu_device_free_internal(amdgpu_device_handle dev);
  
-void amdgpu_bo_free_internal(amdgpu_bo_handle bo);

-
  void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, uint64_t start,
   uint64_t max, uint64_t alignment);
  
@@ -177,37 +175,6 @@ static inline bool update_references(atomic_t *dst, atomic_t *src)

  }
  
  /**

- * Assignment between two amdgpu_bo pointers with reference counting.
- *
- * Usage:
- *struct amdgpu_bo *dst = ... , *src = ...;
- *
- *dst = src;
- *// No reference counting. Only use this when you need to move
- *// a reference from one pointer to another.
- *
- *amdgpu_bo_reference(&dst, src);
- *// Reference counters are updated. dst is decremented and src is
- *// incremented. dst is freed if its reference counter is 0.
- */
-static inline void amdgpu_bo_reference(struct amdgpu_bo **dst,
-   struct amdgpu_bo *src)
-{
-   pthread_mutex_t *mlock;
-   struct amdgpu_bo* bo = *dst;
-
-   assert(bo != NULL);
-   mlock = &bo->dev->bo_table_mutex;
-   pthread_mutex_lock(mlock);
-
-   if (update_references(&bo->refcount, src?&src->refcount:NULL))
-   amdgpu_bo_free_internal(bo);
-
-   pthread_mutex_unlock(mlock);
-   *dst = src;
-}
-
-/**
   * Assignment between two amdgpu_device pointers with reference counting.
   *
   * Usage:



___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH libdrm 2/2] drm: merge and cleanup amdgpu_bo_free

2017-08-08 Thread Monk Liu
From: Monk Liu 

since bo_reference and bo_internal_free are
all only used by bo_free, so we just merge them
together

Change-Id: I72ebc9c8bcfcd23f4d52a1385db871a95c23859e
Signed-off-by: Monk Liu 
---
 amdgpu/amdgpu_bo.c   | 52 +++-
 amdgpu/amdgpu_internal.h | 33 --
 2 files changed, 29 insertions(+), 56 deletions(-)

diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index 82f38c0..901673a 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -52,27 +52,6 @@ static void amdgpu_close_kms_handle(amdgpu_device_handle dev,
drmIoctl(dev->fd, DRM_IOCTL_GEM_CLOSE, &args);
 }
 
-void amdgpu_bo_free_internal(amdgpu_bo_handle bo)
-{
-   /* Remove the buffer from the hash tables. */
-   util_hash_table_remove(bo->dev->bo_handles,
-  (void*)(uintptr_t)bo->handle);
-   if (bo->flink_name) {
-   util_hash_table_remove(bo->dev->bo_flink_names,
-  (void*)(uintptr_t)bo->flink_name);
-   }
-
-   /* Release CPU access. */
-   if (bo->cpu_map_count > 0) {
-   bo->cpu_map_count = 1;
-   amdgpu_bo_cpu_unmap(bo);
-   }
-
-   amdgpu_close_kms_handle(bo->dev, bo->handle);
-   pthread_mutex_destroy(&bo->cpu_access_mutex);
-   free(bo);
-}
-
 int amdgpu_bo_alloc(amdgpu_device_handle dev,
struct amdgpu_bo_alloc_request *alloc_buffer,
amdgpu_bo_handle *buf_handle)
@@ -415,8 +394,35 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
 
 int amdgpu_bo_free(amdgpu_bo_handle buf_handle)
 {
-   /* Just drop the reference. */
-   amdgpu_bo_reference(&buf_handle, NULL);
+   struct amdgpu_device *dev;
+   struct amdgpu_bo *bo = buf_handle;
+
+   assert(bo != NULL);
+   dev = bo->dev;
+   pthread_mutex_lock(&dev->bo_table_mutex);
+
+   if (update_references(&bo->refcount, NULL)) {
+   /* Remove the buffer from the hash tables. */
+   util_hash_table_remove(dev->bo_handles,
+   (void*)(uintptr_t)bo->handle);
+
+   if (bo->flink_name) {
+   util_hash_table_remove(dev->bo_flink_names,
+   
(void*)(uintptr_t)bo->flink_name);
+   }
+
+   /* Release CPU access. */
+   if (bo->cpu_map_count > 0) {
+   bo->cpu_map_count = 1;
+   amdgpu_bo_cpu_unmap(bo);
+   }
+
+   amdgpu_close_kms_handle(dev, bo->handle);
+   pthread_mutex_destroy(&bo->cpu_access_mutex);
+   free(bo);
+   }
+
+   pthread_mutex_unlock(&dev->bo_table_mutex);
return 0;
 }
 
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
index 79da0e7..a6bf831 100644
--- a/amdgpu/amdgpu_internal.h
+++ b/amdgpu/amdgpu_internal.h
@@ -133,8 +133,6 @@ struct amdgpu_semaphore {
 
 void amdgpu_device_free_internal(amdgpu_device_handle dev);
 
-void amdgpu_bo_free_internal(amdgpu_bo_handle bo);
-
 void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, uint64_t start,
   uint64_t max, uint64_t alignment);
 
@@ -177,37 +175,6 @@ static inline bool update_references(atomic_t *dst, 
atomic_t *src)
 }
 
 /**
- * Assignment between two amdgpu_bo pointers with reference counting.
- *
- * Usage:
- *struct amdgpu_bo *dst = ... , *src = ...;
- *
- *dst = src;
- *// No reference counting. Only use this when you need to move
- *// a reference from one pointer to another.
- *
- *amdgpu_bo_reference(&dst, src);
- *// Reference counters are updated. dst is decremented and src is
- *// incremented. dst is freed if its reference counter is 0.
- */
-static inline void amdgpu_bo_reference(struct amdgpu_bo **dst,
-   struct amdgpu_bo *src)
-{
-   pthread_mutex_t *mlock;
-   struct amdgpu_bo* bo = *dst;
-
-   assert(bo != NULL);
-   mlock = &bo->dev->bo_table_mutex;
-   pthread_mutex_lock(mlock);
-
-   if (update_references(&bo->refcount, src?&src->refcount:NULL))
-   amdgpu_bo_free_internal(bo);
-
-   pthread_mutex_unlock(mlock);
-   *dst = src;
-}
-
-/**
  * Assignment between two amdgpu_device pointers with reference counting.
  *
  * Usage:
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx