pci_create_slot(9)
π pci_create_slot π
okay so bestie, we're in the kernel API manual for pci_create_slot(9) β yes that (9) is the section number, she's fancy like that. this page is literally all about creating (or refcounting!) a physical PCI slot. slay. let's get into it β¨
πΈ NAME πΈ
pci_create_slot β create or increment refcount for physical PCI slot
like, either you get a brand new slot or you bump the refcount on one that already exists. main character behaviour either way π
π SYNOPSIS π
struct pci_slot * pci_create_slot (struct pci_bus *parent , int slot_nr
, const char *name , struct hotplug_slot *hotplug );
β¨ ARGUMENTS β¨
parentβ thestruct pci_busof the parent bridge. your origin story, basically π¦slot_nrβ one of three vibes:PCI_SLOT(pci_dev->devfn),PCI_SLOT_PLACEHOLDERfor a placeholder, orPCI_SLOT_ALL_DEVICES. pick your fighter πnameβ the user visible string, presented in/sys/bus/pci/slots/<name>. this is her public-facing @ πhotplugβ set it if the caller is a hotplug driver,NULLotherwise. are you a hotplug driver or not, be honest π
π DESCRIPTION π
okay so PCI slots have first class attributes β think address, speed, width β and a struct pci_slot is what manages them. this interface will either hand a new struct pci_slot back to the caller, or, if the pci_slot already exists, its refcount gets incremented. no duplicates, no drama, periodt β¨
slots are uniquely identified by a pci_bus, slot_nr tuple. that's the whole ID, that's the vibe check π₯
π©Ή broken firmware workaround (iykyk)
not me finding out there are known platforms with broken firmware that assign the same name to multiple slots π workaround these broken platforms by renaming the slots on behalf of the caller. so if firmware assigns name N to multiple slots:
- The first slot is assigned N
- The second slot is assigned N-1
- The third slot is assigned N-2 etc.
we're just out here doing damage control for busted firmware, it's giving customer service π
π§ Placeholder slots
in most cases, pci_bus, slot_nr will be sufficient to uniquely identify a slot. but there's one notable exception β pSeries (rpaphp), where the slot_nr cannot be determined until a device is actually inserted into the slot. so in this scenario, the caller may pass PCI_SLOT_PLACEHOLDER for slot_nr. mystery slot energy π΅οΈββοΈ
The following semantics are imposed when the caller passes slot_nr == PCI_SLOT_PLACEHOLDER:
- First, we no longer check for an existing
struct pci_slot, because there may be many slots withslot_nrofPCI_SLOT_PLACEHOLDER. - The other change in semantics is user-visible: the
'address'parameter presented in sysfs will consist solely of adddd:bbtuple, whereddddis the PCI domain of thestruct pci_busandbbis the bus number.
in other words, the devfn of the 'placeholder' slot will not be displayed. she's mysterious, she's withholding info, we respect it π
π Bus-wide slots
for PCIe hotplug, the physical slot encompasses the entire secondary bus β not just a single device number. iconic, honestly. if the device supports ARI and ARI Forwarding is enabled in the upstream bridge, a multi-function device may include functions that appear to have several different device numbers, i.e., PCI_SLOT values. pass slot_nr == PCI_SLOT_ALL_DEVICES to create a slot that matches all devices on the bus π
and unlike placeholder slots, bus-wide slots go through normal slot lookup and reuse existing slots if present. so they play by the rules π
π«Ά SEE ALSO π«Ά
- Kernel file
./drivers/pci/slot.c pci_destroy_slot(9)β the other half of the story, because every creation needs her cleanup arc π
and that's the page bestie! this one's brought to you by ./drivers/pci, dated October 2026 β so like, a little time-travelled, but we ate regardless βπ¦π
π¦ 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