2023-12-04 13:23:50

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 00/36] 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.

I have done this in 3 steps:
- remove all min_buffers_needed = 1 (or 0) because that the default
minimum buffers allocated when calling VIDIOC_REQBUFS
- add min_reqbufs_allocation field and convert all the drivers that I
believe use min_buffers_needed field for VIDIOC_REQBUFS purpose.
- rename min_buffers_needed into min_queues_buffers.

The branch with all patches is here:
https://gitlab.collabora.com/benjamin.gaignard/for-upstream/-/commits/clean_min_need_buffers_v2

I have tested with this command line, I haven't notice issues:
./test-media -kmemleak mc

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

Benjamin Gaignard (36):
media: usb: cx231xx: Remove useless setting of min_buffers_needed
media: chips-media: coda: Remove useless setting of min_buffers_needed
media: microchip: Remove useless setting of min_buffers_needed
media: amphion: Remove useless setting of min_buffers_needed
media: qcom: venus: Remove useless setting of min_buffers_needed
media: i2c: video-i2c: Remove useless setting of min_buffers_needed
media: dvb-core: Remove useless setting of min_buffers_needed
media: atmel: Remove useless setting of min_buffers_needed
media: ipu3: Remove useless setting of min_buffers_needed
media: ti: am437x: Remove useless setting of min_buffers_needed
media: ti: davinci: Remove useless setting of min_buffers_needed
input: touchscreen: atmel: Remove useless setting of
min_buffers_needed
media: ti: j721e-csi2rx: Remove useless setting of min_buffers_needed
media: ti: omap: Remove useless setting of min_buffers_needed
media: pci: intel: ipu3: Remove useless setting of min_buffers_needed
videobuf2: Add min_reqbufs_allocation field to vb2_queue structure
media: test-drivers: Fix misuse of min_buffers_needed field
media: usb: dvb-usb: cxusb-analog: Fix misuse of min_buffers_needed
field
media: usb: gspca: Fix misuse of min_buffers_needed field
media: atmel: Fix misuse of min_buffers_needed field
media: imx7-media-csi: Fix misuse of min_buffers_needed field
media: nuvoton: Fix misuse of min_buffers_needed field
media: sti: hva: Fix misuse of min_buffers_needed field
media: rockchip: rkisp1: Fix misuse of min_buffers_needed field
media: aspeed: Fix misuse of min_buffers_needed field
media: sun4i-csi: Fix misuse of min_buffers_needed field
media: sunxi: sun8i-di: Fix misuse of min_buffers_needed field
media: sun8i-rotate: Fix misuse of min_buffers_needed field
media: sunxi: sun6i-csi: Fix misuse of min_buffers_needed field
media: imx: Fix misuse of min_buffers_needed field
media: starfive: Fix misuse of min_buffers_needed field
media: tegra-video: Fix misuse of min_buffers_needed field
media: ti: cal: Fix misuse of min_buffers_needed field
media: saa7146: Fix misuse of min_buffers_needed field
input: touchscreen: sur40: Fix misuse of min_buffers_needed field
videobuf2: core: Rename min_buffers_needed field to vb2_queue

drivers/input/touchscreen/atmel_mxt_ts.c | 1 -
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 | 1 -
drivers/media/i2c/video-i2c.c | 1 -
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 | 1 -
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 | 5 +---
drivers/media/platform/amphion/vpu_v4l2.c | 2 --
drivers/media/platform/aspeed/aspeed-video.c | 2 +-
drivers/media/platform/atmel/atmel-isi.c | 2 +-
.../platform/chips-media/coda/coda-common.c | 1 -
.../platform/microchip/microchip-isc-base.c | 1 -
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 | 2 --
drivers/media/platform/qcom/venus/venc.c | 2 --
.../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 +-
.../platform/sunxi/sun4i-csi/sun4i_dma.c | 2 +-
.../sunxi/sun6i-csi/sun6i_csi_capture.c | 2 +-
.../media/platform/sunxi/sun8i-di/sun8i-di.c | 3 +-
.../sunxi/sun8i-rotate/sun8i_rotate.c | 3 +-
.../media/platform/ti/am437x/am437x-vpfe.c | 1 -
drivers/media/platform/ti/cal/cal-video.c | 2 +-
.../media/platform/ti/davinci/vpif_capture.c | 1 -
.../media/platform/ti/davinci/vpif_display.c | 1 -
.../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 1 -
drivers/media/platform/ti/omap/omap_vout.c | 1 -
.../media/test-drivers/vimc/vimc-capture.c | 2 +-
drivers/media/test-drivers/vivid/vivid-core.c | 4 +--
drivers/media/usb/cx231xx/cx231xx-417.c | 1 -
drivers/media/usb/cx231xx/cx231xx-video.c | 2 --
drivers/media/usb/dvb-usb/cxusb-analog.c | 2 +-
drivers/media/usb/gspca/gspca.c | 6 ++--
.../media/deprecated/atmel/atmel-isc-base.c | 1 -
drivers/staging/media/imx/imx-media-capture.c | 2 +-
drivers/staging/media/ipu3/ipu3-v4l2.c | 2 --
drivers/staging/media/meson/vdec/vdec.c | 4 +--
.../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 | 10 +++++--
samples/v4l/v4l2-pci-skeleton.c | 2 +-
67 files changed, 77 insertions(+), 97 deletions(-)

--
2.39.2


