linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RFC: get_dma_buf_unless_zero ?
@ 2013-11-06 19:59 Thomas Hellstrom
  0 siblings, 0 replies; only message in thread
From: Thomas Hellstrom @ 2013-11-06 19:59 UTC (permalink / raw)
  To: dri-devel, linaro-mm-sig, linux-kernel

Anyone else but me that feels such a function could be useful?

My main use-case is that it would resolve the mutual refcounting problem:

1) drm buffer object caches a dma_buf pointer which it refcounts
2) The dma-buf holds a refcount to the buffer.

This is resolved today by having the user-space visible part of the 
drm-buffer holding the refcount to the dma_buf. When user-space closes 
the drm-buffer, the reference goes away, and eventually the buffer is 
freed, when all external dma-buf users are done with the dma-buf

However, this also means that the dma-buf remains for the buffer 
lifetime even when there are no external users, which bugs me a bit.

This can be resolved by viewing the drm buffer as a lookup structure 
that doesn't hold a refcount to the dma-buf, but that means that the 
lookup structure (buffer) would need to share locks with the dma-buf 
implementation, unless we have a get_dma_buf_unless_zero, which means we 
can use locks local to the lookup structure, the drm buffer.
(See the last part of the kref documentation for a detailed discussion 
of this).

Now I don't think keeping the dma_buf for the drm buffer lifetime is a 
HUGE problem, but I just wanted to get people's views of this.

Thanks,
Thomas

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-11-06 19:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-06 19:59 RFC: get_dma_buf_unless_zero ? Thomas Hellstrom

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).