lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231127165454.166373-56-benjamin.gaignard@collabora.com>
Date:   Mon, 27 Nov 2023 17:54:54 +0100
From:   Benjamin Gaignard <benjamin.gaignard@...labora.com>
To:     hverkuil@...all.nl, mchehab@...nel.org, tfiga@...omium.org,
        m.szyprowski@...sung.com, matt.ranostay@...sulko.com
Cc:     linux-kernel@...r.kernel.org, linux-media@...r.kernel.org,
        linux-staging@...ts.linux.dev, kernel@...labora.com,
        Benjamin Gaignard <benjamin.gaignard@...labora.com>
Subject: [PATCH 55/55] media: videobuf2: core: Remove 'min_buffers_needed' field

After clean up all the drivers it is possible to remove this
field from vb2_queue structure. It has been replace by
'min_dma_buffers_needed' which indicates how many buffers
a dma engine needs before start streaming and 'min_reqbufs_allocation'
to let drivers specify the minimum number of buffers to be
allocated when calling VIDIO_REQBUFS

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@...labora.com>
---
 .../media/common/videobuf2/videobuf2-core.c   | 25 ++++++-------------
 include/media/videobuf2-core.h                |  5 ----
 2 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index a6ec55db8635..223521cc135d 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -865,11 +865,10 @@ 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);
 	if (q->min_reqbufs_allocation)
-		num_buffers = max_t(unsigned int, num_buffers, q->min_reqbufs_allocation);
+		num_buffers = max_t(unsigned int, *count, q->min_reqbufs_allocation);
 	else
-		num_buffers = max_t(unsigned int, num_buffers, q->min_dma_buffers_needed + 1);
+		num_buffers = max_t(unsigned int, *count, q->min_dma_buffers_needed + 1);
 	min_reqbufs_needed = num_buffers;
 	num_buffers = min_t(unsigned int, num_buffers, q->max_num_buffers);
 	memset(q->alloc_devs, 0, sizeof(q->alloc_devs));
@@ -1851,8 +1850,7 @@ int vb2_core_qbuf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb,
 	 * then we can finally call start_streaming().
 	 */
 	if (q->streaming && !q->start_streaming_called &&
-	    ((q->queued_count >= q->min_buffers_needed) ||
-	    (q->queued_count >= q->min_dma_buffers_needed))) {
+	    q->queued_count >= q->min_dma_buffers_needed) {
 		ret = vb2_start_streaming(q);
 		if (ret) {
 			/*
@@ -2216,12 +2214,6 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)
 		return -EINVAL;
 	}
 
-	if (q_num_bufs < q->min_buffers_needed) {
-		dprintk(q, 1, "need at least %u allocated buffers\n",
-				q->min_buffers_needed);
-		return -EINVAL;
-	}
-
 	if (q_num_bufs < q->min_dma_buffers_needed) {
 		dprintk(q, 1, "need at least %u allocated buffers\n",
 			q->min_dma_buffers_needed);
@@ -2236,8 +2228,7 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)
 	 * Tell driver to start streaming provided sufficient buffers
 	 * are available.
 	 */
-	if (q->queued_count >= q->min_buffers_needed &&
-	    q->queued_count >= q->min_dma_buffers_needed) {
+	if (q->queued_count >= q->min_dma_buffers_needed) {
 		ret = vb2_start_streaming(q);
 		if (ret)
 			goto unprepare;
@@ -2517,8 +2508,7 @@ int vb2_core_queue_init(struct vb2_queue *q)
 		return -EINVAL;
 
 	if (WARN_ON(q->max_num_buffers > MAX_BUFFER_INDEX) ||
-	    WARN_ON(q->min_dma_buffers_needed > q->max_num_buffers) ||
-	    WARN_ON(q->min_buffers_needed > q->max_num_buffers))
+	    WARN_ON(q->min_dma_buffers_needed > q->max_num_buffers))
 		return -EINVAL;
 
 	if (WARN_ON(q->requires_requests && !q->supports_requests))
@@ -2526,14 +2516,13 @@ int vb2_core_queue_init(struct vb2_queue *q)
 
 	/*
 	 * This combination is not allowed since a non-zero value of
-	 * q->min_buffers_needed can cause vb2_core_qbuf() to fail if
+	 * q->min_dma_buffers_needed can cause vb2_core_qbuf() to fail if
 	 * it has to call start_streaming(), and the Request API expects
 	 * that queueing a request (and thus queueing a buffer contained
 	 * in that request) will always succeed. There is no method of
 	 * propagating an error back to userspace.
 	 */
-	if (WARN_ON(q->supports_requests &&
-		    (q->min_buffers_needed || q->min_dma_buffers_needed)))
+	if (WARN_ON(q->supports_requests && q->min_dma_buffers_needed))
 		return -EINVAL;
 
 	INIT_LIST_HEAD(&q->queued_list);
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 0bc97f28a7ea..353dccee7a30 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -546,10 +546,6 @@ struct vb2_buf_ops {
  * @gfp_flags:	additional gfp flags used when allocating the buffers.
  *		Typically this is 0, but it may be e.g. %GFP_DMA or %__GFP_DMA32
  *		to force the buffer allocation to a specific memory zone.
- * @min_buffers_needed: the minimum number of buffers needed before
- *		@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. (Deprecated)
  * @min_dma_buffers_needed: the minimum number of buffers needed before
  *		@start_streaming can be called. Used when a DMA engine
  *		cannot be started unless at least this number of buffers
@@ -623,7 +619,6 @@ struct vb2_queue {
 	unsigned int			buf_struct_size;
 	u32				timestamp_flags;
 	gfp_t				gfp_flags;
-	u32				min_buffers_needed;
 	u32				min_dma_buffers_needed;
 	u32				min_reqbufs_allocation;
 
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