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: <3cdf47f5-ad38-44ca-1720-d70a96432045@xs4all.nl>
Date:   Wed, 27 Apr 2022 08:38:06 +0200
From:   Hans Verkuil <hverkuil-cisco@...all.nl>
To:     Ming Qian <ming.qian@....com>, mchehab@...nel.org,
        shawnguo@...nel.org
Cc:     robh+dt@...nel.org, s.hauer@...gutronix.de, kernel@...gutronix.de,
        festevam@...il.com, linux-imx@....com, aisheng.dong@....com,
        linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH] media: amphion: ensure the buffer count is not less than
 min_buffer

Hi Ming Qian,

On 22/03/2022 09:28, Ming Qian wrote:
> the output buffer count should >= min_buffer_out
> the capture buffer count should >= min_buffer_cap
> 
> Signed-off-by: Ming Qian <ming.qian@....com>
> ---
>  drivers/media/platform/amphion/vpu_v4l2.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/media/platform/amphion/vpu_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.c
> index cbf3315605a9..72a0544f4da3 100644
> --- a/drivers/media/platform/amphion/vpu_v4l2.c
> +++ b/drivers/media/platform/amphion/vpu_v4l2.c
> @@ -355,6 +355,10 @@ static int vpu_vb2_queue_setup(struct vb2_queue *vq,
>  		return 0;
>  	}
>  
> +	if (V4L2_TYPE_IS_OUTPUT(vq->type))
> +		*buf_count = max_t(unsigned int, *buf_count, inst->min_buffer_out);
> +	else
> +		*buf_count = max_t(unsigned int, *buf_count, inst->min_buffer_cap);

I noticed that min_buffer_out/cap is set to 2, but min_buffers_needed
is set to 1. Wouldn't it make more sense to set min_buffers_needed to
2 as well?

If you do that, then the vb2 core will already take care of ensuring that
the buf_count is adjusted.

If you *do* have to do this manually, then you need to place the whole
if-else under 'if (!*num_planes) {', otherwise it will mess up the
VIDIOC_CREATE_BUFS ioctl. See the queue_setup in include/media/videobuf2-core.h
documentation for the sordid details.

Regards,

	Hans

>  	*plane_count = cur_fmt->num_planes;
>  	for (i = 0; i < cur_fmt->num_planes; i++)
>  		psize[i] = cur_fmt->sizeimage[i];

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