pci_create_slot(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 β€” the struct pci_bus of the parent bridge. your origin story, basically πŸ¦‹
  • slot_nr β€” one of three vibes: PCI_SLOT(pci_dev->devfn), PCI_SLOT_PLACEHOLDER for a placeholder, or PCI_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, NULL otherwise. 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 with slot_nr of PCI_SLOT_PLACEHOLDER.
  • The other change in semantics is user-visible: the 'address' parameter presented in sysfs will consist solely of a dddd:bb tuple, where dddd is the PCI domain of the struct pci_bus and bb is 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