summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Widawsky <ben@bwidawsk.net>2012-06-15 14:08:11 -0700
committerBen Widawsky <ben@bwidawsk.net>2012-06-18 16:17:17 -0700
commit02054b3c71e8d90af40cbea92a5d92ca057d3287 (patch)
treea2f7abc6184fbe819f9f80cd73158e0df488c91f
parentd1fcfb17b9642ae351b03056a27b328f314ca80a (diff)
intel: Non-llc based non-blocking maps.non_block_future
Useful for platforms without llc. Put more info here! Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
-rw-r--r--intel/intel_bufmgr_gem.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index b776d2f75..1cf2cc8e7 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -204,6 +204,11 @@ struct _drm_intel_bo_gem {
bool reusable;
/**
+ * Boolean of whether or not we think this buffer is in the GTT domain.
+ * */
+ bool in_gtt_domain;
+
+ /**
* Size in bytes of this buffer and its relocation descendents.
*
* Used to avoid costly tree walking in
@@ -1188,6 +1193,9 @@ static int drm_intel_gem_bo_map(drm_intel_bo *bo, int write_enable)
if (write_enable)
bo_gem->mapped_cpu_write = true;
+ if (!bufmgr_gem->has_llc)
+ bo_gem->in_gtt_domain = 0;
+
drm_intel_gem_bo_mark_mmaps_incoherent(bo);
VG(VALGRIND_MAKE_MEM_DEFINED(bo_gem->mem_virtual, bo->size));
pthread_mutex_unlock(&bufmgr_gem->lock);
@@ -1292,6 +1300,7 @@ int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo)
strerror(errno));
}
+ bo_gem->in_gtt_domain = true;
drm_intel_gem_bo_mark_mmaps_incoherent(bo);
VG(VALGRIND_MAKE_MEM_DEFINED(bo_gem->gtt_virtual, bo->size));
pthread_mutex_unlock(&bufmgr_gem->lock);
@@ -1312,26 +1321,23 @@ int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo)
* does write over the data, it acknowledges that rendering is
* undefined).
*/
-
int drm_intel_gem_bo_map_unsynchronized(drm_intel_bo *bo)
{
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
+ drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
int ret;
- /* If the CPU cache isn't coherent with the GTT, then use a
- * regular synchronized mapping. The problem is that we don't
- * track where the buffer was last used on the CPU side in
- * terms of drm_intel_bo_map vs drm_intel_gem_bo_map_gtt, so
- * we would potentially corrupt the buffer even when the user
- * does reasonable things.
- */
- if (!bufmgr_gem->has_llc)
- return drm_intel_gem_bo_map_gtt(bo);
-
pthread_mutex_lock(&bufmgr_gem->lock);
ret = map_gtt(bo);
- pthread_mutex_unlock(&bufmgr_gem->lock);
+ if (ret)
+ goto out;
+ if (!bufmgr_gem->has_llc)
+ if (!bo_gem->in_gtt_domain)
+ drm_intel_gem_bo_start_gtt_access(bo, 1);
+
+out:
+ pthread_mutex_unlock(&bufmgr_gem->lock);
return ret;
}
@@ -1506,6 +1512,7 @@ drm_intel_gem_bo_start_gtt_access(drm_intel_bo *bo, int write_enable)
set_domain.read_domains, set_domain.write_domain,
strerror(errno));
}
+ bo_gem->in_gtt_domain = true;
}
static void