Skip to contentSkip to conversation

irqchip: nvic: Fix offset for Interrupt Priority Offsets

PATCH Applied Vladimir Murzin 7 participants 22 messages Dec 1, 2021 – Dec 2, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 irqchip: nvic: Fix offset for Interrupt Priority Offsets

According to ARM(v7M) ARM Interrupt Priority Offsets located at 0xE000E400-0xE000E5EC, while 0xE000E300-0xE000E33C covers read-only Interrupt Active Bit Registers

Fixes 292ec080491d ("irqchip: Add support for ARMv7-M NVIC")
---
 drivers/irqchip/irq-nvic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-nvic.c +1 -1
index 63bac3f..ba4759b 100644
@@ -26,7 +26,7 @@
 
 #define NVIC_ISER		0x000
 #define NVIC_ICER		0x080
-#define NVIC_IPR		0x300
+#define NVIC_IPR		0x400
 
 #define NVIC_MAX_BANKS		16
 /*
Signature · 7 lines
2.7.4


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw

PATCH 2/2 irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Rather then restructuring the ARMv7M entrly logic per TODO, just move NVIC to GENERIC_IRQ_MULTI_HANDLER.

---
 arch/arm/include/asm/v7m.h  |  3 ++-
 arch/arm/kernel/entry-v7m.S | 10 +++-------
 drivers/irqchip/Kconfig     |  1 +
 drivers/irqchip/irq-nvic.c  | 22 +++++-----------------
 4 files changed, 11 insertions(+), 25 deletions(-)
arch/arm/include/asm/v7m.h +2 -1
index 2cb00d1..4512f7e 100644
@@ -13,6 +13,7 @@
 #define V7M_SCB_ICSR_PENDSVSET			(1 << 28)
 #define V7M_SCB_ICSR_PENDSVCLR			(1 << 27)
 #define V7M_SCB_ICSR_RETTOBASE			(1 << 11)
+#define V7M_SCB_ICSR_VECTACTIVE			0x000001ff
 
 #define V7M_SCB_VTOR			0x08
 
@@ -38,7 +39,7 @@
 #define V7M_SCB_SHCSR_MEMFAULTENA		(1 << 16)
 
 #define V7M_xPSR_FRAMEPTRALIGN			0x00000200
-#define V7M_xPSR_EXCEPTIONNO			0x000001ff
+#define V7M_xPSR_EXCEPTIONNO			V7M_SCB_ICSR_VECTACTIVE
 
 /*
  * When branching to an address that has bits [31:28] == 0xf an exception return
arch/arm/kernel/entry-v7m.S +3 -7
index 7bde93c..520dd43 100644
@@ -39,14 +39,10 @@ __irq_entry:
 	@
 	@ Invoke the IRQ handler
 	@
-	mrs	r0, ipsr
-	ldr	r1, =V7M_xPSR_EXCEPTIONNO
-	and	r0, r1
-	sub	r0, #16
-	mov	r1, sp
+	mov	r0, sp
 	stmdb	sp!, {lr}
-	@ routine called with r0 = irq number, r1 = struct pt_regs *
-	bl	nvic_handle_irq
+	@ routine called with r0 = struct pt_regs *
+	bl	generic_handle_arch_irq
 
 	pop	{lr}
 	@
drivers/irqchip/Kconfig +1 -0
index 7038957..488eaa1 100644
@@ -58,6 +58,7 @@ config ARM_NVIC
 	bool
 	select IRQ_DOMAIN_HIERARCHY
 	select GENERIC_IRQ_CHIP
+	select GENERIC_IRQ_MULTI_HANDLER
 
 config ARM_VIC
 	bool
drivers/irqchip/irq-nvic.c +5 -17
index ba4759b..125f9c1 100644
@@ -37,25 +37,12 @@
 
 static struct irq_domain *nvic_irq_domain;
 
-static void __nvic_handle_irq(irq_hw_number_t hwirq)
+static void __irq_entry nvic_handle_irq(struct pt_regs *regs)
 {
-	generic_handle_domain_irq(nvic_irq_domain, hwirq);
-}
+	unsigned long icsr = readl_relaxed(BASEADDR_V7M_SCB + V7M_SCB_ICSR);
+	irq_hw_number_t hwirq = (icsr & V7M_SCB_ICSR_VECTACTIVE) - 16;
 
-/*
- * TODO: restructure the ARMv7M entry logic so that this entry logic can live
- * in arch code.
- */
-asmlinkage void __exception_irq_entry
-nvic_handle_irq(irq_hw_number_t hwirq, struct pt_regs *regs)
-{
-	struct pt_regs *old_regs;
-
-	irq_enter();
-	old_regs = set_irq_regs(regs);
-	__nvic_handle_irq(hwirq);
-	set_irq_regs(old_regs);
-	irq_exit();
+	generic_handle_domain_irq(nvic_irq_domain, hwirq);
 }
 
 static int nvic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
