pci_epc_mem_map(9)
π pci_epc_mem_map(9) β the kernel API manual, bestie edition π
okay so real talk, this is a page straight out of the Kernel API Manual and it's all about pci_epc_mem_map β allocate a controller memory region and map it onto a PCI address, no cap β¨
β¨ NAME β¨
pci_epc_mem_map β allocate and map a PCI address to a CPU address π¦
πΈ SYNOPSIS πΈ
int pci_epc_mem_map (struct pci_epc *epc , u8 func_no , u8 vfunc_no ,
u64 pci_addr , size_t pci_size , struct pci_epc_map *map );
π ARGUMENTS π
epcβ the EPC device on which the CPU address is gonna get allocated and mapped, periodt πfunc_noβ the physical endpoint function number inside the EPC device, iykykvfunc_noβ the virtual endpoint function number, and it lives inside that physical function π«Άpci_addrβ the PCI address that the CPU address should be mapped to βpci_sizeβ how many bytes to map, starting frompci_addrπmapβ where the mapping info gets returned, like the little goodie bag of results π
π DESCRIPTION π
So what's actually happening: it allocates a controller memory address region and maps it to an RC PCI address region. The way that it does this is it takes the controller's physical address mapping constraints into account using the controller operation align_addr π. And bestie, if that operation is not defined? Then we're assuming there are literally no alignment constraints for the mapping. easy vibe check π
The effective size of the PCI address range that gets mapped from pci_addr is indicated by map->pci_size β and heads up, this size may be less than the requested pci_size π₯. The local virtual CPU address for the mapping is indicated by map->virt_addr (and map->phys_addr is the physical address, in case you were wondering π). The size and the CPU address of the controller memory that got allocated and mapped are respectively indicated by map->map_size and map->virt_base (and map->phys_base gives you the physical address of map->virt_base β yes, they went there).
Returns 0 on success and a negative error code in case of error π§
β SEE ALSO β
Kernel file ./drivers/pci/endpoint/pci-epc-core.c plus the whole friend group:
pci_epc_put(9)pci_epc_get(9)pci_epc_get_first_free_bar(9)pci_epc_get_next_free_bar(9)pci_epc_get_features(9)pci_epc_get_aux_resources_count(9)pci_epc_get_aux_resources(9)pci_epc_stop(9)pci_epc_start(9)pci_epc_raise_irq(9)pci_epc_map_msi_irq(9)pci_epc_get_msi(9)pci_epc_set_msi(9)pci_epc_get_msix(9)pci_epc_set_msix(9)pci_epc_unmap_addr(9)pci_epc_map_addr(9)pci_epc_mem_unmap(9)pci_epc_clear_bar(9)pci_epc_set_bar(9)pci_epc_bar_size_to_rebar_cap(9)pci_epc_write_header(9)pci_epc_add_epf(9)pci_epc_remove_epf(9)pci_epc_linkup(9)pci_epc_linkdown(9)pci_epc_init_notify(9)pci_epc_notify_pending_init(9)pci_epc_deinit_notify(9)pci_epc_bus_master_enable_notify(9)pci_epc_destroy(9)__pci_epc_create(9)__devm_pci_epc_create(9)
ngl that's a lot of cross-references but every single one of them is iconic in its own right π«Ά
and that's the whole page, bestie π it lives in ./drivers/pci/endpoint, dated October 2026, and it's filed under pci_epc_mem_map(9) in the Kernel API Manual. slay, go map some memory π§β¨π
π¦ 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