[PATCH Dovetail v4 6/8] arm: irq_pipeline: Add arch specific arch_kentry_ implementation

Florian Bezdeka <[email protected]> Tue, 07 Jul 2026 11:50:22 +0200
Newsgroups dev.linux.lists.xenomai
Message-ID <20260707-wip-flo-v7-1-arm-pipelining-fixes-v4-6-057b8af5a2ca@siemens.com>
Moving the stall bit definitions into the architecture specific
implementations allows re-use of those definition within the arch
specifics.

Add the necessary implementation for arm to make the generic
implementation work.

Signed-off-by: Florian Bezdeka <[email protected]>
---
 arch/arm/include/asm/irq_pipeline.h | 41 +++++++++++++++++++++++++++++--------
 1 file changed, 32 insertions(+), 9 deletions(-)

diff --git a/arch/arm/include/asm/irq_pipeline.h b/arch/arm/include/asm/irq_pipeline.h
index 5e3a20149246505e8401bc7157d9c9f13673f45e..3eb735f7cf5fe61112a6dd3403bb89d7532bd1d9 100644
--- a/arch/arm/include/asm/irq_pipeline.h
+++ b/arch/arm/include/asm/irq_pipeline.h
@@ -98,15 +98,33 @@ static inline void arch_handle_irq_pipelined(struct pt_regs *regs)
 	handle_arch_irq(regs);
 }
 
-#define arch_kentry_get_irqstate(__regs)		\
-	({						\
-		to_svc_pt_regs(__regs)->irqstate;	\
-	})
-
-#define arch_kentry_set_irqstate(__regs, __irqstate)		\
-	do {							\
-		to_svc_pt_regs(__regs)->irqstate = __irqstate;	\
-	} while (0)
+#define KENTRY_STALL_BIT      BIT(0) /* Tracks INBAND_STALL_BIT */
+#define KENTRY_LOCKDEP_BIT    BIT(1) /* Tracks hardirqs_enabled */
+
+#define arch_kentry_test_stalled(__regs)			\
+({								\
+	to_svc_pt_regs(__regs)->irqstate & KENTRY_STALL_BIT;	\
+})
+
+#define arch_kentry_test_hardirq(__regs)			\
+({								\
+	to_svc_pt_regs(__regs)->irqstate & KENTRY_LOCKDEP_BIT;	\
+})
+
+#define arch_kentry_clear_irq_state(__regs)			\
+({								\
+	to_svc_pt_regs(__regs)->irqstate = 0;			\
+})
+
+#define arch_kentry_set_stalled(__regs)				\
+({								\
+	to_svc_pt_regs(__regs)->irqstate |= KENTRY_STALL_BIT;	\
+})
+
+#define arch_kentry_set_hardirq(__regs)				\
+({								\
+	to_svc_pt_regs(__regs)->irqstate |= KENTRY_LOCKDEP_BIT;	\
+})
 
 int handle_arch_irq_pipelined(struct pt_regs *regs);
 
@@ -142,6 +160,11 @@ static inline int arch_irqs_disabled_flags(unsigned long flags)
 	return native_irqs_disabled_flags(flags);
 }
 
+#define arch_kentry_test_stalled(regs)	\
+({					\
+	!interrupts_enabled(regs);	\
+})
+
 #endif /* !CONFIG_IRQ_PIPELINE */
 
 #endif /* _ASM_ARM_IRQ_PIPELINE_H */

-- 
2.55.0