@@ -141,6 +128,7 @@ static int __init nvic_of_init(struct device_node *node,
 	for (i = 0; i < irqs; i += 4)
 		writel_relaxed(0, nvic_base + NVIC_IPR + i);
 
+	set_handle_irq(nvic_handle_irq);
 	return 0;
 }
 IRQCHIP_DECLARE(armv7m_nvic, "arm,armv7m-nvic", nvic_of_init);
Signature · 7 lines
2.7.4


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Adding Ard and Arnd, since this looks like it might interact with their series moving other platforms to GENERIC_IRQ_MULTI_HANDLER:

https://lore.kernel.org/linux-arm-kernel/[email protected]/

Quoted 10 lines · Vladimir Murzin

Rather then restructuring the ARMv7M entrly logic per TODO, just move NVIC to GENERIC_IRQ_MULTI_HANDLER.

---
 arch/arm/include/asm/v7m.h  |  3 ++-
 arch/arm/kernel/entry-v7m.S | 10 +++-------
 drivers/irqchip/Kconfig     |  1 +
 drivers/irqchip/irq-nvic.c  | 22 +++++-----------------
 4 files changed, 11 insertions(+), 25 deletions(-)

Nice; thanks for doing this!

FWIW:

Mark.

Quoted 101 lines
arch/arm/include/asm/v7m.h +2 -1
index 2cb00d1..4512f7e 100644
@@ -13,6 +13,7 @@
 #define V7M_SCB_ICSR_PENDSVSET			(1 << 28)
 #define V7M_SCB_ICSR_PENDSVCLR			(1 << 27)
 #define V7M_SCB_ICSR_RETTOBASE			(1 << 11)
+#define V7M_SCB_ICSR_VECTACTIVE			0x000001ff
 
 #define V7M_SCB_VTOR			0x08
 
@@ -38,7 +39,7 @@
 #define V7M_SCB_SHCSR_MEMFAULTENA		(1 << 16)
 
 #define V7M_xPSR_FRAMEPTRALIGN			0x00000200
-#define V7M_xPSR_EXCEPTIONNO			0x000001ff
+#define V7M_xPSR_EXCEPTIONNO			V7M_SCB_ICSR_VECTACTIVE
 
 /*
  * When branching to an address that has bits [31:28] == 0xf an exception return
arch/arm/kernel/entry-v7m.S +3 -7
index 7bde93c..520dd43 100644
@@ -39,14 +39,10 @@ __irq_entry:
 	@
 	@ Invoke the IRQ handler
 	@
-	mrs	r0, ipsr
-	ldr	r1, =V7M_xPSR_EXCEPTIONNO
-	and	r0, r1
-	sub	r0, #16
-	mov	r1, sp
+	mov	r0, sp
 	stmdb	sp!, {lr}
-	@ routine called with r0 = irq number, r1 = struct pt_regs *
-	bl	nvic_handle_irq
+	@ routine called with r0 = struct pt_regs *
+	bl	generic_handle_arch_irq
 
 	pop	{lr}
 	@
drivers/irqchip/Kconfig +1 -0
index 7038957..488eaa1 100644
@@ -58,6 +58,7 @@ config ARM_NVIC
 	bool
 	select IRQ_DOMAIN_HIERARCHY
 	select GENERIC_IRQ_CHIP
+	select GENERIC_IRQ_MULTI_HANDLER
 
 config ARM_VIC
 	bool
drivers/irqchip/irq-nvic.c +5 -17
index ba4759b..125f9c1 100644
@@ -37,25 +37,12 @@
 
 static struct irq_domain *nvic_irq_domain;
 
-static void __nvic_handle_irq(irq_hw_number_t hwirq)
+static void __irq_entry nvic_handle_irq(struct pt_regs *regs)
 {
-	generic_handle_domain_irq(nvic_irq_domain, hwirq);
-}
+	unsigned long icsr = readl_relaxed(BASEADDR_V7M_SCB + V7M_SCB_ICSR);
+	irq_hw_number_t hwirq = (icsr & V7M_SCB_ICSR_VECTACTIVE) - 16;
 
-/*
- * TODO: restructure the ARMv7M entry logic so that this entry logic can live
- * in arch code.
- */
-asmlinkage void __exception_irq_entry
-nvic_handle_irq(irq_hw_number_t hwirq, struct pt_regs *regs)
-{
-	struct pt_regs *old_regs;
-
-	irq_enter();
-	old_regs = set_irq_regs(regs);
-	__nvic_handle_irq(hwirq);
-	set_irq_regs(old_regs);
-	irq_exit();
+	generic_handle_domain_irq(nvic_irq_domain, hwirq);
 }
 
 static int nvic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
