drivers/irqchip/irq-loongarch-avec.c
Source file repositories/reference/linux-study-clean/drivers/irqchip/irq-loongarch-avec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/irqchip/irq-loongarch-avec.c- Extension
.c- Size
- 10234 bytes
- Lines
- 431
- 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.
- 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/cpuhotplug.hlinux/init.hlinux/interrupt.hlinux/irq.hlinux/irqchip.hlinux/irqchip/chained_irq.hlinux/irqdomain.hlinux/kernel.hlinux/msi.hlinux/radix-tree.hlinux/spinlock.hasm/loongarch.hasm/setup.hlinux/irqchip/irq-msi-lib.hirq-loongson.h
Detected Declarations
struct pending_liststruct avecintc_chipfunction avecintc_enablefunction avecintc_ack_irqfunction avecintc_syncfunction avecintc_set_affinityfunction scoped_guardfunction avecintc_cpu_onlinefunction avecintc_cpu_offlinefunction complete_irq_movingfunction list_for_each_entry_safefunction avecintc_compose_msi_msgfunction avecintc_irq_dispatchfunction avecintc_alloc_vectorfunction avecintc_domain_allocfunction avecintc_free_vectorfunction avecintc_domain_freefunction irq_matrix_initfunction avecintc_initfunction pch_msi_parse_madtfunction acpi_cascade_irqdomain_initfunction avecintc_acpi_init
Annotated Snippet
struct pending_list {
struct list_head head;
};
static struct cpumask intersect_mask;
static DEFINE_PER_CPU(struct pending_list, pending_list);
#endif
static DEFINE_PER_CPU(struct irq_desc * [NR_VECTORS], irq_map);
struct avecintc_chip {
raw_spinlock_t lock;
struct fwnode_handle *fwnode;
struct irq_domain *domain;
struct irq_matrix *vector_matrix;
phys_addr_t msi_base_addr;
};
static struct avecintc_chip loongarch_avec;
static inline void avecintc_enable(void)
{
#ifdef CONFIG_MACH_LOONGSON64
u64 value;
value = iocsr_read64(LOONGARCH_IOCSR_MISC_FUNC);
value |= IOCSR_MISC_FUNC_AVEC_EN;
iocsr_write64(value, LOONGARCH_IOCSR_MISC_FUNC);
#endif
}
static inline void avecintc_ack_irq(struct irq_data *d)
{
}
static inline void avecintc_mask_irq(struct irq_data *d)
{
}
static inline void avecintc_unmask_irq(struct irq_data *d)
{
}
#ifdef CONFIG_SMP
static inline void pending_list_init(int cpu)
{
struct pending_list *plist = per_cpu_ptr(&pending_list, cpu);
INIT_LIST_HEAD(&plist->head);
}
void avecintc_sync(struct avecintc_data *adata)
{
struct pending_list *plist;
if (cpu_online(adata->prev_cpu)) {
plist = per_cpu_ptr(&pending_list, adata->prev_cpu);
list_add_tail(&adata->entry, &plist->head);
adata->moving = 1;
mp_ops.send_ipi_single(adata->prev_cpu, ACTION_CLEAR_VECTOR);
}
}
static int avecintc_set_affinity(struct irq_data *data, const struct cpumask *dest, bool force)
{
int cpu, ret, vector;
struct avecintc_data *adata;
scoped_guard(raw_spinlock, &loongarch_avec.lock) {
adata = irq_data_get_irq_chip_data(data);
if (adata->moving)
return -EBUSY;
if (cpu_online(adata->cpu) && cpumask_test_cpu(adata->cpu, dest))
return IRQ_SET_MASK_OK_DONE;
cpumask_and(&intersect_mask, dest, cpu_online_mask);
ret = irq_matrix_alloc(loongarch_avec.vector_matrix, &intersect_mask, false, &cpu);
if (ret < 0)
return ret;
vector = ret;
adata->cpu = cpu;
adata->vec = vector;
per_cpu_ptr(irq_map, adata->cpu)[adata->vec] = irq_data_to_desc(data);
if (!cpu_has_redirectint)
avecintc_sync(adata);
}
Annotation
- Immediate include surface: `linux/cpuhotplug.h`, `linux/init.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/irqchip.h`, `linux/irqchip/chained_irq.h`, `linux/irqdomain.h`, `linux/kernel.h`.
- Detected declarations: `struct pending_list`, `struct avecintc_chip`, `function avecintc_enable`, `function avecintc_ack_irq`, `function avecintc_sync`, `function avecintc_set_affinity`, `function scoped_guard`, `function avecintc_cpu_online`, `function avecintc_cpu_offline`, `function complete_irq_moving`.
- Atlas domain: Driver Families / drivers/irqchip.
- 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.