arch/powerpc/sysdev/xics/ics-native.c
Source file repositories/reference/linux-study-clean/arch/powerpc/sysdev/xics/ics-native.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/sysdev/xics/ics-native.c- Extension
.c- Size
- 6156 bytes
- Lines
- 255
- 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/types.hlinux/kernel.hlinux/irq.hlinux/smp.hlinux/interrupt.hlinux/init.hlinux/cpu.hlinux/of.hlinux/of_address.hlinux/spinlock.hlinux/msi.hlinux/list.hasm/smp.hasm/machdep.hasm/irq.hasm/errno.hasm/xics.hasm/opal.hasm/firmware.h
Detected Declarations
struct ics_nativefunction ics_native_unmask_irqfunction ics_native_startupfunction ics_native_do_maskfunction ics_native_mask_irqfunction ics_native_set_affinityfunction ics_native_checkfunction ics_native_mask_unknownfunction ics_native_get_serverfunction ics_native_host_matchfunction ics_native_add_onefunction ics_native_init
Annotated Snippet
struct ics_native {
struct ics ics;
struct device_node *node;
void __iomem *base;
u32 ibase;
u32 icount;
};
#define to_ics_native(_ics) container_of(_ics, struct ics_native, ics)
static void __iomem *ics_native_xive(struct ics_native *in, unsigned int vec)
{
return in->base + 0x800 + ((vec - in->ibase) << 2);
}
static void ics_native_unmask_irq(struct irq_data *d)
{
unsigned int vec = (unsigned int)irqd_to_hwirq(d);
struct ics *ics = irq_data_get_irq_chip_data(d);
struct ics_native *in = to_ics_native(ics);
unsigned int server;
pr_devel("ics-native: unmask virq %d [hw 0x%x]\n", d->irq, vec);
if (vec < in->ibase || vec >= (in->ibase + in->icount))
return;
server = xics_get_irq_server(d->irq, irq_data_get_affinity_mask(d), 0);
out_be32(ics_native_xive(in, vec), (server << 8) | DEFAULT_PRIORITY);
}
static unsigned int ics_native_startup(struct irq_data *d)
{
#ifdef CONFIG_PCI_MSI
/*
* The generic MSI code returns with the interrupt disabled on the
* card, using the MSI mask bits. Firmware doesn't appear to unmask
* at that level, so we do it here by hand.
*/
if (irq_data_get_msi_desc(d))
pci_msi_unmask_irq(d);
#endif
/* unmask it */
ics_native_unmask_irq(d);
return 0;
}
static void ics_native_do_mask(struct ics_native *in, unsigned int vec)
{
out_be32(ics_native_xive(in, vec), 0xff);
}
static void ics_native_mask_irq(struct irq_data *d)
{
unsigned int vec = (unsigned int)irqd_to_hwirq(d);
struct ics *ics = irq_data_get_irq_chip_data(d);
struct ics_native *in = to_ics_native(ics);
pr_devel("ics-native: mask virq %d [hw 0x%x]\n", d->irq, vec);
if (vec < in->ibase || vec >= (in->ibase + in->icount))
return;
ics_native_do_mask(in, vec);
}
static int ics_native_set_affinity(struct irq_data *d,
const struct cpumask *cpumask,
bool force)
{
unsigned int vec = (unsigned int)irqd_to_hwirq(d);
struct ics *ics = irq_data_get_irq_chip_data(d);
struct ics_native *in = to_ics_native(ics);
int server;
u32 xive;
if (vec < in->ibase || vec >= (in->ibase + in->icount))
return -EINVAL;
server = xics_get_irq_server(d->irq, cpumask, 1);
if (server == -1) {
pr_warn("%s: No online cpus in the mask %*pb for irq %d\n",
__func__, cpumask_pr_args(cpumask), d->irq);
return -1;
}
xive = in_be32(ics_native_xive(in, vec));
xive = (xive & 0xff) | (server << 8);
out_be32(ics_native_xive(in, vec), xive);
return IRQ_SET_MASK_OK;
Annotation
- Immediate include surface: `linux/types.h`, `linux/kernel.h`, `linux/irq.h`, `linux/smp.h`, `linux/interrupt.h`, `linux/init.h`, `linux/cpu.h`, `linux/of.h`.
- Detected declarations: `struct ics_native`, `function ics_native_unmask_irq`, `function ics_native_startup`, `function ics_native_do_mask`, `function ics_native_mask_irq`, `function ics_native_set_affinity`, `function ics_native_check`, `function ics_native_mask_unknown`, `function ics_native_get_server`, `function ics_native_host_match`.
- 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.