@@ -141,6 +128,7 @@ static int __init nvic_of_init(struct device_node *node,
 	for (i = 0; i < irqs; i += 4)
 		writel_relaxed(0, nvic_base + NVIC_IPR + i);
 
+	set_handle_irq(nvic_handle_irq);
 	return 0;
 }
 IRQCHIP_DECLARE(armv7m_nvic, "arm,armv7m-nvic", nvic_of_init);
Signature · 1 line
2.7.4

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Acked-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

In reply to Vladimir Murzin
Quoted 5 lines · Vladimir Murzin

Rather then restructuring the ARMv7M entrly logic per TODO, just move NVIC to GENERIC_IRQ_MULTI_HANDLER.

Thanks for finishing this one off as well! I don't know if you did this as a reaction to me doing the same for the three other platforms that don't use GENERIC_IRQ_MULTI_HANDLER yet[1], or if this was just a lucky coincidence. It sounds like this should be part of Ard's IRQ stack series as well then (adding him to Cc), as it fits in with my patches there.

Would you mind also implementing and testing the missing bits for the stack switching on nommu irq entry, corresponding to [2] so we can just use that part unconditionally as well?

Arnd

[1] https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/commit/?h=arm-up-ti-in-task-v3&id=f3ad7675e9e02996331c69a48f45db60ac8e9852
and parents
[2] https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/diff/arch/arm/kernel/entry-armv.S?h=arm-up-ti-in-task-v3&id=950bf934b1c1c4efe579f40a82a0fca0ae223d2a

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#4 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 7 lines · Arnd Bergmann
Quoted 5 lines · Vladimir Murzin

Rather then restructuring the ARMv7M entrly logic per TODO, just move NVIC to GENERIC_IRQ_MULTI_HANDLER.

Quoted 7 lines

Thanks for finishing this one off as well! I don't know if you did this as a reaction to me doing the same for the three other platforms that don't use GENERIC_IRQ_MULTI_HANDLER yet[1], or if this was just a lucky coincidence. It sounds like this should be part of Ard's IRQ stack series as well then (adding him to Cc), as it fits in with my patches there.

It was reaction to Mark's TODO statement in his original submission [1]. I'd let maintainers to decide on the path it should land :)

Quoted 4 lines

Would you mind also implementing and testing the missing bits for the stack switching on nommu irq entry, corresponding to [2] so we can just use that part unconditionally as well?

I can have a look but no promises since I have few issues with NOMMU ATM (one of them seems to be cross-arch [2])

[1] https://lore.kernel.org/linux-arm-kernel/[email protected]/
[2] https://lore.kernel.org/linux-mm/[email protected]/T/

Cheers
Vladimir

Quoted 7 lines

Arnd

[1] https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/commit/?h=arm-up-ti-in-task-v3&id=f3ad7675e9e02996331c69a48f45db60ac8e9852
and parents
[2] https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/diff/arch/arm/kernel/entry-armv.S?h=arm-up-ti-in-task-v3&id=950bf934b1c1c4efe579f40a82a0fca0ae223d2a

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 10 lines · Vladimir Murzin
Quoted 9 lines · Arnd Bergmann
Quoted 5 lines · Vladimir Murzin

Rather then restructuring the ARMv7M entrly logic per TODO, just move NVIC to GENERIC_IRQ_MULTI_HANDLER.

Quoted 8 lines
Quoted 5 lines

Thanks for finishing this one off as well! I don't know if you did this as a reaction to me doing the same for the three other platforms that don't use GENERIC_IRQ_MULTI_HANDLER yet[1], or if this was just a lucky coincidence. It sounds like this should be part of Ard's IRQ stack series as well then (adding him to Cc), as it fits in with my patches there.

It was reaction to Mark's TODO statement in his original submission [1]. I'd let maintainers to decide on the path it should land :)

Ah, nice, so it was a coincidence after all. I guess my patches were easier because of Mark's (and Marc's) earlier work on related bits.

Quoted 6 lines
Quoted 3 lines

Would you mind also implementing and testing the missing bits for the stack switching on nommu irq entry, corresponding to [2] so we can just use that part unconditionally as well?

I can have a look but no promises since I have few issues with NOMMU ATM (one of them seems to be cross-arch [2])

Yes, I saw that, but I'm not too worried about this on Arm, as we don't support that combination (SMP without MMU) in any of our platforms or in Kconfig without additional patches.

What target are you actually testing on?

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#6 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 27 lines · Arnd Bergmann
Quoted 10 lines · Vladimir Murzin
Quoted 9 lines · Arnd Bergmann
Quoted 5 lines · Vladimir Murzin

Rather then restructuring the ARMv7M entrly logic per TODO, just move NVIC to GENERIC_IRQ_MULTI_HANDLER.

Quoted 8 lines
Quoted 5 lines

Thanks for finishing this one off as well! I don't know if you did this as a reaction to me doing the same for the three other platforms that don't use GENERIC_IRQ_MULTI_HANDLER yet[1], or if this was just a lucky coincidence. It sounds like this should be part of Ard's IRQ stack series as well then (adding him to Cc), as it fits in with my patches there.

