drivers/pci/pci-sysfs.c
Source file repositories/reference/linux-study-clean/drivers/pci/pci-sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/pci-sysfs.c- Extension
.c- Size
- 46092 bytes
- Lines
- 1838
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/cleanup.hlinux/kernel.hlinux/sched.hlinux/pci.hlinux/stat.hlinux/export.hlinux/topology.hlinux/mm.hlinux/fs.hlinux/capability.hlinux/security.hlinux/slab.hlinux/vgaarb.hlinux/pm_runtime.hlinux/msi.hlinux/of.hlinux/aperture.hlinux/unaligned.hpci.h
Detected Declarations
function irq_showfunction broken_parity_status_showfunction broken_parity_status_storefunction pci_dev_show_local_cpufunction local_cpus_showfunction local_cpulist_showfunction cpuaffinity_showfunction cpulistaffinity_showfunction power_state_showfunction resource_showfunction max_link_speed_showfunction max_link_width_showfunction current_link_speed_showfunction current_link_width_showfunction secondary_bus_number_showfunction subordinate_bus_number_showfunction ari_enabled_showfunction modalias_showfunction enable_storefunction enable_showfunction numa_node_storefunction numa_node_showfunction dma_mask_bits_showfunction consistent_dma_mask_bits_showfunction msi_bus_showfunction msi_bus_storefunction rescan_storefunction dev_rescan_storefunction remove_storefunction bus_rescan_storefunction reset_subordinate_storefunction d3cold_allowed_storefunction d3cold_allowed_showfunction devspec_showfunction boot_vga_showfunction serial_number_showfunction pci_read_configfunction pci_write_configfunction pci_dev_config_attr_bin_sizefunction pci_llseek_resourcefunction routinefunction routinefunction spacefunction spacefunction pci_adjust_legacy_attrfunction pci_remove_legacy_filesfunction pci_mmap_resourcefunction pci_mmap_resource_uc
Annotated Snippet
static ssize_t rescan_store(const struct bus_type *bus, const char *buf, size_t count)
{
unsigned long val;
struct pci_bus *b = NULL;
if (kstrtoul(buf, 0, &val) < 0)
return -EINVAL;
if (val) {
pci_lock_rescan_remove();
while ((b = pci_find_next_bus(b)) != NULL)
pci_rescan_bus(b);
pci_unlock_rescan_remove();
}
return count;
}
static BUS_ATTR_WO(rescan);
static struct attribute *pci_bus_attrs[] = {
&bus_attr_rescan.attr,
NULL,
};
static const struct attribute_group pci_bus_group = {
.attrs = pci_bus_attrs,
};
const struct attribute_group *pci_bus_groups[] = {
&pci_bus_group,
NULL,
};
static ssize_t dev_rescan_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{
unsigned long val;
struct pci_dev *pdev = to_pci_dev(dev);
if (kstrtoul(buf, 0, &val) < 0)
return -EINVAL;
if (val) {
pci_lock_rescan_remove();
pci_rescan_bus(pdev->bus);
pci_unlock_rescan_remove();
}
return count;
}
static struct device_attribute dev_attr_dev_rescan = __ATTR(rescan, 0200, NULL,
dev_rescan_store);
static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
unsigned long val;
if (kstrtoul(buf, 0, &val) < 0)
return -EINVAL;
if (val && device_remove_file_self(dev, attr))
pci_stop_and_remove_bus_device_locked(to_pci_dev(dev));
return count;
}
static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0220, NULL,
remove_store);
static ssize_t bus_rescan_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
unsigned long val;
struct pci_bus *bus = to_pci_bus(dev);
if (kstrtoul(buf, 0, &val) < 0)
return -EINVAL;
if (val) {
pci_lock_rescan_remove();
if (!pci_is_root_bus(bus) && list_empty(&bus->devices))
pci_rescan_bus_bridge_resize(bus->self);
else
pci_rescan_bus(bus);
pci_unlock_rescan_remove();
}
return count;
}
static struct device_attribute dev_attr_bus_rescan = __ATTR(rescan, 0200, NULL,
bus_rescan_store);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/cleanup.h`, `linux/kernel.h`, `linux/sched.h`, `linux/pci.h`, `linux/stat.h`, `linux/export.h`, `linux/topology.h`.
- Detected declarations: `function irq_show`, `function broken_parity_status_show`, `function broken_parity_status_store`, `function pci_dev_show_local_cpu`, `function local_cpus_show`, `function local_cpulist_show`, `function cpuaffinity_show`, `function cpulistaffinity_show`, `function power_state_show`, `function resource_show`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.