summaryrefslogtreecommitdiff
path: root/intel
diff options
context:
space:
mode:
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>2014-09-12 13:48:38 +0100
committerDamien Lespiau <damien.lespiau@intel.com>2014-09-15 14:51:25 +0100
commit86b37c61c78edd1353a3f76f678c39e2ec168771 (patch)
tree6e349034ec852064f756e9d30ebee46175c16466 /intel
parent88025ad808aa61b2d5db63b86fc9327aefdecc3b (diff)
downloadlibdrm-86b37c61c78edd1353a3f76f678c39e2ec168771.tar.gz
libdrm-86b37c61c78edd1353a3f76f678c39e2ec168771.tar.bz2
libdrm-86b37c61c78edd1353a3f76f678c39e2ec168771.zip
intel: make drm_intel_gem_bo_get_reloc_count() 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>
Diffstat (limited to 'intel')
-rw-r--r--intel/intel_bufmgr_gem.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index bf6745d2..4e34f75b 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -1783,6 +1783,7 @@ drm_intel_gem_bo_get_reloc_count(drm_intel_bo *bo)
drm_public void
drm_intel_gem_bo_clear_relocs(drm_intel_bo *bo, int start)
{
+ drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
int i;
struct timespec time;
@@ -1790,7 +1791,10 @@ drm_intel_gem_bo_clear_relocs(drm_intel_bo *bo, int start)
clock_gettime(CLOCK_MONOTONIC, &time);
assert(bo_gem->reloc_count >= start);
+
/* Unreference the cleared target buffers */
+ pthread_mutex_lock(&bufmgr_gem->lock);
+
for (i = start; i < bo_gem->reloc_count; i++) {
drm_intel_bo_gem *target_bo_gem = (drm_intel_bo_gem *) bo_gem->reloc_target_info[i].bo;
if (&target_bo_gem->bo != bo) {
@@ -1800,6 +1804,9 @@ drm_intel_gem_bo_clear_relocs(drm_intel_bo *bo, int start)
}
}
bo_gem->reloc_count = start;
+
+ pthread_mutex_unlock(&bufmgr_gem->lock);
+
}
/**