It was reaction to Mark's TODO statement in his original submission [1]. I'd let maintainers to decide on the path it should land :)

Ah, nice, so it was a coincidence after all. I guess my patches were easier because of Mark's (and Marc's) earlier work on related bits.

Quoted 4 lines
Quoted 3 lines

Would you mind also implementing and testing the missing bits for the stack switching on nommu irq entry, corresponding to [2] so we can just use that part unconditionally as well?

Quoted 6 lines
Quoted 2 lines

I can have a look but no promises since I have few issues with NOMMU ATM (one of them seems to be cross-arch [2])

Yes, I saw that, but I'm not too worried about this on Arm, as we don't support that combination (SMP without MMU) in any of our platforms or in Kconfig without additional patches.

That's true, yet it seems to be broken for other arches which seems to be supported (w/o additional patches?)

Quoted 3 lines

What target are you actually testing on?

It is MPS3 board with range of FPGA images. M and R class supported yet AN536 (Cortex-R52x2) has issues which prevents it using in SMP; recent images for M class require new timer (which is WIP).

I also have access to Fast Models - they are easier and quicker to test and do not require visiting office :)

[1] https://developer.arm.com/tools-and-software/development-boards/fpga-prototyping-boards/download-fpga-images

Cheers
Vladimir

Quoted 2 lines

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#7 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 8 lines · Vladimir Murzin
Quoted 4 lines · Arnd Bergmann

Yes, I saw that, but I'm not too worried about this on Arm, as we don't support that combination (SMP without MMU) in any of our platforms or in Kconfig without additional patches.

That's true, yet it seems to be broken for other arches which seems to be supported (w/o additional patches?)

Sure, it should get fixed, it's just not on my list of high-priority problems. For j2, I think there isn't much work going on at the moment, and I think there are other problems on sh nommu smp. For riscv K210, I think there isn't as much interest any more after MMU-based platforms are becoming more available.

Quoted 9 lines
Quoted 2 lines

What target are you actually testing on?

It is MPS3 board with range of FPGA images. M and R class supported yet AN536 (Cortex-R52x2) has issues which prevents it using in SMP; recent images for M class require new timer (which is WIP).

I also have access to Fast Models - they are easier and quicker to test and do not require visiting office :)

Ok, I see. What are your plans for the Cortex-R support? My impression was that there isn't really much interest in upstream support as there is no commercial SoC platform using 32-bit Cortex-R that makes sense to run Linux on (any more), and Cortex-R82 would run with MMU enabled. Do you expect this to change in the future?

As far as I can tell, there is no SMP-capable Cortex-M. If there is, then Ard's THREAD_INFO_IN_TASK series may have another problem because of the lack of the TPIDRURO register. Again, I'm not too worried about that because mainline Linux does not support this configuration, but it's something to keep in mind.

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#8 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 23 lines · Arnd Bergmann
Quoted 8 lines · Vladimir Murzin
Quoted 4 lines · Arnd Bergmann

Yes, I saw that, but I'm not too worried about this on Arm, as we don't support that combination (SMP without MMU) in any of our platforms or in Kconfig without additional patches.

That's true, yet it seems to be broken for other arches which seems to be supported (w/o additional patches?)

Sure, it should get fixed, it's just not on my list of high-priority problems. For j2, I think there isn't much work going on at the moment, and I think there are other problems on sh nommu smp. For riscv K210, I think there isn't as much interest any more after MMU-based platforms are becoming more available.

Quoted 7 lines
Quoted 2 lines

What target are you actually testing on?

It is MPS3 board with range of FPGA images. M and R class supported yet AN536 (Cortex-R52x2) has issues which prevents it using in SMP; recent images for M class require new timer (which is WIP).

Quoted 8 lines
Quoted 2 lines

I also have access to Fast Models - they are easier and quicker to test and do not require visiting office :)

Ok, I see. What are your plans for the Cortex-R support? My impression was that there isn't really much interest in upstream support as there is no commercial SoC platform using 32-bit Cortex-R that makes sense to run Linux on (any more), and Cortex-R82 would run with MMU enabled. Do you expect this to change in the future?

There are not many patches to make Linux run on Cortex-R - it is mostly to undo multiplform, so I'm fine keeping them downstream.

I cannot say how much interest in running Linux with 32-bit Cortex-R, yet occasionally people ask me how to do that (the same applies to M-class).

Quoted 6 lines

As far as I can tell, there is no SMP-capable Cortex-M. If there is, then Ard's THREAD_INFO_IN_TASK series may have another problem because of the lack of the TPIDRURO register. Again, I'm not too worried about that because mainline Linux does not support this configuration, but it's something to keep in mind.

I'm not aware of any SMP-capable Cortex-M either :)

Cheers
Vladimir

Quoted 3 lines

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#9 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann
Quoted 5 lines · Vladimir Murzin