2023-12-04 13:24:02

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 05/36] media: qcom: venus: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Stanimir Varbanov <[email protected]> (maintainer:QUALCOMM VENUS VIDEO ACCELERATOR DRIVER)
CC: Vikash Garodia <[email protected]> (maintainer:QUALCOMM VENUS VIDEO ACCELERATOR DRIVER)
CC: "Bryan O'Donoghue" <[email protected]> (reviewer:QUALCOMM VENUS VIDEO ACCELERATOR DRIVER)
CC: Andy Gross <[email protected]> (maintainer:ARM/QUALCOMM SUPPORT)
CC: Bjorn Andersson <[email protected]> (maintainer:ARM/QUALCOMM SUPPORT)
CC: Konrad Dybcio <[email protected]> (maintainer:ARM/QUALCOMM SUPPORT)
CC: [email protected]
---
drivers/media/platform/qcom/venus/vdec.c | 2 --
drivers/media/platform/qcom/venus/venc.c | 2 --
2 files changed, 4 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index dbf305cec120..8bdffe546219 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -1641,7 +1641,6 @@ 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->dev = inst->core->dev;
src_vq->lock = &inst->ctx_q_lock;
ret = vb2_queue_init(src_vq);
@@ -1656,7 +1655,6 @@ 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->dev = inst->core->dev;
dst_vq->lock = &inst->ctx_q_lock;
return vb2_queue_init(dst_vq);
diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index 44b13696cf82..f2e6bd44ed15 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -1398,7 +1398,6 @@ 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->dev = inst->core->dev;
src_vq->lock = &inst->ctx_q_lock;
if (inst->core->res->hfi_version == HFI_VERSION_1XX)
@@ -1415,7 +1414,6 @@ 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->dev = inst->core->dev;
dst_vq->lock = &inst->ctx_q_lock;
return vb2_queue_init(dst_vq);
--
2.39.2

2023-12-04 13:24:04

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 04/36] media: amphion: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Ming Qian <[email protected]>
CC: Zhou Peng <[email protected]>
---
drivers/media/platform/amphion/vpu_v4l2.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/media/platform/amphion/vpu_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.c
index 87afb4a18d5d..a80c5f28c659 100644
--- a/drivers/media/platform/amphion/vpu_v4l2.c
+++ b/drivers/media/platform/amphion/vpu_v4l2.c
@@ -649,7 +649,6 @@ 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->dev = inst->vpu->dev;
src_vq->lock = &inst->lock;
ret = vb2_queue_init(src_vq);
@@ -666,7 +665,6 @@ 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->dev = inst->vpu->dev;
dst_vq->lock = &inst->lock;
ret = vb2_queue_init(dst_vq);
--
2.39.2

2023-12-04 13:24:07

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 03/36] media: microchip: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Eugen Hristev <[email protected]>
---
drivers/media/platform/microchip/microchip-isc-base.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index 3fba0e2844b6..63c39981f47a 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -1821,7 +1821,6 @@ 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->dev = isc->dev;

ret = vb2_queue_init(q);
--
2.39.2

2023-12-04 13:24:11

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 02/36] media: chips-media: coda: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Philipp Zabel <[email protected]>
---
drivers/media/platform/chips-media/coda/coda-common.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/media/platform/chips-media/coda/coda-common.c b/drivers/media/platform/chips-media/coda/coda-common.c
index f1d85758f6dd..d5529f988d2c 100644
--- a/drivers/media/platform/chips-media/coda/coda-common.c
+++ b/drivers/media/platform/chips-media/coda/coda-common.c
@@ -2546,7 +2546,6 @@ 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->dev = ctx->dev->dev;

return vb2_queue_init(vq);
--
2.39.2

2023-12-04 13:24:27

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 07/36] media: dvb-core: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
---
drivers/media/dvb-core/dvb_vb2.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/media/dvb-core/dvb_vb2.c b/drivers/media/dvb-core/dvb_vb2.c
index 167ff82a6fed..54a3649d8424 100644
--- a/drivers/media/dvb-core/dvb_vb2.c
+++ b/drivers/media/dvb-core/dvb_vb2.c
@@ -171,7 +171,6 @@ 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->ops = &dvb_vb2_qops;
q->mem_ops = &vb2_vmalloc_memops;
q->buf_ops = &dvb_vb2_buf_ops;
--
2.39.2

2023-12-04 13:24:31

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 10/36] media: ti: am437x: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: "Lad, Prabhakar" <[email protected]>
---
drivers/media/platform/ti/am437x/am437x-vpfe.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/media/platform/ti/am437x/am437x-vpfe.c b/drivers/media/platform/ti/am437x/am437x-vpfe.c
index f18acf9286a2..228920450e7a 100644
--- a/drivers/media/platform/ti/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/ti/am437x/am437x-vpfe.c
@@ -2234,7 +2234,6 @@ 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->dev = vpfe->pdev;

err = vb2_queue_init(q);
--
2.39.2

2023-12-04 13:24:34

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 08/36] media: atmel: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Eugen Hristev <[email protected]>
CC: Nicolas Ferre <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: Claudiu Beznea <[email protected]>
---
drivers/staging/media/deprecated/atmel/atmel-isc-base.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/staging/media/deprecated/atmel/atmel-isc-base.c b/drivers/staging/media/deprecated/atmel/atmel-isc-base.c
index 468568b5bb7a..c18f3ba5ae1a 100644
--- a/drivers/staging/media/deprecated/atmel/atmel-isc-base.c
+++ b/drivers/staging/media/deprecated/atmel/atmel-isc-base.c
@@ -1871,7 +1871,6 @@ 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->dev = isc->dev;

ret = vb2_queue_init(q);
--
2.39.2

2023-12-04 13:24:42

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 09/36] media: ipu3: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Sakari Ailus <[email protected]>
CC: Bingbu Cao <[email protected]>
CC: Tianshu Qiu <[email protected]>
---
drivers/staging/media/ipu3/ipu3-v4l2.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 0fe2b858da83..7f9104411edc 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -1197,8 +1197,6 @@ static int imgu_v4l2_node_setup(struct imgu_device *imgu, unsigned int pipe,
sizeof(struct imgu_vb2_buffer);
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->drv_priv = imgu;
vbq->lock = &node->lock;
r = vb2_queue_init(vbq);
--
2.39.2

2023-12-04 13:24:50

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 14/36] media: ti: omap: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
---
drivers/media/platform/ti/omap/omap_vout.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/media/platform/ti/omap/omap_vout.c b/drivers/media/platform/ti/omap/omap_vout.c
index 72ce903717d3..f67a45f1441b 100644
--- a/drivers/media/platform/ti/omap/omap_vout.c
+++ b/drivers/media/platform/ti/omap/omap_vout.c
@@ -1404,7 +1404,6 @@ 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;
vfd->queue = vq;

ret = vb2_queue_init(vq);
--
2.39.2

2023-12-04 13:24:53

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 12/36] input: touchscreen: atmel: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Nick Dyer <[email protected]>
CC: Dmitry Torokhov <[email protected]>
CC: [email protected]
---
drivers/input/touchscreen/atmel_mxt_ts.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 20094b9899f0..d98cf9560511 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -2546,7 +2546,6 @@ 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,
};

static int mxt_vidioc_querycap(struct file *file, void *priv,
--
2.39.2

2023-12-04 13:24:54

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 06/36] media: i2c: video-i2c: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
---
drivers/media/i2c/video-i2c.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
index ebf2ac98a068..8d7f01b50aa7 100644
--- a/drivers/media/i2c/video-i2c.c
+++ b/drivers/media/i2c/video-i2c.c
@@ -795,7 +795,6 @@ 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->ops = &video_i2c_video_qops;
queue->mem_ops = &vb2_vmalloc_memops;

--
2.39.2

2023-12-04 13:24:56

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 13/36] media: ti: j721e-csi2rx: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Jai Luthra <[email protected]>
---
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
index ada61391c8d2..1e5f68f50afb 100644
--- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
+++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
@@ -873,7 +873,6 @@ 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;

ret = vb2_queue_init(q);
if (ret)
--
2.39.2

2023-12-04 13:24:57

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 11/36] media: ti: davinci: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: "Lad, Prabhakar" <[email protected]>
---
drivers/media/platform/ti/davinci/vpif_capture.c | 1 -
drivers/media/platform/ti/davinci/vpif_display.c | 1 -
2 files changed, 2 deletions(-)

diff --git a/drivers/media/platform/ti/davinci/vpif_capture.c b/drivers/media/platform/ti/davinci/vpif_capture.c
index fc42b4bc37e6..300c3cb5cbed 100644
--- a/drivers/media/platform/ti/davinci/vpif_capture.c
+++ b/drivers/media/platform/ti/davinci/vpif_capture.c
@@ -1429,7 +1429,6 @@ 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->lock = &common->lock;
q->dev = vpif_dev;

diff --git a/drivers/media/platform/ti/davinci/vpif_display.c b/drivers/media/platform/ti/davinci/vpif_display.c
index 9dbab1003c1d..d45391a4d8f2 100644
--- a/drivers/media/platform/ti/davinci/vpif_display.c
+++ b/drivers/media/platform/ti/davinci/vpif_display.c
@@ -1169,7 +1169,6 @@ 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->lock = &common->lock;
q->dev = vpif_dev;
err = vb2_queue_init(q);
--
2.39.2

2023-12-04 13:25:00

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 16/36] videobuf2: Add min_reqbufs_allocation field to vb2_queue structure

Add 'min_reqbufs_allocation' field in vb2_queue structure so drivers
can specificy the minimum number of buffers to allocate when calling
VIDIOC_REQBUFS.
Later that will help to distinguish the minimum number of buffers
needed to start streaming versus the minimum allocation requirement.

Signed-off-by: Benjamin Gaignard <[email protected]>
---
drivers/media/common/videobuf2/videobuf2-core.c | 1 +
include/media/videobuf2-core.h | 4 ++++
2 files changed, 5 insertions(+)

diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index 8c1df829745b..c224d13b3105 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -866,6 +866,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, num_buffers, 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));
/*
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 5557d78b6f20..17cacd696ab4 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -550,6 +550,9 @@ struct vb2_buf_ops {
* @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.
+ * @min_reqbufs_allocation: the minimum number of buffers allocated when
+ * calling VIDIOC_REQBUFS. Used when drivers need a to
+ * specify a minimum buffers allocation before setup a queue.
*/
/*
* Private elements (won't appear at the uAPI book):
@@ -615,6 +618,7 @@ struct vb2_queue {
u32 timestamp_flags;
gfp_t gfp_flags;
u32 min_buffers_needed;
+ u32 min_reqbufs_allocation;

struct device *alloc_devs[VB2_MAX_PLANES];

--
2.39.2

2023-12-04 13:25:06

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 17/36] media: test-drivers: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
Obvious test-drivers don't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.
While at it rename function parameter.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Shuah Khan <[email protected]>
CC: Kieran Bingham <[email protected]>
---
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(-)

diff --git a/drivers/media/test-drivers/vimc/vimc-capture.c b/drivers/media/test-drivers/vimc/vimc-capture.c
index aa944270e716..97693561f1e4 100644
--- a/drivers/media/test-drivers/vimc/vimc-capture.c
+++ b/drivers/media/test-drivers/vimc/vimc-capture.c
@@ -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_reqbufs_allocation = 2;
q->lock = &vcapture->lock;
q->dev = v4l2_dev->dev;

diff --git a/drivers/media/test-drivers/vivid/vivid-core.c b/drivers/media/test-drivers/vivid/vivid-core.c
index 353f035fcd19..b4e888ac6016 100644
--- a/drivers/media/test-drivers/vivid/vivid-core.c
+++ b/drivers/media/test-drivers/vivid/vivid-core.c
@@ -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_buffers_needed = supports_requests[dev->inst] ? 0 : min_buffers_needed;
+ q->min_reqbufs_allocation = supports_requests[dev->inst] ? 0 : min_reqbufs_allocation;
q->lock = &dev->mutex;
q->dev = dev->v4l2_dev.dev;
q->supports_requests = supports_requests[dev->inst];
--
2.39.2

2023-12-04 13:25:49

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 18/36] media: usb: dvb-usb: cxusb-analog: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
cxusb-analog driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Michael Krufky <[email protected]>
---
drivers/media/usb/dvb-usb/cxusb-analog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb/cxusb-analog.c b/drivers/media/usb/dvb-usb/cxusb-analog.c
index deba5224cb8d..a038d97dd62e 100644
--- a/drivers/media/usb/dvb-usb/cxusb-analog.c
+++ b/drivers/media/usb/dvb-usb/cxusb-analog.c
@@ -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_reqbufs_allocation = 6;
cxdev->videoqueue.lock = &cxdev->dev_lock;

ret = vb2_queue_init(&cxdev->videoqueue);
--
2.39.2

2023-12-04 13:25:54

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 23/36] media: sti: hva: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
hva driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Jean-Christophe Trotin <[email protected]>
---
drivers/media/platform/st/sti/hva/hva-v4l2.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/st/sti/hva/hva-v4l2.c b/drivers/media/platform/st/sti/hva/hva-v4l2.c
index cfe83e9dc01b..d7bc25b0d69e 100644
--- a/drivers/media/platform/st/sti/hva/hva-v4l2.c
+++ b/drivers/media/platform/st/sti/hva/hva-v4l2.c
@@ -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_reqbufs_allocation = 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_reqbufs_allocation = MIN_STREAMS;
dst_vq->dev = ctx->hva_dev->dev;

return queue_init(ctx, dst_vq);
--
2.39.2

2023-12-04 13:25:57

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 22/36] media: nuvoton: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
nuvoton driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Joseph Liu <[email protected]>
CC: Marvin Lin <[email protected]>
CC: [email protected]
---
drivers/media/platform/nuvoton/npcm-video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/nuvoton/npcm-video.c b/drivers/media/platform/nuvoton/npcm-video.c
index 267e301f2b26..6c122508be1d 100644
--- a/drivers/media/platform/nuvoton/npcm-video.c
+++ b/drivers/media/platform/nuvoton/npcm-video.c
@@ -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_reqbufs_allocation = 3;

rc = vb2_queue_init(vbq);
if (rc) {
--
2.39.2

2023-12-04 13:25:58

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 21/36] media: imx7-media-csi: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
imx7-media-csi driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Rui Miguel Silva <[email protected]>
CC: Laurent Pinchart <[email protected]>
CC: Martin Kepplinger <[email protected]>
CC: Purism Kernel Team <[email protected]>
CC: Mauro Carvalho Chehab <[email protected]>
CC: Shawn Guo <[email protected]>
CC: Sascha Hauer <[email protected]>
CC: Pengutronix Kernel Team <[email protected]>
CC: Fabio Estevam <[email protected]>
CC: NXP Linux Team <[email protected]>
---
drivers/media/platform/nxp/imx7-media-csi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
index 1d2464ca59b8..dcc8c54228e4 100644
--- a/drivers/media/platform/nxp/imx7-media-csi.c
+++ b/drivers/media/platform/nxp/imx7-media-csi.c
@@ -1676,7 +1676,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_reqbufs_allocation = 2;
vq->dev = csi->dev;

ret = vb2_queue_init(vq);
--
2.39.2

2023-12-04 13:26:04

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 24/36] media: rockchip: rkisp1: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
rkisp1 driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Dafna Hirschfeld <[email protected]> (maintainer:ROCKCHIP ISP V1 DRIVER)
CC: Laurent Pinchart <[email protected]> (maintainer:ROCKCHIP ISP V1 DRIVER)
CC: [email protected] (open list:ROCKCHIP ISP V1 DRIVER)
---
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c
index c6d7e01c8949..de3d89b1fac7 100644
--- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c
+++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c
@@ -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_reqbufs_allocation = RKISP1_MIN_BUFFERS_NEEDED;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &node->vlock;
q->dev = cap->rkisp1->dev;
--
2.39.2

2023-12-04 13:26:05

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 15/36] media: pci: intel: ipu3: Remove useless setting of min_buffers_needed

This driver uses min_buffers_needed which vb2 uses to ensure
start_streaming is called when at least 'min_buffers_needed'
buffers are queued. However, this driver doesn't need this,
it can stream fine without any buffers queued.
Just drop this unnecessary restriction.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Yong Zhi <[email protected]>
CC: Sakari Ailus <[email protected]>
CC: Bingbu Cao <[email protected]>
CC: Dan Scally <[email protected]>
CC: Tianshu Qiu <[email protected]>
---
drivers/media/pci/intel/ipu3/ipu3-cio2.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
index 5d3b0ffd3d08..7f72be686981 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
@@ -1589,7 +1589,6 @@ 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->drv_priv = cio2;
vbq->lock = &q->lock;
r = vb2_queue_init(vbq);
--
2.39.2

2023-12-04 13:26:13

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 25/36] media: aspeed: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
aspeed doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
Reviewed-by: Eddie James <[email protected]>
CC: Joel Stanley <[email protected]> (supporter:ARM/ASPEED MACHINE SUPPORT)
CC: Andrew Jeffery <[email protected]> (reviewer:ARM/ASPEED MACHINE SUPPORT)
CC: [email protected] (moderated list:ASPEED VIDEO ENGINE DRIVER)
CC: [email protected] (moderated list:ARM/ASPEED MACHINE SUPPORT)
---
drivers/media/platform/aspeed/aspeed-video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/aspeed/aspeed-video.c b/drivers/media/platform/aspeed/aspeed-video.c
index d08aa7f73d4f..c28b10808cda 100644
--- a/drivers/media/platform/aspeed/aspeed-video.c
+++ b/drivers/media/platform/aspeed/aspeed-video.c
@@ -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_reqbufs_allocation = ASPEED_VIDEO_V4L2_MIN_BUF_REQ;

rc = vb2_queue_init(vbq);
if (rc) {
--
2.39.2

2023-12-04 13:26:26

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 19/36] media: usb: gspca: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
gspca driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
---
drivers/media/usb/gspca/gspca.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 770714c34295..7b701275f76d 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -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_reqbufs_allocation;

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_reqbufs_allocation;

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_reqbufs_allocation = 2;
q->lock = &gspca_dev->usb_lock;
ret = vb2_queue_init(q);
if (ret)
--
2.39.2

2023-12-04 13:26:30

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 27/36] media: sunxi: sun8i-di: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
sun8i-di driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.
V4L2 framework doesn't allow to allocated less than 1 buffer.
Setting min_buffers_need to 1 is useless so remove it.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Chen-Yu Tsai <[email protected]>
CC: Samuel Holland <[email protected]>
---
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
index 90ab1d77b6a5..db370519d4d8 100644
--- a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
+++ b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
@@ -673,7 +673,6 @@ 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->ops = &deinterlace_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
@@ -688,7 +687,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_reqbufs_allocation = 2;
dst_vq->ops = &deinterlace_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
--
2.39.2

2023-12-04 13:26:30

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 26/36] media: sun4i-csi: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
sun4i-csi driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Chen-Yu Tsai <[email protected]>
CC: Jernej Skrabec <[email protected]>
CC: Samuel Holland <[email protected]>
---
drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c
index 95b5633b7914..8f071cba2d25 100644
--- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c
+++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c
@@ -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_reqbufs_allocation = 3;
q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
q->io_modes = VB2_MMAP | VB2_DMABUF;
q->lock = &csi->lock;
--
2.39.2

2023-12-04 13:26:33

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 20/36] media: atmel: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
atmel-isi driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Eugen Hristev <[email protected]>
CC: Mauro Carvalho Chehab <[email protected]>
CC: Nicolas Ferre <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: Claudiu Beznea <[email protected]>
---
drivers/media/platform/atmel/atmel-isi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
index da58f33b6b0a..9c156771568a 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -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_reqbufs_allocation = 2;
q->dev = &pdev->dev;

ret = vb2_queue_init(q);
--
2.39.2

2023-12-04 13:26:34

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 28/36] media: sun8i-rotate: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
sun8i-rotate driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.
Setting min_reqbufs_allocation to 1 is useless since V4L2
framework always allocate at least 1 buffer so remove this line.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Chen-Yu Tsai <[email protected]>
CC: Samuel Holland <[email protected]>
---
drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
index 0b025ec91826..daae1ca6335a 100644
--- a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
+++ b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
@@ -536,7 +536,6 @@ 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->ops = &rotate_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
@@ -551,7 +550,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_reqbufs_allocation = 2;
dst_vq->ops = &rotate_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
--
2.39.2

2023-12-04 13:26:43

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 34/36] media: saa7146: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
saa7146 driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
---
drivers/media/common/saa7146/saa7146_fops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/common/saa7146/saa7146_fops.c b/drivers/media/common/saa7146/saa7146_fops.c
index 79214459387a..db4d725a05d4 100644
--- a/drivers/media/common/saa7146/saa7146_fops.c
+++ b/drivers/media/common/saa7146/saa7146_fops.c
@@ -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_reqbufs_allocation = 2;
q->dev = &dev->pci->dev;
err = vb2_queue_init(q);
if (err)
--
2.39.2

2023-12-04 13:46:33

by Philipp Zabel

[permalink] [raw]
Subject: Re: [PATCH v2 02/36] media: chips-media: coda: Remove useless setting of min_buffers_needed

Hi Benjamin,

On Mo, 2023-12-04 at 14:22 +0100, Benjamin Gaignard wrote:
> This driver uses min_buffers_needed which vb2 uses to ensure
> start_streaming is called when at least 'min_buffers_needed'
> buffers are queued. However, this driver doesn't need this,
> it can stream fine without any buffers queued.
> Just drop this unnecessary restriction.

Did you test this? I think there currently is some initialization in
start_streaming() that doesn't quite work when starting without any
buffers queued (it returns -EINVAL if called with count < 1).
For example, the CODA960 decoder initialization expects 512 bytes of
bitstream payload to run SEQ_INIT, and for JPEG decoding it tries to
determine chroma subsampling from the JPEG header.

regards
Philipp

2023-12-04 14:03:40

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 03/36] media: microchip: Remove useless setting of min_buffers_needed

On 04/12/2023 14:22, Benjamin Gaignard wrote:
> This driver uses min_buffers_needed which vb2 uses to ensure
> start_streaming is called when at least 'min_buffers_needed'
> buffers are queued. However, this driver doesn't need this,
> it can stream fine without any buffers queued.
> Just drop this unnecessary restriction.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: Eugen Hristev <[email protected]>
> ---
> drivers/media/platform/microchip/microchip-isc-base.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
> index 3fba0e2844b6..63c39981f47a 100644
> --- a/drivers/media/platform/microchip/microchip-isc-base.c
> +++ b/drivers/media/platform/microchip/microchip-isc-base.c
> @@ -1821,7 +1821,6 @@ 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;

I don't think this can be dropped. Looking at the isc_start_streaming() function
it expects to have at least one buffer queued.

Regards,

Hans

> q->dev = isc->dev;
>
> ret = vb2_queue_init(q);

2023-12-04 14:27:22

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 07/36] media: dvb-core: Remove useless setting of min_buffers_needed

On 04/12/2023 14:22, Benjamin Gaignard wrote:
> This driver uses min_buffers_needed which vb2 uses to ensure
> start_streaming is called when at least 'min_buffers_needed'
> buffers are queued. However, this driver doesn't need this,
> it can stream fine without any buffers queued.
> Just drop this unnecessary restriction.

This text needs to be updated: this isn't a driver, this is the
dvb_vb2 core framework.

In any case, the patch itself is correct.

Regards,

Hans

>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> ---
> drivers/media/dvb-core/dvb_vb2.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/media/dvb-core/dvb_vb2.c b/drivers/media/dvb-core/dvb_vb2.c
> index 167ff82a6fed..54a3649d8424 100644
> --- a/drivers/media/dvb-core/dvb_vb2.c
> +++ b/drivers/media/dvb-core/dvb_vb2.c
> @@ -171,7 +171,6 @@ 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->ops = &dvb_vb2_qops;
> q->mem_ops = &vb2_vmalloc_memops;
> q->buf_ops = &dvb_vb2_buf_ops;

2023-12-04 14:28:55

by Eugen Hristev

[permalink] [raw]
Subject: Re: [PATCH v2 03/36] media: microchip: Remove useless setting of min_buffers_needed

On 12/4/23 16:03, Hans Verkuil wrote:
> On 04/12/2023 14:22, Benjamin Gaignard wrote:
>> This driver uses min_buffers_needed which vb2 uses to ensure
>> start_streaming is called when at least 'min_buffers_needed'
>> buffers are queued. However, this driver doesn't need this,
>> it can stream fine without any buffers queued.
>> Just drop this unnecessary restriction.
>>
>> Signed-off-by: Benjamin Gaignard <[email protected]>
>> CC: Eugen Hristev <[email protected]>
>> ---
>> drivers/media/platform/microchip/microchip-isc-base.c | 1 -
>> 1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
>> index 3fba0e2844b6..63c39981f47a 100644
>> --- a/drivers/media/platform/microchip/microchip-isc-base.c
>> +++ b/drivers/media/platform/microchip/microchip-isc-base.c
>> @@ -1821,7 +1821,6 @@ 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;
>
> I don't think this can be dropped. Looking at the isc_start_streaming() function
> it expects to have at least one buffer queued.

Stream goes frame by frame with DMA directly into the buffers.
Will this still work without any buffers queued ?

>
> Regards,
>
> Hans
>
>> q->dev = isc->dev;
>>
>> ret = vb2_queue_init(q);
>

2023-12-04 14:32:07

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 11/36] media: ti: davinci: Remove useless setting of min_buffers_needed

On 04/12/2023 14:22, Benjamin Gaignard wrote:
> This driver uses min_buffers_needed which vb2 uses to ensure
> start_streaming is called when at least 'min_buffers_needed'
> buffers are queued. However, this driver doesn't need this,
> it can stream fine without any buffers queued.
> Just drop this unnecessary restriction.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: "Lad, Prabhakar" <[email protected]>
> ---
> drivers/media/platform/ti/davinci/vpif_capture.c | 1 -
> drivers/media/platform/ti/davinci/vpif_display.c | 1 -
> 2 files changed, 2 deletions(-)
>
> diff --git a/drivers/media/platform/ti/davinci/vpif_capture.c b/drivers/media/platform/ti/davinci/vpif_capture.c
> index fc42b4bc37e6..300c3cb5cbed 100644
> --- a/drivers/media/platform/ti/davinci/vpif_capture.c
> +++ b/drivers/media/platform/ti/davinci/vpif_capture.c
> @@ -1429,7 +1429,6 @@ 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->lock = &common->lock;
> q->dev = vpif_dev;
>
> diff --git a/drivers/media/platform/ti/davinci/vpif_display.c b/drivers/media/platform/ti/davinci/vpif_display.c
> index 9dbab1003c1d..d45391a4d8f2 100644
> --- a/drivers/media/platform/ti/davinci/vpif_display.c
> +++ b/drivers/media/platform/ti/davinci/vpif_display.c
> @@ -1169,7 +1169,6 @@ 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->lock = &common->lock;
> q->dev = vpif_dev;
> err = vb2_queue_init(q);

Drop this patch, this is really needed.

Regards,

Hans

2023-12-04 14:32:09

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 10/36] media: ti: am437x: Remove useless setting of min_buffers_needed

On 04/12/2023 14:22, Benjamin Gaignard wrote:
> This driver uses min_buffers_needed which vb2 uses to ensure
> start_streaming is called when at least 'min_buffers_needed'
> buffers are queued. However, this driver doesn't need this,
> it can stream fine without any buffers queued.
> Just drop this unnecessary restriction.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: "Lad, Prabhakar" <[email protected]>
> ---
> drivers/media/platform/ti/am437x/am437x-vpfe.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/media/platform/ti/am437x/am437x-vpfe.c b/drivers/media/platform/ti/am437x/am437x-vpfe.c
> index f18acf9286a2..228920450e7a 100644
> --- a/drivers/media/platform/ti/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/ti/am437x/am437x-vpfe.c
> @@ -2234,7 +2234,6 @@ 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->dev = vpfe->pdev;
>
> err = vb2_queue_init(q);

This driver needs one buffer as well, so drop this patch.

Regards,

Hans

2023-12-04 14:33:27

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 13/36] media: ti: j721e-csi2rx: Remove useless setting of min_buffers_needed

On 04/12/2023 14:23, Benjamin Gaignard wrote:
> This driver uses min_buffers_needed which vb2 uses to ensure
> start_streaming is called when at least 'min_buffers_needed'
> buffers are queued. However, this driver doesn't need this,
> it can stream fine without any buffers queued.
> Just drop this unnecessary restriction.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: Jai Luthra <[email protected]>
> ---
> drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
> index ada61391c8d2..1e5f68f50afb 100644
> --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
> +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
> @@ -873,7 +873,6 @@ 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;
>
> ret = vb2_queue_init(q);
> if (ret)

Drop this patch, this is needed.

Regards,

Hans

2023-12-04 14:33:57

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 14/36] media: ti: omap: Remove useless setting of min_buffers_needed

On 04/12/2023 14:23, Benjamin Gaignard wrote:
> This driver uses min_buffers_needed which vb2 uses to ensure
> start_streaming is called when at least 'min_buffers_needed'
> buffers are queued. However, this driver doesn't need this,
> it can stream fine without any buffers queued.
> Just drop this unnecessary restriction.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> ---
> drivers/media/platform/ti/omap/omap_vout.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/media/platform/ti/omap/omap_vout.c b/drivers/media/platform/ti/omap/omap_vout.c
> index 72ce903717d3..f67a45f1441b 100644
> --- a/drivers/media/platform/ti/omap/omap_vout.c
> +++ b/drivers/media/platform/ti/omap/omap_vout.c
> @@ -1404,7 +1404,6 @@ 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;
> vfd->queue = vq;
>
> ret = vb2_queue_init(vq);

Drop this patch, this is needed.

Regards,

Hans

2023-12-04 14:34:07

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 08/36] media: atmel: Remove useless setting of min_buffers_needed

On 04/12/2023 14:22, Benjamin Gaignard wrote:
> This driver uses min_buffers_needed which vb2 uses to ensure
> start_streaming is called when at least 'min_buffers_needed'
> buffers are queued. However, this driver doesn't need this,
> it can stream fine without any buffers queued.
> Just drop this unnecessary restriction.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: Eugen Hristev <[email protected]>
> CC: Nicolas Ferre <[email protected]>
> CC: Alexandre Belloni <[email protected]>
> CC: Claudiu Beznea <[email protected]>
> ---
> drivers/staging/media/deprecated/atmel/atmel-isc-base.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/staging/media/deprecated/atmel/atmel-isc-base.c b/drivers/staging/media/deprecated/atmel/atmel-isc-base.c
> index 468568b5bb7a..c18f3ba5ae1a 100644
> --- a/drivers/staging/media/deprecated/atmel/atmel-isc-base.c
> +++ b/drivers/staging/media/deprecated/atmel/atmel-isc-base.c
> @@ -1871,7 +1871,6 @@ 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->dev = isc->dev;
>
> ret = vb2_queue_init(q);

This also expects one buffer to be queued on start_streaming.

So this patch can be dropped.

Regards,

Hans

2023-12-04 14:36:40

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 15/36] media: pci: intel: ipu3: Remove useless setting of min_buffers_needed

On 04/12/2023 14:23, Benjamin Gaignard wrote:
> This driver uses min_buffers_needed which vb2 uses to ensure
> start_streaming is called when at least 'min_buffers_needed'
> buffers are queued. However, this driver doesn't need this,
> it can stream fine without any buffers queued.
> Just drop this unnecessary restriction.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: Yong Zhi <[email protected]>
> CC: Sakari Ailus <[email protected]>
> CC: Bingbu Cao <[email protected]>
> CC: Dan Scally <[email protected]>
> CC: Tianshu Qiu <[email protected]>
> ---
> drivers/media/pci/intel/ipu3/ipu3-cio2.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> index 5d3b0ffd3d08..7f72be686981 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> @@ -1589,7 +1589,6 @@ 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->drv_priv = cio2;
> vbq->lock = &q->lock;
> r = vb2_queue_init(vbq);

I can't really tell if this is needed or not. Definitely needs to be reviewed
by Sakari or someone else with sufficient knowledge of this driver.

Regards,

Hans

2023-12-04 14:42:45

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 17/36] media: test-drivers: Fix misuse of min_buffers_needed field

On 04/12/2023 14:23, Benjamin Gaignard wrote:
> 'min_buffers_needed' is suppose to be used to indicate the number
> of buffers needed by DMA engine to start streaming.
> Obvious test-drivers don't use DMA engine and just want to specify
> the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
> That 'min_reqbufs_allocation' field purpose so use it.
> While at it rename function parameter.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: Shuah Khan <[email protected]>
> CC: Kieran Bingham <[email protected]>
> ---
> 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(-)
>
> diff --git a/drivers/media/test-drivers/vimc/vimc-capture.c b/drivers/media/test-drivers/vimc/vimc-capture.c
> index aa944270e716..97693561f1e4 100644
> --- a/drivers/media/test-drivers/vimc/vimc-capture.c
> +++ b/drivers/media/test-drivers/vimc/vimc-capture.c
> @@ -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_reqbufs_allocation = 2;
> q->lock = &vcapture->lock;
> q->dev = v4l2_dev->dev;
>

That's OK.

> diff --git a/drivers/media/test-drivers/vivid/vivid-core.c b/drivers/media/test-drivers/vivid/vivid-core.c
> index 353f035fcd19..b4e888ac6016 100644
> --- a/drivers/media/test-drivers/vivid/vivid-core.c
> +++ b/drivers/media/test-drivers/vivid/vivid-core.c
> @@ -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_buffers_needed = supports_requests[dev->inst] ? 0 : min_buffers_needed;
> + q->min_reqbufs_allocation = supports_requests[dev->inst] ? 0 : min_reqbufs_allocation;

But here you can simplify this to:

q->min_reqbufs_allocation = min_reqbufs_allocation;

The 'supports_requests' restriction is only relevant for q->min_buffers_needed.

Regards,

Hans

> q->lock = &dev->mutex;
> q->dev = dev->v4l2_dev.dev;
> q->supports_requests = supports_requests[dev->inst];

2023-12-04 14:52:54

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 20/36] media: atmel: Fix misuse of min_buffers_needed field

On 04/12/2023 14:23, Benjamin Gaignard wrote:
> 'min_buffers_needed' is suppose to be used to indicate the number
> of buffers needed by DMA engine to start streaming.
> atmel-isi driver doesn't use DMA engine and just want to specify
> the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
> That 'min_reqbufs_allocation' field purpose so use it.

It definitely has a DMA engine, it just can still work if there are no
buffers queued.

>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: Eugen Hristev <[email protected]>
> CC: Mauro Carvalho Chehab <[email protected]>
> CC: Nicolas Ferre <[email protected]>
> CC: Alexandre Belloni <[email protected]>
> CC: Claudiu Beznea <[email protected]>
> ---
> drivers/media/platform/atmel/atmel-isi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
> index da58f33b6b0a..9c156771568a 100644
> --- a/drivers/media/platform/atmel/atmel-isi.c
> +++ b/drivers/media/platform/atmel/atmel-isi.c
> @@ -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_reqbufs_allocation = 2;

The problem is that this really needs to be tested since this change
will enable code paths that haven't been used before.

Regards,

Hans

> q->dev = &pdev->dev;
>
> ret = vb2_queue_init(q);

2023-12-04 14:56:49

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 32/36] media: tegra-video: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
tegra-video driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Thierry Reding <[email protected]>
CC: Jonathan Hunter <[email protected]>
CC: Sowjanya Komatineni <[email protected]>
CC: Luca Ceresoli <[email protected]>
CC: [email protected]
---
drivers/staging/media/tegra-video/vi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
index e0bb59ee3c09..b8242c8c0497 100644
--- a/drivers/staging/media/tegra-video/vi.c
+++ b/drivers/staging/media/tegra-video/vi.c
@@ -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_reqbufs_allocation = 2;
chan->queue.dev = vi->dev;
ret = vb2_queue_init(&chan->queue);
if (ret < 0) {
--
2.39.2

2023-12-04 14:57:01

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 33/36] media: ti: cal: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
Cal driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Benoit Parrot <[email protected]>
---
drivers/media/platform/ti/cal/cal-video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/ti/cal/cal-video.c b/drivers/media/platform/ti/cal/cal-video.c
index e1c5e68e945b..04709dac7221 100644
--- a/drivers/media/platform/ti/cal/cal-video.c
+++ b/drivers/media/platform/ti/cal/cal-video.c
@@ -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_reqbufs_allocation = 3;
q->dev = ctx->cal->dev;

ret = vb2_queue_init(q);
--
2.39.2

2023-12-04 14:57:16

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 29/36] media: sunxi: sun6i-csi: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
sun6i-csi driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Chen-Yu Tsai <[email protected]>
CC: Jernej Skrabec <[email protected]>
CC: Samuel Holland <[email protected]>
---
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
index cf6aadbc130b..73e721936d27 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
@@ -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_reqbufs_allocation = 2;
queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
queue->lock = &capture->lock;
queue->dev = csi_dev->dev;
--
2.39.2

2023-12-04 14:57:16

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 31/36] media: starfive: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
starfive driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Jack Zhu <[email protected]>
CC: Changhuang Liang <[email protected]>
---
drivers/staging/media/starfive/camss/stf-video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/starfive/camss/stf-video.c b/drivers/staging/media/starfive/camss/stf-video.c
index 0b305f21eb53..25038e37e8a6 100644
--- a/drivers/staging/media/starfive/camss/stf-video.c
+++ b/drivers/staging/media/starfive/camss/stf-video.c
@@ -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_reqbufs_allocation = STFCAMSS_MIN_BUFFERS;
ret = vb2_queue_init(q);
if (ret < 0) {
dev_err(video->stfcamss->dev,
--
2.39.2

2023-12-04 14:57:32

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH v2 30/36] media: imx: Fix misuse of min_buffers_needed field

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
imx-media-capture driver doesn't use DMA engine and just want to specify
the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
That 'min_reqbufs_allocation' field purpose so use it.

Signed-off-by: Benjamin Gaignard <[email protected]>
CC: Steve Longerbeam <[email protected]>
CC: Philipp Zabel <[email protected]>
CC: Greg Kroah-Hartman <[email protected]>
CC: Shawn Guo <[email protected]>
CC: Sascha Hauer <[email protected]>
CC: Pengutronix Kernel Team <[email protected]>
CC: Fabio Estevam <[email protected]>
CC: NXP Linux Team <[email protected]>
---
drivers/staging/media/imx/imx-media-capture.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
index ce02199e7b1b..5bb1ebd35d89 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -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_reqbufs_allocation = 2;
vq->dev = priv->dev;

ret = vb2_queue_init(vq);
--
2.39.2

2023-12-04 14:59:27

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 25/36] media: aspeed: Fix misuse of min_buffers_needed field

On 04/12/2023 14:23, Benjamin Gaignard wrote:
> 'min_buffers_needed' is suppose to be used to indicate the number
> of buffers needed by DMA engine to start streaming.
> aspeed doesn't use DMA engine and just want to specify
> the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
> That 'min_reqbufs_allocation' field purpose so use it.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> Reviewed-by: Eddie James <[email protected]>
> CC: Joel Stanley <[email protected]> (supporter:ARM/ASPEED MACHINE SUPPORT)
> CC: Andrew Jeffery <[email protected]> (reviewer:ARM/ASPEED MACHINE SUPPORT)
> CC: [email protected] (moderated list:ASPEED VIDEO ENGINE DRIVER)
> CC: [email protected] (moderated list:ARM/ASPEED MACHINE SUPPORT)
> ---
> drivers/media/platform/aspeed/aspeed-video.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/aspeed/aspeed-video.c b/drivers/media/platform/aspeed/aspeed-video.c
> index d08aa7f73d4f..c28b10808cda 100644
> --- a/drivers/media/platform/aspeed/aspeed-video.c
> +++ b/drivers/media/platform/aspeed/aspeed-video.c
> @@ -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_reqbufs_allocation = ASPEED_VIDEO_V4L2_MIN_BUF_REQ;

Looking at the start_streaming code I think min_buffers_needed should be 1, since
otherwise start_streaming would return -EPROTO.

But clearly the intent is also that 3 buffers minimum are allocated.

So in this case both fields should be set.

Regards,

Hans

>
> rc = vb2_queue_init(vbq);
> if (rc) {

2023-12-04 15:07:58

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 31/36] media: starfive: Fix misuse of min_buffers_needed field

On 04/12/2023 14:23, Benjamin Gaignard wrote:
> 'min_buffers_needed' is suppose to be used to indicate the number
> of buffers needed by DMA engine to start streaming.
> starfive driver doesn't use DMA engine and just want to specify
> the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
> That 'min_reqbufs_allocation' field purpose so use it.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: Jack Zhu <[email protected]>
> CC: Changhuang Liang <[email protected]>
> ---
> drivers/staging/media/starfive/camss/stf-video.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/starfive/camss/stf-video.c b/drivers/staging/media/starfive/camss/stf-video.c
> index 0b305f21eb53..25038e37e8a6 100644
> --- a/drivers/staging/media/starfive/camss/stf-video.c
> +++ b/drivers/staging/media/starfive/camss/stf-video.c
> @@ -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_reqbufs_allocation = STFCAMSS_MIN_BUFFERS;
> ret = vb2_queue_init(q);
> if (ret < 0) {
> dev_err(video->stfcamss->dev,

It's not clear to me if this driver can work without at least one buffer
queued. This would need to be tested first.

Regards,

Hans

2023-12-04 15:10:31

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 33/36] media: ti: cal: Fix misuse of min_buffers_needed field

On 04/12/2023 14:23, Benjamin Gaignard wrote:
> 'min_buffers_needed' is suppose to be used to indicate the number
> of buffers needed by DMA engine to start streaming.
> Cal driver doesn't use DMA engine and just want to specify
> the minimum number of buffers to allocate when calling VIDIOC_REQBUFS.
> That 'min_reqbufs_allocation' field purpose so use it.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: Benoit Parrot <[email protected]>
> ---
> drivers/media/platform/ti/cal/cal-video.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/ti/cal/cal-video.c b/drivers/media/platform/ti/cal/cal-video.c
> index e1c5e68e945b..04709dac7221 100644
> --- a/drivers/media/platform/ti/cal/cal-video.c
> +++ b/drivers/media/platform/ti/cal/cal-video.c
> @@ -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_reqbufs_allocation = 3;
> q->dev = ctx->cal->dev;
>
> ret = vb2_queue_init(q);

This driver definitely needs 1 buffer before it can start DMA, so set
min_buffers_needed to 1.

Regards,

Hans