* Re: Patch "irqchip/sifive-plic: Cache the interrupt enable state" has been added to the 6.18-stable tree
[not found] <20261117161945.1965350-1-sashal@kernel.org>
@ 2026-11-17 17:01 ` Charles Mirabile
2026-11-18 0:23 ` Sasha Levin
0 siblings, 1 reply; 4+ messages in thread
From: Charles Mirabile @ 2026-11-17 17:01 UTC (permalink / raw)
To: stable
Cc: stable-commits, Thomas Gleixner, Radu Rendec, Paul Walmsley,
Samuel Holland
Hi All—
On Tue, Nov 17, 2026 at 11:28 AM Sasha Levin <sashal@kernel.org> wrote:
>
> This is a note to let you know that I've just added the patch titled
>
> irqchip/sifive-plic: Cache the interrupt enable state
>
> to the 6.18-stable tree which can be found at:
> http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
>
> The filename of the patch is:
> irqchip-sifive-plic-cache-the-interrupt-enable-state.patch
> and it can be found in the queue-6.18 subdirectory.
>
> If you, or anyone else, feels it should not be added to the stable tree,
> please let <stable@vger.kernel.org> know about it.
This patch makes substantial changes to the driver and how it
processes interrupts. I am not sure it is a great candidate for
stable.
>
>
>
> commit 036776c9c1002f36de16fa9e17e5fafccd095864
> Author: Charles Mirabile <cmirabil@redhat.com>
> Date: Fri Oct 24 09:36:42 2025 +0100
>
> irqchip/sifive-plic: Cache the interrupt enable state
>
> [ Upstream commit 14ff9e54dd14339776afff78e2d29e0edb3a4402 ]
>
> Optimize the PLIC driver by maintaining the interrupt enable state in the
> handler's enable_save array during normal operation rather than only during
> suspend/resume. This eliminates the need to read enable registers during
> suspend and makes the enable state immediately available for other
> purposes.
>
> Let __plic_toggle() update both the hardware registers and the cached
> enable_save state atomically within the existing enable_lock protection.
>
> That allows to remove the suspend-time enable register reading since
> handler::enable_save now always reflects the current state.
>
> [ tglx: Massaged change log ]
>
> Signed-off-by: Charles Mirabile <cmirabil@redhat.com>
> Signed-off-by: Lucas Zampieri <lzampier@redhat.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Link: https://patch.msgid.link/20251024083647.475239-4-lzampier@redhat.com
> Stable-dep-of: 0f214e5bbee5 ("irqchip/sifive-plic: Avoid signed shift in interrupt enable mask")
Especially if we are just trying to backport this commit...
Consider the following version of 0f214e5bbee5 ("irqchip/sifive-plic:
Avoid signed shift in interrupt enable mask")
diff --git a/drivers/irqchip/irq-sifive-plic.c
b/drivers/irqchip/irq-sifive-plic.c
index ca70641982ed6..0995e1fdd5b47 100644
--- a/drivers/irqchip/irq-sifive-plic.c
+++ b/drivers/irqchip/irq-sifive-plic.c
@@ -97,7 +97,7 @@ static int plic_irq_set_type(struct irq_data *d,
unsigned int type);
static void __plic_toggle(void __iomem *enable_base, int hwirq, int enable)
{
u32 __iomem *reg = enable_base + (hwirq / 32) * sizeof(u32);
- u32 hwirq_mask = 1 << (hwirq % 32);
+ u32 hwirq_mask = BIT(hwirq % 32);
if (enable)
writel(readl(reg) | hwirq_mask, reg);
that applies on 6.18.64. Forgive that this is not a proper patch for
git am, I am not at a system with git-send-email set up.
> Signed-off-by: Sasha Levin <sashal@kernel.org>
>
> diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
> index ca70641982ed6..2056a4d45656a 100644
> --- a/drivers/irqchip/irq-sifive-plic.c
> +++ b/drivers/irqchip/irq-sifive-plic.c
> @@ -94,15 +94,22 @@ static DEFINE_PER_CPU(struct plic_handler, plic_handlers);
>
> static int plic_irq_set_type(struct irq_data *d, unsigned int type);
>
> -static void __plic_toggle(void __iomem *enable_base, int hwirq, int enable)
> +static void __plic_toggle(struct plic_handler *handler, int hwirq, int enable)
> {
> - u32 __iomem *reg = enable_base + (hwirq / 32) * sizeof(u32);
> + u32 __iomem *base = handler->enable_base;
> u32 hwirq_mask = 1 << (hwirq % 32);
> + int group = hwirq / 32;
> + u32 value;
> +
> + value = readl(base + group);
>
> if (enable)
> - writel(readl(reg) | hwirq_mask, reg);
> + value |= hwirq_mask;
> else
> - writel(readl(reg) & ~hwirq_mask, reg);
> + value &= ~hwirq_mask;
> +
> + handler->enable_save[group] = value;
> + writel(value, base + group);
> }
>
> static void plic_toggle(struct plic_handler *handler, int hwirq, int enable)
> @@ -110,7 +117,7 @@ static void plic_toggle(struct plic_handler *handler, int hwirq, int enable)
> unsigned long flags;
>
> raw_spin_lock_irqsave(&handler->enable_lock, flags);
> - __plic_toggle(handler->enable_base, hwirq, enable);
> + __plic_toggle(handler, hwirq, enable);
> raw_spin_unlock_irqrestore(&handler->enable_lock, flags);
> }
>
> @@ -252,33 +259,16 @@ static int plic_irq_set_type(struct irq_data *d, unsigned int type)
>
> static int plic_irq_suspend(void *data)
> {
> - unsigned int i, cpu;
> - unsigned long flags;
> - u32 __iomem *reg;
> struct plic_priv *priv;
>
> priv = per_cpu_ptr(&plic_handlers, smp_processor_id())->priv;
>
> /* irq ID 0 is reserved */
> - for (i = 1; i < priv->nr_irqs; i++) {
> + for (unsigned int i = 1; i < priv->nr_irqs; i++) {
> __assign_bit(i, priv->prio_save,
> readl(priv->regs + PRIORITY_BASE + i * PRIORITY_PER_ID));
> }
>
> - for_each_present_cpu(cpu) {
> - struct plic_handler *handler = per_cpu_ptr(&plic_handlers, cpu);
> -
> - if (!handler->present)
> - continue;
> -
> - raw_spin_lock_irqsave(&handler->enable_lock, flags);
> - for (i = 0; i < DIV_ROUND_UP(priv->nr_irqs, 32); i++) {
> - reg = handler->enable_base + i * sizeof(u32);
> - handler->enable_save[i] = readl(reg);
> - }
> - raw_spin_unlock_irqrestore(&handler->enable_lock, flags);
> - }
> -
> return 0;
> }
>
>
Best—Charlie
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: Patch "irqchip/sifive-plic: Cache the interrupt enable state" has been added to the 6.18-stable tree
@ 2026-11-18 0:23 ` Sasha Levin
0 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2026-11-18 0:19 UTC (permalink / raw)
To: stable
Cc: Sasha Levin, stable-commits, Thomas Gleixner, Radu Rendec,
Paul Walmsley, Samuel Holland, Charles Mirabile
> This patch makes substantial changes to the driver and how it
> processes interrupts. I am not sure it is a great candidate for
> stable.
Agreed. I dropped it, and the BIT() fix that needed it, from the 6.18, 6.12,
6.6 and 6.1 queues. The same applies to your notices for the other three trees.
Could you send git-am-able BIT()-only backports of 0f214e5bbee5
("irqchip/sifive-plic: Avoid signed shift in interrupt enable mask"), one per
tree ([PATCH 6.18.y] through [PATCH 6.1.y])? I'll queue them. 7.3 already has
the cache patch in its base release, so it keeps the original fix.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Patch "irqchip/sifive-plic: Cache the interrupt enable state" has been added to the 6.18-stable tree
@ 2026-11-18 0:23 ` Sasha Levin
0 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2026-11-18 0:23 UTC (permalink / raw)
To: stable
Cc: stable-commits, Thomas Gleixner, Radu Rendec, Paul Walmsley,
Samuel Holland, Charles Mirabile
> This patch makes substantial changes to the driver and how it
> processes interrupts. I am not sure it is a great candidate for
> stable.
Agreed. I dropped it, and the BIT() fix that needed it, from the 6.18, 6.12,
6.6 and 6.1 queues. The same applies to your notices for the other three trees.
Could you send git-am-able BIT()-only backports of 0f214e5bbee5
("irqchip/sifive-plic: Avoid signed shift in interrupt enable mask"), one per
tree ([PATCH 6.18.y] through [PATCH 6.1.y])? I'll queue them. 7.3 already has
the cache patch in its base release, so it keeps the original fix.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask
2026-11-18 0:23 ` Sasha Levin
(?)
@ 2026-11-18 2:04 ` Charles Mirabile
-1 siblings, 0 replies; 4+ messages in thread
From: Charles Mirabile @ 2026-11-18 2:04 UTC (permalink / raw)
To: sashal
Cc: cmirabil, pjw, radu, samuel.holland, stable-commits, stable, tglx,
Pengpeng Hou
Hi—
On Tue, Nov 17, 2026 at 07:23:02PM -0500, Sasha Levin wrote:
> > This patch makes substantial changes to the driver and how it
> > processes interrupts. I am not sure it is a great candidate for
> > stable.
>
> Agreed. I dropped it, and the BIT() fix that needed it, from the 6.18, 6.12,
> 6.6 and 6.1 queues. The same applies to your notices for the other three trees.
>
> Could you send git-am-able BIT()-only backports of 0f214e5bbee5
> ("irqchip/sifive-plic: Avoid signed shift in interrupt enable mask"), one per
> tree ([PATCH 6.18.y] through [PATCH 6.1.y])? I'll queue them. 7.3 already has
> the cache patch in its base release, so it keeps the original fix.
The following (below the scissors) can be am'd on top of all of the trees.
I am not sure exactly what format is desirable for a stable commit, but I
did add the upstream commit hash and my SoB.
>
> --
> Thanks,
> Sasha
Best—Charlie
-- >8 --
commit 9ebdbab003ec949b3739f548f527c18b811d6568
Author: Pengpeng Hou <hppiscas@163.com>
Date: Sun, 20 Sep 2026 21:06:53 +0800
[Upstream commit 0f214e5bbee59d5952d3c061fd65ed9a1e175981]
__plic_toggle() builds a 32-bit interrupt enable mask using a signed
integer literal. A valid interrupt selecting bit 31 evaluates 1 << 31,
which shifts a signed int into its sign bit.
Use BIT(), matching the equivalent mask construction in plic_irq_eoi().
The resulting mask remains representable in u32 on both RV32 and RV64.
The issue was found by our static-analysis tool.
Fixes: 8237f8bc4f6e ("irqchip: add a SiFive PLIC driver")
Signed-off-by: Pengpeng Hou <hppiscas@163.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Assisted-by: gpt 5
Link: https://patch.msgid.link/caplitmus-rv.v2.plic.87a8fc444de44e109889ba28703c76f3@163.com
Signed-off-by: Charles Mirabile <cmirabil@redhat.com>
---
drivers/irqchip/irq-sifive-plic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
index ca70641982ed6..0995e1fdd5b47 100644
--- a/drivers/irqchip/irq-sifive-plic.c
+++ b/drivers/irqchip/irq-sifive-plic.c
@@ -97,7 +97,7 @@ static int plic_irq_set_type(struct irq_data *d, unsigned int type);
static void __plic_toggle(void __iomem *enable_base, int hwirq, int enable)
{
u32 __iomem *reg = enable_base + (hwirq / 32) * sizeof(u32);
- u32 hwirq_mask = 1 << (hwirq % 32);
+ u32 hwirq_mask = BIT(hwirq % 32);
if (enable)
writel(readl(reg) | hwirq_mask, reg);
--
2.56.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-18 2:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261117161945.1965350-1-sashal@kernel.org>
2026-11-17 17:01 ` Patch "irqchip/sifive-plic: Cache the interrupt enable state" has been added to the 6.18-stable tree Charles Mirabile
2026-11-18 0:19 ` Sasha Levin
2026-11-18 0:23 ` Sasha Levin
2026-11-18 2:04 ` [PATCH] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask Charles Mirabile
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.