pci_epc_get_next_free_bar(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ pci_epc_get_next_free_bar(9) ✨

Okay bestie, so this is a page from the Kernel API Manual and honestly? It's a little baby function but it's doing main character work in the PCI endpoint world, so let's get into it πŸ’…

🌸 NAME 🌸

pci_epc_get_next_free_bar β€” it's literally the helper that finds you the next unreserved BAR, starting from @bar πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

enum pci_barno pci_epc_get_next_free_bar (const struct pci_epc_features
*epc_features , enum pci_barno bar );

That's the whole signature, no cap. It hands you back an enum pci_barno, periodt ✨


πŸ’– ARGUMENTS πŸ’–

  • epc_features β€” the pci_epc_features structure that's holding the reserved bar bitmap. Like, it's the one who actually knows which BARs are already taken πŸ™ˆ
  • bar β€” the starting BAR number, aka where the search for an unreserved BAR kicks off from. You pick the starting line, it does the looking πŸ‘‘

πŸ”₯ DESCRIPTION πŸ”₯

So you invoke this when you wanna get the next unreserved BAR starting from bar β€” the one that's actually usable for an endpoint function. That's it, that's the vibe 🫢

It's giving "personal assistant for BAR hunting" and honestly I'm obsessed.

Lowkey important: the reserved-ness comes from that bitmap sitting inside epc_features, so don't go handing it a struct that doesn't know what's reserved, bestie 😭

⭐ SEE ALSO ⭐

Peep the kernel file ./drivers/pci/endpoint/pci-epc-core.c for the full lore, and then go say hi to the whole friend group:

pci_epc_put(9), pci_epc_get(9), pci_epc_get_first_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_map(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)

Like, that's the entire group chat and every single one of them is iconic in their own way πŸ’œ


Mwah πŸ’‹ that's the page! It lives over in ./drivers/pci/endpoint, dated October 2026 β€” see you there, bestie πŸ§šβ€β™€οΈπŸŽ€

πŸ“¦ where this page comes from