Patch "irqchip/sifive-plic: Cache the interrupt enable state" has been added to the 6.6-stable tree
Subsystems (3)
Hi All—
Quoted 8 lines · Sasha Levin
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.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
Quoted 7 lines
The filename of the patch is:
irqchip-sifive-plic-cache-the-interrupt-enable-state.patch
and it can be found in the queue-6.6 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Yes, as with 6.12 and 6.18, I do not think that this makes sense for stable because it is a substantial refactor.
Quoted 22 lines
commit
4de7d81db4c2e56ddbad8b8c4ed6929f37605e2fAuthor: Charles Mirabile <[email protected]> Date: Fri Oct 24 09:36:42 2025 +0100irqchip/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_savearray 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 cachedenable_savestate atomically within the existingenable_lockprotection.That allows to remove the suspend-time enable register reading since
handler::enable_savenow always reflects the current state.
Quoted 7 lines
[ tglx: Massaged change log ]
Signed-off-by Charles Mirabile <[email protected]>Signed-off-by Lucas Zampieri <[email protected]>Signed-off-by Thomas Gleixner <[email protected]>Stable-dep-of:
0f214e5bbee5("irqchip/sifive-plic: Avoid signed shift in interrupt enable mask")
Instead of dragging in this commit to apply 0f214e5bbee5 ("irqchip/sifive-plic: Avoid signed shift in interrupt enable mask"), consider the following which applies on v6.6.162
(quoted diff) +0 -0
b/drivers/irqchip/irq-sifive-plic.c
index 794bdb6d4d1e3..a9f1e87fec166 100644
drivers/irqchip/irq-sifive-plic.c +0 -0
@@ -93,7 +93,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);
Quoted 68 lines
Signed-off-by Sasha Levin <[email protected]>drivers/irqchip/irq-sifive-plic.c +13
-16@@ -90,15 +90,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)@@ -106,7 +113,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); }@@ -251,33 +258,16 @@ static int plic_irq_set_type(struct irq_data *d, unsigned int type)static int plic_irq_suspend (void ) { -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);
drivers/irqchip/irq-sifive-plic.c static int plic_irq_set_type(struct irq_data *d, unsigned int type) · line 273
Quoted 10 lines
drivers/irqchip/irq-sifive-plic.c +0
-7-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