[RFC PATCH 06/36] arm64: irq: introduce a helper for GIC priority initialization
Vladimir Murzin
vladimir.murzin at arm.com
Thu Jul 9 05:13:03 PDT 2026
From: Ada Couprie Diaz <ada.coupriediaz at arm.com>
Arm64's `init_IRQ()` calls `local_daif_restore()` to synchronize
interrupt masking via DAIF and switch to masking via PMR. This
depends on a very specific behaviour of `local_daif_restore()` which
will clear DAIF if masking interrupts via PMR, which will get removed
in the future.
As `setup_arch()` cleared DA only earlier, introduce a dedicated
helper that explicitly initializes the PMR to mask interrupts and
clears DAIF, switching to IRQ priority masking.
Given it is a dedicated helper, add a lockdep assertion as
`setup_arch()` should always have called `trace_hardirqs_off()` when
clearing DA, otherwise something bad happened.
Signed-off-by: Ada Couprie Diaz <ada.coupriediaz at arm.com>
Signed-off-by: Vladimir Murzin <vladimir.murzin at arm.com>
---
arch/arm64/include/asm/daifflags.h | 15 +++++++++++++++
arch/arm64/kernel/irq.c | 7 +++----
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/include/asm/daifflags.h b/arch/arm64/include/asm/daifflags.h
index 795b35128467..56341578e7e3 100644
--- a/arch/arm64/include/asm/daifflags.h
+++ b/arch/arm64/include/asm/daifflags.h
@@ -141,4 +141,19 @@ static __always_inline void local_daif_inherit(struct pt_regs *regs)
*/
write_sysreg(flags, daif);
}
+
+/*
+ * During early boot, we unmask PSR.DA before the GIC has been set up.
+ * If we use IRQ priority masking, the PMR and PSR will be out of sync
+ * after the GIC is enabled : sync them up.
+ */
+static inline void local_interrupt_priority_init(void)
+{
+ WARN_ON(read_sysreg(daif) & PSR_A_BIT);
+ lockdep_assert_irqs_disabled();
+
+ gic_write_pmr(GIC_PRIO_IRQOFF);
+ write_sysreg(DAIF_PROCCTX, daif);
+}
+
#endif
diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c
index 9fafd826002b..c73faa30268d 100644
--- a/arch/arm64/kernel/irq.c
+++ b/arch/arm64/kernel/irq.c
@@ -126,10 +126,9 @@ void __init init_IRQ(void)
if (system_uses_irq_prio_masking()) {
/*
- * Now that we have a stack for our IRQ handler, set
- * the PMR/PSR pair to a consistent state.
+ * Now that we have a stack for our IRQ handler,
+ * let's mask interrupts via the PMR.
*/
- WARN_ON(read_sysreg(daif) & PSR_A_BIT);
- local_daif_restore(DAIF_PROCCTX_NOIRQ);
+ local_interrupt_priority_init();
}
}
--
2.34.1
More information about the linux-arm-kernel
mailing list