aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'amdgpu/amdgpu_internal.h')
-rw-r--r--amdgpu/amdgpu_internal.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
index e68246bf..28d1f38f 100644
--- a/amdgpu/amdgpu_internal.h
+++ b/amdgpu/amdgpu_internal.h
@@ -206,8 +206,17 @@ static inline bool update_references(atomic_t *dst, atomic_t *src)
206static inline void amdgpu_bo_reference(struct amdgpu_bo **dst, 206static inline void amdgpu_bo_reference(struct amdgpu_bo **dst,
207 struct amdgpu_bo *src) 207 struct amdgpu_bo *src)
208{ 208{
209 if (update_references(&(*dst)->refcount, &src->refcount)) 209 pthread_mutex_t *mlock;
210 amdgpu_bo_free_internal(*dst); 210 struct amdgpu_bo* bo = *dst;
211
212 assert(bo != NULL);
213 mlock = &bo->dev->bo_table_mutex;
214 pthread_mutex_lock(mlock);
215
216 if (update_references(&bo->refcount, src?&src->refcount:NULL))
217 amdgpu_bo_free_internal(bo);
218
219 pthread_mutex_unlock(mlock);
211 *dst = src; 220 *dst = src;
212} 221}
213 222