swiotlb_align_offset(9)
π NAME π
bestie, welcome to swiotlb_align_offset(9) from the Kernel API Manual β¨ β this is the function that gets the required offset into an IO TLB allocation. it does exactly what it says on the tin, no cap π
πΈ SYNOPSIS πΈ
the signature is literally this, copied with love:
unsigned int swiotlb_align_offset (struct device *dev , unsigned int
align_mask , u64 addr );
π ARGUMENTS π
devβ the owning device πalign_maskβ the allocation alignment mask π§addrβ the DMA address π¬
π¦ DESCRIPTION π¦
okay so what this returns is the minimum offset from the start of an IO TLB allocation that you need for a given buffer address and allocation alignment to keep the device happy π
first up: the address bits covered by min_align_mask must be identical in the original address and the bounce buffer address. high bits are preserved by choosing a suitable IO TLB slot, but bits below IO_TLB_SHIFT require extra padding bytes before the bounce buffer. that part is giving very precise, very necessary energy π₯
second: align_mask specifies which bits of the first allocated slot must be zero. this may require allocating additional padding slots, and then the offset (in bytes) from the first such padding slot is returned. periodt π
π SEE ALSO π
if you wanna fall down the extended-universe rabbit hole, start with the kernel file ./kernel/dma/swiotlb.c and then check out these icons π«Ά:
struct io_tlb_slot(9)struct io_tlb_area(9)swiotlb_adjust_nareas(9)limit_nareas(9)add_mem_pool(9)alloc_dma_pages(9)swiotlb_alloc_tlb(9)swiotlb_free_tlb(9)swiotlb_alloc_pool(9)swiotlb_dyn_alloc(9)__swiotlb_find_pool(9)swiotlb_del_pool(9)swiotlb_dev_init(9)swiotlb_search_pool_area(9)swiotlb_search_area(9)swiotlb_find_slots(9)mem_pool_used(9)mem_used(9)swiotlb_tbl_map_single(9)swiotlb_del_transient(9)is_swiotlb_allocated(9)default_swiotlb_base(9)default_swiotlb_limit(9)
cute lil sign-off: source/version is ./kernel/dma, date is October 2026, and the page is swiotlb_align_offset(9) β bye bestie, go slay those DMA alignments ππ«Άβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms