]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: raspberrypi: cfe: Fix min_reqbufs_allocation
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tue, 29 Oct 2024 12:47:05 +0000 (14:47 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Aug 2025 16:36:20 +0000 (18:36 +0200)
[ Upstream commit 57b5a302b5d529db96ddc52fbccec005092ebb3d ]

The driver checks if "vq->max_num_buffers + *nbuffers < 3", but
vq->max_num_buffers is (by default) 32, so the check is never true. Nor
does the check make sense.

The original code in the BSP kernel was "vq->num_buffers + *nbuffers <
3", but got mangled along the way to upstream. The intention was to make
sure that at least 3 buffers are allocated.

Fix this by removing the bad lines and setting q->min_reqbufs_allocation
to three.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/platform/raspberrypi/rp1-cfe/cfe.c

index 69a5f23e7954393e74ab2d2a79eddec01d58cc05..9af9efc0d7e7a798055d966cba609bc11a2b89c2 100644 (file)
@@ -1025,9 +1025,6 @@ static int cfe_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
        cfe_dbg(cfe, "%s: [%s] type:%u\n", __func__, node_desc[node->id].name,
                node->buffer_queue.type);
 
-       if (vq->max_num_buffers + *nbuffers < 3)
-               *nbuffers = 3 - vq->max_num_buffers;
-
        if (*nplanes) {
                if (sizes[0] < size) {
                        cfe_err(cfe, "sizes[0] %i < size %u\n", sizes[0], size);
@@ -1999,6 +1996,7 @@ static int cfe_register_node(struct cfe_device *cfe, int id)
        q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
        q->lock = &node->lock;
        q->min_queued_buffers = 1;
+       q->min_reqbufs_allocation = 3;
        q->dev = &cfe->pdev->dev;
 
        ret = vb2_queue_init(q);