public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v2 00/36] Clean up min_buffers_needed misusages
@ 2023-12-04 13:22 Benjamin Gaignard
  2023-12-04 13:22 ` [PATCH v2 01/36] media: usb: cx231xx: Remove useless setting of min_buffers_needed Benjamin Gaignard
                   ` (34 more replies)
  0 siblings, 35 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:22 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard

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


^ permalink raw reply	[flat|nested] 52+ messages in thread

* [PATCH v2 01/36] media: usb: cx231xx: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
@ 2023-12-04 13:22 ` Benjamin Gaignard
  2023-12-04 13:22 ` [PATCH v2 02/36] media: chips-media: coda: " Benjamin Gaignard
                   ` (33 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:22 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard

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 <benjamin.gaignard@collabora.com>
---
 drivers/media/usb/cx231xx/cx231xx-417.c   | 1 -
 drivers/media/usb/cx231xx/cx231xx-video.c | 2 --
 2 files changed, 3 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c
index 45973fe690b2..24c94cfb5268 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1782,7 +1782,6 @@ 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->lock = &dev->lock;
 	err = vb2_queue_init(q);
 	if (err)
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index c8eb4222319d..ce44114e2188 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1811,7 +1811,6 @@ 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->lock = &dev->lock;
 	ret = vb2_queue_init(q);
 	if (ret)
@@ -1871,7 +1870,6 @@ 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->lock = &dev->lock;
 	ret = vb2_queue_init(q);
 	if (ret)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 02/36] media: chips-media: coda: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
  2023-12-04 13:22 ` [PATCH v2 01/36] media: usb: cx231xx: Remove useless setting of min_buffers_needed Benjamin Gaignard
@ 2023-12-04 13:22 ` Benjamin Gaignard
  2023-12-04 13:45   ` Philipp Zabel
  2023-12-04 13:22 ` [PATCH v2 03/36] media: microchip: " Benjamin Gaignard
                   ` (32 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:22 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Philipp Zabel

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 <benjamin.gaignard@collabora.com>
CC: Philipp Zabel <p.zabel@pengutronix.de>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 03/36] media: microchip: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
  2023-12-04 13:22 ` [PATCH v2 01/36] media: usb: cx231xx: Remove useless setting of min_buffers_needed Benjamin Gaignard
  2023-12-04 13:22 ` [PATCH v2 02/36] media: chips-media: coda: " Benjamin Gaignard
@ 2023-12-04 13:22 ` Benjamin Gaignard
  2023-12-04 14:03   ` Hans Verkuil
  2023-12-04 13:22 ` [PATCH v2 04/36] media: amphion: " Benjamin Gaignard
                   ` (31 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:22 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Eugen Hristev

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 <benjamin.gaignard@collabora.com>
CC: Eugen Hristev <eugen.hristev@collabora.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 04/36] media: amphion: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (2 preceding siblings ...)
  2023-12-04 13:22 ` [PATCH v2 03/36] media: microchip: " Benjamin Gaignard
@ 2023-12-04 13:22 ` Benjamin Gaignard
  2023-12-04 13:22 ` [PATCH v2 05/36] media: qcom: venus: " Benjamin Gaignard
                   ` (30 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:22 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Ming Qian, Zhou Peng

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 <benjamin.gaignard@collabora.com>
CC: Ming Qian <ming.qian@nxp.com>
CC: Zhou Peng <eagle.zhou@nxp.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 05/36] media: qcom: venus: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (3 preceding siblings ...)
  2023-12-04 13:22 ` [PATCH v2 04/36] media: amphion: " Benjamin Gaignard
@ 2023-12-04 13:22 ` Benjamin Gaignard
  2023-12-04 13:22 ` [PATCH v2 06/36] media: i2c: video-i2c: " Benjamin Gaignard
                   ` (29 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:22 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Stanimir Varbanov, Vikash Garodia,
	Bryan O'Donoghue, Andy Gross, Bjorn Andersson, Konrad Dybcio,
	linux-arm-msm

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 <benjamin.gaignard@collabora.com>
CC: Stanimir Varbanov <stanimir.k.varbanov@gmail.com> (maintainer:QUALCOMM VENUS VIDEO ACCELERATOR DRIVER)
CC: Vikash Garodia <quic_vgarodia@quicinc.com> (maintainer:QUALCOMM VENUS VIDEO ACCELERATOR DRIVER)
CC: "Bryan O'Donoghue" <bryan.odonoghue@linaro.org> (reviewer:QUALCOMM VENUS VIDEO ACCELERATOR DRIVER)
CC: Andy Gross <agross@kernel.org> (maintainer:ARM/QUALCOMM SUPPORT)
CC: Bjorn Andersson <andersson@kernel.org> (maintainer:ARM/QUALCOMM SUPPORT)
CC: Konrad Dybcio <konrad.dybcio@linaro.org> (maintainer:ARM/QUALCOMM SUPPORT)
CC: linux-arm-msm@vger.kernel.org
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 06/36] media: i2c: video-i2c: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (4 preceding siblings ...)
  2023-12-04 13:22 ` [PATCH v2 05/36] media: qcom: venus: " Benjamin Gaignard
@ 2023-12-04 13:22 ` Benjamin Gaignard
  2023-12-04 13:22 ` [PATCH v2 07/36] media: dvb-core: " Benjamin Gaignard
                   ` (28 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:22 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard

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 <benjamin.gaignard@collabora.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 07/36] media: dvb-core: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (5 preceding siblings ...)
  2023-12-04 13:22 ` [PATCH v2 06/36] media: i2c: video-i2c: " Benjamin Gaignard
@ 2023-12-04 13:22 ` Benjamin Gaignard
  2023-12-04 14:23   ` Hans Verkuil
  2023-12-04 13:22 ` [PATCH v2 08/36] media: atmel: " Benjamin Gaignard
                   ` (27 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:22 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard

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 <benjamin.gaignard@collabora.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 08/36] media: atmel: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (6 preceding siblings ...)
  2023-12-04 13:22 ` [PATCH v2 07/36] media: dvb-core: " Benjamin Gaignard
