vb2_dma_con...max_seg_size(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

ok so vb2_dma_contig_set_max_seg_size β€” say that five times fast, i can't β€” literally just configures the DMA max segment size. that's the whole vibe. bestie it's a one-job function and it does it. ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

int vb2_dma_contig_set_max_seg_size (struct device *dev , unsigned int
size );

πŸŽ€ ARGUMENTS πŸŽ€

  • dev β€” the device you're configuring the DMA parameters for. it's giving "this is the guy i'm setting up" energy. 🫢
  • size β€” the size of the DMA max segment size you wanna set. yes bestie, that's the number. that's what goes in. πŸ’…

🌸 DESCRIPTION 🌸

okay so here's the lore πŸ‘‘: to let the scatter-list get mapped into a single chunk in the DMA address space, your device has to have the DMA max segment size parameter set to a value larger than the buffer size. otherwise? the DMA-mapping subsystem will literally split the mapping into max-segment-size chunks and you're not getting your one-chunk fantasy. 😭

that's the whole point of this function β€” it sets the DMA max segment size parameter so DMA-mapping can map a buffer as a single chunk in DMA address space. no cap.

⚠️ heads up: this code assumes the DMA-mapping subsystem will merge all scatterlist segments if that's really possible β€” for example, when an IOMMU is available and enabled. so it's betting on the merge. πŸ’€

ideally, this parameter should be set by the generic bus code, but it's left hanging with the default 64KiB value because of historical limitations in other subsystems (like limited USB host drivers), and there's no good place to set it to the proper value. so here we are. πŸ™ˆ

✨ when to call it: this function should be called from drivers that are known to operate on platforms with IOMMU and that provide access to shared buffers (either USERPTR or DMABUF). and bestie, listen β€” this should be done before initializing the videobuf2 queue. order matters, iykyk. πŸ”₯

🧚 SEE ALSO 🧚

  • kernel file ./drivers/media/common/videobuf2/videobuf2-dma-contig.c β€” go read it, it's iconic πŸ’œ

that's the whole page, bestie!! mwah πŸ“

source: ./drivers/media/common/videobuf2 Β· version: vb2_dma_con...max_seg_size(9) Β· dated October 2026 β€” slay, see u in the next release πŸ’…βœ¨

πŸ“¦ where this page comes from