drivers/pci/msi/legacy.c
Source file repositories/reference/linux-study-clean/drivers/pci/msi/legacy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/msi/legacy.c- Extension
.c- Size
- 1738 bytes
- Lines
- 81
- 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.
- 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
msi.h
Detected Declarations
function Interruptfunction arch_teardown_msi_irqfunction msi_for_each_descfunction arch_teardown_msi_irqsfunction msi_for_each_descfunction pci_msi_setup_check_resultfunction pci_msi_legacy_setup_msi_irqsfunction pci_msi_legacy_teardown_msi_irqs
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* PCI Message Signaled Interrupt (MSI).
*
* Legacy architecture specific setup and teardown mechanism.
*/
#include "msi.h"
/* Arch hooks */
int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
{
return -EINVAL;
}
void __weak arch_teardown_msi_irq(unsigned int irq)
{
}
int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
struct msi_desc *desc;
int ret;
/*
* If an architecture wants to support multiple MSI, it needs to
* override arch_setup_msi_irqs()
*/
if (type == PCI_CAP_ID_MSI && nvec > 1)
return 1;
msi_for_each_desc(desc, &dev->dev, MSI_DESC_NOTASSOCIATED) {
ret = arch_setup_msi_irq(dev, desc);
if (ret)
return ret < 0 ? ret : -ENOSPC;
}
return 0;
}
void __weak arch_teardown_msi_irqs(struct pci_dev *dev)
{
struct msi_desc *desc;
int i;
msi_for_each_desc(desc, &dev->dev, MSI_DESC_ASSOCIATED) {
for (i = 0; i < desc->nvec_used; i++)
arch_teardown_msi_irq(desc->irq + i);
}
}
static int pci_msi_setup_check_result(struct pci_dev *dev, int type, int ret)
{
struct msi_desc *desc;
int avail = 0;
if (type != PCI_CAP_ID_MSIX || ret >= 0)
return ret;
/* Scan the MSI descriptors for successfully allocated ones. */
msi_for_each_desc(desc, &dev->dev, MSI_DESC_ASSOCIATED)
avail++;
return avail ? avail : ret;
}
int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
int ret = arch_setup_msi_irqs(dev, nvec, type);
ret = pci_msi_setup_check_result(dev, type, ret);
if (!ret)
ret = msi_device_populate_sysfs(&dev->dev);
return ret;
}
void pci_msi_legacy_teardown_msi_irqs(struct pci_dev *dev)
{
msi_device_destroy_sysfs(&dev->dev);
arch_teardown_msi_irqs(dev);
}
Annotation
- Immediate include surface: `msi.h`.
- Detected declarations: `function Interrupt`, `function arch_teardown_msi_irq`, `function msi_for_each_desc`, `function arch_teardown_msi_irqs`, `function msi_for_each_desc`, `function pci_msi_setup_check_result`, `function pci_msi_legacy_setup_msi_irqs`, `function pci_msi_legacy_teardown_msi_irqs`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source implementation candidate.
- 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.