drivers/irqchip/irq-gic-v3.c
Source file repositories/reference/linux-study-clean/drivers/irqchip/irq-gic-v3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/irqchip/irq-gic-v3.c- Extension
.c- Size
- 67056 bytes
- Lines
- 2619
- 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.
- 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/cpu.hlinux/cpu_pm.hlinux/delay.hlinux/interrupt.hlinux/irqdomain.hlinux/kernel.hlinux/kstrtox.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/percpu.hlinux/refcount.hlinux/slab.hlinux/iopoll.hlinux/irqchip.hlinux/irqchip/arm-gic-common.hlinux/irqchip/arm-gic-v3.hlinux/irqchip/arm-gic-v3-prio.hlinux/bitfield.hlinux/bits.hlinux/arm-smccc.hasm/cputype.hasm/exception.hasm/smp_plat.hasm/virt.hirq-gic-common.h
Detected Declarations
struct redist_regionstruct gic_chip_datastruct partition_affinityenum gic_intid_rangefunction gic_get_pribitsfunction gic_has_group0function gic_dist_security_disabledfunction gic_prio_initfunction GICfunction __get_intid_rangefunction get_intid_rangefunction gic_irq_in_rdistfunction gic_do_wait_for_rwpfunction gic_dist_wait_for_rwpfunction gic_redist_wait_for_rwpfunction gic_enable_redistfunction convert_offset_indexfunction gic_peek_irqfunction gic_poke_irqfunction gic_mask_irqfunction gic_eoimode1_mask_irqfunction gic_unmask_irqfunction gic_supports_nmifunction gic_irq_set_irqchip_statefunction gic_irq_get_irqchip_statefunction gic_irq_set_priofunction gic_irq_nmi_setupfunction gic_irq_nmi_teardownfunction gic_arm64_erratum_2941627_neededfunction gic_eoi_irqfunction gic_eoimode1_eoi_irqfunction gic_set_typefunction gic_irq_set_vcpu_affinityfunction gic_cpu_to_affinityfunction gic_deactivate_unhandledfunction gic_complete_ackfunction gic_rpr_is_nmi_priofunction gic_irqnr_is_specialfunction __gic_handle_irqfunction __gic_handle_nmifunction __gic_handle_irq_from_irqsonfunction __gic_handle_irq_from_irqsofffunction gic_handle_irqfunction gic_dist_initfunction gic_iterate_rdistsfunction __gic_populate_rdistfunction gic_populate_rdistfunction __gic_update_rdist_properties
Annotated Snippet
struct redist_region {
void __iomem *redist_base;
phys_addr_t phys_base;
bool single_redist;
};
struct gic_chip_data {
struct fwnode_handle *fwnode;
phys_addr_t dist_phys_base;
void __iomem *dist_base;
struct redist_region *redist_regions;
struct rdists rdists;
struct irq_domain *domain;
u64 redist_stride;
u32 nr_redist_regions;
u64 flags;
bool has_rss;
unsigned int ppi_nr;
struct partition_affinity *parts;
unsigned int nr_parts;
};
struct partition_affinity {
cpumask_t mask;
struct fwnode_handle *partition_id;
};
#define T241_CHIPS_MAX 4
static void __iomem *t241_dist_base_alias[T241_CHIPS_MAX] __read_mostly;
static DEFINE_STATIC_KEY_FALSE(gic_nvidia_t241_erratum);
static DEFINE_STATIC_KEY_FALSE(gic_arm64_2941627_erratum);
static struct gic_chip_data gic_data __read_mostly;
static DEFINE_STATIC_KEY_TRUE(supports_deactivate_key);
#define GIC_ID_NR (1U << GICD_TYPER_ID_BITS(gic_data.rdists.gicd_typer))
#define GIC_LINE_NR min(GICD_TYPER_SPIS(gic_data.rdists.gicd_typer), 1020U)
#define GIC_ESPI_NR GICD_TYPER_ESPIS(gic_data.rdists.gicd_typer)
static bool nmi_support_forbidden;
/*
* There are 16 SGIs, though we only actually use 8 in Linux. The other 8 SGIs
* are potentially stolen by the secure side. Some code, especially code dealing
* with hwirq IDs, is simplified by accounting for all 16.
*/
#define SGI_NR 16
/*
* The behaviours of RPR and PMR registers differ depending on the value of
* SCR_EL3.FIQ, and the behaviour of non-secure priority registers of the
* distributor and redistributors depends on whether security is enabled in the
* GIC.
*
* When security is enabled, non-secure priority values from the (re)distributor
* are presented to the GIC CPUIF as follow:
* (GIC_(R)DIST_PRI[irq] >> 1) | 0x80;
*
* If SCR_EL3.FIQ == 1, the values written to/read from PMR and RPR at non-secure
* EL1 are subject to a similar operation thus matching the priorities presented
* from the (re)distributor when security is enabled. When SCR_EL3.FIQ == 0,
* these values are unchanged by the GIC.
*
* see GICv3/GICv4 Architecture Specification (IHI0069D):
* - section 4.8.1 Non-secure accesses to register fields for Secure interrupt
* priorities.
* - Figure 4-7 Secure read of the priority field for a Non-secure Group 1
* interrupt.
*/
static DEFINE_STATIC_KEY_FALSE(supports_pseudo_nmis);
static u32 gic_get_pribits(void)
{
u32 pribits;
pribits = gic_read_ctlr();
pribits &= ICC_CTLR_EL1_PRI_BITS_MASK;
pribits >>= ICC_CTLR_EL1_PRI_BITS_SHIFT;
pribits++;
return pribits;
}
static bool gic_has_group0(void)
{
u32 val;
u32 old_pmr;
old_pmr = gic_read_pmr();
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/cpu.h`, `linux/cpu_pm.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/irqdomain.h`, `linux/kernel.h`, `linux/kstrtox.h`.
- Detected declarations: `struct redist_region`, `struct gic_chip_data`, `struct partition_affinity`, `enum gic_intid_range`, `function gic_get_pribits`, `function gic_has_group0`, `function gic_dist_security_disabled`, `function gic_prio_init`, `function GIC`, `function __get_intid_range`.
- 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.
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.