Intel-GFX Archive on lore.kernel.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] drm/i915: Only free the unpin_work if cancelled before being run
Date: Tue, 17 Apr 2012 14:30:35 +0100	[thread overview]
Message-ID: <1334669450_13182@CP5-2952> (raw)
In-Reply-To: <20120417103345.GJ4104@phenom.ffwll.local>

On Tue, 17 Apr 2012 12:33:46 +0200, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Tue, Apr 17, 2012 at 10:53:24AM +0100, Chris Wilson wrote:
> > On Tue, 17 Apr 2012 10:29:38 +0100, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > > The unpin worker frees it work struct and so during intel_crtc_disable
> > > we should only also free the work struct if cancel_work_sync() reports
> > > that it successfully cancelled the work prior to it being executed and
> > > thus avoid the double free.
> > > 
> > > The impact is only for people unloading modules during a fullscreen game
> > > or movie playback, so extremely small.
> > 
> > Futher review (hunting for some sign of workqueue corruption, cf
> > https://bugs.freedesktop.org/show_bug.cgi?id=48798) says that if work is
> > non-NULL here it will not have been scheduled so cancel_work_sync() will
> > always return true.
> 
> Well, I've failed to notice this while reviewing the unpin_work life-cycle
> ...
> 
> > Which also means that we have no way of waiting upon the scheduled
> > unpin_work. :|
> 
> ... but have noticed that we lose any reference from intel_crtc to the
> unpin work once it's scheduled, and checked that we properly flush the
> work queue: See the ordering of irq disable, flush workqueue, then crtc
> destroy (in mode_config_cleanup).
> 
> We even have a flush_workqueu in i915_dma.c before tearing down gem, but
> that won't work too well now that unpin also frobs around with the fbc
> state (which is gone by now). But there's still the misleading comment
> that this syncs up with unpin work.
> 
> Care to clean this up a bit by
> - ditching the unnecessary flush_workqueu in i915_dma.c
Indeed looks superfluous. If we consider the unlikelihood the cleanup
code being well-tested, I'd prefer that we did do something like
drain_workqueue() as the first step in unload().

> - move the comment about syncing up with unpin_work to where we actually
>   sync up

I'm not finding another point where we explicitly sync with outstanding
unpin work. Probably due to the comment being in the wrong place...

> - and kill the superflous cancel_work?
Which also reminds me that the unpin_work holds onto a few references
that need to be released as well as the kfree. See above about these code
paths being relatively untrod.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

  reply	other threads:[~2012-04-17 13:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-17  9:29 [PATCH] drm/i915: Only free the unpin_work if cancelled before being run Chris Wilson
2012-04-17  9:47 ` Daniel Vetter
2012-04-17  9:53 ` Chris Wilson
2012-04-17 10:33   ` Daniel Vetter
2012-04-17 13:30     ` Chris Wilson [this message]
2012-04-17 13:44       ` Daniel Vetter
2012-04-17 13:45         ` 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=1334669450_13182@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