kernel/irq/irqdesc.c
Source file repositories/reference/linux-study-clean/kernel/irq/irqdesc.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/irq/irqdesc.c- Extension
.c- Size
- 27967 bytes
- Lines
- 1092
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/irq.hlinux/slab.hlinux/export.hlinux/interrupt.hlinux/kernel_stat.hlinux/maple_tree.hlinux/irqdomain.hlinux/sysfs.hlinux/string_choices.hinternals.h
Detected Declarations
function irq_affinity_setupfunction init_irq_default_affinityfunction init_irq_default_affinityfunction irq_redirect_workfunction desc_smp_initfunction free_masksfunction alloc_masksfunction desc_smp_initfunction irq_get_nr_irqsfunction irq_set_nr_irqsfunction irq_find_free_areafunction irq_insert_descfunction delete_irq_descfunction init_descfunction per_cpu_count_showfunction for_each_possible_cpufunction chip_name_showfunction hwirq_showfunction type_showfunction wakeup_showfunction name_showfunction actions_showfunction scoped_guardfunction irq_sysfs_addfunction irq_sysfs_delfunction irq_sysfs_initfunction irq_sysfs_addfunction irq_lock_sparsefunction irq_unlock_sparsefunction irq_kobj_releasefunction delayed_free_descfunction irq_desc_free_rcufunction free_descfunction alloc_descsfunction irq_expand_nr_irqsfunction early_irq_initfunction early_irq_initfunction free_descfunction for_each_possible_cpufunction alloc_descsfunction irq_expand_nr_irqsfunction irq_mark_irqfunction handle_irq_descfunction generic_handle_irqfunction contextfunction generic_handle_domain_irqfunction contextfunction generic_handle_domain_nmi
Annotated Snippet
static inline void free_masks(struct irq_desc *desc) { }
#endif
static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
const struct cpumask *affinity, struct module *owner)
{
desc->irq_common_data.handler_data = NULL;
desc->irq_common_data.msi_desc = NULL;
desc->irq_data.common = &desc->irq_common_data;
desc->irq_data.irq = irq;
desc->irq_data.chip = &no_irq_chip;
desc->irq_data.chip_data = NULL;
irq_settings_clr_and_set(desc, ~0, _IRQ_DEFAULT_INIT_FLAGS);
irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED);
irqd_set(&desc->irq_data, IRQD_IRQ_MASKED);
desc->handle_irq = handle_bad_irq;
desc->depth = 1;
desc->irq_count = 0;
desc->irqs_unhandled = 0;
desc->tot_count = 0;
desc->name = NULL;
desc->owner = owner;
rcuref_init(&desc->refcnt, 1);
desc_smp_init(desc, node, affinity);
}
unsigned int total_nr_irqs __read_mostly = NR_IRQS;
/**
* irq_get_nr_irqs() - Number of interrupts supported by the system.
*/
unsigned int irq_get_nr_irqs(void)
{
return total_nr_irqs;
}
EXPORT_SYMBOL_GPL(irq_get_nr_irqs);
/**
* irq_set_nr_irqs() - Set the number of interrupts supported by the system.
* @nr: New number of interrupts.
*
* Return: @nr.
*/
unsigned int __init irq_set_nr_irqs(unsigned int nr)
{
total_nr_irqs = nr;
irq_proc_calc_prec();
return nr;
}
static DEFINE_MUTEX(sparse_irq_lock);
static struct maple_tree sparse_irqs = MTREE_INIT_EXT(sparse_irqs,
MT_FLAGS_ALLOC_RANGE |
MT_FLAGS_LOCK_EXTERN |
MT_FLAGS_USE_RCU,
sparse_irq_lock);
static int irq_find_free_area(unsigned int from, unsigned int cnt)
{
MA_STATE(mas, &sparse_irqs, 0, 0);
if (mas_empty_area(&mas, from, MAX_SPARSE_IRQS, cnt))
return -ENOSPC;
return mas.index;
}
struct irq_desc *irq_find_desc_at_or_after(unsigned int offset)
{
unsigned long index = offset;
lockdep_assert_in_rcu_read_lock();
return mt_find(&sparse_irqs, &index, total_nr_irqs);
}
static void irq_insert_desc(unsigned int irq, struct irq_desc *desc)
{
MA_STATE(mas, &sparse_irqs, irq, irq);
WARN_ON(mas_store_gfp(&mas, desc, GFP_KERNEL) != 0);
}
static void delete_irq_desc(unsigned int irq)
{
MA_STATE(mas, &sparse_irqs, irq, irq);
mas_erase(&mas);
}
#ifdef CONFIG_SPARSE_IRQ
static const struct kobj_type irq_kobj_type;
#endif
Annotation
- Immediate include surface: `linux/irq.h`, `linux/slab.h`, `linux/export.h`, `linux/interrupt.h`, `linux/kernel_stat.h`, `linux/maple_tree.h`, `linux/irqdomain.h`, `linux/sysfs.h`.
- Detected declarations: `function irq_affinity_setup`, `function init_irq_default_affinity`, `function init_irq_default_affinity`, `function irq_redirect_work`, `function desc_smp_init`, `function free_masks`, `function alloc_masks`, `function desc_smp_init`, `function irq_get_nr_irqs`, `function irq_set_nr_irqs`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.