Skip to contentSkip to conversation

irqchip/sifive-plic: fix call to __plic_toggle in M-Mode code path

PATCH Applied Charles Mirabile 3 participants 4 messages Nov 3, 2025 – Dec 19, 2025

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

PATCH 1/1 irqchip/sifive-plic: fix call to __plic_toggle in M-Mode code path

The code path for M-Mode linux that disables interrupts for other contexts was missed when refactoring __plic_toggle.

Since the new version caches updates to the state for the primary context, its use in this codepath is no longer desireable even if it could be made correct.

Replace the calls to __plic_toggle with a loop that simply disables all of the interrupts in groups of 32 with a direct mmio write.

Fixes 14ff9e54dd14 ("irqchip/sifive-plic: Cache the interrupt enable state")
---
 drivers/irqchip/irq-sifive-plic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/irqchip/irq-sifive-plic.c +3 -3
index cbd7697bc148..0de3003981f1 100644
@@ -592,12 +592,12 @@ static int plic_probe(struct fwnode_handle *fwnode)
 		if (parent_hwirq != RV_IRQ_EXT) {
 			/* Disable S-mode enable bits if running in M-mode. */
 			if (IS_ENABLED(CONFIG_RISCV_M_MODE)) {
-				void __iomem *enable_base = priv->regs +
+				u32 __iomem *enable_base = priv->regs +
 					CONTEXT_ENABLE_BASE +
 					i * CONTEXT_ENABLE_SIZE;
 
-				for (hwirq = 1; hwirq <= nr_irqs; hwirq++)
-					__plic_toggle(enable_base, hwirq, 0);
+				for (int j = 0; j <= nr_irqs / 32; j++)
+					writel(0, enable_base + j);
 			}
 			continue;
 		}
Signature · 1 line
2.43.0
#1 lore raw

[tip: irq/core] irqchip/sifive-plic: Fix call to __plic_toggle() in M-Mode code path

The following commit has been merged into the irq/core branch of tip:

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     3d02464f7b12d3244f2fbc210afcdd0cdb7da4f7
Gitweb:        https://git.kernel.org/tip/3d02464f7b12d3244f2fbc210afcdd0cdb7da4f7
Author:        Charles Mirabile <[email protected]>
AuthorDate:    Mon, 03 Nov 2025 11:18:13 -05:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Mon, 03 Nov 2025 23:15:04 +01:00

irqchip/sifive-plic: Fix call to __plic_toggle() in M-Mode code path

The code path for M-Mode linux that disables interrupts for other contexts was missed when refactoring __plic_toggle().

Since the new version caches updates to the state for the primary context, its use in this codepath is no longer desireable even if it could be made correct.

Replace the calls to __plic_toggle() with a loop that simply disables all of the interrupts in groups of 32 with a direct mmio write.

---
 drivers/irqchip/irq-sifive-plic.c |  9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/irqchip/irq-sifive-plic.c +4 -5
index cbd7697..39ea044 100644
@@ -592,12 +592,11 @@ static int plic_probe(struct fwnode_handle *fwnode)
 		if (parent_hwirq != RV_IRQ_EXT) {
 			/* Disable S-mode enable bits if running in M-mode. */
 			if (IS_ENABLED(CONFIG_RISCV_M_MODE)) {
-				void __iomem *enable_base = priv->regs +
-					CONTEXT_ENABLE_BASE +
-					i * CONTEXT_ENABLE_SIZE;
+				u32 __iomem *enable_base = priv->regs +	CONTEXT_ENABLE_BASE +
+							   i * CONTEXT_ENABLE_SIZE;
 
-				for (hwirq = 1; hwirq <= nr_irqs; hwirq++)
-					__plic_toggle(enable_base, hwirq, 0);
+				for (int j = 0; j <= nr_irqs / 32; j++)
+					writel(0, enable_base + j);
 			}
 			continue;
 		}
#2 lore raw

[tip: irq/drivers] irqchip/sifive-plic: Fix call to __plic_toggle() in M-Mode code path

In reply to Charles Mirabile
The following commit has been merged into the irq/drivers branch of tip:

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     a045359e72455c4fd178fbedbf398f8df7da97e7
Gitweb:        https://git.kernel.org/tip/a045359e72455c4fd178fbedbf398f8df7da97e7
Author:        Charles Mirabile <[email protected]>
AuthorDate:    Mon, 03 Nov 2025 11:18:13 -05:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Tue, 11 Nov 2025 22:11:16 +01:00

irqchip/sifive-plic: Fix call to __plic_toggle() in M-Mode code path

The code path for M-Mode linux that disables interrupts for other contexts was missed when refactoring __plic_toggle().

Since the new version caches updates to the state for the primary context, its use in this codepath is no longer desireable even if it could be made correct.

Replace the calls to __plic_toggle() with a loop that simply disables all of the interrupts in groups of 32 with a direct mmio write.

---
 drivers/irqchip/irq-sifive-plic.c |  9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/irqchip/irq-sifive-plic.c +4 -5
index c03340e..c5db7d6 100644
@@ -679,12 +679,11 @@ static int plic_probe(struct fwnode_handle *fwnode)
 		if (parent_hwirq != RV_IRQ_EXT) {
 			/* Disable S-mode enable bits if running in M-mode. */
 			if (IS_ENABLED(CONFIG_RISCV_M_MODE)) {
-				void __iomem *enable_base = priv->regs +
-					CONTEXT_ENABLE_BASE +
-					i * CONTEXT_ENABLE_SIZE;
+				u32 __iomem *enable_base = priv->regs +	CONTEXT_ENABLE_BASE +
+							   i * CONTEXT_ENABLE_SIZE;
 
-				for (hwirq = 1; hwirq <= nr_irqs; hwirq++)
-					__plic_toggle(enable_base, hwirq, 0);
+				for (int j = 0; j <= nr_irqs / 32; j++)
+					writel(0, enable_base + j);
 			}
 			continue;
 		}
#3 lore raw
In reply to Charles Mirabile
This patch was applied to riscv/linux.git (fixes) by Thomas Gleixner <[email protected]>:

Hello:

This patch was applied to riscv/linux.git (fixes)
by Thomas Gleixner <[email protected]>:

Quoted 8 lines · On Mon, 3 Nov 2025 11:18:13 -0500 you wrote:

The code path for M-Mode linux that disables interrupts for other contexts was missed when refactoring __plic_toggle.

Since the new version caches updates to the state for the primary context, its use in this codepath is no longer desireable even if it could be made correct.

[...]

Here is the summary with links:
- irqchip/sifive-plic: fix call to __plic_toggle in M-Mode code path

    https://git.kernel.org/riscv/c/a045359e7245

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html