drivers/pci/controller/cadence/pcie-cadence-ep.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/cadence/pcie-cadence-ep.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/cadence/pcie-cadence-ep.c- Extension
.c- Size
- 21869 bytes
- Lines
- 776
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/kernel.hlinux/module.hlinux/of.hlinux/pci-epc.hlinux/platform_device.hlinux/sizes.hpcie-cadence.h../../pci.h
Detected Declarations
function cdns_pcie_get_fn_from_vfnfunction cdns_pcie_ep_write_headerfunction cdns_pcie_ep_set_barfunction cdns_pcie_ep_clear_barfunction cdns_pcie_ep_map_addrfunction cdns_pcie_ep_unmap_addrfunction cdns_pcie_ep_set_msifunction cdns_pcie_ep_get_msifunction cdns_pcie_ep_get_msixfunction cdns_pcie_ep_set_msixfunction cdns_pcie_ep_assert_intxfunction cdns_pcie_ep_send_intx_irqfunction cdns_pcie_ep_send_msi_irqfunction cdns_pcie_ep_map_msi_irqfunction cdns_pcie_ep_send_msix_irqfunction cdns_pcie_ep_raise_irqfunction cdns_pcie_ep_startfunction cdns_pcie_ep_get_featuresfunction cdns_pcie_ep_disablefunction cdns_pcie_ep_setupexport cdns_pcie_ep_disableexport cdns_pcie_ep_setup
Annotated Snippet
if (vfn > 0) {
dev_err(dev, "Cannot raise INTX interrupts for VF\n");
return -EINVAL;
}
return cdns_pcie_ep_send_intx_irq(ep, fn, vfn, 0);
case PCI_IRQ_MSI:
return cdns_pcie_ep_send_msi_irq(ep, fn, vfn, interrupt_num);
case PCI_IRQ_MSIX:
return cdns_pcie_ep_send_msix_irq(ep, fn, vfn, interrupt_num);
default:
break;
}
return -EINVAL;
}
static int cdns_pcie_ep_start(struct pci_epc *epc)
{
struct cdns_pcie_ep *ep = epc_get_drvdata(epc);
struct cdns_pcie *pcie = &ep->pcie;
struct device *dev = pcie->dev;
int max_epfs = sizeof(epc->function_num_map) * 8;
int ret, epf, last_fn;
u32 reg, value;
u8 cap;
cap = cdns_pcie_find_capability(pcie, PCI_CAP_ID_EXP);
/*
* BIT(0) is hardwired to 1, hence function 0 is always enabled
* and can't be disabled anyway.
*/
cdns_pcie_writel(pcie, CDNS_PCIE_LM_EP_FUNC_CFG, epc->function_num_map);
/*
* Next function field in ARI_CAP_AND_CTR register for last function
* should be 0. Clear Next Function Number field for the last
* function used.
*/
last_fn = find_last_bit(&epc->function_num_map, BITS_PER_LONG);
reg = CDNS_PCIE_CORE_PF_I_ARI_CAP_AND_CTRL(last_fn);
value = cdns_pcie_readl(pcie, reg);
value &= ~CDNS_PCIE_ARI_CAP_NFN_MASK;
cdns_pcie_writel(pcie, reg, value);
if (ep->quirk_disable_flr) {
for (epf = 0; epf < max_epfs; epf++) {
if (!(epc->function_num_map & BIT(epf)))
continue;
value = cdns_pcie_ep_fn_readl(pcie, epf,
cap + PCI_EXP_DEVCAP);
value &= ~PCI_EXP_DEVCAP_FLR;
cdns_pcie_ep_fn_writel(pcie, epf,
cap + PCI_EXP_DEVCAP, value);
}
}
ret = cdns_pcie_start_link(pcie);
if (ret) {
dev_err(dev, "Failed to start link\n");
return ret;
}
return 0;
}
static const struct pci_epc_features cdns_pcie_epc_vf_features = {
.msi_capable = true,
.msix_capable = true,
.align = 65536,
};
static const struct pci_epc_features cdns_pcie_epc_features = {
.msi_capable = true,
.msix_capable = true,
.align = 256,
};
static const struct pci_epc_features*
cdns_pcie_ep_get_features(struct pci_epc *epc, u8 func_no, u8 vfunc_no)
{
if (!vfunc_no)
return &cdns_pcie_epc_features;
return &cdns_pcie_epc_vf_features;
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/pci-epc.h`, `linux/platform_device.h`, `linux/sizes.h`.
- Detected declarations: `function cdns_pcie_get_fn_from_vfn`, `function cdns_pcie_ep_write_header`, `function cdns_pcie_ep_set_bar`, `function cdns_pcie_ep_clear_bar`, `function cdns_pcie_ep_map_addr`, `function cdns_pcie_ep_unmap_addr`, `function cdns_pcie_ep_set_msi`, `function cdns_pcie_ep_get_msi`, `function cdns_pcie_ep_get_msix`, `function cdns_pcie_ep_set_msix`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration 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.