arch/sparc/kernel/pci_msi.c
Source file repositories/reference/linux-study-clean/arch/sparc/kernel/pci_msi.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/kernel/pci_msi.c- Extension
.c- Size
- 9920 bytes
- Lines
- 447
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- 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.
- 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.
- 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/kernel.hlinux/interrupt.hlinux/of.hlinux/platform_device.hlinux/slab.hlinux/irq.hpci_impl.h
Detected Declarations
function Copyrightfunction pick_msiqfunction alloc_msifunction free_msifunction sparc64_setup_msi_irqfunction sparc64_teardown_msi_irqfunction msi_bitmap_allocfunction msi_bitmap_freefunction msi_table_allocfunction msi_table_freefunction bringup_one_msi_queuefunction sparc64_bringup_msi_queuesfunction sparc64_pbm_msi_init
Annotated Snippet
if (likely(err > 0)) {
unsigned int irq;
irq = pbm->msi_irq_table[msi - pbm->msi_first];
generic_handle_irq(irq);
}
if (unlikely(err < 0))
goto err_dequeue;
if (err == 0)
break;
}
if (likely(head != orig_head)) {
err = ops->set_head(pbm, msiqid, head);
if (unlikely(err < 0))
goto err_set_head;
}
return IRQ_HANDLED;
err_get_head:
printk(KERN_EMERG "MSI: Get head on msiqid[%lu] gives error %d\n",
msiqid, err);
goto err_out;
err_dequeue:
printk(KERN_EMERG "MSI: Dequeue head[%lu] from msiqid[%lu] "
"gives error %d\n",
head, msiqid, err);
goto err_out;
err_set_head:
printk(KERN_EMERG "MSI: Set head[%lu] on msiqid[%lu] "
"gives error %d\n",
head, msiqid, err);
goto err_out;
err_out:
return IRQ_NONE;
}
static u32 pick_msiq(struct pci_pbm_info *pbm)
{
static DEFINE_SPINLOCK(rotor_lock);
unsigned long flags;
u32 ret, rotor;
spin_lock_irqsave(&rotor_lock, flags);
rotor = pbm->msiq_rotor;
ret = pbm->msiq_first + rotor;
if (++rotor >= pbm->msiq_num)
rotor = 0;
pbm->msiq_rotor = rotor;
spin_unlock_irqrestore(&rotor_lock, flags);
return ret;
}
static int alloc_msi(struct pci_pbm_info *pbm)
{
int i;
for (i = 0; i < pbm->msi_num; i++) {
if (!test_and_set_bit(i, pbm->msi_bitmap))
return i + pbm->msi_first;
}
return -ENOENT;
}
static void free_msi(struct pci_pbm_info *pbm, int msi_num)
{
msi_num -= pbm->msi_first;
clear_bit(msi_num, pbm->msi_bitmap);
}
static struct irq_chip msi_irq = {
.name = "PCI-MSI",
.irq_mask = pci_msi_mask_irq,
.irq_unmask = pci_msi_unmask_irq,
.irq_enable = pci_msi_unmask_irq,
.irq_disable = pci_msi_mask_irq,
/* XXX affinity XXX */
};
static int sparc64_setup_msi_irq(unsigned int *irq_p,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/interrupt.h`, `linux/of.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/irq.h`, `pci_impl.h`.
- Detected declarations: `function Copyright`, `function pick_msiq`, `function alloc_msi`, `function free_msi`, `function sparc64_setup_msi_irq`, `function sparc64_teardown_msi_irq`, `function msi_bitmap_alloc`, `function msi_bitmap_free`, `function msi_table_alloc`, `function msi_table_free`.
- Atlas domain: Architecture Layer / arch/sparc.
- 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.