intel-gfx.lists.freedesktop.org archive mirror
 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] drm/i915: Close race between processing unpin task and queueing the flip
Date: Sat, 01 Dec 2012 22:32:04 +0000	[thread overview]
Message-ID: <275ffc$7lntjv@fmsmga002.fm.intel.com> (raw)
In-Reply-To: <20121201203521.GH4384@phenom.ffwll.local>

On Sat, 1 Dec 2012 21:35:21 +0100, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Sat, Dec 01, 2012 at 05:48:50PM +0000, Chris Wilson wrote:
> > Before queuing the flip but crucially after attaching the unpin-work to
> > the crtc, we continue to setup the unpin-work. However, should the
> > hardware fire early, we see the connected unpin-work and queue the task.
> > The task then promptly runs and unpins the fb before we finish taking
> > the required references or even pinning it... Havoc.
> > 
> > To close the race, we use the flip-pending atomic to indicate when the
> > flip is finally setup and enqueued. So during the flip-done processing,
> > we can check more accurately whether the flip was expected.
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> 
> Hm, can't this logic race?
> 
> - emit the MI_FLIP
> 
> - flip irq happens because the gpu is idle and completes it right away
> (or our thread is preempted), work->pending increments from 0 -> 1
> 
> - queue_flip sets work->pending to 1

-> write RING_TAIL, flush the commands to CS, begin execution of MI_FLIP

I'm not happy with the explanation, but I could reliably (100%) hit the
race whilst loading a 2+GiB image using eog under compiz on an 965gm
with only 2GIB of ram. As soon as it hit kswapd, the system would OOPS
with an unpin leak. Which means that was a flip pending/done prior to
the pinning + MI_FLIP. This patch adds a strong defence against that
spurious flip done, but doesn't explain where it came from.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

  reply	other threads:[~2012-12-01 22:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-01 17:48 [PATCH] drm/i915: Close race between processing unpin task and queueing the flip Chris Wilson
2012-12-01 20:35 ` Daniel Vetter
2012-12-01 22:32   ` Chris Wilson [this message]
2012-12-02  1:15     ` Daniel Vetter
2012-12-02  9:26       ` Chris Wilson
2012-12-02 11:38         ` Daniel Vetter
2012-12-03 11:25 Chris Wilson
2012-12-03 11:36 Chris Wilson
2012-12-06 13:10 ` 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='275ffc$7lntjv@fmsmga002.fm.intel.com' \
    --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;
as well as URLs for NNTP newsgroup(s).