mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2026-04-25 13:20:42 +02:00
intel: make bo_unreference() thread safe
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
parent
743af59669
commit
88025ad808
1 changed files with 8 additions and 3 deletions
|
|
@ -1157,7 +1157,8 @@ static void drm_intel_gem_bo_unreference(drm_intel_bo *bo)
|
|||
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
|
||||
|
||||
assert(atomic_read(&bo_gem->refcount) > 0);
|
||||
if (atomic_dec_and_test(&bo_gem->refcount)) {
|
||||
|
||||
if (atomic_add_unless(&bo_gem->refcount, -1, 1)) {
|
||||
drm_intel_bufmgr_gem *bufmgr_gem =
|
||||
(drm_intel_bufmgr_gem *) bo->bufmgr;
|
||||
struct timespec time;
|
||||
|
|
@ -1165,8 +1166,12 @@ static void drm_intel_gem_bo_unreference(drm_intel_bo *bo)
|
|||
clock_gettime(CLOCK_MONOTONIC, &time);
|
||||
|
||||
pthread_mutex_lock(&bufmgr_gem->lock);
|
||||
drm_intel_gem_bo_unreference_final(bo, time.tv_sec);
|
||||
drm_intel_gem_cleanup_bo_cache(bufmgr_gem, time.tv_sec);
|
||||
|
||||
if (atomic_dec_and_test(&bo_gem->refcount)) {
|
||||
drm_intel_gem_bo_unreference_final(bo, time.tv_sec);
|
||||
drm_intel_gem_cleanup_bo_cache(bufmgr_gem, time.tv_sec);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&bufmgr_gem->lock);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue