linux/drivers/media
John Sheu d644cca50f media: vb2: Allow reqbufs(0) with "in use" MMAP buffers
Videobuf2 presently does not allow VIDIOC_REQBUFS to destroy outstanding
buffers if the queue is of type V4L2_MEMORY_MMAP, and if the buffers are
considered "in use".  This is different behavior than for other memory
types and prevents us from deallocating buffers in following two cases:

1) There are outstanding mmap()ed views on the buffer. However even if
   we put the buffer in reqbufs(0), there will be remaining references,
   due to vma .open/close() adjusting vb2 buffer refcount appropriately.
   This means that the buffer will be in fact freed only when the last
   mmap()ed view is unmapped.

2) Buffer has been exported as a DMABUF. Refcount of the vb2 buffer
   is managed properly by VB2 DMABUF ops, i.e. incremented on DMABUF
   get and decremented on DMABUF release. This means that the buffer
   will be alive until all importers release it.

Considering both cases above, there does not seem to be any need to
prevent reqbufs(0) operation, because buffer lifetime is already
properly managed by both mmap() and DMABUF code paths. Let's remove it
and allow userspace freeing the queue (and potentially allocating a new
one) even though old buffers might be still in processing.

To let userspace know that the kernel now supports orphaning buffers
that are still in use, add a new V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS
to be set by reqbufs and create_bufs.

[p.zabel@pengutronix.de: added V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS,
 updated documentation, and added back debug message]

Signed-off-by: John Sheu <sheu@chromium.org>
Reviewed-by: Pawel Osciak <posciak@chromium.org>
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: added V4L2-BUF-CAP-SUPPORTS-ORPHANED-BUFS ref]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-11-23 06:41:39 -05:00
..
cec media: cec: keep track of outstanding transmits 2018-11-23 05:56:14 -05:00
common media: vb2: Allow reqbufs(0) with "in use" MMAP buffers 2018-11-23 06:41:39 -05:00
dvb-core media updates for v4.20-rc1 2018-10-31 10:53:29 -07:00
dvb-frontends media updates for v4.20-rc1 2018-10-31 10:53:29 -07:00
firewire media: replace strcpy() by strscpy() 2018-09-11 13:32:17 -04:00
i2c media: adv*/tc358743/ths8200: fill in min width/height/pixelclock 2018-11-23 06:20:55 -05:00
mmc media: siano: use GFP_DMA only for smssdio 2018-05-15 08:04:42 -04:00
pci media: saa7134: hvr1110 can decode rc6 2018-11-22 13:31:32 -05:00
platform media: venus: firmware: add no TZ boot and shutdown routine 2018-11-23 06:34:12 -05:00
radio media: replace strcpy() by strscpy() 2018-09-11 13:32:17 -04:00
rc media: rc: ensure close() is called on rc_unregister_device 2018-11-22 13:33:24 -05:00
spi media: cxd2880-spi: Modified how to declare structure 2018-05-05 10:37:12 -04:00
tuners media: si2157: declare its own pads 2018-09-17 13:16:19 -04:00
usb media: pulse8-cec: return 0 when invalidating the logical address 2018-11-23 05:49:11 -05:00
v4l2-core media: v4l2-mem2mem: Avoid calling .device_run in v4l2_m2m_job_finish 2018-11-23 06:37:47 -05:00
Kconfig media: cec: Kconfig coding style issue 2018-05-09 16:26:50 -04:00
Makefile media: media-request: implement media requests 2018-08-31 11:04:51 -04:00
media-device.c media updates for v4.20-rc1 2018-10-31 10:53:29 -07:00
media-devnode.c MAINTAINERS & files: Canonize the e-mails I use at files 2018-05-04 06:21:06 -04:00
media-entity.c media: v4l2-mc: switch it to use the new approach to setup pipelines 2018-09-17 13:16:19 -04:00
media-request.c media: media-request: EPERM -> EACCES/EBUSY 2018-09-11 09:57:29 -04:00