@ 2023-12-04 13:22 ` Benjamin Gaignard
  2023-12-04 14:24   ` Hans Verkuil
  2023-12-04 13:22 ` [PATCH v2 09/36] media: ipu3: " Benjamin Gaignard
                   ` (26 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:22 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Eugen Hristev, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea

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 <benjamin.gaignard@collabora.com>
CC: Eugen Hristev <eugen.hristev@collabora.com>
CC: Nicolas Ferre <nicolas.ferre@microchip.com>
CC: Alexandre Belloni <alexandre.belloni@bootlin.com>
CC: Claudiu Beznea <claudiu.beznea@tuxon.dev>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 09/36] media: ipu3: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (7 preceding siblings ...)
  2023-12-04 13:22 ` [PATCH v2 08/36] media: atmel: " Benjamin Gaignard
@ 2023-12-04 13:22 ` Benjamin Gaignard
  2023-12-04 13:22 ` [PATCH v2 10/36] media: ti: am437x: " Benjamin Gaignard
                   ` (25 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:22 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Sakari Ailus, Bingbu Cao, Tianshu Qiu

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 <benjamin.gaignard@collabora.com>
CC: Sakari Ailus <sakari.ailus@linux.intel.com>
CC: Bingbu Cao <bingbu.cao@intel.com>
CC: Tianshu Qiu <tian.shu.qiu@intel.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 10/36] media: ti: am437x: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (8 preceding siblings ...)
  2023-12-04 13:22 ` [PATCH v2 09/36] media: ipu3: " Benjamin Gaignard
@ 2023-12-04 13:22 ` Benjamin Gaignard
  2023-12-04 14:29   ` Hans Verkuil
  2023-12-04 13:22 ` [PATCH v2 11/36] media: ti: davinci: " Benjamin Gaignard
                   ` (24 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:22 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Lad, Prabhakar

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 <benjamin.gaignard@collabora.com>
CC: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 11/36] media: ti: davinci: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (9 preceding siblings ...)
  2023-12-04 13:22 ` [PATCH v2 10/36] media: ti: am437x: " Benjamin Gaignard
