Le mardi 05 mars 2024 à 15:36 +0100, Florian Echtler a écrit : > Hello everyone, > > I'm taking another stab at fixing the DMA bug in the sur40 driver which has been > present for some time now. > > The bug was introduced as a side effect of this commit: > https://github.com/torvalds/linux/commit/6eb0233ec2d0df288fe8515d5b0b2b15562e05bb > > The sur40 is a bit of an odd duck which uses USB bulk transfers for video data, > so AFAICT there is no other driver I could use as an example for this combination. The UVC driver can operate in BULK. It really depends on the UVC device you have. This is one of the rare device I know for that: https://inogeni.com/product/4k2usb3/ What is the symptoms ? maybe I didn't notice it and its now having this bug ? ... > > I've tried the following variants: > > - videobuf2-dma-sg (this is the currently broken in-kernel version): > > Fails with error -22 (EINVAL) in usb_sg_init, because sgt->nents is 0. Can't > tell what the root cause is, but based on the message of the breaking commit, > I would assume that using dma-sg directly for USB devices is simply not > supported? > > - videobuf2-vmalloc: > > Fails with dmesg error: ehci-pci: rejecting DMA map of vmalloc memory (this is > sort of understandable, I guess, just wanted to be sure). > > - videobuf2-dma-contig: > > Fails with dmesg error: dma alloc of size 520192 failed. This seems quite low, > it shouldn't be an issue to map 500k of contiguous memory somewhere? > > So, in summary, my question is: how should I use the videobuf2 framework to get > USB bulk data into V4L2 buffers as efficiently as possible? Because it does seem > that none of the "obvious" solutions works... Ah, I believe I see the difference, UVC driver will always bounce the data into vmalloc buffer, cause the data is chunked and payload in variable sizes. So its not using any of the 3 allocators you mention. That being said, videobuf2-dma- contig should have worked, its used in nearly all the codecs driver, including for 4K decoding. https://elixir.bootlin.com/linux/latest/source/drivers/media/usb/uvc/uvc_video.c#L1677 Nicolas > > Thank you and best, Florian > -- > SENT FROM MY DEC VT50 TERMINAL