sg_phys(9)
π« sg_phys(9) β the kernel API manual, but make it make sense
okay bestie, so the manual page name is sg_phys and it lives in section 9 of the Kernel API Manual β that's the Linux kernel docs, and yes we're absolutely going to get into it π
β¨ NAME β¨
sg_phys β returns the physical address of an sg entry. that's it, that's the whole vibe π¦
πΈ SYNOPSIS πΈ
dma_addr_t sg_phys (struct scatterlist *sg );
like, you hand it a struct scatterlist * and it hands you back a dma_addr_t. no cap, that's the whole transaction π
π ARGUMENTS π
sgβ the SG entry. literally just the scatterlist entry you're curious about β¨
π DESCRIPTION π
so what this does is: it calls page_to_phys on the page inside this sg entry, and then it adds the sg offset on top. that's the whole recipe, periodt π₯
β οΈ okay but listen β the caller must know that it's legal to callpage_to_physon the sg page. like, that's on you, not on this function. pls don't come forsg_physif you rolled up with an illegal page π
π«Ά SEE ALSO π«Ά
kernel file ./include/linux/scatterlist.h β and also, the entire friend group:
sg_next(9)sg_assign_page(9)sg_set_page(9)sg_set_folio(9)sg_set_buf(9)sg_chain(9)sg_mark_end(9)sg_unmark_end(9)sg_dma_is_bus_address(9)sg_dma_mark_bus_address(9)sg_dma_unmark_bus_address(9)sg_dma_is_swiotlb(9)sg_dma_mark_swiotlb(9)sg_virt(9)sg_init_marker(9)sg_alloc_table_from_pages(9)sg_page_iter_page(9)sg_page_iter_dma_address(9)for_each_sg_page(9)for_each_sg_dma_page(9)for_each_sgtable_page(9)for_each_sgtable_dma_page(9)
and that's the page, bestie π§ this one's from the ./include/linux directory, dated October 2026, and it's filed under sg_phys(9) β go forth and compute physical addresses responsibly ππβ
π¦ 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