arch/powerpc/platforms/pseries/msi.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/pseries/msi.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/pseries/msi.c- Extension
.c- Size
- 17760 bytes
- Lines
- 713
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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/crash_dump.hlinux/device.hlinux/irq.hlinux/irqchip/irq-msi-lib.hlinux/irqdomain.hlinux/msi.hlinux/seq_file.hasm/rtas.hasm/hw_irq.hasm/ppc-pci.hasm/machdep.hpseries.h
Detected Declarations
struct pseries_msi_devicestruct msi_countsfunction rtas_change_msifunction rtas_disable_msifunction rtas_query_irq_numberfunction check_reqfunction check_req_msifunction check_req_msixfunction msi_quota_for_devicefunction rtas_hack_32bit_msi_gen2function rtas_prepare_msi_irqsfunction pseries_msi_ops_preparefunction pseries_msi_ops_teardownfunction pseries_msi_shutdownfunction pseries_msi_write_msgfunction pseries_init_dev_msi_infofunction pseries_msi_compose_msgfunction pseries_irq_parent_domain_allocfunction pseries_irq_domain_allocfunction pseries_irq_domain_freefunction __pseries_msi_allocate_domainsfunction pseries_msi_allocate_domainsfunction pseries_msi_free_domainsfunction rtas_msi_pci_irq_fixupfunction rtas_msi_init
Annotated Snippet
struct pseries_msi_device {
unsigned int msi_quota;
unsigned int msi_used;
};
static int query_token, change_token;
#define RTAS_QUERY_FN 0
#define RTAS_CHANGE_FN 1
#define RTAS_RESET_FN 2
#define RTAS_CHANGE_MSI_FN 3
#define RTAS_CHANGE_MSIX_FN 4
#define RTAS_CHANGE_32MSI_FN 5
#define RTAS_CHANGE_32MSIX_FN 6
/* RTAS Helpers */
static int rtas_change_msi(struct pci_dn *pdn, u32 func, u32 num_irqs)
{
u32 addr, seq_num, rtas_ret[3];
unsigned long buid;
int rc;
addr = rtas_config_addr(pdn->busno, pdn->devfn, 0);
buid = pdn->phb->buid;
seq_num = 1;
do {
if (func == RTAS_CHANGE_MSI_FN || func == RTAS_CHANGE_MSIX_FN ||
func == RTAS_CHANGE_32MSI_FN || func == RTAS_CHANGE_32MSIX_FN)
rc = rtas_call(change_token, 6, 4, rtas_ret, addr,
BUID_HI(buid), BUID_LO(buid),
func, num_irqs, seq_num);
else
rc = rtas_call(change_token, 6, 3, rtas_ret, addr,
BUID_HI(buid), BUID_LO(buid),
func, num_irqs, seq_num);
seq_num = rtas_ret[1];
} while (rtas_busy_delay(rc));
/*
* If the RTAS call succeeded, return the number of irqs allocated.
* If not, make sure we return a negative error code.
*/
if (rc == 0)
rc = rtas_ret[0];
else if (rc > 0)
rc = -rc;
pr_debug("rtas_msi: ibm,change_msi(func=%d,num=%d), got %d rc = %d\n",
func, num_irqs, rtas_ret[0], rc);
return rc;
}
static void rtas_disable_msi(struct pci_dev *pdev)
{
struct pci_dn *pdn;
pdn = pci_get_pdn(pdev);
if (!pdn)
return;
/*
* disabling MSI with the explicit interface also disables MSI-X
*/
if (rtas_change_msi(pdn, RTAS_CHANGE_MSI_FN, 0) != 0) {
/*
* may have failed because explicit interface is not
* present
*/
if (rtas_change_msi(pdn, RTAS_CHANGE_FN, 0) != 0) {
pr_debug("rtas_msi: Setting MSIs to 0 failed!\n");
}
}
}
static int rtas_query_irq_number(struct pci_dn *pdn, int offset)
{
u32 addr, rtas_ret[2];
unsigned long buid;
int rc;
addr = rtas_config_addr(pdn->busno, pdn->devfn, 0);
buid = pdn->phb->buid;
do {
rc = rtas_call(query_token, 4, 3, rtas_ret, addr,
BUID_HI(buid), BUID_LO(buid), offset);
Annotation
- Immediate include surface: `linux/crash_dump.h`, `linux/device.h`, `linux/irq.h`, `linux/irqchip/irq-msi-lib.h`, `linux/irqdomain.h`, `linux/msi.h`, `linux/seq_file.h`, `asm/rtas.h`.
- Detected declarations: `struct pseries_msi_device`, `struct msi_counts`, `function rtas_change_msi`, `function rtas_disable_msi`, `function rtas_query_irq_number`, `function check_req`, `function check_req_msi`, `function check_req_msix`, `function msi_quota_for_device`, `function rtas_hack_32bit_msi_gen2`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.