Skip to contentSkip to conversation

parisc: Add constant for control registers and clean up mfctl()

PATCH In review Helge Deller 2 participants 3 messages Mar 25, 2022 – Mar 26, 2022 PA-RISC architecture

lore
Share & tools
lore

Helge Deller

author maintainer
#0 lore raw

PATCH 1/2 parisc: Add constant for control registers and clean up mfctl()

Clean up the code and add often used constants.

---
 arch/parisc/include/asm/special_insns.h | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
arch/parisc/include/asm/special_insns.h +8 -9
index 41b3ddbd344c..c822bd0c0e3c 100644
@@ -30,11 +30,15 @@
 	pa;						\
 })
 
+#define CR_EIEM 15	/* External Interrupt Enable Mask */
+#define CR_CR16 16	/* CR16 Interval Timer */
+#define CR_EIRR 23	/* External Interrupt Request Register */
+
 #define mfctl(reg)	({		\
 	unsigned long cr;		\
 	__asm__ __volatile__(		\
-		"mfctl " #reg ",%0" :	\
-		 "=r" (cr)		\
+		"mfctl %1,%0" :		\
+		 "=r" (cr) : "i" (reg)	\
 	);				\
 	cr;				\
 })
@@ -44,13 +48,8 @@
 		: /* no outputs */ \
 		: "r" (gr), "i" (cr) : "memory")
 
-/* these are here to de-mystefy the calling code, and to provide hooks */
-/* which I needed for debugging EIEM problems -PB */
-#define get_eiem() mfctl(15)
-static inline void set_eiem(unsigned long val)
-{
-	mtctl(val, 15);
-}
+#define get_eiem()	mfctl(CR_EIEM)
+#define set_eiem(val)	mtctl(val, CR_EIEM)
 
 #define mfsp(reg)	({		\
 	unsigned long cr;		\

--
2.35.1

author maintainer
#1 lore raw

PATCH 2/2 parisc: Delay until next timer irq in __cpu_disable()

Wait for next timer irq to trigger, then clear all pending external irqs before jumping into rendevous PDC loop.

---
 arch/parisc/kernel/smp.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/parisc/kernel/smp.c +9 -0
index 60cc33fd345c..564442ac74c9 100644
@@ -491,6 +491,15 @@ int __cpu_disable(void)
 
 	/* disable all irqs, including timer irq */
 	local_irq_disable();
+
+	/* wait for next timer irq ... */
+	mdelay(1000/HZ+100);
+
+	/* ... and then clear all pending external irqs */
+	set_eiem(0);
+	mtctl(~0UL, CR_EIRR);
+	mfctl(CR_EIRR);
+	mtctl(0, CR_EIRR);
 #endif
 	return 0;
 }

--
2.35.1

#2 lore raw

Re: [PATCH 2/2] parisc: Delay until next timer irq in __cpu_disable()

Quoted 2 lines · On Fri, 25 Mar 2022 17:40:40 +0100 Helge Deller <[email protected]> wrote:

Wait for next timer irq to trigger, then clear all pending external irqs before jumping into rendevous PDC loop.

*rendezvous

Quoted 27 lines
---
 arch/parisc/kernel/smp.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/parisc/kernel/smp.c +9 -1
index 60cc33fd345c..564442ac74c9 100644
@@ -491,6 +491,15 @@ int __cpu_disable(void)
 
 	/* disable all irqs, including timer irq */
 	local_irq_disable();
+
+	/* wait for next timer irq ... */
+	mdelay(1000/HZ+100);
+
+	/* ... and then clear all pending external irqs */
+	set_eiem(0);
+	mtctl(~0UL, CR_EIRR);
+	mfctl(CR_EIRR);
+	mtctl(0, CR_EIRR);
 #endif
 	return 0;
 }
--
Quoted 2 lines

2.35.1

Kind regards,
jer