swiotlb_tbl_map_single(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿ’– swiotlb_tbl_map_single(9) โ€” Kernel API Manual ๐Ÿ’–

๐ŸŒธ NAME ๐ŸŒธ

swiotlb_tbl_map_single โ€” bounce buffer map a single contiguous physical area

โœจ SYNOPSIS โœจ

phys_addr_t swiotlb_tbl_map_single (struct device *dev , phys_addr_t
orig_addr , size_t mapping_size , unsigned int alloc_align_mask , enum
dma_data_direction dir , unsigned long *attrs );

๐ŸŽ€ ARGUMENTS ๐ŸŽ€

  • dev โ€” Device which maps the buffer.
  • orig_addr โ€” Original (non-bounced) physical IO buffer address.
  • mapping_size โ€” Requested size of the actual bounce buffer, excluding any pre- or post-padding for alignment.
  • alloc_align_mask โ€” Required start and end alignment of the allocated buffer.
  • dir โ€” DMA direction.
  • attrs โ€” Optional DMA attributes for the map operation, updated to match the selected SWIOTLB pool.

๐Ÿ’… DESCRIPTION ๐Ÿ’…

Okay so the job is: find and allocate a suitable sequence of IO TLB slots for the request โ€” bestie, that's the whole quest. ๐Ÿซถ The device's SWIOTLB pool must match the device's current DMA encryption requirements. If the device requires decrypted DMA, bouncing is done through an unencrypted pool and the mapping is marked shared. If the device can DMA to encrypted memory, bouncing is done through an encrypted pool even when the original DMA address was unencrypted. Enabling encrypted DMA for a device is therefore expected to update its default io_tlb_mem to an encrypted pool, so later bounce mappings for both encrypted and decrypted original memory use that encrypted pool. ๐Ÿ”โœจ

Alignment tea โ˜•: the allocated space starts at an alignment specified by alloc_align_mask, and the size of the allocated space is rounded up so that the total amount of allocated space is a multiple of (alloc_align_mask + 1). If alloc_align_mask is zero, the allocated space may be at any alignment and the size is not rounded up. Slay the math. ๐Ÿงฎ๐Ÿ’…

Now the returned address: it's within the allocated space and matches the bits of orig_addr that are specified in the DMA min_align_mask for the device. As such, this returned address may be offset from the beginning of the allocated space. The bounce buffer space starting at the returned address for mapping_size bytes is initialized to the contents of the original IO buffer area. Any pre-padding (due to an offset) and any post-padding (due to rounding-up the size) is not initialized. โš ๏ธ So do not assume the padding got a glow-up.

๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

Kernel file ./kernel/dma/swiotlb.c โ€” and the whole friend group:


Source line: ./kernel/dma ยท date edition: October 2026 ยท page: swiotlb_tbl_map_single(9) โ€” bye bestie, go map responsibly ๐Ÿ’–๐ŸŽ€

๐Ÿ“ฆ where this page comes from