Rather then restructuring the ARMv7M entrly logic per TODO, just move NVIC to GENERIC_IRQ_MULTI_HANDLER.

Quoted 8 lines

Thanks for finishing this one off as well! I don't know if you did this as a reaction to me doing the same for the three other platforms that don't use GENERIC_IRQ_MULTI_HANDLER yet[1], or if this was just a lucky coincidence. It sounds like this should be part of Ard's IRQ stack series as well then (adding him to Cc), as it fits in with my patches there.

Yes, I'll add this one to my series. But only the 2/2, the other one looks like a bugfix and can be put into the patch tracker.

Quoted 4 lines

Would you mind also implementing and testing the missing bits for the stack switching on nommu irq entry, corresponding to [2] so we can just use that part unconditionally as well?

It seems trivial enough to add that for v7m as well, so I will include a patch for it in my v3. But I won't be able to test it, though.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#10 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 18 lines · Ard Biesheuvel
Quoted 8 lines · Arnd Bergmann
Quoted 5 lines · Vladimir Murzin

Rather then restructuring the ARMv7M entrly logic per TODO, just move NVIC to GENERIC_IRQ_MULTI_HANDLER.

Quoted 8 lines

Thanks for finishing this one off as well! I don't know if you did this as a reaction to me doing the same for the three other platforms that don't use GENERIC_IRQ_MULTI_HANDLER yet[1], or if this was just a lucky coincidence. It sounds like this should be part of Ard's IRQ stack series as well then (adding him to Cc), as it fits in with my patches there.

Quoted 2 lines

Yes, I'll add this one to my series. But only the 2/2, the other one looks like a bugfix and can be put into the patch tracker.

I'll pick 1/2 now and send it as part of the irqchip fixes.

        M.
Signature · 6 lines
Jazz is not dead. It just smells funny...

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#11 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

In reply to Ard Biesheuvel
Quoted 3 lines · Ard Biesheuvel

It seems trivial enough to add that for v7m as well, so I will include a patch for it in my v3. But I won't be able to test it, though.

Ok, perfect. Adding Jesse to Cc, they are in the process of adding another Cortex-M based platform and should be able to test this by merging in your changes from [1] after you have uploaded the latest version.

Arnd

[1] https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=arm-up-ti-in-task-v3

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#12 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 8 lines · Arnd Bergmann
Quoted 3 lines · Ard Biesheuvel

It seems trivial enough to add that for v7m as well, so I will include a patch for it in my v3. But I won't be able to test it, though.

Ok, perfect. Adding Jesse to Cc, they are in the process of adding another Cortex-M based platform and should be able to test this by merging in your changes from [1] after you have uploaded the latest version.

I'm happy to test it as well. I'm wondering if there are specific scenarios (or maybe some tests) to consider?

Cheers
Vladimir

Quoted 5 lines

Arnd

[1] https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=arm-up-ti-in-task-v3

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#13 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 7 lines · Vladimir Murzin
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · Ard Biesheuvel

It seems trivial enough to add that for v7m as well, so I will include a patch for it in my v3. But I won't be able to test it, though.

Quoted 6 lines
Quoted 3 lines

Ok, perfect. Adding Jesse to Cc, they are in the process of adding another Cortex-M based platform and should be able to test this by merging in your changes from [1] after you have uploaded the latest version.

I'm happy to test it as well. I'm wondering if there are specific scenarios (or maybe some tests) to consider?

If the IRQ stacks fail in some way, it most likely won't boot at all, so as long as you can get into user space, I'd be 99% confident that it's good.

For the MMU based platforms, the series lets us detect stack overflows when either the per-thread stack or the IRQ stack runs into an unmapped vmalloc page, and there are some unit tests that exercise this. I don't think you can do this with the MPU though, and certainly not when the MPU is disabled.

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#14 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 16 lines · Arnd Bergmann
Quoted 7 lines · Vladimir Murzin
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · Ard Biesheuvel

It seems trivial enough to add that for v7m as well, so I will include a patch for it in my v3. But I won't be able to test it, though.

Quoted 6 lines
Quoted 3 lines

Ok, perfect. Adding Jesse to Cc, they are in the process of adding another Cortex-M based platform and should be able to test this by merging in your changes from [1] after you have uploaded the latest version.

I'm happy to test it as well. I'm wondering if there are specific scenarios (or maybe some tests) to consider?

Quoted 9 lines

If the IRQ stacks fail in some way, it most likely won't boot at all, so as long as you can get into user space, I'd be 99% confident that it's good.

For the MMU based platforms, the series lets us detect stack overflows when either the per-thread stack or the IRQ stack runs into an unmapped vmalloc page, and there are some unit tests that exercise this. I don't think you can do this with the MPU though, and certainly not when the MPU is disabled.

Latest version of the code is here, if anyone wants to test it:
https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=arm-up-ti-in-task-v3

