All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/i915: Flush the context object from the CPU caches upon switching
@ 2012-07-15 11:34 Chris Wilson
  2012-07-15 11:34 ` [PATCH 2/3] drm/i915: fix invalid reference handling of the default ctx obj Chris Wilson
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Chris Wilson @ 2012-07-15 11:34 UTC (permalink / raw)
  To: intel-gfx

The issue is that we stale data in the CPU caches, when we come to
swap-out the object, the CPU may short-circuit the reads from those
cacheline and so corrupt the context object.

Secondary, leaving the context object as being marked in the CPU write
domain whilst on the GPU active list is a bad idea and will throw
warnings later.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_gem_context.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 9ae3f2c..fd978bb 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -374,6 +374,13 @@ static int do_switch(struct drm_i915_gem_object *from_obj,
 	if (ret)
 		return ret;
 
+	/* Clear this page out of any CPU caches for coherent swap-in/out */
+	ret = i915_gem_object_set_to_gtt_domain(to->obj, false);
+	if (ret) {
+		i915_gem_object_unpin(to->obj);
+		return ret;
+	}
+
 	if (!to->obj->has_global_gtt_mapping)
 		i915_gem_gtt_bind_object(to->obj, to->obj->cache_level);
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-07-16 18:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-15 11:34 [PATCH 1/3] drm/i915: Flush the context object from the CPU caches upon switching Chris Wilson
2012-07-15 11:34 ` [PATCH 2/3] drm/i915: fix invalid reference handling of the default ctx obj Chris Wilson
2012-07-15 11:34 ` [PATCH 3/3] drm/i915: Cleanup context switching through do_switch() Chris Wilson
2012-07-16 17:15   ` Ben Widawsky
2012-07-16 18:27   ` Daniel Vetter
2012-07-15 15:16 ` [PATCH 1/3] drm/i915: Flush the context object from the CPU caches upon switching Daniel Vetter
2012-07-15 19:09   ` Chris Wilson
2012-07-16  8:43     ` Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.