[129/190] drm/i915: Before accessing an object via the cpu, flush GTT writes
diff mbox

Message ID 1452509174-16671-43-git-send-email-chris@chris-wilson.co.uk
State New
Headers show

Commit Message

Chris Wilson Jan. 11, 2016, 10:45 a.m. UTC
If we want to read the pages directly via the CPU, we have to be sure
that we have to flush the writes via the GTT (as the CPU can not see
the address aliasing).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c | 4 ++++
 1 file changed, 4 insertions(+)

Patch
diff mbox

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index e18c0d4d24ad..c12bda7a4277 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -500,6 +500,8 @@  int i915_gem_obj_prepare_shmem_read(struct drm_i915_gem_object *obj,
 	if (!obj->base.filp)
 		return -EINVAL;
 
+	i915_gem_object_flush_gtt_write_domain(obj);
+
 	if (!(obj->base.read_domains & I915_GEM_DOMAIN_CPU)) {
 		ret = i915_gem_object_wait_rendering(obj, true);
 		if (ret)
@@ -540,6 +542,8 @@  int i915_gem_obj_prepare_shmem_write(struct drm_i915_gem_object *obj,
 	if (!obj->base.filp)
 		return -EINVAL;
 
+	i915_gem_object_flush_gtt_write_domain(obj);
+
 	if (obj->base.write_domain != I915_GEM_DOMAIN_CPU) {
 		ret = i915_gem_object_wait_rendering(obj, false);
 		if (ret)