@ 2023-12-04 13:22 ` Benjamin Gaignard
  2023-12-04 14:30   ` Hans Verkuil
  2023-12-04 13:22 ` [PATCH v2 12/36] input: touchscreen: atmel: " Benjamin Gaignard
                   ` (23 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:22 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Lad, Prabhakar

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 <benjamin.gaignard@collabora.com>
CC: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 12/36] input: touchscreen: atmel: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (10 preceding siblings ...)
  2023-12-04 13:22 ` [PATCH v2 11/36] media: ti: davinci: " Benjamin Gaignard
@ 2023-12-04 13:22 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 13/36] media: ti: j721e-csi2rx: " Benjamin Gaignard
                   ` (22 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:22 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Nick Dyer, Dmitry Torokhov, linux-input

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 <benjamin.gaignard@collabora.com>
CC: Nick Dyer <nick@shmanahar.org>
CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
CC: linux-input@vger.kernel.org
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 13/36] media: ti: j721e-csi2rx: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (11 preceding siblings ...)
  2023-12-04 13:22 ` [PATCH v2 12/36] input: touchscreen: atmel: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 14:31   ` Hans Verkuil
  2023-12-04 13:23 ` [PATCH v2 14/36] media: ti: omap: " Benjamin Gaignard
                   ` (21 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Jai Luthra

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 <benjamin.gaignard@collabora.com>
CC: Jai Luthra <j-luthra@ti.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 14/36] media: ti: omap: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (12 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 13/36] media: ti: j721e-csi2rx: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 14:32   ` Hans Verkuil
  2023-12-04 13:23 ` [PATCH v2 15/36] media: pci: intel: ipu3: " Benjamin Gaignard
                   ` (20 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard

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 <benjamin.gaignard@collabora.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 15/36] media: pci: intel: ipu3: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (13 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 14/36] media: ti: omap: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 14:36   ` Hans Verkuil
  2023-12-04 13:23 ` [PATCH v2 16/36] videobuf2: Add min_reqbufs_allocation field to vb2_queue structure Benjamin Gaignard
                   ` (19 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Yong Zhi, Sakari Ailus, Bingbu Cao, Dan Scally,
	Tianshu Qiu

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 <benjamin.gaignard@collabora.com>
CC: Yong Zhi <yong.zhi@intel.com>
CC: Sakari Ailus <sakari.ailus@linux.intel.com>
CC: Bingbu Cao <bingbu.cao@intel.com>
CC: Dan Scally <djrscally@gmail.com>
CC: Tianshu Qiu <tian.shu.qiu@intel.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 16/36] videobuf2: Add min_reqbufs_allocation field to vb2_queue structure
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (14 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 15/36] media: pci: intel: ipu3: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 17/36] media: test-drivers: Fix misuse of min_buffers_needed field Benjamin Gaignard
                   ` (18 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard

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 <benjamin.gaignard@collabora.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 17/36] media: test-drivers: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (15 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 16/36] videobuf2: Add min_reqbufs_allocation field to vb2_queue structure Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 14:42   ` Hans Verkuil
  2023-12-04 13:23 ` [PATCH v2 18/36] media: usb: dvb-usb: cxusb-analog: " Benjamin Gaignard
                   ` (17 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Shuah Khan, Kieran Bingham

'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 <benjamin.gaignard@collabora.com>
CC: Shuah Khan <skhan@linuxfoundation.org>
CC: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 18/36] media: usb: dvb-usb: cxusb-analog: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (16 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 17/36] media: test-drivers: Fix misuse of min_buffers_needed field Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 19/36] media: usb: gspca: " Benjamin Gaignard
                   ` (16 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Michael Krufky

'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 <benjamin.gaignard@collabora.com>
CC: Michael Krufky <mkrufky@linuxtv.org>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 19/36] media: usb: gspca: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (17 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 18/36] media: usb: dvb-usb: cxusb-analog: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 20/36] media: atmel: " Benjamin Gaignard
                   ` (15 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard

'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 <benjamin.gaignard@collabora.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 20/36] media: atmel: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (18 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 19/36] media: usb: gspca: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 14:52   ` Hans Verkuil
  2023-12-04 13:23 ` [PATCH v2 21/36] media: imx7-media-csi: " Benjamin Gaignard
                   ` (14 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Eugen Hristev, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea

'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 <benjamin.gaignard@collabora.com>
CC: Eugen Hristev <eugen.hristev@collabora.com>
CC: Mauro Carvalho Chehab <mchehab@kernel.org>
CC: Nicolas Ferre <nicolas.ferre@microchip.com>
CC: Alexandre Belloni <alexandre.belloni@bootlin.com>
CC: Claudiu Beznea <claudiu.beznea@tuxon.dev>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 21/36] media: imx7-media-csi: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (19 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 20/36] media: atmel: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 22/36] media: nuvoton: " Benjamin Gaignard
                   ` (13 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Rui Miguel Silva, Laurent Pinchart,
	Martin Kepplinger, Purism Kernel Team, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team

'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 <benjamin.gaignard@collabora.com>
CC: Rui Miguel Silva <rmfrfs@gmail.com>
CC: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
CC: Martin Kepplinger <martink@posteo.de>
CC: Purism Kernel Team <kernel@puri.sm>
CC: Mauro Carvalho Chehab <mchehab@kernel.org>
CC: Shawn Guo <shawnguo@kernel.org>
CC: Sascha Hauer <s.hauer@pengutronix.de>
CC: Pengutronix Kernel Team <kernel@pengutronix.de>
CC: Fabio Estevam <festevam@gmail.com>
CC: NXP Linux Team <linux-imx@nxp.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 22/36] media: nuvoton: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (20 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 21/36] media: imx7-media-csi: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 23/36] media: sti: hva: " Benjamin Gaignard
                   ` (12 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Joseph Liu, Marvin Lin, openbmc

'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 <benjamin.gaignard@collabora.com>
CC: Joseph Liu <kwliu@nuvoton.com>
CC: Marvin Lin <kflin@nuvoton.com>
CC: openbmc@lists.ozlabs.org
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 23/36] media: sti: hva: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (21 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 22/36] media: nuvoton: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 24/36] media: rockchip: rkisp1: " Benjamin Gaignard
                   ` (11 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Jean-Christophe Trotin

'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 <benjamin.gaignard@collabora.com>
CC: Jean-Christophe Trotin <jean-christophe.trotin@foss.st.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 24/36] media: rockchip: rkisp1: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (22 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 23/36] media: sti: hva: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 25/36] media: aspeed: " Benjamin Gaignard
                   ` (10 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Dafna Hirschfeld, Laurent Pinchart,
	linux-rockchip

'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 <benjamin.gaignard@collabora.com>
CC: Dafna Hirschfeld <dafna@fastmail.com> (maintainer:ROCKCHIP ISP V1 DRIVER)
CC: Laurent Pinchart <laurent.pinchart@ideasonboard.com> (maintainer:ROCKCHIP ISP V1 DRIVER)
CC: linux-rockchip@lists.infradead.org (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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 25/36] media: aspeed: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (23 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 24/36] media: rockchip: rkisp1: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 14:59   ` Hans Verkuil
  2023-12-04 13:23 ` [PATCH v2 26/36] media: sun4i-csi: " Benjamin Gaignard
                   ` (9 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Eddie James, Joel Stanley, Andrew Jeffery,
	openbmc, linux-aspeed

'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 <benjamin.gaignard@collabora.com>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
CC: Joel Stanley <joel@jms.id.au> (supporter:ARM/ASPEED MACHINE SUPPORT)
CC: Andrew Jeffery <andrew@codeconstruct.com.au> (reviewer:ARM/ASPEED MACHINE SUPPORT)
CC: openbmc@lists.ozlabs.org (moderated list:ASPEED VIDEO ENGINE DRIVER)
CC: linux-aspeed@lists.ozlabs.org (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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 26/36] media: sun4i-csi: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (24 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 25/36] media: aspeed: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 27/36] media: sunxi: sun8i-di: " Benjamin Gaignard
                   ` (8 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland

'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 <benjamin.gaignard@collabora.com>
CC: Chen-Yu Tsai <wens@csie.org>
CC: Jernej Skrabec <jernej.skrabec@gmail.com>
CC: Samuel Holland <samuel@sholland.org>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 27/36] media: sunxi: sun8i-di: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (25 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 26/36] media: sun4i-csi: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 28/36] media: sun8i-rotate: " Benjamin Gaignard
                   ` (7 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Chen-Yu Tsai, Samuel Holland

'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 <benjamin.gaignard@collabora.com>
CC: Chen-Yu Tsai <wens@csie.org>
CC: Samuel Holland <samuel@sholland.org>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 28/36] media: sun8i-rotate: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (26 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 27/36] media: sunxi: sun8i-di: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 29/36] media: sunxi: sun6i-csi: " Benjamin Gaignard
                   ` (6 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Chen-Yu Tsai, Samuel Holland

'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 <benjamin.gaignard@collabora.com>
CC: Chen-Yu Tsai <wens@csie.org>
CC: Samuel Holland <samuel@sholland.org>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 29/36] media: sunxi: sun6i-csi: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (27 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 28/36] media: sun8i-rotate: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 30/36] media: imx: " Benjamin Gaignard
                   ` (5 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland

'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 <benjamin.gaignard@collabora.com>
CC: Chen-Yu Tsai <wens@csie.org>
CC: Jernej Skrabec <jernej.skrabec@gmail.com>
CC: Samuel Holland <samuel@sholland.org>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 30/36] media: imx: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (28 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 29/36] media: sunxi: sun6i-csi: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:52   ` Philipp Zabel
  2023-12-04 13:23 ` [PATCH v2 31/36] media: starfive: " Benjamin Gaignard
                   ` (4 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Steve Longerbeam, Philipp Zabel,
	Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team

'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 <benjamin.gaignard@collabora.com>
CC: Steve Longerbeam <slongerbeam@gmail.com>
CC: Philipp Zabel <p.zabel@pengutronix.de>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: Shawn Guo <shawnguo@kernel.org>
CC: Sascha Hauer <s.hauer@pengutronix.de>
CC: Pengutronix Kernel Team <kernel@pengutronix.de>
CC: Fabio Estevam <festevam@gmail.com>
CC: NXP Linux Team <linux-imx@nxp.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 31/36] media: starfive: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (29 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 30/36] media: imx: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 15:07   ` Hans Verkuil
  2023-12-04 13:23 ` [PATCH v2 32/36] media: tegra-video: " Benjamin Gaignard
                   ` (3 subsequent siblings)
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Jack Zhu, Changhuang Liang

'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 <benjamin.gaignard@collabora.com>
CC: Jack Zhu <jack.zhu@starfivetech.com>
CC: Changhuang Liang <changhuang.liang@starfivetech.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 32/36] media: tegra-video: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (30 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 31/36] media: starfive: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 33/36] media: ti: cal: " Benjamin Gaignard
                   ` (2 subsequent siblings)
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Thierry Reding, Jonathan Hunter,
	Sowjanya Komatineni, Luca Ceresoli, linux-tegra

