devm_pci_remap_cfg_resource(9)
π devm_pci_remap_cfg_resource(9) π
okay bestie, so this is a page from the Kernel API Manual β yes, that manual β and it's about devm_pci_remap_cfg_resource, which lowkey does a whole little glow-up routine on a PCI config-space resource. stay with me, it's actually iconic π
β¨ NAME β¨
devm_pci_remap_cfg_resource β check, request region and ioremap cfg resource
no cap, that's the whole vibe: check it, request it, map it. three steps, one function, main character energy π₯
πΈ SYNOPSIS πΈ
void __iomem * devm_pci_remap_cfg_resource (struct device *dev , struct
resource *res );
it gives you back a void __iomem * β literally a pointer into mapped memory β or an error code dressed up as one. we'll get to that π«Ά
π¦ ARGUMENTS π¦
devβ the generic device that's handling the resource for you. it's the responsible adult in this situation, fr fr.resβ the configuration space resource to be handled. this is the thing getting checked, requested, and mapped β¨
π DESCRIPTION π
okay so here's what happens, and it's kind of a lot (affectionate):
it checks that a resource is a valid memory region, then requests the memory region, and then ioremaps it using the pci_remap_cfgspace API β which is the whole point, because that API makes sure the proper PCI configuration space memory attributes are guaranteed. like, that's its entire job and it ate π
and the best part? all operations are managed and will be undone on driver detach. you don't have to clean up after yourself. the devm machinery handles it. no leaks, no mess, no 3am debugging. we love a self-cleaning function π
it returns a pointer to the remapped memory, or an IOMEM_ERR_PTR encoded error code on failure. so yeah β check it with IS_ERR(), bestie, always π
usage example, straight from the source, keep it exact:
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_pci_remap_cfg_resource(pdev->dev, res);
if (IS_ERR(base))
return PTR_ERR(base);
see how it grabs the resource, maps it, and then immediately vibe-checks the result with IS_ERR(base) before returning PTR_ERR(base)? that's the pattern. memorize it. iykyk π
β SEE ALSO β
- Kernel file
./drivers/pci/devres.c devm_pci_remap_iospace(9)devm_pci_remap_cfgspace(9)pcim_set_mwi(9)pcim_intx(9)pcim_enable_device(9)pcim_pin_device(9)pcim_iomap_table(9)pcim_iomap(9)pcim_iounmap(9)pcim_iomap_region(9)pcim_iounmap_region(9)pcim_iomap_regions(9)pcim_request_region(9)pcim_release_region(9)pcim_release_all_regions(9)pcim_request_all_regions(9)pcim_iomap_range(9)
like, that's the whole friend group right there π«Ά go read them too, they're all serving π
and that's the page!! mwah π this lil gem lives in ./drivers/pci and it's dated October 2026 β so yeah, fresh off the press, and the title of the whole thing is devm_pci_remap_cfg_resource(9) in case you forgot already (no shade, it's a long name). go map some config space, bestie πΈπ§ββοΈπ
π¦ 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