All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: David Herrmann <dh.herrmann@gmail.com>
Cc: USB list <linux-usb@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: dma-buf and ->dev refcount fun
Date: Tue, 25 Mar 2014 11:59:01 +0100	[thread overview]
Message-ID: <20140325105901.GZ26878@phenom.ffwll.local> (raw)
In-Reply-To: <CANq1E4SdvcdYZ2UXBV1-sr0jeiFZ+2Vx-ULRwjkD02VEHMc6CA@mail.gmail.com>

On Tue, Mar 25, 2014 at 10:40:45AM +0100, David Herrmann wrote:
> Hi
> 
> On Tue, Mar 25, 2014 at 9:01 AM, Daniel Vetter <daniel@ffwll.ch> wrote:
> > Besides the issue at hand though I think drivers need to make sure
> > that the device they use for attaching does outlive the dma-buf. Which
> > for real hotpluggin probably means that drivers need to drop all
> > attachment on unplug (the dma mapping is useless anyway) and just keep
> > all their imported gem objects alive with just a reference to the
> > dma-buf object itself.
> 
> Drivers should never touch other drivers or even look at them. There
> is no reason i915 is responsible of keeping udl alive. That gets
> really messy and may introduce circular dependencies.
> 
> I'd like to see exported dma-bufs reference their drm-device owner.
> This way, the drm-device stays around until the dma-buf is removed. To
> avoid lazy device destruction, a driver can (during unplug) simply
> detach all dma-bufs if, and only if, they first made the dma-buf
> somehow stand-alone.
> 
> For example: udl can just move the allocated pages into the dma-buf,
> mark it as dead and detach it. The udl-device can get destructed and
> whenever i915 releases the dma-buf, the udl-dma-buf ops see it's dead
> and just deref it / release dma-buf resources. But this is all not
> needed if the exported dma-bufs just reference "drm_device", which is
> imho the easiest fix.

The issue at hand is the other way round, i.e. i915 exporting, udl
importing. The i915/dma-buf falls over because the device struct
referenced in the attachment disappeared. Dave fixed it by grabbing a
reference, I think the better fix would be to simply not attach (since udl
doesn't need it anyway). Either works.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

      parent reply	other threads:[~2014-03-25 10:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-25  3:53 dma-buf and ->dev refcount fun Dave Airlie
2014-03-25  8:01 ` Daniel Vetter
2014-03-25  9:01   ` Thomas Hellstrom
     [not found]   ` <CAKMK7uGcLTLbMD+YvL1oy7r+jj0P23ZoFEkKG-MJRaPADWugmw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-25  9:40     ` David Herrmann
2014-03-25 10:11       ` Dave Airlie
2014-03-25 10:59       ` Daniel Vetter [this message]

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=20140325105901.GZ26878@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dh.herrmann@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-usb@vger.kernel.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 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.