kfd_mem_dmamap_sg_bo(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… kfd_mem_dmamap_sg_bo(9) πŸ’…

okay so bestie, we're deep in the Kernel API Manual today (yes, that's the manual name, we're fancy like that ✨) and this one is all about making a DMA mapped sg_table so you can actually reach a DOORBELL or MMIO BO. buckle up πŸŽ€


✨ NAME ✨

kfd_mem_dmamap_sg_bo β€” create a DMA mapped sg_table so you can access a DOORBELL or MMIO BO. that's the whole vibe πŸ¦‹


🫢 SYNOPSIS 🫢

int kfd_mem_dmamap_sg_bo (struct kgd_mem *mem , struct
kfd_mem_attachment *attachment );

like, two args, one int back. iconic signature, no notes πŸ”₯


🌸 ARGUMENTS 🌸

  • mem β€” the SG BO of the DOORBELL or MMIO resource, living on the owning device. it's giving "this is my resource and i'm proud of it" πŸ’–
  • attachment β€” the virtual address attachment of that BO on the accessing device. the "hey can i borrow this" side of the relationship 🫢

πŸ’œ DESCRIPTION πŸ’œ

okay so the whole tea here is that it depends on who's asking πŸ‘€

An access request from the device that owns the DOORBELL does not need DMA mapping. why? because that request doesn't go through the PCIe root complex β€” it literally loops back. it's a self-call, it's staying home, it's not making the trek 🏠✨

The need to DMA map only shows up when you're accessing a peer device's DOORBELL. that's when the request has to travel, and travel means mapping 😀

In contrast, all access requests for MMIO need to be DMA mapped without regard to device ownership. every single one. no exceptions, no "but it's my own device" excuses. because MMIO access requests do go through the PCIe root complex. it's the commute, and the commute is mandatory πŸš—πŸ’¨


🧚 how the slay actually happens 🧚

This is accomplished in two steps:

  • Obtain the DMA mapped address of the DOORBELL or MMIO memory that could be used in updating the requesting device's page table πŸ’…
  • Signal TTM to mark the memory pointed to by the requesting device's BO as GPU accessible. this allows an update of the requesting device's page table with entries associated with DOOREBELL or MMIO memory ⭐ (yes bestie, that's how "DOORBELL" is spelled in that one spot in the source β€” we don't gatekeep, we just report 😭)

πŸ¦‹ where you'll catch this method πŸ¦‹

This method is invoked in the following contexts:

  • Mapping of DOORBELL or MMIO BO of same or peer device πŸ‘‘
  • Validating an evicted DOOREBELL or MMIO BO on the device seeking access πŸ™ˆ
ngl if you're seeing this get called, somebody's page table is about to get an update. stay hydrated and check your device ownership fr fr πŸ’€

🌈 RETURN 🌈

  • ZERO if successful πŸ’–
  • NON-ZERO otherwise 😭

that's it, that's the whole return contract. lowkey elegant, highkey stressful.


⭐ SEE ALSO ⭐

Kernel file ./drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

and the whole friend group 🫢:


and that's the page, bestie πŸ’…βœ¨

this little masterpiece lives over in ./drivers/gpu/drm/amd/amdgpu, dated October 2026, served fresh under the Kernel API Manual banner. go forth, map responsibly, and remember: peer DOORBELLs need DMA mapping, MMIO always needs it. mwah πŸŽ€πŸ’–πŸ¦‹

πŸ“¦ where this page comes from