drivers/pci/controller/pci-aardvark.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/pci-aardvark.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/pci-aardvark.c- Extension
.c- Size
- 60005 bytes
- Lines
- 1988
- 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/bitfield.hlinux/delay.hlinux/gpio/consumer.hlinux/interrupt.hlinux/irq.hlinux/irqchip/irq-msi-lib.hlinux/irqdomain.hlinux/kernel.hlinux/module.hlinux/pci.hlinux/pci-ecam.hlinux/init.hlinux/phy/phy.hlinux/platform_device.hlinux/msi.hlinux/of_address.hlinux/of_pci.h../pci.h../pci-bridge-emul.h
Detected Declarations
struct advk_pciefunction advk_writelfunction advk_readlfunction advk_pcie_ltssm_statefunction advk_pcie_link_upfunction advk_pcie_link_activefunction advk_pcie_link_trainingfunction advk_pcie_wait_for_linkfunction advk_pcie_wait_for_retrainfunction advk_pcie_issue_perstfunction advk_pcie_train_linkfunction advk_pcie_set_ob_winfunction advk_pcie_disable_ob_winfunction advk_pcie_setup_hwfunction advk_pcie_check_pio_statusfunction Statusfunction advk_pcie_wait_piofunction advk_pci_bridge_emul_base_conf_readfunction advk_pci_bridge_emul_base_conf_writefunction advk_pci_bridge_emul_pcie_conf_readfunction advk_pci_bridge_emul_pcie_conf_writefunction advk_pci_bridge_emul_ext_conf_readfunction advk_pci_bridge_emul_ext_conf_writefunction advk_sw_pci_bridge_initfunction advk_pcie_valid_devicefunction advk_pcie_pio_is_runningfunction advk_pcie_rd_conffunction advk_pcie_rd_conffunction advk_pcie_wr_conffunction advk_msi_irq_compose_msi_msgfunction advk_msi_irq_maskfunction advk_msi_irq_unmaskfunction advk_msi_irq_domain_allocfunction advk_msi_irq_domain_freefunction advk_pcie_irq_maskfunction advk_pcie_irq_unmaskfunction advk_pcie_irq_mapfunction advk_pcie_init_msi_irq_domainfunction advk_pcie_remove_msi_irq_domainfunction advk_pcie_init_irq_domainfunction advk_pcie_remove_irq_domainfunction advk_pcie_rp_irq_mapfunction advk_pcie_init_rp_irq_domainfunction advk_pcie_remove_rp_irq_domainfunction advk_pcie_handle_pmefunction advk_pcie_handle_msifunction advk_pcie_handle_intfunction advk_pcie_irq_handler
Annotated Snippet
struct advk_pcie {
struct platform_device *pdev;
void __iomem *base;
struct {
phys_addr_t match;
phys_addr_t remap;
phys_addr_t mask;
u32 actions;
} wins[OB_WIN_COUNT];
u8 wins_count;
struct irq_domain *rp_irq_domain;
struct irq_domain *irq_domain;
struct irq_chip irq_chip;
raw_spinlock_t irq_lock;
struct irq_domain *msi_inner_domain;
raw_spinlock_t msi_irq_lock;
DECLARE_BITMAP(msi_used, MSI_IRQ_NUM);
struct mutex msi_used_lock;
int link_gen;
struct pci_bridge_emul bridge;
struct gpio_desc *reset_gpio;
struct phy *phy;
};
static inline void advk_writel(struct advk_pcie *pcie, u32 val, u64 reg)
{
writel(val, pcie->base + reg);
}
static inline u32 advk_readl(struct advk_pcie *pcie, u64 reg)
{
return readl(pcie->base + reg);
}
static u8 advk_pcie_ltssm_state(struct advk_pcie *pcie)
{
u32 val;
u8 ltssm_state;
val = advk_readl(pcie, CFG_REG);
ltssm_state = (val >> LTSSM_SHIFT) & LTSSM_MASK;
return ltssm_state;
}
static inline bool advk_pcie_link_up(struct advk_pcie *pcie)
{
/* check if LTSSM is in normal operation - some L* state */
u8 ltssm_state = advk_pcie_ltssm_state(pcie);
return ltssm_state >= LTSSM_L0 && ltssm_state < LTSSM_DISABLED;
}
static inline bool advk_pcie_link_active(struct advk_pcie *pcie)
{
/*
* According to PCIe Base specification 3.0, Table 4-14: Link
* Status Mapped to the LTSSM, and 4.2.6.3.6 Configuration.Idle
* is Link Up mapped to LTSSM Configuration.Idle, Recovery, L0,
* L0s, L1 and L2 states. And according to 3.2.1. Data Link
* Control and Management State Machine Rules is DL Up status
* reported in DL Active state.
*/
u8 ltssm_state = advk_pcie_ltssm_state(pcie);
return ltssm_state >= LTSSM_CONFIG_IDLE && ltssm_state < LTSSM_DISABLED;
}
static inline bool advk_pcie_link_training(struct advk_pcie *pcie)
{
/*
* According to PCIe Base specification 3.0, Table 4-14: Link
* Status Mapped to the LTSSM is Link Training mapped to LTSSM
* Configuration and Recovery states.
*/
u8 ltssm_state = advk_pcie_ltssm_state(pcie);
return ((ltssm_state >= LTSSM_CONFIG_LINKWIDTH_START &&
ltssm_state < LTSSM_L0) ||
(ltssm_state >= LTSSM_RECOVERY_EQUALIZATION_PHASE0 &&
ltssm_state <= LTSSM_RECOVERY_EQUALIZATION_PHASE3));
}
static int advk_pcie_wait_for_link(struct advk_pcie *pcie)
{
int retries;
/* check if the link is up or not */
for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) {
if (advk_pcie_link_up(pcie))
return 0;
usleep_range(LINK_WAIT_USLEEP_MIN, LINK_WAIT_USLEEP_MAX);
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/irqchip/irq-msi-lib.h`, `linux/irqdomain.h`, `linux/kernel.h`.
- Detected declarations: `struct advk_pcie`, `function advk_writel`, `function advk_readl`, `function advk_pcie_ltssm_state`, `function advk_pcie_link_up`, `function advk_pcie_link_active`, `function advk_pcie_link_training`, `function advk_pcie_wait_for_link`, `function advk_pcie_wait_for_retrain`, `function advk_pcie_issue_perst`.
- 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.