Commit de18a29e authored by Daniel Vetter's avatar Daniel Vetter Committed by Chris Wilson

drm/i915: fix regression due to ba3d8d74

We don't track gpu flush request in any special way. So even with
obj->write_domain == 0, a gpu flush might be outstanding but no
yet executed. Even worse, the latest request might use the object
only for reading. So and unconditional call to object_wait_rendering
is needed for !pipelined.

Hence revert that patch fully and untangle the flushing from the
synchronization again.
Reported-by: default avatarKeith Packard <keithp@keithp.com>
Tested-by: default avatarKeith Packard <keithp@keithp.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
parent ba84cd1f
...@@ -38,8 +38,7 @@ ...@@ -38,8 +38,7 @@
static uint32_t i915_gem_get_gtt_alignment(struct drm_gem_object *obj); static uint32_t i915_gem_get_gtt_alignment(struct drm_gem_object *obj);
static int i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj, static int i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj);
bool pipelined);
static void i915_gem_object_flush_gtt_write_domain(struct drm_gem_object *obj); static void i915_gem_object_flush_gtt_write_domain(struct drm_gem_object *obj);
static void i915_gem_object_flush_cpu_write_domain(struct drm_gem_object *obj); static void i915_gem_object_flush_cpu_write_domain(struct drm_gem_object *obj);
static int i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj, static int i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj,
...@@ -2594,7 +2593,7 @@ i915_gem_object_put_fence_reg(struct drm_gem_object *obj, ...@@ -2594,7 +2593,7 @@ i915_gem_object_put_fence_reg(struct drm_gem_object *obj,
if (reg->gpu) { if (reg->gpu) {
int ret; int ret;
ret = i915_gem_object_flush_gpu_write_domain(obj, true); ret = i915_gem_object_flush_gpu_write_domain(obj);
if (ret) if (ret)
return ret; return ret;
...@@ -2742,8 +2741,7 @@ i915_gem_clflush_object(struct drm_gem_object *obj) ...@@ -2742,8 +2741,7 @@ i915_gem_clflush_object(struct drm_gem_object *obj)
/** Flushes any GPU write domain for the object if it's dirty. */ /** Flushes any GPU write domain for the object if it's dirty. */
static int static int
i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj, i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj)
bool pipelined)
{ {
struct drm_device *dev = obj->dev; struct drm_device *dev = obj->dev;
uint32_t old_write_domain; uint32_t old_write_domain;
...@@ -2762,10 +2760,7 @@ i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj, ...@@ -2762,10 +2760,7 @@ i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj,
obj->read_domains, obj->read_domains,
old_write_domain); old_write_domain);
if (pipelined)
return 0; return 0;
return i915_gem_object_wait_rendering(obj, true);
} }
/** Flushes the GTT write domain for the object if it's dirty. */ /** Flushes the GTT write domain for the object if it's dirty. */
...@@ -2826,17 +2821,14 @@ i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj, int write) ...@@ -2826,17 +2821,14 @@ i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj, int write)
if (obj_priv->gtt_space == NULL) if (obj_priv->gtt_space == NULL)
return -EINVAL; return -EINVAL;
ret = i915_gem_object_flush_gpu_write_domain(obj, false); ret = i915_gem_object_flush_gpu_write_domain(obj);
if (ret != 0) if (ret != 0)
return ret; return ret;
i915_gem_object_flush_cpu_write_domain(obj);
if (write) {
ret = i915_gem_object_wait_rendering(obj, true); ret = i915_gem_object_wait_rendering(obj, true);
if (ret) if (ret)
return ret; return ret;
}
i915_gem_object_flush_cpu_write_domain(obj);
old_write_domain = obj->write_domain; old_write_domain = obj->write_domain;
old_read_domains = obj->read_domains; old_read_domains = obj->read_domains;
...@@ -2875,7 +2867,7 @@ i915_gem_object_set_to_display_plane(struct drm_gem_object *obj, ...@@ -2875,7 +2867,7 @@ i915_gem_object_set_to_display_plane(struct drm_gem_object *obj,
if (obj_priv->gtt_space == NULL) if (obj_priv->gtt_space == NULL)
return -EINVAL; return -EINVAL;
ret = i915_gem_object_flush_gpu_write_domain(obj, true); ret = i915_gem_object_flush_gpu_write_domain(obj);
if (ret) if (ret)
return ret; return ret;
...@@ -2924,9 +2916,12 @@ i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj, int write) ...@@ -2924,9 +2916,12 @@ i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj, int write)
uint32_t old_write_domain, old_read_domains; uint32_t old_write_domain, old_read_domains;
int ret; int ret;
ret = i915_gem_object_flush_gpu_write_domain(obj, false); ret = i915_gem_object_flush_gpu_write_domain(obj);
if (ret != 0) if (ret != 0)
return ret; return ret;
ret = i915_gem_object_wait_rendering(obj, true);
if (ret)
return ret;
i915_gem_object_flush_gtt_write_domain(obj); i915_gem_object_flush_gtt_write_domain(obj);
...@@ -2935,12 +2930,6 @@ i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj, int write) ...@@ -2935,12 +2930,6 @@ i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj, int write)
*/ */
i915_gem_object_set_to_full_cpu_read_domain(obj); i915_gem_object_set_to_full_cpu_read_domain(obj);
if (write) {
ret = i915_gem_object_wait_rendering(obj, true);
if (ret)
return ret;
}
old_write_domain = obj->write_domain; old_write_domain = obj->write_domain;
old_read_domains = obj->read_domains; old_read_domains = obj->read_domains;
...@@ -3205,9 +3194,13 @@ i915_gem_object_set_cpu_read_domain_range(struct drm_gem_object *obj, ...@@ -3205,9 +3194,13 @@ i915_gem_object_set_cpu_read_domain_range(struct drm_gem_object *obj,
if (offset == 0 && size == obj->size) if (offset == 0 && size == obj->size)
return i915_gem_object_set_to_cpu_domain(obj, 0); return i915_gem_object_set_to_cpu_domain(obj, 0);
ret = i915_gem_object_flush_gpu_write_domain(obj, false); ret = i915_gem_object_flush_gpu_write_domain(obj);
if (ret != 0) if (ret != 0)
return ret; return ret;
ret = i915_gem_object_wait_rendering(obj, true);
if (ret)
return ret;
i915_gem_object_flush_gtt_write_domain(obj); i915_gem_object_flush_gtt_write_domain(obj);
/* If we're already fully in the CPU read domain, we're done. */ /* If we're already fully in the CPU read domain, we're done. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment