drivers/irqchip/irq-riscv-aplic-direct.c
Source file repositories/reference/linux-study-clean/drivers/irqchip/irq-riscv-aplic-direct.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/irqchip/irq-riscv-aplic-direct.c- Extension
.c- Size
- 9197 bytes
- Lines
- 344
- 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/acpi.hlinux/bitfield.hlinux/bitops.hlinux/cpu.hlinux/cpumask.hlinux/interrupt.hlinux/irqchip.hlinux/irqchip/chained_irq.hlinux/irqchip/riscv-aplic.hlinux/module.hlinux/of_address.hlinux/printk.hlinux/smp.hirq-riscv-aplic-main.h
Detected Declarations
struct aplic_directstruct aplic_idcfunction aplic_direct_irq_eoifunction aplic_direct_irqdomain_translatefunction aplic_direct_irqdomain_allocfunction aplic_direct_handle_irqfunction aplic_idc_set_deliveryfunction aplic_direct_restore_statesfunction aplic_direct_dying_cpufunction aplic_direct_starting_cpufunction aplic_direct_parse_parent_hwirqfunction aplic_direct_setup
Annotated Snippet
struct aplic_direct {
struct aplic_priv priv;
struct irq_domain *irqdomain;
struct cpumask lmask;
};
struct aplic_idc {
u32 hart_index;
void __iomem *regs;
struct aplic_direct *direct;
};
static unsigned int aplic_direct_parent_irq;
static DEFINE_PER_CPU(struct aplic_idc, aplic_idcs);
static void aplic_direct_irq_eoi(struct irq_data *d)
{
/*
* The fasteoi_handler requires irq_eoi() callback hence
* provide a dummy handler.
*/
}
#ifdef CONFIG_SMP
static int aplic_direct_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
bool force)
{
struct aplic_priv *priv = irq_data_get_irq_chip_data(d);
struct aplic_direct *direct = container_of(priv, struct aplic_direct, priv);
struct aplic_idc *idc;
unsigned int cpu, val;
void __iomem *target;
if (force)
cpu = cpumask_first_and(&direct->lmask, mask_val);
else
cpu = cpumask_first_and_and(&direct->lmask, mask_val, cpu_online_mask);
if (cpu >= nr_cpu_ids)
return -EINVAL;
idc = per_cpu_ptr(&aplic_idcs, cpu);
target = priv->regs + APLIC_TARGET_BASE + (d->hwirq - 1) * sizeof(u32);
val = FIELD_PREP(APLIC_TARGET_HART_IDX, idc->hart_index);
val |= FIELD_PREP(APLIC_TARGET_IPRIO, APLIC_DEFAULT_PRIORITY);
writel(val, target);
irq_data_update_effective_affinity(d, cpumask_of(cpu));
return IRQ_SET_MASK_OK_DONE;
}
#endif
static struct irq_chip aplic_direct_chip = {
.name = "APLIC-DIRECT",
.irq_mask = aplic_irq_mask,
.irq_unmask = aplic_irq_unmask,
.irq_set_type = aplic_irq_set_type,
.irq_eoi = aplic_direct_irq_eoi,
#ifdef CONFIG_SMP
.irq_set_affinity = aplic_direct_set_affinity,
#endif
.flags = IRQCHIP_SET_TYPE_MASKED |
IRQCHIP_SKIP_SET_WAKE |
IRQCHIP_MASK_ON_SUSPEND,
};
static int aplic_direct_irqdomain_translate(struct irq_domain *d, struct irq_fwspec *fwspec,
unsigned long *hwirq, unsigned int *type)
{
struct aplic_priv *priv = d->host_data;
return aplic_irqdomain_translate(fwspec, priv->gsi_base, hwirq, type);
}
static int aplic_direct_irqdomain_alloc(struct irq_domain *domain, unsigned int virq,
unsigned int nr_irqs, void *arg)
{
struct aplic_priv *priv = domain->host_data;
struct aplic_direct *direct = container_of(priv, struct aplic_direct, priv);
struct irq_fwspec *fwspec = arg;
irq_hw_number_t hwirq;
unsigned int type;
int i, ret;
ret = aplic_irqdomain_translate(fwspec, priv->gsi_base, &hwirq, &type);
if (ret)
return ret;
for (i = 0; i < nr_irqs; i++) {
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/bitfield.h`, `linux/bitops.h`, `linux/cpu.h`, `linux/cpumask.h`, `linux/interrupt.h`, `linux/irqchip.h`, `linux/irqchip/chained_irq.h`.
- Detected declarations: `struct aplic_direct`, `struct aplic_idc`, `function aplic_direct_irq_eoi`, `function aplic_direct_irqdomain_translate`, `function aplic_direct_irqdomain_alloc`, `function aplic_direct_handle_irq`, `function aplic_idc_set_delivery`, `function aplic_direct_restore_states`, `function aplic_direct_dying_cpu`, `function aplic_direct_starting_cpu`.
- 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.