diff mbox series

[27/55] media: sun6i-isp: Stop abusing of min_buffers_needed field

Message ID 20231127165454.166373-28-benjamin.gaignard@collabora.com (mailing list archive)
State New, archived
Headers show
Series Clean up queue_setup()/min_buffers_needed (ab)use | expand

Commit Message

Benjamin Gaignard Nov. 27, 2023, 4:54 p.m. UTC
'min_buffers_needed' is suppose to be used to indicate the number
of buffers needed by DMA engine to start streaming.
sun6i-isp 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: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
CC: Chen-Yu Tsai <wens@csie.org>
CC: Jernej Skrabec <jernej.skrabec@gmail.com>
CC: Samuel Holland <samuel@sholland.org>
CC: linux-sunxi@lists.linux.dev
---
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c | 2 +-
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Paul Kocialkowski Nov. 29, 2023, 1:40 p.m. UTC | #1
Hi Benjamin,

On Mon 27 Nov 23, 17:54, Benjamin Gaignard wrote:
> 'min_buffers_needed' is suppose to be used to indicate the number
> of buffers needed by DMA engine to start streaming.
> sun6i-isp 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.

The hardware actually has its own DMA engine. It can work with just one buffer
though (which will never be returned to userspace). But I think we should still
require at least two buffers allocated, otherwise the driver will be of no use
at all.

So I don't think the commit message here is correct.

Cheers,

Paul

> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> CC: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> CC: Chen-Yu Tsai <wens@csie.org>
> CC: Jernej Skrabec <jernej.skrabec@gmail.com>
> CC: Samuel Holland <samuel@sholland.org>
> CC: linux-sunxi@lists.linux.dev
> ---
>  drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c | 2 +-
>  drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c
> index 1595a9607775..f47f9946c19f 100644
> --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c
> +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c
> @@ -660,7 +660,7 @@ int sun6i_isp_capture_setup(struct sun6i_isp_device *isp_dev)
>  	queue->buf_struct_size = sizeof(struct sun6i_isp_buffer);
>  	queue->ops = &sun6i_isp_capture_queue_ops;
>  	queue->mem_ops = &vb2_dma_contig_memops;
> -	queue->min_buffers_needed = 2;
> +	queue->min_reqbufs_allocation = 2;
>  	queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>  	queue->lock = &capture->lock;
>  	queue->dev = isp_dev->dev;
> diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c
> index e28be895b486..259f6bfcb620 100644
> --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c
> +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c
> @@ -489,7 +489,7 @@ int sun6i_isp_params_setup(struct sun6i_isp_device *isp_dev)
>  	queue->buf_struct_size = sizeof(struct sun6i_isp_buffer);
>  	queue->ops = &sun6i_isp_params_queue_ops;
>  	queue->mem_ops = &vb2_vmalloc_memops;
> -	queue->min_buffers_needed = 1;
> +	queue->min_reqbufs_allocation = 1;
>  	queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>  	queue->lock = &params->lock;
>  	queue->dev = isp_dev->dev;
> -- 
> 2.39.2
>
Benjamin Gaignard Nov. 29, 2023, 2:03 p.m. UTC | #2
Le 29/11/2023 à 14:40, Paul Kocialkowski a écrit :
> Hi Benjamin,
>
> On Mon 27 Nov 23, 17:54, Benjamin Gaignard wrote:
>> 'min_buffers_needed' is suppose to be used to indicate the number
>> of buffers needed by DMA engine to start streaming.
>> sun6i-isp 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.
> The hardware actually has its own DMA engine. It can work with just one buffer
> though (which will never be returned to userspace). But I think we should still
> require at least two buffers allocated, otherwise the driver will be of no use
> at all.
>
> So I don't think the commit message here is correct.

That is exactly the info I hope to get for this first series since I don't know
each hardware block details.
I will remove this commit and make the driver use min_queued_buffers field instead
so that will fit with it needs.

Thanks,
Benjamin

>
> Cheers,
>
> Paul
>
>> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
>> CC: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
>> CC: Chen-Yu Tsai <wens@csie.org>
>> CC: Jernej Skrabec <jernej.skrabec@gmail.com>
>> CC: Samuel Holland <samuel@sholland.org>
>> CC: linux-sunxi@lists.linux.dev
>> ---
>>   drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c | 2 +-
>>   drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c  | 2 +-
>>   2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c
>> index 1595a9607775..f47f9946c19f 100644
>> --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c
>> +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c
>> @@ -660,7 +660,7 @@ int sun6i_isp_capture_setup(struct sun6i_isp_device *isp_dev)
>>   	queue->buf_struct_size = sizeof(struct sun6i_isp_buffer);
>>   	queue->ops = &sun6i_isp_capture_queue_ops;
>>   	queue->mem_ops = &vb2_dma_contig_memops;
>> -	queue->min_buffers_needed = 2;
>> +	queue->min_reqbufs_allocation = 2;
>>   	queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>>   	queue->lock = &capture->lock;
>>   	queue->dev = isp_dev->dev;
>> diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c
>> index e28be895b486..259f6bfcb620 100644
>> --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c
>> +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c
>> @@ -489,7 +489,7 @@ int sun6i_isp_params_setup(struct sun6i_isp_device *isp_dev)
>>   	queue->buf_struct_size = sizeof(struct sun6i_isp_buffer);
>>   	queue->ops = &sun6i_isp_params_queue_ops;
>>   	queue->mem_ops = &vb2_vmalloc_memops;
>> -	queue->min_buffers_needed = 1;
>> +	queue->min_reqbufs_allocation = 1;
>>   	queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>>   	queue->lock = &params->lock;
>>   	queue->dev = isp_dev->dev;
>> -- 
>> 2.39.2
>>
diff mbox series

Patch

diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c
index 1595a9607775..f47f9946c19f 100644
--- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c
+++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c
@@ -660,7 +660,7 @@  int sun6i_isp_capture_setup(struct sun6i_isp_device *isp_dev)
 	queue->buf_struct_size = sizeof(struct sun6i_isp_buffer);
 	queue->ops = &sun6i_isp_capture_queue_ops;
 	queue->mem_ops = &vb2_dma_contig_memops;
-	queue->min_buffers_needed = 2;
+	queue->min_reqbufs_allocation = 2;
 	queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 	queue->lock = &capture->lock;
 	queue->dev = isp_dev->dev;
diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c
index e28be895b486..259f6bfcb620 100644
--- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c
+++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c
@@ -489,7 +489,7 @@  int sun6i_isp_params_setup(struct sun6i_isp_device *isp_dev)
 	queue->buf_struct_size = sizeof(struct sun6i_isp_buffer);
 	queue->ops = &sun6i_isp_params_queue_ops;
 	queue->mem_ops = &vb2_vmalloc_memops;
-	queue->min_buffers_needed = 1;
+	queue->min_reqbufs_allocation = 1;
 	queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 	queue->lock = &params->lock;
 	queue->dev = isp_dev->dev;