Once Mr. Robot confirms that nothing is broken, I'll send it out to the ML.

Signature · 6 lines
Ard.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#15 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 27 lines · Ard Biesheuvel
Quoted 16 lines · Arnd Bergmann
Quoted 7 lines · Vladimir Murzin
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · Ard Biesheuvel

It seems trivial enough to add that for v7m as well, so I will include a patch for it in my v3. But I won't be able to test it, though.

Quoted 6 lines
Quoted 3 lines

Ok, perfect. Adding Jesse to Cc, they are in the process of adding another Cortex-M based platform and should be able to test this by merging in your changes from [1] after you have uploaded the latest version.

I'm happy to test it as well. I'm wondering if there are specific scenarios (or maybe some tests) to consider?

Quoted 9 lines

If the IRQ stacks fail in some way, it most likely won't boot at all, so as long as you can get into user space, I'd be 99% confident that it's good.

For the MMU based platforms, the series lets us detect stack overflows when either the per-thread stack or the IRQ stack runs into an unmapped vmalloc page, and there are some unit tests that exercise this. I don't think you can do this with the MPU though, and certainly not when the MPU is disabled.

Quoted 3 lines

Latest version of the code is here, if anyone wants to test it:
https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=arm-up-ti-in-task-v3

I'm afraid it is broken (even w/o last patch). I'm getting

[    0.071350] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.071747] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.084497] bad: scheduling from the idle thread!
[    0.084744] CPU: 0 PID: 0 Comm: kworker/0:0H Not tainted 5.16.0-rc1-0f57a2aad139 #2428
[    0.085357] Hardware name: Generic DT based system
$ git bisect log
git bisect start
# good: [fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf] Linux 5.16-rc1
git bisect good fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf
# bad: [e42c59caa4d8f37444388cc388bfc55653bf00dc] ARM: v7m: enable support for IRQ stacks
git bisect bad e42c59caa4d8f37444388cc388bfc55653bf00dc
# good: [cbf7b30e70b7e2eacebd885674675746e93583f6] ARM: entry: rework stack realignment code in svc_entry
git bisect good cbf7b30e70b7e2eacebd885674675746e93583f6
# good: [02c0315277721c4fc2082850da0714127594473d] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER
git bisect good 02c0315277721c4fc2082850da0714127594473d
# good: [9cc24032abc2847a8e61e55e2ec9bd34e1eff1c4] ARM: percpu: add SMP_ON_UP support
git bisect good 9cc24032abc2847a8e61e55e2ec9bd34e1eff1c4
# good: [8adfea395669037ee79620b8b534e101d5ce65e6] ARM: smp: defer TPIDRURO update for SMP v6 configurations too
git bisect good 8adfea395669037ee79620b8b534e101d5ce65e6
# bad: [0f57a2aad13912dde5746ffc5f43bd46aa3d8b2d] ARM: implement THREAD_INFO_IN_TASK for uniprocessor systems
git bisect bad 0f57a2aad13912dde5746ffc5f43bd46aa3d8b2d
# first bad commit: [0f57a2aad13912dde5746ffc5f43bd46aa3d8b2d] ARM: implement THREAD_INFO_IN_TASK for uniprocessor systems

At the first glance it seems that __switch_to in entry-v7m.S missing set_current

Cheers
Vladimir

Quoted 2 lines

Once Mr. Robot confirms that nothing is broken, I'll send it out to the ML.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#16 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 59 lines · Vladimir Murzin
Quoted 27 lines · Ard Biesheuvel
Quoted 16 lines · Arnd Bergmann
Quoted 7 lines · Vladimir Murzin
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · Ard Biesheuvel

It seems trivial enough to add that for v7m as well, so I will include a patch for it in my v3. But I won't be able to test it, though.

Quoted 6 lines
Quoted 3 lines

Ok, perfect. Adding Jesse to Cc, they are in the process of adding another Cortex-M based platform and should be able to test this by merging in your changes from [1] after you have uploaded the latest version.

I'm happy to test it as well. I'm wondering if there are specific scenarios (or maybe some tests) to consider?

Quoted 9 lines

If the IRQ stacks fail in some way, it most likely won't boot at all, so as long as you can get into user space, I'd be 99% confident that it's good.

For the MMU based platforms, the series lets us detect stack overflows when either the per-thread stack or the IRQ stack runs into an unmapped vmalloc page, and there are some unit tests that exercise this. I don't think you can do this with the MPU though, and certainly not when the MPU is disabled.

Quoted 3 lines

Latest version of the code is here, if anyone wants to test it:
https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=arm-up-ti-in-task-v3

I'm afraid it is broken (even w/o last patch). I'm getting

[    0.071350] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.071747] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.084497] bad: scheduling from the idle thread!
[    0.084744] CPU: 0 PID: 0 Comm: kworker/0:0H Not tainted 5.16.0-rc1-0f57a2aad139 #2428
[    0.085357] Hardware name: Generic DT based system
$ git bisect log
git bisect start
# good: [fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf] Linux 5.16-rc1
git bisect good fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf
# bad: [e42c59caa4d8f37444388cc388bfc55653bf00dc] ARM: v7m: enable support for IRQ stacks
git bisect bad e42c59caa4d8f37444388cc388bfc55653bf00dc
# good: [cbf7b30e70b7e2eacebd885674675746e93583f6] ARM: entry: rework stack realignment code in svc_entry
git bisect good cbf7b30e70b7e2eacebd885674675746e93583f6
# good: [02c0315277721c4fc2082850da0714127594473d] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER
git bisect good 02c0315277721c4fc2082850da0714127594473d
# good: [9cc24032abc2847a8e61e55e2ec9bd34e1eff1c4] ARM: percpu: add SMP_ON_UP support
git bisect good 9cc24032abc2847a8e61e55e2ec9bd34e1eff1c4
# good: [8adfea395669037ee79620b8b534e101d5ce65e6] ARM: smp: defer TPIDRURO update for SMP v6 configurations too
git bisect good 8adfea395669037ee79620b8b534e101d5ce65e6
# bad: [0f57a2aad13912dde5746ffc5f43bd46aa3d8b2d] ARM: implement THREAD_INFO_IN_TASK for uniprocessor systems
git bisect bad 0f57a2aad13912dde5746ffc5f43bd46aa3d8b2d
# first bad commit: [0f57a2aad13912dde5746ffc5f43bd46aa3d8b2d] ARM: implement THREAD_INFO_IN_TASK for uniprocessor systems
Quoted 2 lines

At the first glance it seems that __switch_to in entry-v7m.S missing set_current

Thanks for testing, and thanks for bisecting. Unfortunately, I can't easily test these changes myself.

Could you please check whether the following change would be sufficient to fix this?

https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/commit/?h=tmp

Thanks,
Ard.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#17 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 63 lines · Ard Biesheuvel
Quoted 59 lines · Vladimir Murzin
Quoted 27 lines · Ard Biesheuvel
Quoted 16 lines · Arnd Bergmann
Quoted 7 lines · Vladimir Murzin
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · Ard Biesheuvel

It seems trivial enough to add that for v7m as well, so I will include a patch for it in my v3. But I won't be able to test it, though.

Quoted 6 lines
Quoted 3 lines

Ok, perfect. Adding Jesse to Cc, they are in the process of adding another Cortex-M based platform and should be able to test this by merging in your changes from [1] after you have uploaded the latest version.

I'm happy to test it as well. I'm wondering if there are specific scenarios (or maybe some tests) to consider?

Quoted 9 lines

If the IRQ stacks fail in some way, it most likely won't boot at all, so as long as you can get into user space, I'd be 99% confident that it's good.

For the MMU based platforms, the series lets us detect stack overflows when either the per-thread stack or the IRQ stack runs into an unmapped vmalloc page, and there are some unit tests that exercise this. I don't think you can do this with the MPU though, and certainly not when the MPU is disabled.

Quoted 3 lines

Latest version of the code is here, if anyone wants to test it:
https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=arm-up-ti-in-task-v3

I'm afraid it is broken (even w/o last patch). I'm getting

[    0.071350] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.071747] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.084497] bad: scheduling from the idle thread!
[    0.084744] CPU: 0 PID: 0 Comm: kworker/0:0H Not tainted 5.16.0-rc1-0f57a2aad139 #2428
[    0.085357] Hardware name: Generic DT based system
$ git bisect log
git bisect start
# good: [fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf] Linux 5.16-rc1
git bisect good fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf
# bad: [e42c59caa4d8f37444388cc388bfc55653bf00dc] ARM: v7m: enable support for IRQ stacks
git bisect bad e42c59caa4d8f37444388cc388bfc55653bf00dc
# good: [cbf7b30e70b7e2eacebd885674675746e93583f6] ARM: entry: rework stack realignment code in svc_entry
git bisect good cbf7b30e70b7e2eacebd885674675746e93583f6
# good: [02c0315277721c4fc2082850da0714127594473d] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER
git bisect good 02c0315277721c4fc2082850da0714127594473d
# good: [9cc24032abc2847a8e61e55e2ec9bd34e1eff1c4] ARM: percpu: add SMP_ON_UP support
git bisect good 9cc24032abc2847a8e61e55e2ec9bd34e1eff1c4
# good: [8adfea395669037ee79620b8b534e101d5ce65e6] ARM: smp: defer TPIDRURO update for SMP v6 configurations too
git bisect good 8adfea395669037ee79620b8b534e101d5ce65e6
# bad: [0f57a2aad13912dde5746ffc5f43bd46aa3d8b2d] ARM: implement THREAD_INFO_IN_TASK for uniprocessor systems
git bisect bad 0f57a2aad13912dde5746ffc5f43bd46aa3d8b2d
# first bad commit: [0f57a2aad13912dde5746ffc5f43bd46aa3d8b2d] ARM: implement THREAD_INFO_IN_TASK for uniprocessor systems
Quoted 2 lines

