dma-buf and ->dev refcount fun

David Herrmann dh.herrmann at gmail.com
Tue Mar 25 02:40:45 PDT 2014


Hi

On Tue, Mar 25, 2014 at 9:01 AM, Daniel Vetter <daniel at 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.

David


More information about the dri-devel mailing list