kfd_mem_dmamap_sg_bo(9)
π 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 π
ZEROif 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 π«Ά:
reuse_dmamap(9)amdgpu_amdkfd_reserve_mem_limit(9)create_dmamap_sg_bo(9)amdgpu_amdkfd_remove_all_eviction_fences(9)create_sg_table(9)kfd_mem_dmaunmap_sg_bo(9)reserve_bo_and_vm(9)reserve_bo_and_cond_vms(9)unreserve_bo_and_vms(9)amdgpu_amdkfd_gpuvm_pin_bo(9)amdgpu_amdkfd_gpuvm_unpin_bo(9)amdgpu_amdkfd_map_gtt_bo_to_gart(9)
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
- 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