'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 <benjamin.gaignard@collabora.com>
CC: Thierry Reding <thierry.reding@gmail.com>
CC: Jonathan Hunter <jonathanh@nvidia.com>
CC: Sowjanya Komatineni <skomatineni@nvidia.com>
CC: Luca Ceresoli <luca.ceresoli@bootlin.com>
CC: linux-tegra@vger.kernel.org
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 33/36] media: ti: cal: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (31 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 32/36] media: tegra-video: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 15:10   ` Hans Verkuil
  2023-12-04 13:23 ` [PATCH v2 34/36] media: saa7146: " Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 35/36] input: touchscreen: sur40: " Benjamin Gaignard
  34 siblings, 1 reply; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Benoit Parrot

'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 <benjamin.gaignard@collabora.com>
CC: Benoit Parrot <bparrot@ti.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 34/36] media: saa7146: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (32 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 33/36] media: ti: cal: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  2023-12-04 13:23 ` [PATCH v2 35/36] input: touchscreen: sur40: " Benjamin Gaignard
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard

'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 <benjamin.gaignard@collabora.com>
---
 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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 35/36] input: touchscreen: sur40: Fix misuse of min_buffers_needed field
  2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
                   ` (33 preceding siblings ...)
  2023-12-04 13:23 ` [PATCH v2 34/36] media: saa7146: " Benjamin Gaignard
@ 2023-12-04 13:23 ` Benjamin Gaignard
  34 siblings, 0 replies; 52+ messages in thread
