public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/3] drm/i915: Flush the context object from the CPU caches upon switching
Date: Sun, 15 Jul 2012 20:09:36 +0100	[thread overview]
Message-ID: <1342379395_1961@CP5-2952> (raw)
In-Reply-To: <20120715151634.GD5184@phenom.ffwll.local>

On Sun, 15 Jul 2012 17:16:34 +0200, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Sun, Jul 15, 2012 at 12:34:22PM +0100, Chris Wilson wrote:
> > 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;
> > +	}
> > +
> 
> Do I understand things correctly that thanks to clever use of
> set_to_gtt_domain with write = false and not setting a write_domain when
> moving the old context object to the active list we won't block? If so,
> I'll add a short note to that effect to the commit message when merging.

Worse, it was accidentally very clever. :(

Definitely needs a comment and in the future a new function to dtrt
intentionally!
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

  reply	other threads:[~2012-07-15 19:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2012-07-16  8:43     ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1342379395_1961@CP5-2952 \
    --to=chris@chris-wilson.co.uk \
    --cc=daniel@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox