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] [day] [month] [year] [list]
Message-ID: <aWZoZQ6z24zx9To7@lizhi-Precision-Tower-5810>
Date: Tue, 13 Jan 2026 10:44:37 -0500
From: Frank Li <Frank.li@....com>
To: Xu Yang <xu.yang_2@....com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Michael Grzeschik <m.grzeschik@...gutronix.de>, jun.li@....com,
	imx@...ts.linux.dev, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 4/4] usb: gadget: uvc: retry vb2_reqbufs() with
 vb_vmalloc_memops if use_sg fail

On Tue, Jan 13, 2026 at 05:53:10PM +0800, Xu Yang wrote:
> Based on the reality[1][2] that vb2_dma_sg_alloc() can't alloc buffer with
> device DMA limits, those device will always get below error: "swiotlb
> buffer is full (sz: 393216 bytes), total 65536 (slots), used 2358 (slots)"
> and the uvc gadget function can't work at all.
>
> The videobuf2-dma-sg.c driver doesn't has a formal improve about this issue
> till now. For UVC gadget, the videobuf2 subsystem doesn't do dma_map() on
> vmalloc returned big buffer when allocate the video buffers, however, it do
> it for dma_sg returned buffer. So the issue happens for vb2_dma_sg_alloc().
>
> To workaround the issue, lets retry vb2_reqbufs() with
> vb_vmalloc_memops if it fails to allocate buffer with vb2_dma_sg_memops.
> If use vmalloced buffer, UVC gadget will allocate some small buffers for
> each usb_request to do dma transfer, then uvc driver will memcopy data
> from big buffer to small buffer.
>
> Link[1]: https://lore.kernel.org/linux-media/20230828075420.2009568-1-anle.pan@nxp.com/
> Link[2]: https://lore.kernel.org/linux-media/20230914145812.12851-1-hui.fang@nxp.com/
> Signed-off-by: Xu Yang <xu.yang_2@....com>
Reviewed-by: Frank Li <Frank.Li@....com>
>
> ---
> Changes in v2:
>  - add more information in commit message
> ---
>  drivers/usb/gadget/function/uvc_queue.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c
> index 21d80322cb6148ed87eb77f453a1f1644e4923ae..586e5524c171f115d98af5dda43fb800466f46d2 100644
> --- a/drivers/usb/gadget/function/uvc_queue.c
> +++ b/drivers/usb/gadget/function/uvc_queue.c
> @@ -182,7 +182,15 @@ int uvcg_alloc_buffers(struct uvc_video_queue *queue,
>  {
>  	int ret;
>
> +retry:
>  	ret = vb2_reqbufs(&queue->queue, rb);
> +	if (ret < 0 && queue->use_sg) {
> +		uvc_trace(UVC_TRACE_IOCTL,
> +			  "failed to alloc buffer with sg enabled, try non-sg mode\n");
> +		queue->use_sg = 0;
> +		queue->queue.mem_ops = &vb2_vmalloc_memops;
> +		goto retry;
> +	}
>
>  	return ret ? ret : rb->count;
>  }
>
> --
> 2.34.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