From: Benjamin Gaignard @ 2023-12-04 13:23 UTC (permalink / raw)
  To: hverkuil, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Benjamin Gaignard, Dmitry Torokhov, linux-input

'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
sur40 touchscreen 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 <benjamin.gaignard@collabora.com>
CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
CC: linux-input@vger.kernel.org
---
 drivers/input/touchscreen/sur40.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index e7d2a52169a0..4da3063c352e 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -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_reqbufs_allocation = 3,
 };
 
 static const struct v4l2_file_operations sur40_video_fops = {
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 02/36] media: chips-media: coda: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 ` [PATCH v2 02/36] media: chips-media: coda: " Benjamin Gaignard
@ 2023-12-04 13:45   ` Philipp Zabel
  0 siblings, 0 replies; 52+ messages in thread
From: Philipp Zabel @ 2023-12-04 13:45 UTC (permalink / raw)
  To: Benjamin Gaignard, hverkuil, mchehab, tfiga, m.szyprowski,
	matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel

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

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 30/36] media: imx: Fix misuse of min_buffers_needed field
  2023-12-04 13:23 ` [PATCH v2 30/36] media: imx: " Benjamin Gaignard
@ 2023-12-04 13:52   ` Philipp Zabel
  0 siblings, 0 replies; 52+ messages in thread
From: Philipp Zabel @ 2023-12-04 13:52 UTC (permalink / raw)
  To: Benjamin Gaignard, hverkuil, mchehab, tfiga, m.szyprowski,
	matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel,
	Steve Longerbeam, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team

Hi Benjamin,

On Mo, 2023-12-04 at 14:23 +0100, Benjamin Gaignard wrote:
> '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.

This is used by imx-media-csi and imx-ic-prpencvf. Both expect two
buffers to setup the IDMAC DMA engine double buffer (see
csi_idmac_setup_vb2_buf()/prp_setup_vb2_buf()).

These functions can cope with less than two buffers queued, by using a
special "underrun" buffer as a workaround, but the hardware does
require two buffer addresses, so I'm not sure whether this really
should be called a misuse of min_buffers_needed.

