drivers/irqchip/irq-mips-cpu.c
Source file repositories/reference/linux-study-clean/drivers/irqchip/irq-mips-cpu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/irqchip/irq-mips-cpu.c- Extension
.c- Size
- 7006 bytes
- Lines
- 286
- Domain
- Driver Families
- Bucket
- drivers/irqchip
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- 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/init.hlinux/interrupt.hlinux/kernel.hlinux/irq.hlinux/irqchip.hlinux/irqdomain.hasm/irq_cpu.hasm/mipsregs.hasm/mipsmtregs.hasm/setup.h
Detected Declarations
struct cpu_ipi_domain_statefunction unmask_mips_irqfunction mask_mips_irqfunction mips_mt_cpu_irq_startupfunction mips_mt_cpu_irq_ackfunction mips_mt_send_ipifunction plat_irq_dispatchfunction mips_cpu_intc_mapfunction mips_cpu_ipi_allocfunction mips_cpu_ipi_matchfunction mips_cpu_register_ipi_domainfunction mips_cpu_register_ipi_domainfunction mips_cpu_irq_initfunction mips_cpu_irq_of_init
Annotated Snippet
struct cpu_ipi_domain_state {
DECLARE_BITMAP(allocated, 2);
};
static int mips_cpu_ipi_alloc(struct irq_domain *domain, unsigned int virq,
unsigned int nr_irqs, void *arg)
{
struct cpu_ipi_domain_state *state = domain->host_data;
unsigned int i, hwirq;
int ret;
for (i = 0; i < nr_irqs; i++) {
hwirq = find_first_zero_bit(state->allocated, 2);
if (hwirq == 2)
return -EBUSY;
bitmap_set(state->allocated, hwirq, 1);
ret = irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq,
&mips_mt_cpu_irq_controller,
NULL);
if (ret)
return ret;
ret = irq_domain_set_hwirq_and_chip(domain->parent, virq + i, hwirq,
&mips_mt_cpu_irq_controller,
NULL);
if (ret)
return ret;
ret = irq_set_irq_type(virq + i, IRQ_TYPE_LEVEL_HIGH);
if (ret)
return ret;
}
return 0;
}
static int mips_cpu_ipi_match(struct irq_domain *d, struct device_node *node,
enum irq_domain_bus_token bus_token)
{
bool is_ipi;
switch (bus_token) {
case DOMAIN_BUS_IPI:
is_ipi = d->bus_token == bus_token;
return (!node || (to_of_node(d->fwnode) == node)) && is_ipi;
default:
return 0;
}
}
static const struct irq_domain_ops mips_cpu_ipi_chip_ops = {
.alloc = mips_cpu_ipi_alloc,
.match = mips_cpu_ipi_match,
};
static void mips_cpu_register_ipi_domain(struct device_node *of_node)
{
struct cpu_ipi_domain_state *ipi_domain_state;
ipi_domain_state = kzalloc_obj(*ipi_domain_state);
ipi_domain = irq_domain_create_hierarchy(irq_domain, IRQ_DOMAIN_FLAG_IPI_SINGLE, 2,
of_fwnode_handle(of_node),
&mips_cpu_ipi_chip_ops, ipi_domain_state);
if (!ipi_domain)
panic("Failed to add MIPS CPU IPI domain");
irq_domain_update_bus_token(ipi_domain, DOMAIN_BUS_IPI);
}
#else /* !CONFIG_GENERIC_IRQ_IPI */
static inline void mips_cpu_register_ipi_domain(struct device_node *of_node) {}
#endif /* !CONFIG_GENERIC_IRQ_IPI */
static void __init __mips_cpu_irq_init(struct device_node *of_node)
{
/* Mask interrupts. */
clear_c0_status(ST0_IM);
clear_c0_cause(CAUSEF_IP);
irq_domain = irq_domain_create_legacy(of_fwnode_handle(of_node), 8, MIPS_CPU_IRQ_BASE, 0,
&mips_cpu_intc_irq_domain_ops, NULL);
if (!irq_domain)
panic("Failed to add irqdomain for MIPS CPU");
/*
* Only proceed to register the software interrupt IPI implementation
* for CPUs which implement the MIPS MT (multi-threading) ASE.
Annotation
- Immediate include surface: `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/irq.h`, `linux/irqchip.h`, `linux/irqdomain.h`, `asm/irq_cpu.h`, `asm/mipsregs.h`.
- Detected declarations: `struct cpu_ipi_domain_state`, `function unmask_mips_irq`, `function mask_mips_irq`, `function mips_mt_cpu_irq_startup`, `function mips_mt_cpu_irq_ack`, `function mips_mt_send_ipi`, `function plat_irq_dispatch`, `function mips_cpu_intc_map`, `function mips_cpu_ipi_alloc`, `function mips_cpu_ipi_match`.
- Atlas domain: Driver Families / drivers/irqchip.
- Implementation status: source implementation candidate.
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.