Clean up min_buffers_needed misusages
Subsystems (62)
v4 cover Clean up min_buffers_needed misusages
This series implement Hans's RFC: https://www.spinics.net/lists/linux-media/msg244455.html
To summarize Hans's proposal it is needed to distinguish two cases:
- the minimal number of buffers to be allocated when calling VIDIOC_REQBUFS.
- the minimale number of queued buffers before start streaming. Until now drivers use vb2_queue min_buffers_needed field in the both cases but before introduce delete buffers we need to clarify for which usage each of them use min_buffers_needed field.
The branch with all patches is here:
https://gitlab.collabora.com/benjamin.gaignard/for-upstream/-/commits/clean_min_need_buffers_v5
I have tested with this command line, I haven't notice issues:
./test-media -kmemleak mc
changes in version 5:
- Fix the comments done by Hans:
Rework comments on videobuf2-core.h
Add checks in vb2_core_queue_init().
- Patch test-drivers to use min_reqbufs_allocation field.
changes in version 4:
- restore removed lines in zoran and vdec drivers.
changes in version 3:
- Just rename min_buffers_needed into min_queued_buffers everywhere without trying to fix the drivers.
- Introduce min_reqbufs_allocation field to be used when calling VIDIOC_REQBUFS.
changes in version 2:
- change min_buffers_needed into min_queues_buffers instead of min_dma_buffers_needed
- patches order
- only one patch to rename min_buffers_needed into min_queues_buffer
Benjamin Gaignard (3):
videobuf2: core: Rename min_buffers_needed field to vb2_queue
videobuf2: Add min_reqbufs_allocation field to vb2_queue structure
media: test-drivers: Set REQBUFS minimum number of buffers
drivers/input/touchscreen/atmel_mxt_ts.c | 2 +- drivers/input/touchscreen/sur40.c | 2 +- drivers/media/common/saa7146/saa7146_fops.c | 2 +- .../media/common/videobuf2/videobuf2-core.c | 34 +++++++++++-------- drivers/media/dvb-core/dvb_vb2.c | 2 +- drivers/media/i2c/video-i2c.c | 2 +- drivers/media/pci/bt8xx/bttv-driver.c | 2 +- drivers/media/pci/cobalt/cobalt-v4l2.c | 2 +- drivers/media/pci/cx18/cx18-streams.c | 2 +- drivers/media/pci/cx23885/cx23885-417.c | 2 +- drivers/media/pci/cx23885/cx23885-dvb.c | 2 +- drivers/media/pci/cx23885/cx23885-video.c | 4 +-- drivers/media/pci/cx25821/cx25821-video.c | 2 +- drivers/media/pci/cx88/cx88-blackbird.c | 2 +- drivers/media/pci/cx88/cx88-dvb.c | 2 +- drivers/media/pci/cx88/cx88-video.c | 4 +-- drivers/media/pci/dt3155/dt3155.c | 2 +- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- drivers/media/pci/mgb4/mgb4_vin.c | 2 +- drivers/media/pci/mgb4/mgb4_vout.c | 2 +- drivers/media/pci/tw5864/tw5864-video.c | 2 +- drivers/media/pci/tw68/tw68-video.c | 2 +- drivers/media/pci/tw686x/tw686x-video.c | 2 +- drivers/media/pci/zoran/zoran_driver.c | 6 ++-- drivers/media/platform/amphion/vpu_v4l2.c | 4 +-- drivers/media/platform/aspeed/aspeed-video.c | 2 +- drivers/media/platform/atmel/atmel-isi.c | 2 +- .../platform/chips-media/coda/coda-common.c | 2 +- .../platform/microchip/microchip-isc-base.c | 2 +- drivers/media/platform/nuvoton/npcm-video.c | 2 +- drivers/media/platform/nxp/imx7-media-csi.c | 2 +- .../platform/nxp/imx8-isi/imx8-isi-video.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 4 +-- drivers/media/platform/qcom/venus/venc.c | 4 +-- .../platform/renesas/rcar-vin/rcar-dma.c | 2 +- drivers/media/platform/renesas/renesas-ceu.c | 2 +- .../platform/renesas/rzg2l-cru/rzg2l-video.c | 2 +- drivers/media/platform/renesas/sh_vou.c | 2 +- .../platform/rockchip/rkisp1/rkisp1-capture.c | 2 +- drivers/media/platform/st/sti/hva/hva-v4l2.c | 4 +-- drivers/media/platform/st/stm32/stm32-dcmi.c | 2 +- .../st/stm32/stm32-dcmipp/dcmipp-bytecap.c | 4 +-- .../platform/sunxi/sun4i-csi/sun4i_dma.c | 2 +- .../sunxi/sun6i-csi/sun6i_csi_capture.c | 2 +- .../media/platform/sunxi/sun8i-di/sun8i-di.c | 4 +-- .../sunxi/sun8i-rotate/sun8i_rotate.c | 4 +-- .../media/platform/ti/am437x/am437x-vpfe.c | 2 +- drivers/media/platform/ti/cal/cal-video.c | 2 +- .../media/platform/ti/davinci/vpif_capture.c | 2 +- .../media/platform/ti/davinci/vpif_display.c | 2 +- .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 2 +- drivers/media/platform/ti/omap/omap_vout.c | 2 +- .../media/test-drivers/vimc/vimc-capture.c | 2 +- drivers/media/test-drivers/vivid/vivid-core.c | 4 +-- drivers/media/usb/cx231xx/cx231xx-417.c | 2 +- drivers/media/usb/cx231xx/cx231xx-video.c | 4 +-- drivers/media/usb/dvb-usb/cxusb-analog.c | 2 +- drivers/media/usb/gspca/gspca.c | 6 ++-- .../media/deprecated/atmel/atmel-isc-base.c | 2 +- drivers/staging/media/imx/imx-media-capture.c | 2 +- drivers/staging/media/ipu3/ipu3-v4l2.c | 2 +- drivers/staging/media/meson/vdec/vdec.c | 6 ++-- .../staging/media/starfive/camss/stf-video.c | 2 +- .../media/sunxi/sun6i-isp/sun6i_isp_capture.c | 2 +- .../media/sunxi/sun6i-isp/sun6i_isp_params.c | 2 +- drivers/staging/media/tegra-video/vi.c | 2 +- include/media/videobuf2-core.h | 20 +++++++++-- samples/v4l/v4l2-pci-skeleton.c | 2 +- 68 files changed, 121 insertions(+), 99 deletions(-)
Signature · 1 line
2.40.1
PATCH v5 1/3 videobuf2: core: Rename min_buffers_needed field to vb2_queue
Rename min_buffers_needed into min_queued_buffers and update the documentation about it.
---
version 5:
- reqbufs minimum allocation is at least q->min_queued_buffers + 1.
- rework min_queued_buffers documentation.
drivers/input/touchscreen/atmel_mxt_ts.c | 2 +- drivers/input/touchscreen/sur40.c | 2 +- drivers/media/common/saa7146/saa7146_fops.c | 2 +- .../media/common/videobuf2/videobuf2-core.c | 28 +++++++++---------- drivers/media/dvb-core/dvb_vb2.c | 2 +- drivers/media/i2c/video-i2c.c | 2 +- drivers/media/pci/bt8xx/bttv-driver.c | 2 +- drivers/media/pci/cobalt/cobalt-v4l2.c | 2 +- drivers/media/pci/cx18/cx18-streams.c | 2 +- drivers/media/pci/cx23885/cx23885-417.c | 2 +- drivers/media/pci/cx23885/cx23885-dvb.c | 2 +- drivers/media/pci/cx23885/cx23885-video.c | 4 +-- drivers/media/pci/cx25821/cx25821-video.c | 2 +- drivers/media/pci/cx88/cx88-blackbird.c | 2 +- drivers/media/pci/cx88/cx88-dvb.c | 2 +- drivers/media/pci/cx88/cx88-video.c | 4 +-- drivers/media/pci/dt3155/dt3155.c | 2 +- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- drivers/media/pci/mgb4/mgb4_vin.c | 2 +- drivers/media/pci/mgb4/mgb4_vout.c | 2 +- drivers/media/pci/tw5864/tw5864-video.c | 2 +- drivers/media/pci/tw68/tw68-video.c | 2 +- drivers/media/pci/tw686x/tw686x-video.c | 2 +- drivers/media/pci/zoran/zoran_driver.c | 6 ++-- drivers/media/platform/amphion/vpu_v4l2.c | 4 +-- drivers/media/platform/aspeed/aspeed-video.c | 2 +- drivers/media/platform/atmel/atmel-isi.c | 2 +- .../platform/chips-media/coda/coda-common.c | 2 +- .../platform/microchip/microchip-isc-base.c | 2 +- drivers/media/platform/nuvoton/npcm-video.c | 2 +- drivers/media/platform/nxp/imx7-media-csi.c | 2 +- .../platform/nxp/imx8-isi/imx8-isi-video.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 4 +-- drivers/media/platform/qcom/venus/venc.c | 4 +-- .../platform/renesas/rcar-vin/rcar-dma.c | 2 +- drivers/media/platform/renesas/renesas-ceu.c | 2 +- .../platform/renesas/rzg2l-cru/rzg2l-video.c | 2 +- drivers/media/platform/renesas/sh_vou.c | 2 +- .../platform/rockchip/rkisp1/rkisp1-capture.c | 2 +- drivers/media/platform/st/sti/hva/hva-v4l2.c | 4 +-- drivers/media/platform/st/stm32/stm32-dcmi.c | 2 +- .../st/stm32/stm32-dcmipp/dcmipp-bytecap.c | 4 +-- .../platform/sunxi/sun4i-csi/sun4i_dma.c | 2 +- .../sunxi/sun6i-csi/sun6i_csi_capture.c | 2 +- .../media/platform/sunxi/sun8i-di/sun8i-di.c | 4 +-- .../sunxi/sun8i-rotate/sun8i_rotate.c | 4 +-- .../media/platform/ti/am437x/am437x-vpfe.c | 2 +- drivers/media/platform/ti/cal/cal-video.c | 2 +- .../media/platform/ti/davinci/vpif_capture.c | 2 +- .../media/platform/ti/davinci/vpif_display.c | 2 +- .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 2 +- drivers/media/platform/ti/omap/omap_vout.c | 2 +- .../media/test-drivers/vimc/vimc-capture.c | 2 +- drivers/media/test-drivers/vivid/vivid-core.c | 2 +- drivers/media/usb/cx231xx/cx231xx-417.c | 2 +- drivers/media/usb/cx231xx/cx231xx-video.c | 4 +-- drivers/media/usb/dvb-usb/cxusb-analog.c | 2 +- drivers/media/usb/gspca/gspca.c | 6 ++-- .../media/deprecated/atmel/atmel-isc-base.c | 2 +- drivers/staging/media/imx/imx-media-capture.c | 2 +- drivers/staging/media/ipu3/ipu3-v4l2.c | 2 +- drivers/staging/media/meson/vdec/vdec.c | 6 ++-- .../staging/media/starfive/camss/stf-video.c | 2 +- .../media/sunxi/sun6i-isp/sun6i_isp_capture.c | 2 +- .../media/sunxi/sun6i-isp/sun6i_isp_params.c | 2 +- drivers/staging/media/tegra-video/vi.c | 2 +- include/media/videobuf2-core.h | 7 +++-- samples/v4l/v4l2-pci-skeleton.c | 2 +- 68 files changed, 101 insertions(+), 98 deletions(-)
drivers/input/touchscreen/atmel_mxt_ts.c +1 -1
@@ -2546,7 +2546,7 @@ static const struct vb2_queue mxt_queue = { .ops = &mxt_queue_ops, .mem_ops = &vb2_vmalloc_memops, .timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC, - .min_buffers_needed = 1, + .min_queued_buffers = 1, }; static int mxt_vidioc_querycap(struct file *file, void *priv,
drivers/input/touchscreen/sur40.c +1 -1
@@ -1124,7 +1124,7 @@ static const struct vb2_queue sur40_queue = { .ops = &sur40_queue_ops, .mem_ops = &vb2_dma_sg_memops, .timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC, - .min_buffers_needed = 3, + .min_queued_buffers = 3, };static const struct v4l2_file_operations sur40_video_fops = {
drivers/media/common/saa7146/saa7146_fops.c +1 -1
@@ -387,7 +387,7 @@ int saa7146_register_device(struct video_device *vfd, struct saa7146_dev *dev, q->gfp_flags = __GFP_DMA32; q->buf_struct_size =sizeof (struct saa7146_buf ); q->lock = &dev->v4l2_lock; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->dev = &dev->pci->dev; err =vb2_queue_init (q);if (err)
drivers/media/common/videobuf2/videobuf2-core.c +14 -14
@@ -865,7 +865,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,/* * Make sure the requested values and current defaults are sane. */ - num_buffers = max_t(unsigned int, *count, q->min_buffers_needed); + num_buffers = max_t(unsigned int, *count, q->min_queued_buffers + 1); num_buffers = min_t(unsigned int, num_buffers, q->max_num_buffers);memset (q->alloc_devs,0 ,sizeof (q->alloc_devs));/*
@@ -917,7 +917,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,* There is no point in continuing if we can't allocate the minimum * number of buffers needed by this vb2_queue. */ -if (allocated_buffers < q->min_buffers_needed) +if (allocated_buffers < q->min_queued_buffers) ret = -ENOMEM ;/*
@@ -1653,7 +1653,7 @@ EXPORT_SYMBOL_GPL(vb2_core_prepare_buf);* @q: videobuf2 queue * * Attempt to start streaming. When this function is called there must be -* at least q->min_buffers_needed buffers queued up (i.e. the minimum +* at least q->min_queued_buffers queued up (i.e. the minimum * number of buffers required for the DMA engine to function). If the * @start_streaming op fails it is supposed to return all the driver-owned * buffers back to vb2 in state QUEUED. Check if that happened and if
@@ -1846,7 +1846,7 @@ int vb2_core_qbuf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb,* then we can finally call start_streaming(). */ if (q->streaming && !q->start_streaming_called && - q->queued_count >= q->min_buffers_needed) { + q->queued_count >= q->min_queued_buffers) { ret =vb2_start_streaming (q);if (ret) {/*
@@ -2210,9 +2210,9 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)return -EINVAL ; } -if (q_num_bufs < q->min_buffers_needed) { -dprintk (q,1 ,"need at least %u allocated buffers\n" , - q->min_buffers_needed); +if (q_num_bufs < q->min_queued_buffers) { +dprintk (q,1 ,"need at least %u queued buffers\n" , + q->min_queued_buffers);return -EINVAL ; }
@@ -2224,7 +2224,7 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)* Tell driver to start streaming provided sufficient buffers * are available. */ -if (q->queued_count >= q->min_buffers_needed) { +if (q->queued_count >= q->min_queued_buffers) { ret =vb2_start_streaming (q);if (ret) goto unprepare;
@@ -2504,7 +2504,7 @@ int vb2_core_queue_init(struct vb2_queue *q)return -EINVAL ;if (WARN_ON (q->max_num_buffers >MAX_BUFFER_INDEX ) || -WARN_ON (q->min_buffers_needed > q->max_num_buffers)) +WARN_ON (q->min_queued_buffers > q->max_num_buffers))return -EINVAL ;if (WARN_ON (q->requires_requests && !q->supports_requests))
@@ -2512,13 +2512,13 @@ int vb2_core_queue_init(struct vb2_queue *q)/* * This combination is not allowed since a non-zero value of -* q->min_buffers_needed can cause vb2_core_qbuf() to fail if +* q->min_queued_buffers can cause vb2_core_qbuf() to fail if * it has to call start_streaming(), and the Request API expects * that queueing a request (and thus queueing a buffer contained * in that request) will always succeed. There is no method of * propagating an error back to userspace. */ -if (WARN_ON (q->supports_requests && q->min_buffers_needed)) +if (WARN_ON (q->supports_requests && q->min_queued_buffers))return -EINVAL ;INIT_LIST_HEAD (&q->queued_list);
@@ -2735,14 +2735,14 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)return -EBUSY ;/* -* Start with q->min_buffers_needed + 1, driver can increase it in +* Start with q->min_queued_buffers + 1, driver can increase it in * queue_setup() * -* 'min_buffers_needed' buffers need to be queued up before you +* 'min_queued_buffers' buffers need to be queued up before you * can start streaming, plus 1 for userspace (or in this case, * kernelspace) processing. */ - count =max (2 , q->min_buffers_needed +1 ); + count =max (2 , q->min_queued_buffers +1 ); dprintk(q, 3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n", (read) ? "read" : "write", count, q->fileio_read_once,
drivers/media/dvb-core/dvb_vb2.c +1 -1
@@ -171,7 +171,7 @@ int dvb_vb2_init(struct dvb_vb2_ctx *ctx, const char *name, int nonblocking) q->io_modes =VB2_MMAP ; q->drv_priv = ctx; q->buf_struct_size =sizeof (struct dvb_buffer ); - q->min_buffers_needed =1 ; + q->min_queued_buffers =1 ; q->ops = &dvb_vb2_qops; q->mem_ops = &vb2_vmalloc_memops; q->buf_ops = &dvb_vb2_buf_ops;
drivers/media/i2c/video-i2c.c +1 -1
@@ -795,7 +795,7 @@ static int video_i2c_probe(struct i2c_client *client) queue->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; queue->drv_priv = data; queue->buf_struct_size =sizeof (struct video_i2c_buffer ); - queue->min_buffers_needed =1 ; + queue->min_queued_buffers =1 ; queue->ops = &video_i2c_video_qops; queue->mem_ops = &vb2_vmalloc_memops;
drivers/media/pci/bt8xx/bttv-driver.c +1 -1
@@ -3113,7 +3113,7 @@ static int vdev_init(struct bttv *btv, struct video_device *vfd, q->gfp_flags = __GFP_DMA32; q->buf_struct_size =sizeof (struct bttv_buffer ); q->lock = &btv->lock; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->dev = &btv->c.pci->dev; err =vb2_queue_init (q);if (err)
drivers/media/pci/cobalt/cobalt-v4l2.c +1 -1
@@ -1260,7 +1260,7 @@ static int cobalt_node_register(struct cobalt *cobalt, int node) q->ops = &cobalt_qops; q->mem_ops = &vb2_dma_sg_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->lock = &s->lock; q->dev = &cobalt->pci_dev->dev; vdev->queue = q;
drivers/media/pci/cx18/cx18-streams.c +1 -1
@@ -287,7 +287,7 @@ static int cx18_stream_init(struct cx18 *cx, int type) s->vidq.ops = &cx18_vb2_qops; s->vidq.mem_ops = &vb2_vmalloc_memops; s->vidq.timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - s->vidq.min_buffers_needed =2 ; + s->vidq.min_queued_buffers =2 ; s->vidq.gfp_flags =GFP_DMA32 ; s->vidq.dev = &cx->pci_dev->dev; s->vidq.lock = &cx->serialize_lock;
drivers/media/pci/cx23885/cx23885-417.c +1 -1
@@ -1525,7 +1525,7 @@ int cx23885_417_register(struct cx23885_dev *dev) q->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; q->io_modes =VB2_MMAP |VB2_USERPTR |VB2_DMABUF |VB2_READ ; q->gfp_flags =GFP_DMA32 ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->drv_priv = dev; q->buf_struct_size =sizeof (struct cx23885_buffer ); q->ops = &cx23885_qops;
drivers/media/pci/cx23885/cx23885-dvb.c +1 -1
@@ -2667,7 +2667,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port) q->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; q->io_modes =VB2_MMAP |VB2_USERPTR |VB2_DMABUF |VB2_READ ; q->gfp_flags =GFP_DMA32 ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->drv_priv = port; q->buf_struct_size =sizeof (struct cx23885_buffer ); q->ops = &dvb_qops;
drivers/media/pci/cx23885/cx23885-video.c +2 -2
@@ -1321,7 +1321,7 @@ int cx23885_video_register(struct cx23885_dev *dev) q->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; q->io_modes =VB2_MMAP |VB2_USERPTR |VB2_DMABUF |VB2_READ ; q->gfp_flags =GFP_DMA32 ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->drv_priv = dev; q->buf_struct_size =sizeof (struct cx23885_buffer ); q->ops = &cx23885_video_qops;
@@ -1338,7 +1338,7 @@ int cx23885_video_register(struct cx23885_dev *dev) q->type =V4L2_BUF_TYPE_VBI_CAPTURE ; q->io_modes =VB2_MMAP |VB2_USERPTR |VB2_DMABUF |VB2_READ ; q->gfp_flags =GFP_DMA32 ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->drv_priv = dev; q->buf_struct_size =sizeof (struct cx23885_buffer ); q->ops = &cx23885_vbi_qops;
drivers/media/pci/cx25821/cx25821-video.c +1 -1
@@ -730,7 +730,7 @@ int cx25821_video_register(struct cx25821_dev *dev) q->io_modes =VB2_MMAP |VB2_USERPTR |VB2_DMABUF ; q->io_modes |= is_output ?VB2_WRITE :VB2_READ ; q->gfp_flags =GFP_DMA32 ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->drv_priv = chan; q->buf_struct_size =sizeof (struct cx25821_buffer ); q->ops = &cx25821_video_qops;
drivers/media/pci/cx88/cx88-blackbird.c +1 -1
@@ -1195,7 +1195,7 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv) q->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; q->io_modes =VB2_MMAP |VB2_USERPTR |VB2_DMABUF |VB2_READ ; q->gfp_flags =GFP_DMA32 ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->drv_priv = dev; q->buf_struct_size =sizeof (struct cx88_buffer ); q->ops = &blackbird_qops;
drivers/media/pci/cx88/cx88-dvb.c +1 -1
@@ -1776,7 +1776,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) q->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; q->io_modes =VB2_MMAP |VB2_USERPTR |VB2_DMABUF |VB2_READ ; q->gfp_flags =GFP_DMA32 ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->drv_priv = dev; q->buf_struct_size =sizeof (struct cx88_buffer ); q->ops = &dvb_qops;
drivers/media/pci/cx88/cx88-video.c +2 -2
@@ -1411,7 +1411,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, q->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; q->io_modes =VB2_MMAP |VB2_USERPTR |VB2_DMABUF |VB2_READ ; q->gfp_flags =GFP_DMA32 ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->drv_priv = dev; q->buf_struct_size =sizeof (struct cx88_buffer ); q->ops = &cx8800_video_qops;
@@ -1428,7 +1428,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, q->type =V4L2_BUF_TYPE_VBI_CAPTURE ; q->io_modes =VB2_MMAP |VB2_USERPTR |VB2_DMABUF |VB2_READ ; q->gfp_flags =GFP_DMA32 ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->drv_priv = dev; q->buf_struct_size =sizeof (struct cx88_buffer ); q->ops = &cx8800_vbi_qops;
drivers/media/pci/dt3155/dt3155.c +1 -1
@@ -517,7 +517,7 @@ static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id) pd->vidq.ops = &q_ops; pd->vidq.mem_ops = &vb2_dma_contig_memops; pd->vidq.drv_priv = pd; - pd->vidq.min_buffers_needed =2 ; + pd->vidq.min_queued_buffers =2 ; pd->vidq.gfp_flags =GFP_DMA32 ; pd->vidq.lock = &pd->mux;/* for locking v4l2_file_operations */ pd->vidq.dev = &pdev->dev;
drivers/media/pci/intel/ipu3/ipu3-cio2.c +1 -1
@@ -1589,7 +1589,7 @@ static int cio2_queue_init(struct cio2_device *cio2, struct cio2_queue *q) vbq->mem_ops = &vb2_dma_sg_memops; vbq->buf_struct_size =sizeof (struct cio2_buffer ); vbq->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - vbq->min_buffers_needed =1 ; + vbq->min_queued_buffers =1 ; vbq->drv_priv = cio2; vbq->lock = &q->lock; r =vb2_queue_init (vbq);
drivers/media/pci/mgb4/mgb4_vin.c +1 -1
@@ -849,7 +849,7 @@ struct mgb4_vin_dev *mgb4_vin_create(struct mgb4_dev *mgbdev, int id) vindev->queue.mem_ops = &vb2_dma_sg_memops; vindev->queue.gfp_flags =GFP_DMA32 ; vindev->queue.timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - vindev->queue.min_buffers_needed =2 ; + vindev->queue.min_queued_buffers =2 ; vindev->queue.drv_priv = vindev; vindev->queue.lock = &vindev->lock; vindev->queue.dev = dev;
drivers/media/pci/mgb4/mgb4_vout.c +1 -1
@@ -523,7 +523,7 @@ struct mgb4_vout_dev *mgb4_vout_create(struct mgb4_dev *mgbdev, int id) voutdev->queue.mem_ops = &vb2_dma_sg_memops; voutdev->queue.gfp_flags =GFP_DMA32 ; voutdev->queue.timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - voutdev->queue.min_buffers_needed =2 ; + voutdev->queue.min_queued_buffers =2 ; voutdev->queue.drv_priv = voutdev; voutdev->queue.lock = &voutdev->lock; voutdev->queue.dev = dev;
drivers/media/pci/tw5864/tw5864-video.c +1 -1
@@ -1114,7 +1114,7 @@ static int tw5864_video_input_init(struct tw5864_input *input, int video_nr) input->vidq.gfp_flags =0 ; input->vidq.buf_struct_size =sizeof (struct tw5864_buf ); input->vidq.lock = &input->lock; - input->vidq.min_buffers_needed =2 ; + input->vidq.min_queued_buffers =2 ; input->vidq.dev = &input->root->pci->dev; ret =vb2_queue_init (&input->vidq);if (ret)
drivers/media/pci/tw68/tw68-video.c +1 -1
@@ -952,7 +952,7 @@ int tw68_video_init2(struct tw68_dev *dev, int video_nr) dev->vidq.gfp_flags = __GFP_DMA32 | __GFP_KSWAPD_RECLAIM; dev->vidq.buf_struct_size =sizeof (struct tw68_buf ); dev->vidq.lock = &dev->lock; - dev->vidq.min_buffers_needed =2 ; + dev->vidq.min_queued_buffers =2 ; dev->vidq.dev = &dev->pci->dev; ret =vb2_queue_init (&dev->vidq);if (ret)
drivers/media/pci/tw686x/tw686x-video.c +1 -1
@@ -1222,7 +1222,7 @@ int tw686x_video_init(struct tw686x_dev *dev) vc->vidq.ops = &tw686x_video_qops; vc->vidq.mem_ops = dev->dma_ops->mem_ops; vc->vidq.timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - vc->vidq.min_buffers_needed =2 ; + vc->vidq.min_queued_buffers =2 ; vc->vidq.lock = &vc->vb_mutex; vc->vidq.gfp_flags = dev->dma_mode !=TW686X_DMA_MODE_MEMCPY ?GFP_DMA32 :0 ;
drivers/media/pci/zoran/zoran_driver.c +3 -3
@@ -749,8 +749,8 @@ static int zr_vb2_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, unsi zr->buf_in_reserve =0 ; -if (*nbuffers < vq->min_buffers_needed) - *nbuffers = vq->min_buffers_needed; +if (*nbuffers < vq->min_queued_buffers) + *nbuffers = vq->min_queued_buffers;if (*nplanes) {if (sizes[0 ] < size)
@@ -971,7 +971,7 @@ int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir) vq->mem_ops = &vb2_dma_contig_memops; vq->gfp_flags =GFP_DMA32 ; vq->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - vq->min_buffers_needed =9 ; + vq->min_queued_buffers =9 ; vq->lock = &zr->lock; err =vb2_queue_init (vq);if (err)
drivers/media/platform/amphion/vpu_v4l2.c +2 -2
@@ -649,7 +649,7 @@ static int vpu_m2m_queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_q src_vq->mem_ops = &vb2_vmalloc_memops; src_vq->drv_priv = inst; src_vq->buf_struct_size =sizeof (struct vpu_vb2_buffer ); - src_vq->min_buffers_needed =1 ; + src_vq->min_queued_buffers =1 ; src_vq->dev = inst->vpu->dev; src_vq->lock = &inst->lock; ret =vb2_queue_init (src_vq);
@@ -666,7 +666,7 @@ static int vpu_m2m_queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_q dst_vq->mem_ops = &vb2_vmalloc_memops; dst_vq->drv_priv = inst; dst_vq->buf_struct_size =sizeof (struct vpu_vb2_buffer ); - dst_vq->min_buffers_needed =1 ; + dst_vq->min_queued_buffers =1 ; dst_vq->dev = inst->vpu->dev; dst_vq->lock = &inst->lock; ret =vb2_queue_init (dst_vq);
drivers/media/platform/aspeed/aspeed-video.c +1 -1
@@ -2034,7 +2034,7 @@ static int aspeed_video_setup_video(struct aspeed_video *video) vbq->drv_priv = video; vbq->buf_struct_size =sizeof (struct aspeed_video_buffer ); vbq->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - vbq->min_buffers_needed =ASPEED_VIDEO_V4L2_MIN_BUF_REQ ; + vbq->min_queued_buffers =ASPEED_VIDEO_V4L2_MIN_BUF_REQ ; rc =vb2_queue_init (vbq);if (rc) {
drivers/media/platform/atmel/atmel-isi.c +1 -1
@@ -1244,7 +1244,7 @@ static int atmel_isi_probe(struct platform_device *pdev) q->ops = &isi_video_qops; q->mem_ops = &vb2_dma_contig_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->dev = &pdev->dev; ret =vb2_queue_init (q);
drivers/media/platform/chips-media/coda/coda-common.c +1 -1
@@ -2546,7 +2546,7 @@ static int coda_queue_init(struct coda_ctx *ctx, struct vb2_queue *vq)* would need to be reflected in job_ready(). Currently we expect all * queues to have at least one buffer queued. */ - vq->min_buffers_needed =1 ; + vq->min_queued_buffers =1 ; vq->dev = ctx->dev->dev;return vb2_queue_init (vq);
drivers/media/platform/microchip/microchip-isc-base.c +1 -1
@@ -1780,7 +1780,7 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier) q->mem_ops = &vb2_dma_contig_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; q->lock = &isc->lock; - q->min_buffers_needed =1 ; + q->min_queued_buffers =1 ; q->dev = isc->dev; ret =vb2_queue_init (q);
drivers/media/platform/nuvoton/npcm-video.c +1 -1
@@ -1612,7 +1612,7 @@ static int npcm_video_setup_video(struct npcm_video *video) vbq->drv_priv = video; vbq->buf_struct_size =sizeof (struct npcm_video_buffer ); vbq->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - vbq->min_buffers_needed =3 ; + vbq->min_queued_buffers =3 ; rc =vb2_queue_init (vbq);if (rc) {
drivers/media/platform/nxp/imx7-media-csi.c +1 -1
@@ -1691,7 +1691,7 @@ static int imx7_csi_video_init(struct imx7_csi *csi) vq->mem_ops = &vb2_dma_contig_memops; vq->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; vq->lock = &csi->vdev_mutex; - vq->min_buffers_needed =2 ; + vq->min_queued_buffers =2 ; vq->dev = csi->dev; ret =vb2_queue_init (vq);
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +1 -1
@@ -1453,7 +1453,7 @@ int mxc_isi_video_register(struct mxc_isi_pipe *pipe, q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size =sizeof (struct mxc_isi_buffer ); q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->lock = &video->lock; q->dev = pipe->isi->dev;
drivers/media/platform/qcom/venus/vdec.c +2 -2
@@ -1641,7 +1641,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq, src_vq->drv_priv = inst; src_vq->buf_struct_size =sizeof (struct venus_buffer ); src_vq->allow_zero_bytesused =1 ; - src_vq->min_buffers_needed =0 ; + src_vq->min_queued_buffers =0 ; src_vq->dev = inst->core->dev; src_vq->lock = &inst->ctx_q_lock; ret =vb2_queue_init (src_vq);
@@ -1656,7 +1656,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->drv_priv = inst; dst_vq->buf_struct_size =sizeof (struct venus_buffer ); dst_vq->allow_zero_bytesused =1 ; - dst_vq->min_buffers_needed =0 ; + dst_vq->min_queued_buffers =0 ; dst_vq->dev = inst->core->dev; dst_vq->lock = &inst->ctx_q_lock;return vb2_queue_init (dst_vq);
drivers/media/platform/qcom/venus/venc.c +2 -2
@@ -1398,7 +1398,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq, src_vq->drv_priv = inst; src_vq->buf_struct_size =sizeof (struct venus_buffer ); src_vq->allow_zero_bytesused =1 ; - src_vq->min_buffers_needed =1 ; + src_vq->min_queued_buffers =1 ; src_vq->dev = inst->core->dev; src_vq->lock = &inst->ctx_q_lock;if (inst->core->res->hfi_version ==HFI_VERSION_1XX )
@@ -1415,7 +1415,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->drv_priv = inst; dst_vq->buf_struct_size =sizeof (struct venus_buffer ); dst_vq->allow_zero_bytesused =1 ; - dst_vq->min_buffers_needed =1 ; + dst_vq->min_queued_buffers =1 ; dst_vq->dev = inst->core->dev; dst_vq->lock = &inst->ctx_q_lock;return vb2_queue_init (dst_vq);
drivers/media/platform/renesas/rcar-vin/rcar-dma.c +1 -1
@@ -1559,7 +1559,7 @@ int rvin_dma_register(struct rvin_dev *vin, int irq) q->ops = &rvin_qops; q->mem_ops = &vb2_dma_contig_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =4 ; + q->min_queued_buffers =4 ; q->dev = vin->dev; ret =vb2_queue_init (q);
drivers/media/platform/renesas/renesas-ceu.c +1 -1
@@ -1399,7 +1399,7 @@ static int ceu_notify_complete(struct v4l2_async_notifier *notifier) q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size =sizeof (struct ceu_buffer ); q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->lock = &ceudev->mlock; q->dev = ceudev->v4l2_dev.dev;
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +1 -1
@@ -767,7 +767,7 @@ int rzg2l_cru_dma_register(struct rzg2l_cru_dev *cru) q->ops = &rzg2l_cru_qops; q->mem_ops = &vb2_dma_contig_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =4 ; + q->min_queued_buffers =4 ; q->dev = cru->dev; ret =vb2_queue_init (q);
drivers/media/platform/renesas/sh_vou.c +1 -1
@@ -1297,7 +1297,7 @@ static int sh_vou_probe(struct platform_device *pdev) q->ops = &sh_vou_qops; q->mem_ops = &vb2_dma_contig_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->lock = &vou_dev->fop_lock; q->dev = &pdev->dev; ret =vb2_queue_init (q);
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +1 -1
@@ -1431,7 +1431,7 @@ static int rkisp1_register_capture(struct rkisp1_capture *cap) q->ops = &rkisp1_vb2_ops; q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size =sizeof (struct rkisp1_buffer ); - q->min_buffers_needed =RKISP1_MIN_BUFFERS_NEEDED ; + q->min_queued_buffers =RKISP1_MIN_BUFFERS_NEEDED ; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; q->lock = &node->vlock; q->dev = cap->rkisp1->dev;
drivers/media/platform/st/sti/hva/hva-v4l2.c +2 -2
@@ -1142,7 +1142,7 @@ static int hva_queue_init(void *priv, struct vb2_queue *src_vq, src_vq->type =V4L2_BUF_TYPE_VIDEO_OUTPUT ; src_vq->buf_struct_size =sizeof (struct hva_frame ); - src_vq->min_buffers_needed =MIN_FRAMES ; + src_vq->min_queued_buffers =MIN_FRAMES ; src_vq->dev = ctx->hva_dev->dev; ret =queue_init (ctx, src_vq);
@@ -1151,7 +1151,7 @@ static int hva_queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; dst_vq->buf_struct_size =sizeof (struct hva_stream ); - dst_vq->min_buffers_needed =MIN_STREAMS ; + dst_vq->min_queued_buffers =MIN_STREAMS ; dst_vq->dev = ctx->hva_dev->dev;return queue_init (ctx, dst_vq);
drivers/media/platform/st/stm32/stm32-dcmi.c +1 -1
@@ -2031,7 +2031,7 @@ static int dcmi_probe(struct platform_device *pdev) q->ops = &dcmi_video_qops; q->mem_ops = &vb2_dma_contig_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->allow_cache_hints =1 ; q->dev = &pdev->dev;
drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-bytecap.c +2 -2
@@ -424,7 +424,7 @@ static int dcmipp_bytecap_start_streaming(struct vb2_queue *vq,reg_set (vcap,DCMIPP_P0FSCR ,DCMIPP_P0FSCR_PIPEN );/* -* vb2 framework guarantee that we have at least 'min_buffers_needed' +* vb2 framework guarantee that we have at least 'min_queued_buffers' * buffers in the list at this moment */ vcap->next =list_first_entry (&vcap->buffers,typeof (*buf), list);
@@ -889,7 +889,7 @@ struct dcmipp_ent_device *dcmipp_bytecap_ent_init(struct device *dev, q->ops = &dcmipp_bytecap_qops; q->mem_ops = &vb2_dma_contig_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =1 ; + q->min_queued_buffers =1 ; q->dev = dev;/* DCMIPP requires 16 bytes aligned buffers */
drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c +1 -1
@@ -411,7 +411,7 @@ int sun4i_csi_dma_register(struct sun4i_csi *csi, int irq)for (i =0 ; i <CSI_MAX_BUFFER ; i++) csi->current_buf[i] =NULL ; - q->min_buffers_needed =3 ; + q->min_queued_buffers =3 ; q->type =V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ; q->io_modes =VB2_MMAP |VB2_DMABUF ; q->lock = &csi->lock;
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +1 -1
@@ -1010,7 +1010,7 @@ int sun6i_csi_capture_setup(struct sun6i_csi_device *csi_dev) queue->buf_struct_size =sizeof (struct sun6i_csi_buffer ); queue->ops = &sun6i_csi_capture_queue_ops; queue->mem_ops = &vb2_dma_contig_memops; - queue->min_buffers_needed =2 ; + queue->min_queued_buffers =2 ; queue->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; queue->lock = &capture->lock; queue->dev = csi_dev->dev;
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c +2 -2
@@ -673,7 +673,7 @@ static int deinterlace_queue_init(void *priv, struct vb2_queue *src_vq, src_vq->io_modes =VB2_MMAP |VB2_DMABUF ; src_vq->drv_priv = ctx; src_vq->buf_struct_size =sizeof (struct v4l2_m2m_buffer ); - src_vq->min_buffers_needed =1 ; + src_vq->min_queued_buffers =1 ; src_vq->ops = &deinterlace_qops; src_vq->mem_ops = &vb2_dma_contig_memops; src_vq->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_COPY ;
@@ -688,7 +688,7 @@ static int deinterlace_queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->io_modes =VB2_MMAP |VB2_DMABUF ; dst_vq->drv_priv = ctx; dst_vq->buf_struct_size =sizeof (struct v4l2_m2m_buffer ); - dst_vq->min_buffers_needed =2 ; + dst_vq->min_queued_buffers =2 ; dst_vq->ops = &deinterlace_qops; dst_vq->mem_ops = &vb2_dma_contig_memops; dst_vq->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_COPY ;
drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c +2 -2
@@ -536,7 +536,7 @@ static int rotate_queue_init(void *priv, struct vb2_queue *src_vq, src_vq->io_modes =VB2_MMAP |VB2_DMABUF ; src_vq->drv_priv = ctx; src_vq->buf_struct_size =sizeof (struct v4l2_m2m_buffer ); - src_vq->min_buffers_needed =1 ; + src_vq->min_queued_buffers =1 ; src_vq->ops = &rotate_qops; src_vq->mem_ops = &vb2_dma_contig_memops; src_vq->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_COPY ;
@@ -551,7 +551,7 @@ static int rotate_queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->io_modes =VB2_MMAP |VB2_DMABUF ; dst_vq->drv_priv = ctx; dst_vq->buf_struct_size =sizeof (struct v4l2_m2m_buffer ); - dst_vq->min_buffers_needed =2 ; + dst_vq->min_queued_buffers =2 ; dst_vq->ops = &rotate_qops; dst_vq->mem_ops = &vb2_dma_contig_memops; dst_vq->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_COPY ;
drivers/media/platform/ti/am437x/am437x-vpfe.c +1 -1
@@ -2234,7 +2234,7 @@ static int vpfe_probe_complete(struct vpfe_device *vpfe) q->buf_struct_size =sizeof (struct vpfe_cap_buffer ); q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; q->lock = &vpfe->lock; - q->min_buffers_needed =1 ; + q->min_queued_buffers =1 ; q->dev = vpfe->pdev; err =vb2_queue_init (q);
drivers/media/platform/ti/cal/cal-video.c +1 -1
@@ -1010,7 +1010,7 @@ int cal_ctx_v4l2_init(struct cal_ctx *ctx) q->mem_ops = &vb2_dma_contig_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; q->lock = &ctx->mutex; - q->min_buffers_needed =3 ; + q->min_queued_buffers =3 ; q->dev = ctx->cal->dev; ret =vb2_queue_init (q);
drivers/media/platform/ti/davinci/vpif_capture.c +1 -1
@@ -1429,7 +1429,7 @@ static int vpif_probe_complete(void) q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size =sizeof (struct vpif_cap_buffer ); q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =1 ; + q->min_queued_buffers =1 ; q->lock = &common->lock; q->dev = vpif_dev;
drivers/media/platform/ti/davinci/vpif_display.c +1 -1
@@ -1169,7 +1169,7 @@ static int vpif_probe_complete(void) q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size =sizeof (struct vpif_disp_buffer ); q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =1 ; + q->min_queued_buffers =1 ; q->lock = &common->lock; q->dev = vpif_dev; err =vb2_queue_init (q);
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +1 -1
@@ -873,7 +873,7 @@ static int ti_csi2rx_init_vb2q(struct ti_csi2rx_dev *csi) q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; q->dev =dmaengine_get_dma_device (csi->dma.chan); q->lock = &csi->mutex; - q->min_buffers_needed =1 ; + q->min_queued_buffers =1 ; ret =vb2_queue_init (q);if (ret)
drivers/media/platform/ti/omap/omap_vout.c +1 -1
@@ -1404,7 +1404,7 @@ static int __init omap_vout_setup_video_data(struct omap_vout_device *vout) vq->ops = &omap_vout_vb2_ops; vq->mem_ops = &vb2_dma_contig_memops; vq->lock = &vout->lock; - vq->min_buffers_needed =1 ; + vq->min_queued_buffers =1 ; vfd->queue = vq; ret =vb2_queue_init (vq);
drivers/media/test-drivers/vimc/vimc-capture.c +1 -1
@@ -432,7 +432,7 @@ static struct vimc_ent_device *vimc_capture_add(struct vimc_device *vimc, q->mem_ops = vimc_allocator ==VIMC_ALLOCATOR_DMA_CONTIG ? &vb2_dma_contig_memops : &vb2_vmalloc_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->lock = &vcapture->lock; q->dev = v4l2_dev->dev;
drivers/media/test-drivers/vivid/vivid-core.c +1 -1
@@ -898,7 +898,7 @@ static int vivid_create_queue(struct vivid_dev *dev, q->mem_ops = allocators[dev->inst] ==1 ? &vb2_dma_contig_memops : &vb2_vmalloc_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed = supports_requests[dev->inst] ?0 : min_buffers_needed; + q->min_queued_buffers = supports_requests[dev->inst] ?0 : min_buffers_needed; q->lock = &dev->mutex; q->dev = dev->v4l2_dev.dev; q->supports_requests = supports_requests[dev->inst];
drivers/media/usb/cx231xx/cx231xx-417.c +1 -1
@@ -1782,7 +1782,7 @@ int cx231xx_417_register(struct cx231xx *dev) q->ops = &cx231xx_video_qops; q->mem_ops = &vb2_vmalloc_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =1 ; + q->min_queued_buffers =1 ; q->lock = &dev->lock; err =vb2_queue_init (q);if (err)
drivers/media/usb/cx231xx/cx231xx-video.c +2 -2
@@ -1811,7 +1811,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) q->ops = &cx231xx_video_qops; q->mem_ops = &vb2_vmalloc_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =1 ; + q->min_queued_buffers =1 ; q->lock = &dev->lock; ret =vb2_queue_init (q);if (ret)
@@ -1871,7 +1871,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) q->ops = &cx231xx_vbi_qops; q->mem_ops = &vb2_vmalloc_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =1 ; + q->min_queued_buffers =1 ; q->lock = &dev->lock; ret =vb2_queue_init (q);if (ret)
drivers/media/usb/dvb-usb/cxusb-analog.c +1 -1
@@ -1632,7 +1632,7 @@ static int cxusb_medion_register_analog_video(struct dvb_usb_device *dvbdev) cxdev->videoqueue.buf_struct_size =sizeof (struct cxusb_medion_vbuffer ); cxdev->videoqueue.timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - cxdev->videoqueue.min_buffers_needed =6 ; + cxdev->videoqueue.min_queued_buffers =6 ; cxdev->videoqueue.lock = &cxdev->dev_lock; ret =vb2_queue_init (&cxdev->videoqueue);
drivers/media/usb/gspca/gspca.c +3 -3
@@ -1257,7 +1257,7 @@ static int vidioc_g_parm(struct file *filp, void *priv, {struct gspca_dev *gspca_dev =video_drvdata (filp); - parm->parm.capture.readbuffers = gspca_dev->queue.min_buffers_needed; + parm->parm.capture.readbuffers = gspca_dev->queue.min_queued_buffers;if (!gspca_dev->sd_desc->get_streamparm)return 0 ;
@@ -1273,7 +1273,7 @@ static int vidioc_s_parm(struct file *filp, void *priv, {struct gspca_dev *gspca_dev =video_drvdata (filp); - parm->parm.capture.readbuffers = gspca_dev->queue.min_buffers_needed; + parm->parm.capture.readbuffers = gspca_dev->queue.min_queued_buffers;if (!gspca_dev->sd_desc->set_streamparm) { parm->parm.capture.capability =0 ;
@@ -1517,7 +1517,7 @@ int gspca_dev_probe2(struct usb_interface *intf, q->ops = &gspca_qops; q->mem_ops = &vb2_vmalloc_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ; q->lock = &gspca_dev->usb_lock; ret =vb2_queue_init (q);if (ret)
drivers/staging/media/deprecated/atmel/atmel-isc-base.c +1 -1
@@ -1871,7 +1871,7 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier) q->mem_ops = &vb2_dma_contig_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; q->lock = &isc->lock; - q->min_buffers_needed =1 ; + q->min_queued_buffers =1 ; q->dev = isc->dev; ret =vb2_queue_init (q);
drivers/staging/media/imx/imx-media-capture.c +1 -1
@@ -1022,7 +1022,7 @@ imx_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd, vq->mem_ops = &vb2_dma_contig_memops; vq->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; vq->lock = &priv->mutex; - vq->min_buffers_needed =2 ; + vq->min_queued_buffers =2 ; vq->dev = priv->dev; ret =vb2_queue_init (vq);
drivers/staging/media/ipu3/ipu3-v4l2.c +1 -1
@@ -1198,7 +1198,7 @@ static int imgu_v4l2_node_setup(struct imgu_device *imgu, unsigned int pipe, vbq->buf_struct_size = imgu->buf_struct_size; vbq->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ;/* can streamon w/o buffers */ - vbq->min_buffers_needed =0 ; + vbq->min_queued_buffers =0 ; vbq->drv_priv = imgu; vbq->lock = &node->lock; r =vb2_queue_init (vbq);
drivers/staging/media/meson/vdec/vdec.c +3 -3
@@ -184,7 +184,7 @@ static void process_num_buffers(struct vb2_queue *q,* we need all of them to be queued into the driver */ sess->num_dst_bufs = q_num_bufs + *num_buffers; - q->min_buffers_needed =max (fmt_out->min_buffers, sess->num_dst_bufs); + q->min_queued_buffers =max (fmt_out->min_buffers, sess->num_dst_bufs); } static int vdec_queue_setup(struct vb2_queue *q, unsigned int *num_buffers,
@@ -825,7 +825,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq, src_vq->mem_ops = &vb2_dma_contig_memops; src_vq->drv_priv = sess; src_vq->buf_struct_size =sizeof (struct dummy_buf ); - src_vq->min_buffers_needed =1 ; + src_vq->min_queued_buffers =1 ; src_vq->dev = sess->core->dev; src_vq->lock = &sess->lock; ret =vb2_queue_init (src_vq);
@@ -839,7 +839,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->mem_ops = &vb2_dma_contig_memops; dst_vq->drv_priv = sess; dst_vq->buf_struct_size =sizeof (struct dummy_buf ); - dst_vq->min_buffers_needed =1 ; + dst_vq->min_queued_buffers =1 ; dst_vq->dev = sess->core->dev; dst_vq->lock = &sess->lock;return vb2_queue_init (dst_vq);
drivers/staging/media/starfive/camss/stf-video.c +1 -1
@@ -513,7 +513,7 @@ int stf_video_register(struct stfcamss_video *video, q->buf_struct_size =sizeof (struct stfcamss_buffer ); q->dev = video->stfcamss->dev; q->lock = &video->q_lock; - q->min_buffers_needed =STFCAMSS_MIN_BUFFERS ; + q->min_queued_buffers =STFCAMSS_MIN_BUFFERS ; ret =vb2_queue_init (q);if (ret <0 ) { dev_err(video->stfcamss->dev,
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c +1 -1
@@ -660,7 +660,7 @@ int sun6i_isp_capture_setup(struct sun6i_isp_device *isp_dev) queue->buf_struct_size =sizeof (struct sun6i_isp_buffer ); queue->ops = &sun6i_isp_capture_queue_ops; queue->mem_ops = &vb2_dma_contig_memops; - queue->min_buffers_needed =2 ; + queue->min_queued_buffers =2 ; queue->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; queue->lock = &capture->lock; queue->dev = isp_dev->dev;
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c +1 -1
@@ -489,7 +489,7 @@ int sun6i_isp_params_setup(struct sun6i_isp_device *isp_dev) queue->buf_struct_size =sizeof (struct sun6i_isp_buffer ); queue->ops = &sun6i_isp_params_queue_ops; queue->mem_ops = &vb2_vmalloc_memops; - queue->min_buffers_needed =1 ; + queue->min_queued_buffers =1 ; queue->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; queue->lock = ¶ms->lock; queue->dev = isp_dev->dev;
drivers/staging/media/tegra-video/vi.c +1 -1
@@ -1174,7 +1174,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan) chan->queue.ops = &tegra_channel_queue_qops; chan->queue.mem_ops = &vb2_dma_contig_memops; chan->queue.timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - chan->queue.min_buffers_needed =2 ; + chan->queue.min_queued_buffers =2 ; chan->queue.dev = vi->dev; ret =vb2_queue_init (&chan->queue);if (ret <0 ) {
include/media/videobuf2-core.h +5 -2
@@ -546,10 +546,13 @@ struct vb2_buf_ops {* @gfp_flags: additional gfp flags used when allocating the buffers. * Typically this is 0, but it may be e.g. %GFP_DMA or %__GFP_DMA32 * to force the buffer allocation to a specific memory zone. -* @min_buffers_needed: the minimum number of buffers needed before +* @min_queued_buffers: the minimum number of queued buffers needed before * @start_streaming can be called. Used when a DMA engine * cannot be started unless at least this number of buffers * have been queued into the driver. +* VIDIOC_REQBUFS will ensure at least @min_queued_buffers + 1 +* buffers will be allocated. Note that VIDIOC_CREATE_BUFS will not +* modify the requested buffer count. */ /* * Private elements (won't appear at the uAPI book):
@@ -614,7 +617,7 @@ struct vb2_queue {unsigned int buf_struct_size;u32 timestamp_flags;gfp_t gfp_flags; -u32 min_buffers_needed; +u32 min_queued_buffers;struct device *alloc_devs[VB2_MAX_PLANES ];
samples/v4l/v4l2-pci-skeleton.c +1 -1
@@ -821,7 +821,7 @@ static int skeleton_probe(struct pci_dev *pdev, const struct pci_device_id *ent)* available before it can be started. The start_streaming() op * won't be called until at least this many buffers are queued up. */ - q->min_buffers_needed =2 ; + q->min_queued_buffers =2 ;/* * The serialization lock for the streaming ioctls. This is the same * as the main serialization lock, but if some of the non-streaming
Signature · 1 line
2.40.1
Re: [PATCH v5 1/3] videobuf2: core: Rename min_buffers_needed field to vb2_queue
Hi Benjamin,
Quoted 2 lines · Benjamin Gaignard
Rename
min_buffers_neededintomin_queued_buffersand update the documentation about it.
I merged this patch, but not the others. I also dropped one functional change:
<snip>
drivers/media/common/videobuf2/videobuf2-core.c int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, · line 871
Quoted 13 lines
drivers/media/common/videobuf2/videobuf2-core.c +1
-1@@ -865,7 +865,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,/* * Make sure the requested values and current defaults are sane. */ - num_buffers = max_t(unsigned int, *count, q->min_buffers_needed); + num_buffers = max_t(unsigned int, *count, q->min_queued_buffers + 1); num_buffers = min_t(unsigned int, num_buffers, q->max_num_buffers);memset (q->alloc_devs,0 ,sizeof (q->alloc_devs));/*
That "+ 1" didn't really belong here, since everything else was just renaming a field. Such a patch shouldn't make any other changes.
There were also three more occurrences of min_buffers_needed (one in a comment, two in a vivid function argument), and I renamed those as well.
'git grep min_buffers_needed' now no longer shows any hits.
I decided not to take the other patches, I think it is best if you rebase and repost the series on top of staging and in the new year we'll continue with it. I did not feel that I had enough time to really review the remaining patches.
However, it is nice to have this large rename patch merged. It touches on a lot of files, so it is annoying to have to carry that around. And now was a good moment to merge it.
Regards,
Hans
Re: [PATCH v5 1/3] videobuf2: core: Rename min_buffers_needed field to vb2_queue
Le 13/12/2023 à 17:39, Hans Verkuil a écrit :
Quoted 26 lines
Hi Benjamin,
Quoted 2 lines · Benjamin Gaignard
Rename
min_buffers_neededintomin_queued_buffersand update the documentation about it.I merged this patch, but not the others. I also dropped one functional change:
<snip>
drivers/media/common/videobuf2/videobuf2-core.c int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, · line 871
Quoted 13 lines
drivers/media/common/videobuf2/videobuf2-core.c +1
-1@@ -865,7 +865,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,/* * Make sure the requested values and current defaults are sane. */ - num_buffers = max_t(unsigned int, *count, q->min_buffers_needed); + num_buffers = max_t(unsigned int, *count, q->min_queued_buffers + 1); num_buffers = min_t(unsigned int, num_buffers, q->max_num_buffers);memset (q->alloc_devs,0 ,sizeof (q->alloc_devs));/* That "+ 1" didn't really belong here, since everything else was just renaming a field. Such a patch shouldn't make any other changes.
Quoted 8 lines
There were also three more occurrences of
min_buffers_needed(one in a comment, two in a vivid function argument), and I renamed those as well.'git grep
min_buffers_needed' now no longer shows any hits.I decided not to take the other patches, I think it is best if you rebase and repost the series on top of staging and in the new year we'll continue with it. I did not feel that I had enough time to really review the remaining patches.
Do you want me to re-post only the two missing patches or should I add the patches for delete buffers feature since it is the ultimate goal of this ?
Regards,
Benjamin
Quoted 9 lines
However, it is nice to have this large rename patch merged. It touches on a lot of files, so it is annoying to have to carry that around. And now was a good moment to merge it.
Regards,
Hans
Re: [PATCH v5 1/3] videobuf2: core: Rename min_buffers_needed field to vb2_queue
Quoted 31 lines · Benjamin Gaignard
Le 13/12/2023 à 17:39, Hans Verkuil a écrit :
Quoted 29 lines
Hi Benjamin,
Quoted 2 lines · Benjamin Gaignard
Rename
min_buffers_neededintomin_queued_buffersand update the documentation about it.I merged this patch, but not the others. I also dropped one functional change:
<snip>
drivers/media/common/videobuf2/videobuf2-core.c int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, · line 871
Quoted 13 lines
drivers/media/common/videobuf2/videobuf2-core.c +1
-1@@ -865,7 +865,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, /* * Make sure the requested values and current defaults are sane. */ - num_buffers = max_t(unsigned int, *count, q->min_buffers_needed); + num_buffers = max_t(unsigned int, *count, q->min_queued_buffers + 1); num_buffers = min_t(unsigned int, num_buffers, q->max_num_buffers); memset(q->alloc_devs, 0, sizeof(q->alloc_devs)); /*That "+ 1" didn't really belong here, since everything else was just renaming a field. Such a patch shouldn't make any other changes.
There were also three more occurrences of
min_buffers_needed(one in a comment, two in a vivid function argument), and I renamed those as well.
Quoted 8 lines
Quoted 5 lines
'git grep
min_buffers_needed' now no longer shows any hits.I decided not to take the other patches, I think it is best if you rebase and repost the series on top of staging and in the new year we'll continue with it. I did not feel that I had enough time to really review the remaining patches.
Do you want me to re-post only the two missing patches or should I add the patches for delete buffers feature since it is the ultimate goal of this ?
I have no preference, to be honest.
Regards,
Hans
Quoted 14 lines
Regards,
BenjaminQuoted 9 lines
However, it is nice to have this large rename patch merged. It touches on a lot of files, so it is annoying to have to carry that around. And now was a good moment to merge it.
Regards,
Hans
Tomasz Figa
maintainerRe: [PATCH v5 1/3] videobuf2: core: Rename min_buffers_needed field to vb2_queue
In reply to Benjamin GaignardHi Benjamin,
Quoted 3 lines · Benjamin Gaignard
Rename
min_buffers_neededintomin_queued_buffersand update the documentation about it.
Sorry for being late to the party. I think this is generally a good idea, thanks for doing this! Just one comment inline.
[snip]
drivers/media/common/videobuf2/videobuf2-core.c int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, · line 868
Quoted 10 lines
drivers/media/common/videobuf2/videobuf2-core.c +1
-1@@ -865,7 +865,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,/* * Make sure the requested values and current defaults are sane. */ - num_buffers = max_t(unsigned int, *count, q->min_buffers_needed); + num_buffers = max_t(unsigned int, *count, q->min_queued_buffers + 1);
Where does this + 1 come from here?
Agreed with Hans that this change deserves its own patch with a proper explanation in its description.
Quoted 31 lines
drivers/media/common/videobuf2/videobuf2-core.c +3
-3num_buffers = min_t(unsigned int, num_buffers, q->max_num_buffers);memset (q->alloc_devs,0 ,sizeof (q->alloc_devs));/* @@ -917,7 +917,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,* There is no point in continuing if we can't allocate the minimum * number of buffers needed by this vb2_queue. */ -if (allocated_buffers < q->min_buffers_needed) +if (allocated_buffers < q->min_queued_buffers) ret = -ENOMEM ;/* @@ -1653,7 +1653,7 @@ EXPORT_SYMBOL_GPL(vb2_core_prepare_buf);* @q: videobuf2 queue * * Attempt to start streaming. When this function is called there must be -* at least q->min_buffers_needed buffers queued up (i.e. the minimum +* at least q->min_queued_buffers queued up (i.e. the minimum * number of buffers required for the DMA engine to function). If the * @start_streaming op fails it is supposed to return all the driver-owned * buffers back to vb2 in state QUEUED. Check if that happened and if @@ -1846,7 +1846,7 @@ int vb2_core_qbuf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb,* then we can finally call start_streaming(). */ if (q->streaming && !q->start_streaming_called && - q->queued_count >= q->min_buffers_needed) { + q->queued_count >= q->min_queued_buffers) { ret =vb2_start_streaming (q);if (ret) {/*
drivers/media/common/videobuf2/videobuf2-core.c int vb2_core_streamon(struct vb2_queue *q, unsigned int type) · line 2214
Quoted 8 lines
drivers/media/common/videobuf2/videobuf2-core.c +2
-3@@ -2210,9 +2210,9 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)return -EINVAL ; } -if (q_num_bufs < q->min_buffers_needed) { -dprintk (q,1 ,"need at least %u allocated buffers\n" , - q->min_buffers_needed); +if (q_num_bufs < q->min_queued_buffers) { + dprintk(q, 1, "need at least %u queued buffers\n",
Note that the value being checked here is the number of allocated buffers, not queued buffers. So basically we're enforcing here that at the time STREAMON is called, there is enough buffers allocated to queue the minimum number of buffers to start streaming, but then later down we're not actually enforcing that they are queued - if not, the queue start_streaming operation is deferred until enough buffers are queued.
The question is: Do we really want this to be an error? Or should we just be consistent with the allocated-but-not-queued case and let the application allocate more buffers later using CREATE_BUFS? (Another question: How does an application know how many buffers to allocate for STREAMON to work?)
That said, this doesn't really affect the correctness of the patch itself. Just some additional oddity in the current implementation that we could simplify in the future.
Quoted 4 lines
drivers/media/common/videobuf2/videobuf2-core.c +1
-0+ q->min_queued_buffers);return -EINVAL ; }
[snip]
Quoted 6 lines
include/media/videobuf2-core.h +0
-0@@ -546,10 +546,13 @@ struct vb2_buf_ops {* @gfp_flags: additional gfp flags used when allocating the buffers.
include/media/videobuf2-core.h struct vb2_buf_ops { · line 555
Quoted 10 lines
include/media/videobuf2-core.h +4
-1* Typically this is 0, but it may be e.g. %GFP_DMA or %__GFP_DMA32 * to force the buffer allocation to a specific memory zone. -* @min_buffers_needed: the minimum number of buffers needed before +* @min_queued_buffers: the minimum number of queued buffers needed before * @start_streaming can be called. Used when a DMA engine * cannot be started unless at least this number of buffers * have been queued into the driver. +* VIDIOC_REQBUFS will ensure at least @min_queued_buffers + 1 +* buffers will be allocated. Note that VIDIOC_CREATE_BUFS will not +* modify the requested buffer count.
Same here, this + 1 needs a proper explanation.
Also, I don't like this API inconsistency where REQBUFS guarantees the right number of buffers, but CREATE_BUFS doesn't. In fact, would an application have a way to know how many buffers to allocate if it simply wants to use CREATE_BUFS?
(It's generally related to the oddity that I pointed out above. Maybe we should let the allocation code only handle allocation constraints and not care about STREAMON constraints?)
[snip]
Best regards,
Tomasz
Re: [PATCH v5 1/3] videobuf2: core: Rename min_buffers_needed field to vb2_queue
Le 26/12/2023 à 09:23, Tomasz Figa a écrit :
Quoted 10 lines
Hi Benjamin,
Quoted 3 lines · Benjamin Gaignard
Rename
min_buffers_neededintomin_queued_buffersand update the documentation about it.Sorry for being late to the party. I think this is generally a good idea, thanks for doing this! Just one comment inline.
[snip]
Quoted 13 lines
drivers/media/common/videobuf2/videobuf2-core.c int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, · line 868
Quoted 10 lines
drivers/media/common/videobuf2/videobuf2-core.c +1
-1@@ -865,7 +865,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,/* * Make sure the requested values and current defaults are sane. */ - num_buffers = max_t(unsigned int, *count, q->min_buffers_needed); + num_buffers = max_t(unsigned int, *count, q->min_queued_buffers + 1);Where does this + 1 come from here?
Agreed with Hans that this change deserves its own patch with a proper explanation in its description.
Hans have merged this patch without this line.
Since I still aiming to add delete buffers feature I have include this change in this series:
https://www.spinics.net/lists/linux-media/msg246289.html
Regards,
Benjamin
Quoted 92 lines
Quoted 32 lines
drivers/media/common/videobuf2/videobuf2-core.c +3
-3num_buffers = min_t(unsigned int, num_buffers, q->max_num_buffers);memset (q->alloc_devs,0 ,sizeof (q->alloc_devs));/* @@ -917,7 +917,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,* There is no point in continuing if we can't allocate the minimum * number of buffers needed by this vb2_queue. */ -if (allocated_buffers < q->min_buffers_needed) +if (allocated_buffers < q->min_queued_buffers) ret = -ENOMEM ;/* @@ -1653,7 +1653,7 @@ EXPORT_SYMBOL_GPL(vb2_core_prepare_buf);* @q: videobuf2 queue * * Attempt to start streaming. When this function is called there must be -* at least q->min_buffers_needed buffers queued up (i.e. the minimum +* at least q->min_queued_buffers queued up (i.e. the minimum * number of buffers required for the DMA engine to function). If the * @start_streaming op fails it is supposed to return all the driver-owned * buffers back to vb2 in state QUEUED. Check if that happened and if @@ -1846,7 +1846,7 @@ int vb2_core_qbuf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb,* then we can finally call start_streaming(). */ if (q->streaming && !q->start_streaming_called && - q->queued_count >= q->min_buffers_needed) { + q->queued_count >= q->min_queued_buffers) { ret =vb2_start_streaming (q);if (ret) {/* drivers/media/common/videobuf2/videobuf2-core.c int vb2_core_streamon(struct vb2_queue *q, unsigned int type) · line 2214
Quoted 8 lines
drivers/media/common/videobuf2/videobuf2-core.c +2
-3@@ -2210,9 +2210,9 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)return -EINVAL ; } -if (q_num_bufs < q->min_buffers_needed) { -dprintk (q,1 ,"need at least %u allocated buffers\n" , - q->min_buffers_needed); +if (q_num_bufs < q->min_queued_buffers) { + dprintk(q, 1, "need at least %u queued buffers\n",Note that the value being checked here is the number of allocated buffers, not queued buffers. So basically we're enforcing here that at the time STREAMON is called, there is enough buffers allocated to queue the minimum number of buffers to start streaming, but then later down we're not actually enforcing that they are queued - if not, the queue
start_streamingoperation is deferred until enough buffers are queued.The question is: Do we really want this to be an error? Or should we just be consistent with the allocated-but-not-queued case and let the application allocate more buffers later using
CREATE_BUFS? (Another question: How does an application know how many buffers to allocate for STREAMON to work?)That said, this doesn't really affect the correctness of the patch itself. Just some additional oddity in the current implementation that we could simplify in the future.
Quoted 4 lines
drivers/media/common/videobuf2/videobuf2-core.c +1
-0+ q->min_queued_buffers);return -EINVAL ; }[snip]
Quoted 6 lines
include/media/videobuf2-core.h +0
-0@@ -546,10 +546,13 @@ struct vb2_buf_ops {* @gfp_flags: additional gfp flags used when allocating the buffers. include/media/videobuf2-core.h struct vb2_buf_ops { · line 555
Quoted 10 lines
include/media/videobuf2-core.h +4
-1* Typically this is 0, but it may be e.g. %GFP_DMA or %__GFP_DMA32 * to force the buffer allocation to a specific memory zone. -* @min_buffers_needed: the minimum number of buffers needed before +* @min_queued_buffers: the minimum number of queued buffers needed before * @start_streaming can be called. Used when a DMA engine * cannot be started unless at least this number of buffers * have been queued into the driver. +* VIDIOC_REQBUFS will ensure at least @min_queued_buffers + 1 +* buffers will be allocated. Note that VIDIOC_CREATE_BUFS will not +* modify the requested buffer count. Same here, this + 1 needs a proper explanation.
Also, I don't like this API inconsistency where REQBUFS guarantees the right number of buffers, butCREATE_BUFSdoesn't. In fact, would an application have a way to know how many buffers to allocate if it simply wants to useCREATE_BUFS?(It's generally related to the oddity that I pointed out above. Maybe we should let the allocation code only handle allocation constraints and not care about STREAMON constraints?)
[snip]
Best regards,
Tomasz
PATCH v5 2/3 videobuf2: Add min_reqbufs_allocation field to vb2_queue structure
In reply to Benjamin GaignardAdd 'min_reqbufs_allocation' field in vb2_queue structure so drivers can specificy the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
If used this minimum should be higher than the minimum number of queued buffers needed to start streaming.
---
version 5:
- Add WARN_ON() vb2_core_queue_init()
- Check min_reqbufs_allocation value in vb2_core_queue_init() so it is at least equal to min_queued_buffers + 1.
- Rework min_reqbufs_allocation documentation.
drivers/media/common/videobuf2/videobuf2-core.c | 10 ++++++++-- include/media/videobuf2-core.h | 13 +++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-)
drivers/media/common/videobuf2/videobuf2-core.c +8 -2
@@ -865,7 +865,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,/* * Make sure the requested values and current defaults are sane. */ - num_buffers = max_t(unsigned int, *count, q->min_queued_buffers + 1); + num_buffers = max_t(unsigned int, *count, q->min_reqbufs_allocation); num_buffers = min_t(unsigned int, num_buffers, q->max_num_buffers);memset (q->alloc_devs,0 ,sizeof (q->alloc_devs));/*
@@ -917,7 +917,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,* There is no point in continuing if we can't allocate the minimum * number of buffers needed by this vb2_queue. */ -if (allocated_buffers < q->min_queued_buffers) +if (allocated_buffers < q->min_reqbufs_allocation) ret = -ENOMEM ;/*
@@ -2521,6 +2521,12 @@ int vb2_core_queue_init(struct vb2_queue *q)if (WARN_ON (q->supports_requests && q->min_queued_buffers))return -EINVAL ; + q->min_reqbufs_allocation = max_t(unsigned int, + q->min_reqbufs_allocation, + q->min_queued_buffers +1 ); +if (WARN_ON (q->min_reqbufs_allocation > q->max_num_buffers)) +return -EINVAL ; +INIT_LIST_HEAD (&q->queued_list);INIT_LIST_HEAD (&q->done_list);spin_lock_init (&q->done_lock);
include/media/videobuf2-core.h +13 -0
@@ -553,6 +553,18 @@ struct vb2_buf_ops {* VIDIOC_REQBUFS will ensure at least @min_queued_buffers + 1 * buffers will be allocated. Note that VIDIOC_CREATE_BUFS will not * modify the requested buffer count. +* @min_reqbufs_allocation: the minimum number of buffers to be allocated when +* calling VIDIOC_REQBUFS. Drivers can set this if there has to +* be a certain number of buffers available for the hardware to +* work effectively. If set, then @min_reqbufs_allocation must be +* larger than @min_queued_buffers + 1. +* This field is only used by VIDIOC_REQBUFS. This allows calling +* that ioctl with a buffer count of 1 and it will be automatically +* adjusted to a workable buffer count. VIDIOC_CREATE_BUFS will not +* modify the requested buffer count. +* If this field is > 3, then it is highly recommended that the +* driver implements the V4L2_CID_MIN_BUFFERS_FOR_CAPTURE/OUTPUT +* control. */ /* * Private elements (won't appear at the uAPI book):
@@ -618,6 +630,7 @@ struct vb2_queue {u32 timestamp_flags;gfp_t gfp_flags;u32 min_queued_buffers; +u32 min_reqbufs_allocation;struct device *alloc_devs[VB2_MAX_PLANES ];
Signature · 1 line
2.40.1
PATCH v5 3/3 media: test-drivers: Set REQBUFS minimum number of buffers
In reply to Benjamin GaignardTest drivers require at least 2 buffers to be allocated when calling REQBUFS so set queue min_reqbufs_allocation field instead of min_queued_buffers.
While at it remane vivid_create_queue() parameter.
--- drivers/media/test-drivers/vimc/vimc-capture.c | 2 +- drivers/media/test-drivers/vivid/vivid-core.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/media/test-drivers/vimc/vimc-capture.c +1 -1
@@ -432,7 +432,7 @@ static struct vimc_ent_device *vimc_capture_add(struct vimc_device *vimc, q->mem_ops = vimc_allocator ==VIMC_ALLOCATOR_DMA_CONTIG ? &vb2_dma_contig_memops : &vb2_vmalloc_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_queued_buffers =2 ; + q->min_reqbufs_allocation =2 ; q->lock = &vcapture->lock; q->dev = v4l2_dev->dev;
drivers/media/test-drivers/vivid/vivid-core.c +2 -2
@@ -861,7 +861,7 @@ static const struct media_device_ops vivid_media_ops = {static int vivid_create_queue (struct vivid_dev *dev,struct vb2_queue *q,u32 buf_type, -unsigned int min_buffers_needed, +unsigned int min_reqbufs_allocation,const struct vb2_ops *ops) {if (buf_type ==V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->multiplanar)
@@ -898,7 +898,7 @@ static int vivid_create_queue(struct vivid_dev *dev, q->mem_ops = allocators[dev->inst] ==1 ? &vb2_dma_contig_memops : &vb2_vmalloc_memops; q->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC ; - q->min_queued_buffers = supports_requests[dev->inst] ?0 : min_buffers_needed; + q->min_reqbufs_allocation = min_reqbufs_allocation; q->lock = &dev->mutex; q->dev = dev->v4l2_dev.dev; q->supports_requests = supports_requests[dev->inst];
Signature · 1 line
2.40.1
Main subject in wrong it is the cover letter for v5 series.
Le 11/12/2023 à 14:32, Benjamin Gaignard a écrit :
Quoted 110 lines
This series implement Hans's RFC: https://www.spinics.net/lists/linux-media/msg244455.html
To summarize Hans's proposal it is needed to distinguish two cases:
- the minimal number of buffers to be allocated when callingVIDIOC_REQBUFS.
- the minimale number of queued buffers before start streaming. Until now drivers usevb2_queuemin_buffers_neededfield in the both cases but before introduce delete buffers we need to clarify for which usage each of them usemin_buffers_neededfield.The branch with all patches is here:
https://gitlab.collabora.com/benjamin.gaignard/for-upstream/-/commits/clean_min_need_buffers_v5I have tested with this command line, I haven't notice issues:
./test-media -kmemleak mcchanges in version 5:
- Fix the comments done by Hans:
Rework comments onvideobuf2-core.h
Add checks invb2_core_queue_init().
- Patch test-drivers to usemin_reqbufs_allocationfield.changes in version 4:
- restore removed lines in zoran and vdec drivers.changes in version 3:
- Just renamemin_buffers_neededintomin_queued_bufferseverywhere without trying to fix the drivers.
- Introducemin_reqbufs_allocationfield to be used when callingVIDIOC_REQBUFS.changes in version 2:
- changemin_buffers_neededintomin_queues_buffersinstead ofmin_dma_buffers_needed
- patches order
- only one patch to renamemin_buffers_neededintomin_queues_bufferBenjamin Gaignard (3):
videobuf2: core: Renamemin_buffers_neededfield tovb2_queue
videobuf2: Addmin_reqbufs_allocationfield tovb2_queuestructure
media: test-drivers: Set REQBUFS minimum number of buffersdrivers/input/touchscreen/atmel_mxt_ts.c | 2 +- drivers/input/touchscreen/sur40.c | 2 +- drivers/media/common/saa7146/saa7146_fops.c | 2 +- .../media/common/videobuf2/videobuf2-core.c | 34 +++++++++++-------- drivers/media/dvb-core/dvb_vb2.c | 2 +- drivers/media/i2c/video-i2c.c | 2 +- drivers/media/pci/bt8xx/bttv-driver.c | 2 +- drivers/media/pci/cobalt/cobalt-v4l2.c | 2 +- drivers/media/pci/cx18/cx18-streams.c | 2 +- drivers/media/pci/cx23885/cx23885-417.c | 2 +- drivers/media/pci/cx23885/cx23885-dvb.c | 2 +- drivers/media/pci/cx23885/cx23885-video.c | 4 +-- drivers/media/pci/cx25821/cx25821-video.c | 2 +- drivers/media/pci/cx88/cx88-blackbird.c | 2 +- drivers/media/pci/cx88/cx88-dvb.c | 2 +- drivers/media/pci/cx88/cx88-video.c | 4 +-- drivers/media/pci/dt3155/dt3155.c | 2 +- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- drivers/media/pci/mgb4/mgb4_vin.c | 2 +- drivers/media/pci/mgb4/mgb4_vout.c | 2 +- drivers/media/pci/tw5864/tw5864-video.c | 2 +- drivers/media/pci/tw68/tw68-video.c | 2 +- drivers/media/pci/tw686x/tw686x-video.c | 2 +- drivers/media/pci/zoran/zoran_driver.c | 6 ++-- drivers/media/platform/amphion/vpu_v4l2.c | 4 +-- drivers/media/platform/aspeed/aspeed-video.c | 2 +- drivers/media/platform/atmel/atmel-isi.c | 2 +- .../platform/chips-media/coda/coda-common.c | 2 +- .../platform/microchip/microchip-isc-base.c | 2 +- drivers/media/platform/nuvoton/npcm-video.c | 2 +- drivers/media/platform/nxp/imx7-media-csi.c | 2 +- .../platform/nxp/imx8-isi/imx8-isi-video.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 4 +-- drivers/media/platform/qcom/venus/venc.c | 4 +-- .../platform/renesas/rcar-vin/rcar-dma.c | 2 +- drivers/media/platform/renesas/renesas-ceu.c | 2 +- .../platform/renesas/rzg2l-cru/rzg2l-video.c | 2 +- drivers/media/platform/renesas/sh_vou.c | 2 +- .../platform/rockchip/rkisp1/rkisp1-capture.c | 2 +- drivers/media/platform/st/sti/hva/hva-v4l2.c | 4 +-- drivers/media/platform/st/stm32/stm32-dcmi.c | 2 +- .../st/stm32/stm32-dcmipp/dcmipp-bytecap.c | 4 +-- .../platform/sunxi/sun4i-csi/sun4i_dma.c | 2 +- .../sunxi/sun6i-csi/sun6i_csi_capture.c | 2 +- .../media/platform/sunxi/sun8i-di/sun8i-di.c | 4 +-- .../sunxi/sun8i-rotate/sun8i_rotate.c | 4 +-- .../media/platform/ti/am437x/am437x-vpfe.c | 2 +- drivers/media/platform/ti/cal/cal-video.c | 2 +- .../media/platform/ti/davinci/vpif_capture.c | 2 +- .../media/platform/ti/davinci/vpif_display.c | 2 +- .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 2 +- drivers/media/platform/ti/omap/omap_vout.c | 2 +- .../media/test-drivers/vimc/vimc-capture.c | 2 +- drivers/media/test-drivers/vivid/vivid-core.c | 4 +-- drivers/media/usb/cx231xx/cx231xx-417.c | 2 +- drivers/media/usb/cx231xx/cx231xx-video.c | 4 +-- drivers/media/usb/dvb-usb/cxusb-analog.c | 2 +- drivers/media/usb/gspca/gspca.c | 6 ++-- .../media/deprecated/atmel/atmel-isc-base.c | 2 +- drivers/staging/media/imx/imx-media-capture.c | 2 +- drivers/staging/media/ipu3/ipu3-v4l2.c | 2 +- drivers/staging/media/meson/vdec/vdec.c | 6 ++-- .../staging/media/starfive/camss/stf-video.c | 2 +- .../media/sunxi/sun6i-isp/sun6i_isp_capture.c | 2 +- .../media/sunxi/sun6i-isp/sun6i_isp_params.c | 2 +- drivers/staging/media/tegra-video/vi.c | 2 +- include/media/videobuf2-core.h | 20 +++++++++-- samples/v4l/v4l2-pci-skeleton.c | 2 +- 68 files changed, 121 insertions(+), 99 deletions(-)