regards
Philipp

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 03/36] media: microchip: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 ` [PATCH v2 03/36] media: microchip: " Benjamin Gaignard
@ 2023-12-04 14:03   ` Hans Verkuil
  2023-12-04 14:25     ` Eugen Hristev
  0 siblings, 1 reply; 52+ messages in thread
From: Hans Verkuil @ 2023-12-04 14:03 UTC (permalink / raw)
  To: Benjamin Gaignard, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel, Eugen Hristev

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 <benjamin.gaignard@collabora.com>
> CC: Eugen Hristev <eugen.hristev@collabora.com>
> ---
>  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);


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 07/36] media: dvb-core: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 ` [PATCH v2 07/36] media: dvb-core: " Benjamin Gaignard
@ 2023-12-04 14:23   ` Hans Verkuil
  0 siblings, 0 replies; 52+ messages in thread
From: Hans Verkuil @ 2023-12-04 14:23 UTC (permalink / raw)
  To: Benjamin Gaignard, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel

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 <benjamin.gaignard@collabora.com>
> ---
>  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;


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 08/36] media: atmel: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 ` [PATCH v2 08/36] media: atmel: " Benjamin Gaignard
@ 2023-12-04 14:24   ` Hans Verkuil
  0 siblings, 0 replies; 52+ messages in thread
From: Hans Verkuil @ 2023-12-04 14:24 UTC (permalink / raw)
  To: Benjamin Gaignard, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel, Eugen Hristev,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea

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 <benjamin.gaignard@collabora.com>
> CC: Eugen Hristev <eugen.hristev@collabora.com>
> CC: Nicolas Ferre <nicolas.ferre@microchip.com>
> CC: Alexandre Belloni <alexandre.belloni@bootlin.com>
> CC: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> ---
>  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

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 03/36] media: microchip: Remove useless setting of min_buffers_needed
  2023-12-04 14:03   ` Hans Verkuil
@ 2023-12-04 14:25     ` Eugen Hristev
  0 siblings, 0 replies; 52+ messages in thread
From: Eugen Hristev @ 2023-12-04 14:25 UTC (permalink / raw)
  To: Hans Verkuil, Benjamin Gaignard, mchehab, tfiga, m.szyprowski,
	matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel

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 <benjamin.gaignard@collabora.com>
>> CC: Eugen Hristev <eugen.hristev@collabora.com>
>> ---
>>  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);
> 


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 10/36] media: ti: am437x: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 ` [PATCH v2 10/36] media: ti: am437x: " Benjamin Gaignard
@ 2023-12-04 14:29   ` Hans Verkuil
  0 siblings, 0 replies; 52+ messages in thread
From: Hans Verkuil @ 2023-12-04 14:29 UTC (permalink / raw)
  To: Benjamin Gaignard, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel, Lad, Prabhakar

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 <benjamin.gaignard@collabora.com>
> CC: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 11/36] media: ti: davinci: Remove useless setting of min_buffers_needed
  2023-12-04 13:22 ` [PATCH v2 11/36] media: ti: davinci: " Benjamin Gaignard
@ 2023-12-04 14:30   ` Hans Verkuil
  0 siblings, 0 replies; 52+ messages in thread
From: Hans Verkuil @ 2023-12-04 14:30 UTC (permalink / raw)
  To: Benjamin Gaignard, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel, Lad, Prabhakar

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 <benjamin.gaignard@collabora.com>
> CC: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 13/36] media: ti: j721e-csi2rx: Remove useless setting of min_buffers_needed
  2023-12-04 13:23 ` [PATCH v2 13/36] media: ti: j721e-csi2rx: " Benjamin Gaignard
@ 2023-12-04 14:31   ` Hans Verkuil
  0 siblings, 0 replies; 52+ messages in thread
From: Hans Verkuil @ 2023-12-04 14:31 UTC (permalink / raw)
  To: Benjamin Gaignard, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel, Jai Luthra

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 <benjamin.gaignard@collabora.com>
> CC: Jai Luthra <j-luthra@ti.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 14/36] media: ti: omap: Remove useless setting of min_buffers_needed
  2023-12-04 13:23 ` [PATCH v2 14/36] media: ti: omap: " Benjamin Gaignard
@ 2023-12-04 14:32   ` Hans Verkuil
  0 siblings, 0 replies; 52+ messages in thread
From: Hans Verkuil @ 2023-12-04 14:32 UTC (permalink / raw)
  To: Benjamin Gaignard, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel

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 <benjamin.gaignard@collabora.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 15/36] media: pci: intel: ipu3: Remove useless setting of min_buffers_needed
  2023-12-04 13:23 ` [PATCH v2 15/36] media: pci: intel: ipu3: " Benjamin Gaignard
