drm/i915/gem: Serialise object before changing cache-level
diff mbox series

Message ID 20191213223140.1830738-1-chris@chris-wilson.co.uk
State New
Headers show
Series
  • drm/i915/gem: Serialise object before changing cache-level
Related show

Commit Message

Chris Wilson Dec. 13, 2019, 10:31 p.m. UTC
Wait for the object to be idle before changing its cache-level and
unbinding. This was dropped as supposedly superfluous from commit
8b1c78e06e61 ("drm/i915: Avoid calling i915_gem_object_unbind holding
object lock"), but it turns out to prevent some cache dirt escaping.
Smells like papering over a race...

Closes: https://gitlab.freedesktop.org/drm/intel/issues/820
Fixes: 8b1c78e06e61 ("drm/i915: Avoid calling i915_gem_object_unbind holding object lock")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Andi Shyti <andi.shyti@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_domain.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Andi Shyti Dec. 16, 2019, 10:56 a.m. UTC | #1
Hi Chris,

On Fri, Dec 13, 2019 at 10:31:40PM +0000, Chris Wilson wrote:
> Wait for the object to be idle before changing its cache-level and
> unbinding. This was dropped as supposedly superfluous from commit
> 8b1c78e06e61 ("drm/i915: Avoid calling i915_gem_object_unbind holding
> object lock"), but it turns out to prevent some cache dirt escaping.
> Smells like papering over a race...
> 
> Closes: https://gitlab.freedesktop.org/drm/intel/issues/820
> Fixes: 8b1c78e06e61 ("drm/i915: Avoid calling i915_gem_object_unbind holding object lock")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Andi Shyti <andi.shyti@intel.com>

Acked-by: Andi Shyti <andi.shyti@intel.com>

Thanks,
Andi

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_domain.c b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
index 88ab7e71f36c..65f1851e2863 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_domain.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
@@ -190,6 +190,13 @@  int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
 	if (obj->cache_level == cache_level)
 		return 0;
 
+	ret = i915_gem_object_wait(obj,
+				   I915_WAIT_INTERRUPTIBLE |
+				   I915_WAIT_ALL,
+				   MAX_SCHEDULE_TIMEOUT);
+	if (ret)
+		return ret;
+
 	ret = i915_gem_object_lock_interruptible(obj);
 	if (ret)
 		return ret;