drivers/pci/controller/pcie-xilinx.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/pcie-xilinx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/pcie-xilinx.c- Extension
.c- Size
- 16519 bytes
- Lines
- 625
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: implementation source
- Status
- source 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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interrupt.hlinux/irq.hlinux/irqchip/irq-msi-lib.hlinux/irqdomain.hlinux/kernel.hlinux/init.hlinux/msi.hlinux/of_address.hlinux/of_pci.hlinux/of_platform.hlinux/of_irq.hlinux/pci.hlinux/pci-ecam.hlinux/platform_device.h../pci.h
Detected Declarations
struct xilinx_pciefunction pcie_readfunction pcie_writefunction xilinx_pcie_link_upfunction xilinx_pcie_clear_err_interruptsfunction xilinx_pcie_valid_devicefunction xilinx_msi_top_irq_ackfunction xilinx_msi_domain_allocfunction xilinx_msi_domain_freefunction xilinx_init_dev_msi_infofunction xilinx_allocate_msi_domainsfunction xilinx_free_irq_domainsfunction xilinx_pcie_intx_mapfunction xilinx_pcie_intr_handlerfunction xilinx_pcie_init_irq_domainfunction xilinx_pcie_init_portfunction xilinx_pcie_parse_dtfunction xilinx_pcie_probe
Annotated Snippet
struct xilinx_pcie {
struct device *dev;
void __iomem *reg_base;
unsigned long msi_map[BITS_TO_LONGS(XILINX_NUM_MSI_IRQS)];
struct mutex map_lock;
struct irq_domain *msi_domain;
struct irq_domain *leg_domain;
struct list_head resources;
};
static inline u32 pcie_read(struct xilinx_pcie *pcie, u32 reg)
{
return readl(pcie->reg_base + reg);
}
static inline void pcie_write(struct xilinx_pcie *pcie, u32 val, u32 reg)
{
writel(val, pcie->reg_base + reg);
}
static inline bool xilinx_pcie_link_up(struct xilinx_pcie *pcie)
{
return (pcie_read(pcie, XILINX_PCIE_REG_PSCR) &
XILINX_PCIE_REG_PSCR_LNKUP) ? 1 : 0;
}
/**
* xilinx_pcie_clear_err_interrupts - Clear Error Interrupts
* @pcie: PCIe port information
*/
static void xilinx_pcie_clear_err_interrupts(struct xilinx_pcie *pcie)
{
struct device *dev = pcie->dev;
unsigned long val = pcie_read(pcie, XILINX_PCIE_REG_RPEFR);
if (val & XILINX_PCIE_RPEFR_ERR_VALID) {
dev_dbg(dev, "Requester ID %lu\n",
val & XILINX_PCIE_RPEFR_REQ_ID);
pcie_write(pcie, XILINX_PCIE_RPEFR_ALL_MASK,
XILINX_PCIE_REG_RPEFR);
}
}
/**
* xilinx_pcie_valid_device - Check if a valid device is present on bus
* @bus: PCI Bus structure
* @devfn: device/function
*
* Return: 'true' on success and 'false' if invalid device is found
*/
static bool xilinx_pcie_valid_device(struct pci_bus *bus, unsigned int devfn)
{
struct xilinx_pcie *pcie = bus->sysdata;
/* Check if link is up when trying to access downstream pcie ports */
if (!pci_is_root_bus(bus)) {
if (!xilinx_pcie_link_up(pcie))
return false;
} else if (devfn > 0) {
/* Only one device down on each root port */
return false;
}
return true;
}
/**
* xilinx_pcie_map_bus - Get configuration base
* @bus: PCI Bus structure
* @devfn: Device/function
* @where: Offset from base
*
* Return: Base address of the configuration space needed to be
* accessed.
*/
static void __iomem *xilinx_pcie_map_bus(struct pci_bus *bus,
unsigned int devfn, int where)
{
struct xilinx_pcie *pcie = bus->sysdata;
if (!xilinx_pcie_valid_device(bus, devfn))
return NULL;
return pcie->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where);
}
/* PCIe operations */
static struct pci_ops xilinx_pcie_ops = {
.map_bus = xilinx_pcie_map_bus,
.read = pci_generic_config_read,
.write = pci_generic_config_write,
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/irq.h`, `linux/irqchip/irq-msi-lib.h`, `linux/irqdomain.h`, `linux/kernel.h`, `linux/init.h`, `linux/msi.h`, `linux/of_address.h`.
- Detected declarations: `struct xilinx_pcie`, `function pcie_read`, `function pcie_write`, `function xilinx_pcie_link_up`, `function xilinx_pcie_clear_err_interrupts`, `function xilinx_pcie_valid_device`, `function xilinx_msi_top_irq_ack`, `function xilinx_msi_domain_alloc`, `function xilinx_msi_domain_free`, `function xilinx_init_dev_msi_info`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source 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.