@ 2023-12-04 14:36   ` Hans Verkuil
  0 siblings, 0 replies; 52+ messages in thread
From: Hans Verkuil @ 2023-12-04 14:36 UTC (permalink / raw)
  To: Benjamin Gaignard, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel, Yong Zhi,
	Sakari Ailus, Bingbu Cao, Dan Scally, Tianshu Qiu

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 <benjamin.gaignard@collabora.com>
> CC: Yong Zhi <yong.zhi@intel.com>
> CC: Sakari Ailus <sakari.ailus@linux.intel.com>
> CC: Bingbu Cao <bingbu.cao@intel.com>
> CC: Dan Scally <djrscally@gmail.com>
> CC: Tianshu Qiu <tian.shu.qiu@intel.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 17/36] media: test-drivers: Fix misuse of min_buffers_needed field
  2023-12-04 13:23 ` [PATCH v2 17/36] media: test-drivers: Fix misuse of min_buffers_needed field Benjamin Gaignard
@ 2023-12-04 14:42   ` Hans Verkuil
  0 siblings, 0 replies; 52+ messages in thread
From: Hans Verkuil @ 2023-12-04 14:42 UTC (permalink / raw)
  To: Benjamin Gaignard, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel, Shuah Khan,
	Kieran Bingham

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 <benjamin.gaignard@collabora.com>
> CC: Shuah Khan <skhan@linuxfoundation.org>
> CC: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  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];


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 20/36] media: atmel: Fix misuse of min_buffers_needed field
  2023-12-04 13:23 ` [PATCH v2 20/36] media: atmel: " Benjamin Gaignard
@ 2023-12-04 14:52   ` Hans Verkuil
  0 siblings, 0 replies; 52+ messages in thread
From: Hans Verkuil @ 2023-12-04 14:52 UTC (permalink / raw)
  To: Benjamin Gaignard, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel, Eugen Hristev,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea

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 <benjamin.gaignard@collabora.com>
> CC: Eugen Hristev <eugen.hristev@collabora.com>
> CC: Mauro Carvalho Chehab <mchehab@kernel.org>
> CC: Nicolas Ferre <nicolas.ferre@microchip.com>
> CC: Alexandre Belloni <alexandre.belloni@bootlin.com>
> CC: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> ---
>  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);


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 25/36] media: aspeed: Fix misuse of min_buffers_needed field
  2023-12-04 13:23 ` [PATCH v2 25/36] media: aspeed: " Benjamin Gaignard
@ 2023-12-04 14:59   ` Hans Verkuil
  0 siblings, 0 replies; 52+ messages in thread
From: Hans Verkuil @ 2023-12-04 14:59 UTC (permalink / raw)
  To: Benjamin Gaignard, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel, Eddie James,
	Joel Stanley, Andrew Jeffery, openbmc, linux-aspeed

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 <benjamin.gaignard@collabora.com>
> Reviewed-by: Eddie James <eajames@linux.ibm.com>
> CC: Joel Stanley <joel@jms.id.au> (supporter:ARM/ASPEED MACHINE SUPPORT)
> CC: Andrew Jeffery <andrew@codeconstruct.com.au> (reviewer:ARM/ASPEED MACHINE SUPPORT)
> CC: openbmc@lists.ozlabs.org (moderated list:ASPEED VIDEO ENGINE DRIVER)
> CC: linux-aspeed@lists.ozlabs.org (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) {


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 31/36] media: starfive: Fix misuse of min_buffers_needed field
  2023-12-04 13:23 ` [PATCH v2 31/36] media: starfive: " Benjamin Gaignard
@ 2023-12-04 15:07   ` Hans Verkuil
  0 siblings, 0 replies; 52+ messages in thread
From: Hans Verkuil @ 2023-12-04 15:07 UTC (permalink / raw)
  To: Benjamin Gaignard, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel, Jack Zhu,
	Changhuang Liang

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 <benjamin.gaignard@collabora.com>
> CC: Jack Zhu <jack.zhu@starfivetech.com>
> CC: Changhuang Liang <changhuang.liang@starfivetech.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 33/36] media: ti: cal: Fix misuse of min_buffers_needed field
  2023-12-04 13:23 ` [PATCH v2 33/36] media: ti: cal: " Benjamin Gaignard