At the first glance it seems that __switch_to in entry-v7m.S missing set_current

Quoted 8 lines

Thanks for testing, and thanks for bisecting. Unfortunately, I can't easily test these changes myself.

Could you please check whether the following change would be sufficient to fix this?

https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/commit/?h=tmp

Booted fine now.

$ cat /proc/interrupts

CPU0

 16:         25  nvic_irq   4 Edge      mps2-clkevt
 17:          0  nvic_irq  32 Edge      mps2-uart-rx
 18:       1124  nvic_irq  33 Edge      mps2-uart-tx
 19:          0  nvic_irq  47 Edge      mps2-uart-overrun

Err: 0

Note: 0 interrupts for mps2-uart-rx is expected since it is automated environment

Cheers
Vladimir

Quoted 3 lines

Thanks,
Ard.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#18 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 4 lines · Vladimir Murzin
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Vladimir Murzin

...

Quoted 17 lines
Quoted 11 lines
Quoted 2 lines

At the first glance it seems that __switch_to in entry-v7m.S missing set_current

Thanks for testing, and thanks for bisecting. Unfortunately, I can't easily test these changes myself.

Could you please check whether the following change would be sufficient to fix this?

https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/commit/?h=tmp

Booted fine now.

$ cat /proc/interrupts

CPU0

Quoted 9 lines
 16:         25  nvic_irq   4 Edge      mps2-clkevt
 17:          0  nvic_irq  32 Edge      mps2-uart-rx
 18:       1124  nvic_irq  33 Edge      mps2-uart-tx
 19:          0  nvic_irq  47 Edge      mps2-uart-overrun

Err: 0

Note: 0 interrupts for mps2-uart-rx is expected since it is automated environment

Excellent, thanks again. I will fold in that change.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#19 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

Quoted 29 lines · Ard Biesheuvel
Quoted 4 lines · Vladimir Murzin
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Vladimir Murzin

...

Quoted 23 lines
Quoted 11 lines
Quoted 2 lines

At the first glance it seems that __switch_to in entry-v7m.S missing set_current

Thanks for testing, and thanks for bisecting. Unfortunately, I can't easily test these changes myself.

Could you please check whether the following change would be sufficient to fix this?

https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/commit/?h=tmp

Booted fine now.

$ cat /proc/interrupts

CPU0

  16:         25  nvic_irq   4 Edge      mps2-clkevt
  17:          0  nvic_irq  32 Edge      mps2-uart-rx
  18:       1124  nvic_irq  33 Edge      mps2-uart-tx
  19:          0  nvic_irq  47 Edge      mps2-uart-overrun

Err: 0

Quoted 6 lines
Quoted 3 lines

Note: 0 interrupts for mps2-uart-rx is expected since it is automated environment

Excellent, thanks again. I will fold in that change.

It works for me now aswell!

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Acked-by on v1 2/2
#20 lore raw

Re: [PATCH 2/2] irqchip: nvic: Use GENERIC_IRQ_MULTI_HANDLER

In reply to Vladimir Murzin
Quoted 5 lines · Vladimir Murzin

Rather then restructuring the ARMv7M entrly logic per TODO, just move NVIC to GENERIC_IRQ_MULTI_HANDLER.

Assuming this will be part of Ard's series:

	M.
Signature · 6 lines
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#21 lore raw
In reply to Vladimir Murzin
The following commit has been merged into the irq/irqchip-fixes branch of irqchip:

The following commit has been merged into the irq/irqchip-fixes branch of irqchip:

Commit-ID:     c5e0cbe2858d278a27d5b3fe31890aea5be064c4
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/c5e0cbe2858d278a27d5b3fe31890aea5be064c4
Author:        Vladimir Murzin <[email protected]>
AuthorDate:    Wed, 01 Dec 2021 11:02:58 
Committer:     Marc Zyngier <[email protected]>
CommitterDate: Thu, 02 Dec 2021 09:27:06 

irqchip: nvic: Fix offset for Interrupt Priority Offsets

According to ARM(v7M) ARM Interrupt Priority Offsets located at 0xE000E400-0xE000E5EC, while 0xE000E300-0xE000E33C covers read-only Interrupt Active Bit Registers

Fixes 292ec080491d ("irqchip: Add support for ARMv7-M NVIC")
---
 drivers/irqchip/irq-nvic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-nvic.c +1 -1
index 63bac3f..ba4759b 100644
@@ -26,7 +26,7 @@
 
 #define NVIC_ISER		0x000
 #define NVIC_ICER		0x080
-#define NVIC_IPR		0x300
+#define NVIC_IPR		0x400
 
 #define NVIC_MAX_BANKS		16
 /*