Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: raspberrypi: cfe: Fix min_reqbufs_allocation

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>

authored by

Tomi Valkeinen and committed by
Hans Verkuil
57b5a302 5211354f

+1 -3
+1 -3
drivers/media/platform/raspberrypi/rp1-cfe/cfe.c
··· 1024 1024 cfe_dbg(cfe, "%s: [%s] type:%u\n", __func__, node_desc[node->id].name, 1025 1025 node->buffer_queue.type); 1026 1026 1027 - if (vq->max_num_buffers + *nbuffers < 3) 1028 - *nbuffers = 3 - vq->max_num_buffers; 1029 - 1030 1027 if (*nplanes) { 1031 1028 if (sizes[0] < size) { 1032 1029 cfe_err(cfe, "sizes[0] %i < size %u\n", sizes[0], size); ··· 1995 1998 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1996 1999 q->lock = &node->lock; 1997 2000 q->min_queued_buffers = 1; 2001 + q->min_reqbufs_allocation = 3; 1998 2002 q->dev = &cfe->pdev->dev; 1999 2003 2000 2004 ret = vb2_queue_init(q);