@ 2023-12-04 15:10   ` Hans Verkuil
  0 siblings, 0 replies; 52+ messages in thread
From: Hans Verkuil @ 2023-12-04 15:10 UTC (permalink / raw)
  To: Benjamin Gaignard, mchehab, tfiga, m.szyprowski, matt.ranostay
  Cc: linux-kernel, linux-media, linux-staging, kernel, Benoit Parrot

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 <benjamin.gaignard@collabora.com>
> CC: Benoit Parrot <bparrot@ti.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2023-12-04 15:10 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-04 13:22 [PATCH v2 00/36] Clean up min_buffers_needed misusages Benjamin Gaignard
2023-12-04 13:22 ` [PATCH v2 01/36] media: usb: cx231xx: Remove useless setting of min_buffers_needed Benjamin Gaignard
2023-12-04 13:22 ` [PATCH v2 02/36] media: chips-media: coda: " Benjamin Gaignard
2023-12-04 13:45   ` Philipp Zabel
2023-12-04 13:22 ` [PATCH v2 03/36] media: microchip: " Benjamin Gaignard
2023-12-04 14:03   ` Hans Verkuil
2023-12-04 14:25     ` Eugen Hristev
2023-12-04 13:22 ` [PATCH v2 04/36] media: amphion: " Benjamin Gaignard
2023-12-04 13:22 ` [PATCH v2 05/36] media: qcom: venus: " Benjamin Gaignard
2023-12-04 13:22 ` [PATCH v2 06/36] media: i2c: video-i2c: " Benjamin Gaignard
2023-12-04 13:22 ` [PATCH v2 07/36] media: dvb-core: " Benjamin Gaignard
2023-12-04 14:23   ` Hans Verkuil
2023-12-04 13:22 ` [PATCH v2 08/36] media: atmel: " Benjamin Gaignard
2023-12-04 14:24   ` Hans Verkuil
2023-12-04 13:22 ` [PATCH v2 09/36] media: ipu3: " Benjamin Gaignard
2023-12-04 13:22 ` [PATCH v2 10/36] media: ti: am437x: " Benjamin Gaignard
2023-12-04 14:29   ` Hans Verkuil
2023-12-04 13:22 ` [PATCH v2 11/36] media: ti: davinci: " Benjamin Gaignard
2023-12-04 14:30   ` Hans Verkuil
2023-12-04 13:22 ` [PATCH v2 12/36] input: touchscreen: atmel: " Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 13/36] media: ti: j721e-csi2rx: " Benjamin Gaignard
2023-12-04 14:31   ` Hans Verkuil
2023-12-04 13:23 ` [PATCH v2 14/36] media: ti: omap: " Benjamin Gaignard
2023-12-04 14:32   ` Hans Verkuil
2023-12-04 13:23 ` [PATCH v2 15/36] media: pci: intel: ipu3: " Benjamin Gaignard
2023-12-04 14:36   ` Hans Verkuil
2023-12-04 13:23 ` [PATCH v2 16/36] videobuf2: Add min_reqbufs_allocation field to vb2_queue structure Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 17/36] media: test-drivers: Fix misuse of min_buffers_needed field Benjamin Gaignard
2023-12-04 14:42   ` Hans Verkuil
2023-12-04 13:23 ` [PATCH v2 18/36] media: usb: dvb-usb: cxusb-analog: " Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 19/36] media: usb: gspca: " Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 20/36] media: atmel: " Benjamin Gaignard
2023-12-04 14:52   ` Hans Verkuil
2023-12-04 13:23 ` [PATCH v2 21/36] media: imx7-media-csi: " Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 22/36] media: nuvoton: " Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 23/36] media: sti: hva: " Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 24/36] media: rockchip: rkisp1: " Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 25/36] media: aspeed: " Benjamin Gaignard
2023-12-04 14:59   ` Hans Verkuil
2023-12-04 13:23 ` [PATCH v2 26/36] media: sun4i-csi: " Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 27/36] media: sunxi: sun8i-di: " Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 28/36] media: sun8i-rotate: " Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 29/36] media: sunxi: sun6i-csi: " Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 30/36] media: imx: " Benjamin Gaignard
2023-12-04 13:52   ` Philipp Zabel
2023-12-04 13:23 ` [PATCH v2 31/36] media: starfive: " Benjamin Gaignard
2023-12-04 15:07   ` Hans Verkuil
2023-12-04 13:23 ` [PATCH v2 32/36] media: tegra-video: " Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 33/36] media: ti: cal: " Benjamin Gaignard
2023-12-04 15:10   ` Hans Verkuil
2023-12-04 13:23 ` [PATCH v2 34/36] media: saa7146: " Benjamin Gaignard
2023-12-04 13:23 ` [PATCH v2 35/36] input: touchscreen: sur40: " Benjamin Gaignard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox