* [patch 0/7] genirq/generic_chip: Convert locking to guards
@ 2025-03-13 14:31 Thomas Gleixner
2025-03-13 14:31 ` [patch 1/7] genirq/generic-chip: Make locking unconditional Thomas Gleixner
` (7 more replies)
0 siblings, 8 replies; 26+ messages in thread
From: Thomas Gleixner @ 2025-03-13 14:31 UTC (permalink / raw)
To: LKML
Cc: Jiri Slaby, Andrew Lunn, Sebastian Hesselbarth, Gregory Clement,
Uwe Kleine-König, Linus Walleij, Bartosz Golaszewski,
Talel Shenhar, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Florian Fainelli, Guo Ren, Herve Codina, Huacai Chen, Jiaxun Yang,
Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
The following series converts the generic chip locking to lock guards,
which reduces code size and improves readability.
The conversion was largely done with Coccinelle.
The series applies on Linus tree and is available from git:
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git irq/generic-chip
Thanks,
tglx
---
arch/arm/plat-orion/gpio.c | 6 +---
drivers/gpio/gpio-mvebu.c | 15 +++-------
drivers/irqchip/irq-al-fic.c | 18 +++---------
drivers/irqchip/irq-atmel-aic.c | 19 ++++---------
drivers/irqchip/irq-atmel-aic5.c | 28 +++++--------------
drivers/irqchip/irq-bcm7120-l2.c | 22 ++++++---------
drivers/irqchip/irq-brcmstb-l2.c | 8 +----
drivers/irqchip/irq-csky-apb-intc.c | 3 --
drivers/irqchip/irq-dw-apb-ictl.c | 3 --
drivers/irqchip/irq-ingenic-tcu.c | 9 ++----
drivers/irqchip/irq-lan966x-oic.c | 18 ++++--------
drivers/irqchip/irq-loongson-liointc.c | 9 +-----
drivers/irqchip/irq-mscc-ocelot.c | 3 --
drivers/irqchip/irq-stm32-exti.c | 21 ++++----------
drivers/irqchip/irq-sunxi-nmi.c | 9 +-----
drivers/irqchip/irq-tb10x.c | 13 ++-------
drivers/soc/dove/pmu.c | 3 --
include/linux/irq.h | 25 -----------------
kernel/irq/generic-chip.c | 47 +++++++++++----------------------
19 files changed, 80 insertions(+), 199 deletions(-)
^ permalink raw reply [flat|nested] 26+ messages in thread
* [patch 1/7] genirq/generic-chip: Make locking unconditional
2025-03-13 14:31 [patch 0/7] genirq/generic_chip: Convert locking to guards Thomas Gleixner
@ 2025-03-13 14:31 ` Thomas Gleixner
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2025-03-13 14:31 ` [patch 2/7] genirq/generic-chip: Convert core code to lock guards Thomas Gleixner
` (6 subsequent siblings)
7 siblings, 1 reply; 26+ messages in thread
From: Thomas Gleixner @ 2025-03-13 14:31 UTC (permalink / raw)
To: LKML
Cc: Jiri Slaby, Andrew Lunn, Sebastian Hesselbarth, Gregory Clement,
Uwe Kleine-König, Linus Walleij, Bartosz Golaszewski,
Talel Shenhar, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Florian Fainelli, Guo Ren, Herve Codina, Huacai Chen, Jiaxun Yang,
Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
The SMP conditional wrappers around raw_spin_[un]lock() have no real
value. On !SMP kernels the lock operations are NOOPs except for a
preempt_disable/enable() pair on PREEMPT enabled kernels, which are not
really worth to optimize for. Aside of that this evades lockdep on !SMP
kernels.
Remove the !SMP stubs and make it unconditional.
No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/irq.h | 5 -----
1 file changed, 5 deletions(-)
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -1219,7 +1219,6 @@ static inline struct irq_chip_type *irq_
#define IRQ_MSK(n) (u32)((n) < 32 ? ((1 << (n)) - 1) : UINT_MAX)
-#ifdef CONFIG_SMP
static inline void irq_gc_lock(struct irq_chip_generic *gc)
{
raw_spin_lock(&gc->lock);
@@ -1229,10 +1228,6 @@ static inline void irq_gc_unlock(struct
{
raw_spin_unlock(&gc->lock);
}
-#else
-static inline void irq_gc_lock(struct irq_chip_generic *gc) { }
-static inline void irq_gc_unlock(struct irq_chip_generic *gc) { }
-#endif
/*
* The irqsave variants are for usage in non interrupt code. Do not use
^ permalink raw reply [flat|nested] 26+ messages in thread
* [patch 2/7] genirq/generic-chip: Convert core code to lock guards
2025-03-13 14:31 [patch 0/7] genirq/generic_chip: Convert locking to guards Thomas Gleixner
2025-03-13 14:31 ` [patch 1/7] genirq/generic-chip: Make locking unconditional Thomas Gleixner
@ 2025-03-13 14:31 ` Thomas Gleixner
2025-03-14 10:55 ` Linus Walleij
` (2 more replies)
2025-03-13 14:31 ` [patch 3/7] soc: dove: Convert generic irqchip locking to guard() Thomas Gleixner
` (5 subsequent siblings)
7 siblings, 3 replies; 26+ messages in thread
From: Thomas Gleixner @ 2025-03-13 14:31 UTC (permalink / raw)
To: LKML
Cc: Jiri Slaby, Andrew Lunn, Sebastian Hesselbarth, Gregory Clement,
Uwe Kleine-König, Linus Walleij, Bartosz Golaszewski,
Talel Shenhar, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Florian Fainelli, Guo Ren, Herve Codina, Huacai Chen, Jiaxun Yang,
Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
Replace the irq_gc_lock/unlock() pairs with guards. There is no point to
implement a guard wrapper for them as they just wrap around raw_spin_lock*().
Switch the other lock instances in the core code to guards as well.
Conversion was done with Coccinelle plus manual fixups.
No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
kernel/irq/generic-chip.c | 47 +++++++++++++++-------------------------------
1 file changed, 16 insertions(+), 31 deletions(-)
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -40,10 +40,9 @@ void irq_gc_mask_disable_reg(struct irq_
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, mask, ct->regs.disable);
*ct->mask_cache &= ~mask;
- irq_gc_unlock(gc);
}
EXPORT_SYMBOL_GPL(irq_gc_mask_disable_reg);
@@ -60,10 +59,9 @@ void irq_gc_mask_set_bit(struct irq_data
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
*ct->mask_cache |= mask;
irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask);
- irq_gc_unlock(gc);
}
EXPORT_SYMBOL_GPL(irq_gc_mask_set_bit);
@@ -80,10 +78,9 @@ void irq_gc_mask_clr_bit(struct irq_data
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
*ct->mask_cache &= ~mask;
irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask);
- irq_gc_unlock(gc);
}
EXPORT_SYMBOL_GPL(irq_gc_mask_clr_bit);
@@ -100,10 +97,9 @@ void irq_gc_unmask_enable_reg(struct irq
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, mask, ct->regs.enable);
*ct->mask_cache |= mask;
- irq_gc_unlock(gc);
}
EXPORT_SYMBOL_GPL(irq_gc_unmask_enable_reg);
@@ -117,9 +113,8 @@ void irq_gc_ack_set_bit(struct irq_data
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, mask, ct->regs.ack);
- irq_gc_unlock(gc);
}
EXPORT_SYMBOL_GPL(irq_gc_ack_set_bit);
@@ -133,9 +128,8 @@ void irq_gc_ack_clr_bit(struct irq_data
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = ~d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, mask, ct->regs.ack);
- irq_gc_unlock(gc);
}
/**
@@ -156,11 +150,10 @@ void irq_gc_mask_disable_and_ack_set(str
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, mask, ct->regs.disable);
*ct->mask_cache &= ~mask;
irq_reg_writel(gc, mask, ct->regs.ack);
- irq_gc_unlock(gc);
}
EXPORT_SYMBOL_GPL(irq_gc_mask_disable_and_ack_set);
@@ -174,9 +167,8 @@ void irq_gc_eoi(struct irq_data *d)
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, mask, ct->regs.eoi);
- irq_gc_unlock(gc);
}
/**
@@ -196,12 +188,11 @@ int irq_gc_set_wake(struct irq_data *d,
if (!(mask & gc->wake_enabled))
return -EINVAL;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
if (on)
gc->wake_active |= mask;
else
gc->wake_active &= ~mask;
- irq_gc_unlock(gc);
return 0;
}
EXPORT_SYMBOL_GPL(irq_gc_set_wake);
@@ -288,7 +279,6 @@ int irq_domain_alloc_generic_chips(struc
{
struct irq_domain_chip_generic *dgc;
struct irq_chip_generic *gc;
- unsigned long flags;
int numchips, i;
size_t dgc_sz;
size_t gc_sz;
@@ -340,9 +330,8 @@ int irq_domain_alloc_generic_chips(struc
goto err;
}
- raw_spin_lock_irqsave(&gc_lock, flags);
- list_add_tail(&gc->list, &gc_list);
- raw_spin_unlock_irqrestore(&gc_lock, flags);
+ scoped_guard (raw_spinlock, &gc_lock)
+ list_add_tail(&gc->list, &gc_list);
/* Calc pointer to the next generic chip */
tmp += gc_sz;
}
@@ -459,7 +448,6 @@ int irq_map_generic_chip(struct irq_doma
struct irq_chip_generic *gc;
struct irq_chip_type *ct;
struct irq_chip *chip;
- unsigned long flags;
int idx;
gc = __irq_get_domain_generic_chip(d, hw_irq);
@@ -479,9 +467,8 @@ int irq_map_generic_chip(struct irq_doma
/* We only init the cache for the first mapping of a generic chip */
if (!gc->installed) {
- raw_spin_lock_irqsave(&gc->lock, flags);
+ guard(raw_spinlock_irq)(&gc->lock);
irq_gc_init_mask_cache(gc, dgc->gc_flags);
- raw_spin_unlock_irqrestore(&gc->lock, flags);
}
/* Mark the interrupt as installed */
@@ -548,9 +535,8 @@ void irq_setup_generic_chip(struct irq_c
struct irq_chip *chip = &ct->chip;
unsigned int i;
- raw_spin_lock(&gc_lock);
- list_add_tail(&gc->list, &gc_list);
- raw_spin_unlock(&gc_lock);
+ scoped_guard (raw_spinlock, &gc_lock)
+ list_add_tail(&gc->list, &gc_list);
irq_gc_init_mask_cache(gc, flags);
@@ -616,9 +602,8 @@ void irq_remove_generic_chip(struct irq_
{
unsigned int i, virq;
- raw_spin_lock(&gc_lock);
- list_del(&gc->list);
- raw_spin_unlock(&gc_lock);
+ scoped_guard (raw_spinlock, &gc_lock)
+ list_del(&gc->list);
for (i = 0; msk; msk >>= 1, i++) {
if (!(msk & 0x01))
^ permalink raw reply [flat|nested] 26+ messages in thread
* [patch 3/7] soc: dove: Convert generic irqchip locking to guard()
2025-03-13 14:31 [patch 0/7] genirq/generic_chip: Convert locking to guards Thomas Gleixner
2025-03-13 14:31 ` [patch 1/7] genirq/generic-chip: Make locking unconditional Thomas Gleixner
2025-03-13 14:31 ` [patch 2/7] genirq/generic-chip: Convert core code to lock guards Thomas Gleixner
@ 2025-03-13 14:31 ` Thomas Gleixner
2025-03-13 14:48 ` Andrew Lunn
` (2 more replies)
2025-03-13 14:31 ` [patch 4/7] ARM: orion/gpio:: " Thomas Gleixner
` (4 subsequent siblings)
7 siblings, 3 replies; 26+ messages in thread
From: Thomas Gleixner @ 2025-03-13 14:31 UTC (permalink / raw)
To: LKML
Cc: Jiri Slaby, Andrew Lunn, Sebastian Hesselbarth, Gregory Clement,
Uwe Kleine-König, Linus Walleij, Bartosz Golaszewski,
Talel Shenhar, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Florian Fainelli, Guo Ren, Herve Codina, Huacai Chen, Jiaxun Yang,
Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
Conversion was done with Coccinelle. No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Gregory Clement <gregory.clement@bootlin.com>
---
drivers/soc/dove/pmu.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/drivers/soc/dove/pmu.c
+++ b/drivers/soc/dove/pmu.c
@@ -257,10 +257,9 @@ static void pmu_irq_handler(struct irq_d
* So, let's structure the code so that the window is as small as
* possible.
*/
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
done &= readl_relaxed(base + PMC_IRQ_CAUSE);
writel_relaxed(done, base + PMC_IRQ_CAUSE);
- irq_gc_unlock(gc);
}
static int __init dove_init_pmu_irq(struct pmu_data *pmu, int irq)
^ permalink raw reply [flat|nested] 26+ messages in thread
* [patch 4/7] ARM: orion/gpio:: Convert generic irqchip locking to guard()
2025-03-13 14:31 [patch 0/7] genirq/generic_chip: Convert locking to guards Thomas Gleixner
` (2 preceding siblings ...)
2025-03-13 14:31 ` [patch 3/7] soc: dove: Convert generic irqchip locking to guard() Thomas Gleixner
@ 2025-03-13 14:31 ` Thomas Gleixner
2025-03-14 10:56 ` Linus Walleij
` (2 more replies)
2025-03-13 14:31 ` [patch 5/7] gpio: mvebu: " Thomas Gleixner
` (3 subsequent siblings)
7 siblings, 3 replies; 26+ messages in thread
From: Thomas Gleixner @ 2025-03-13 14:31 UTC (permalink / raw)
To: LKML
Cc: Jiri Slaby, Andrew Lunn, Sebastian Hesselbarth, Gregory Clement,
Uwe Kleine-König, Linus Walleij, Bartosz Golaszewski,
Talel Shenhar, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Florian Fainelli, Guo Ren, Herve Codina, Huacai Chen, Jiaxun Yang,
Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
Conversion was done with Coccinelle. No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Gregory Clement <gregory.clement@bootlin.com>
---
arch/arm/plat-orion/gpio.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
--- a/arch/arm/plat-orion/gpio.c
+++ b/arch/arm/plat-orion/gpio.c
@@ -496,11 +496,10 @@ static void orion_gpio_unmask_irq(struct
u32 reg_val;
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
reg_val = irq_reg_readl(gc, ct->regs.mask);
reg_val |= mask;
irq_reg_writel(gc, reg_val, ct->regs.mask);
- irq_gc_unlock(gc);
}
static void orion_gpio_mask_irq(struct irq_data *d)
@@ -510,11 +509,10 @@ static void orion_gpio_mask_irq(struct i
u32 mask = d->mask;
u32 reg_val;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
reg_val = irq_reg_readl(gc, ct->regs.mask);
reg_val &= ~mask;
irq_reg_writel(gc, reg_val, ct->regs.mask);
- irq_gc_unlock(gc);
}
void __init orion_gpio_init(int gpio_base, int ngpio,
^ permalink raw reply [flat|nested] 26+ messages in thread
* [patch 5/7] gpio: mvebu: Convert generic irqchip locking to guard()
2025-03-13 14:31 [patch 0/7] genirq/generic_chip: Convert locking to guards Thomas Gleixner
` (3 preceding siblings ...)
2025-03-13 14:31 ` [patch 4/7] ARM: orion/gpio:: " Thomas Gleixner
@ 2025-03-13 14:31 ` Thomas Gleixner
2025-03-14 10:19 ` Bartosz Golaszewski
` (2 more replies)
2025-03-13 14:31 ` [patch 6/7] irqchip: Convert generic irqchip locking to guards Thomas Gleixner
` (2 subsequent siblings)
7 siblings, 3 replies; 26+ messages in thread
From: Thomas Gleixner @ 2025-03-13 14:31 UTC (permalink / raw)
To: LKML
Cc: Jiri Slaby, Uwe Kleine-König, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Sebastian Hesselbarth,
Gregory Clement, Talel Shenhar, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, Florian Fainelli, Guo Ren, Herve Codina,
Huacai Chen, Jiaxun Yang, Maxime Coquelin, Alexandre Torgue,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: "Uwe Kleine-König" <ukleinek@kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>
---
drivers/gpio/gpio-mvebu.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -407,9 +407,8 @@ static void mvebu_gpio_irq_ack(struct ir
struct mvebu_gpio_chip *mvchip = gc->private;
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
mvebu_gpio_write_edge_cause(mvchip, ~mask);
- irq_gc_unlock(gc);
}
static void mvebu_gpio_edge_irq_mask(struct irq_data *d)
@@ -419,10 +418,9 @@ static void mvebu_gpio_edge_irq_mask(str
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
ct->mask_cache_priv &= ~mask;
mvebu_gpio_write_edge_mask(mvchip, ct->mask_cache_priv);
- irq_gc_unlock(gc);
}
static void mvebu_gpio_edge_irq_unmask(struct irq_data *d)
@@ -432,11 +430,10 @@ static void mvebu_gpio_edge_irq_unmask(s
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
mvebu_gpio_write_edge_cause(mvchip, ~mask);
ct->mask_cache_priv |= mask;
mvebu_gpio_write_edge_mask(mvchip, ct->mask_cache_priv);
- irq_gc_unlock(gc);
}
static void mvebu_gpio_level_irq_mask(struct irq_data *d)
@@ -446,10 +443,9 @@ static void mvebu_gpio_level_irq_mask(st
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
ct->mask_cache_priv &= ~mask;
mvebu_gpio_write_level_mask(mvchip, ct->mask_cache_priv);
- irq_gc_unlock(gc);
}
static void mvebu_gpio_level_irq_unmask(struct irq_data *d)
@@ -459,10 +455,9 @@ static void mvebu_gpio_level_irq_unmask(
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
ct->mask_cache_priv |= mask;
mvebu_gpio_write_level_mask(mvchip, ct->mask_cache_priv);
- irq_gc_unlock(gc);
}
/*****************************************************************************
^ permalink raw reply [flat|nested] 26+ messages in thread
* [patch 6/7] irqchip: Convert generic irqchip locking to guards
2025-03-13 14:31 [patch 0/7] genirq/generic_chip: Convert locking to guards Thomas Gleixner
` (4 preceding siblings ...)
2025-03-13 14:31 ` [patch 5/7] gpio: mvebu: " Thomas Gleixner
@ 2025-03-13 14:31 ` Thomas Gleixner
2025-03-14 10:56 ` Linus Walleij
` (2 more replies)
2025-03-13 14:31 ` [patch 7/7] genirq/generic-chip: Remove unused lock wrappers Thomas Gleixner
2025-03-16 8:50 ` [patch 0/7] genirq/generic_chip: Convert locking to guards Markus Elfring
7 siblings, 3 replies; 26+ messages in thread
From: Thomas Gleixner @ 2025-03-13 14:31 UTC (permalink / raw)
To: LKML
Cc: Jiri Slaby, Talel Shenhar, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, Florian Fainelli, Guo Ren, Herve Codina,
Huacai Chen, Jiaxun Yang, Maxime Coquelin, Alexandre Torgue,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Uwe Kleine-König,
Linus Walleij, Bartosz Golaszewski
Conversion was done with Coccinelle and a few manual fixups.
In a few interrupt chip callbacks this changes replaces
raw_spin_lock_irqsave() with a guard(raw_spinlock). That's intended and
correct because those interrupt chip callbacks are invoked with the
interrupt descriptor lock held and interrupts disabled. No point in using
the irqsave variant.
No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Talel Shenhar <talel@amazon.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Cc: Florian Fainelli <florian.fainelli@broadcom.com>
Cc: Guo Ren <guoren@kernel.org>
Cc: Herve Codina <herve.codina@bootlin.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Chen-Yu Tsai <wens@csie.org>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: Samuel Holland <samuel@sholland.org>
---
drivers/irqchip/irq-al-fic.c | 18 +++++-------------
drivers/irqchip/irq-atmel-aic.c | 19 ++++++-------------
drivers/irqchip/irq-atmel-aic5.c | 28 ++++++++--------------------
drivers/irqchip/irq-bcm7120-l2.c | 22 +++++++++-------------
drivers/irqchip/irq-brcmstb-l2.c | 8 ++------
drivers/irqchip/irq-csky-apb-intc.c | 3 +--
drivers/irqchip/irq-dw-apb-ictl.c | 3 +--
drivers/irqchip/irq-ingenic-tcu.c | 9 +++------
drivers/irqchip/irq-lan966x-oic.c | 18 +++++++-----------
drivers/irqchip/irq-loongson-liointc.c | 9 ++-------
drivers/irqchip/irq-mscc-ocelot.c | 3 +--
drivers/irqchip/irq-stm32-exti.c | 21 ++++++---------------
drivers/irqchip/irq-sunxi-nmi.c | 9 ++-------
drivers/irqchip/irq-tb10x.c | 13 +++----------
14 files changed, 56 insertions(+), 127 deletions(-)
--- a/drivers/irqchip/irq-al-fic.c
+++ b/drivers/irqchip/irq-al-fic.c
@@ -65,15 +65,13 @@ static int al_fic_irq_set_type(struct ir
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data);
struct al_fic *fic = gc->private;
enum al_fic_state new_state;
- int ret = 0;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
if (((flow_type & IRQ_TYPE_SENSE_MASK) != IRQ_TYPE_LEVEL_HIGH) &&
((flow_type & IRQ_TYPE_SENSE_MASK) != IRQ_TYPE_EDGE_RISING)) {
pr_debug("fic doesn't support flow type %d\n", flow_type);
- ret = -EINVAL;
- goto err;
+ return -EINVAL;
}
new_state = (flow_type & IRQ_TYPE_LEVEL_HIGH) ?
@@ -91,16 +89,10 @@ static int al_fic_irq_set_type(struct ir
if (fic->state == AL_FIC_UNCONFIGURED) {
al_fic_set_trigger(fic, gc, new_state);
} else if (fic->state != new_state) {
- pr_debug("fic %s state already configured to %d\n",
- fic->name, fic->state);
- ret = -EINVAL;
- goto err;
+ pr_debug("fic %s state already configured to %d\n", fic->name, fic->state);
+ return -EINVAL;
}
-
-err:
- irq_gc_unlock(gc);
-
- return ret;
+ return 0;
}
static void al_fic_irq_handler(struct irq_desc *desc)
--- a/drivers/irqchip/irq-atmel-aic.c
+++ b/drivers/irqchip/irq-atmel-aic.c
@@ -78,9 +78,8 @@ static int aic_retrigger(struct irq_data
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
/* Enable interrupt on AIC5 */
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, d->mask, AT91_AIC_ISCR);
- irq_gc_unlock(gc);
return 1;
}
@@ -106,30 +105,27 @@ static void aic_suspend(struct irq_data
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, gc->mask_cache, AT91_AIC_IDCR);
irq_reg_writel(gc, gc->wake_active, AT91_AIC_IECR);
- irq_gc_unlock(gc);
}
static void aic_resume(struct irq_data *d)
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, gc->wake_active, AT91_AIC_IDCR);
irq_reg_writel(gc, gc->mask_cache, AT91_AIC_IECR);
- irq_gc_unlock(gc);
}
static void aic_pm_shutdown(struct irq_data *d)
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, 0xffffffff, AT91_AIC_IDCR);
irq_reg_writel(gc, 0xffffffff, AT91_AIC_ICCR);
- irq_gc_unlock(gc);
}
#else
#define aic_suspend NULL
@@ -175,10 +171,8 @@ static int aic_irq_domain_xlate(struct i
{
struct irq_domain_chip_generic *dgc = d->gc;
struct irq_chip_generic *gc;
- unsigned long flags;
unsigned smr;
- int idx;
- int ret;
+ int idx, ret;
if (!dgc)
return -EINVAL;
@@ -194,11 +188,10 @@ static int aic_irq_domain_xlate(struct i
gc = dgc->gc[idx];
- irq_gc_lock_irqsave(gc, flags);
+ guard(raw_spinlock_irq)(&gc->lock);
smr = irq_reg_readl(gc, AT91_AIC_SMR(*out_hwirq));
aic_common_set_priority(intspec[2], &smr);
irq_reg_writel(gc, smr, AT91_AIC_SMR(*out_hwirq));
- irq_gc_unlock_irqrestore(gc, flags);
return ret;
}
--- a/drivers/irqchip/irq-atmel-aic5.c
+++ b/drivers/irqchip/irq-atmel-aic5.c
@@ -92,11 +92,10 @@ static void aic5_mask(struct irq_data *d
* Disable interrupt on AIC5. We always take the lock of the
* first irq chip as all chips share the same registers.
*/
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
irq_reg_writel(gc, d->hwirq, AT91_AIC5_SSR);
irq_reg_writel(gc, 1, AT91_AIC5_IDCR);
gc->mask_cache &= ~d->mask;
- irq_gc_unlock(bgc);
}
static void aic5_unmask(struct irq_data *d)
@@ -109,11 +108,10 @@ static void aic5_unmask(struct irq_data
* Enable interrupt on AIC5. We always take the lock of the
* first irq chip as all chips share the same registers.
*/
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
irq_reg_writel(gc, d->hwirq, AT91_AIC5_SSR);
irq_reg_writel(gc, 1, AT91_AIC5_IECR);
gc->mask_cache |= d->mask;
- irq_gc_unlock(bgc);
}
static int aic5_retrigger(struct irq_data *d)
@@ -122,11 +120,9 @@ static int aic5_retrigger(struct irq_dat
struct irq_chip_generic *bgc = irq_get_domain_generic_chip(domain, 0);
/* Enable interrupt on AIC5 */
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
irq_reg_writel(bgc, d->hwirq, AT91_AIC5_SSR);
irq_reg_writel(bgc, 1, AT91_AIC5_ISCR);
- irq_gc_unlock(bgc);
-
return 1;
}
@@ -137,14 +133,12 @@ static int aic5_set_type(struct irq_data
unsigned int smr;
int ret;
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
irq_reg_writel(bgc, d->hwirq, AT91_AIC5_SSR);
smr = irq_reg_readl(bgc, AT91_AIC5_SMR);
ret = aic_common_set_type(d, type, &smr);
if (!ret)
irq_reg_writel(bgc, smr, AT91_AIC5_SMR);
- irq_gc_unlock(bgc);
-
return ret;
}
@@ -166,7 +160,7 @@ static void aic5_suspend(struct irq_data
smr_cache[i] = irq_reg_readl(bgc, AT91_AIC5_SMR);
}
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
for (i = 0; i < dgc->irqs_per_chip; i++) {
mask = 1 << i;
if ((mask & gc->mask_cache) == (mask & gc->wake_active))
@@ -178,7 +172,6 @@ static void aic5_suspend(struct irq_data
else
irq_reg_writel(bgc, 1, AT91_AIC5_IDCR);
}
- irq_gc_unlock(bgc);
}
static void aic5_resume(struct irq_data *d)
@@ -190,7 +183,7 @@ static void aic5_resume(struct irq_data
int i;
u32 mask;
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
if (smr_cache) {
irq_reg_writel(bgc, 0xffffffff, AT91_AIC5_SPU);
@@ -214,7 +207,6 @@ static void aic5_resume(struct irq_data
else
irq_reg_writel(bgc, 1, AT91_AIC5_IDCR);
}
- irq_gc_unlock(bgc);
}
static void aic5_pm_shutdown(struct irq_data *d)
@@ -225,13 +217,12 @@ static void aic5_pm_shutdown(struct irq_
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
int i;
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
for (i = 0; i < dgc->irqs_per_chip; i++) {
irq_reg_writel(bgc, i + gc->irq_base, AT91_AIC5_SSR);
irq_reg_writel(bgc, 1, AT91_AIC5_IDCR);
irq_reg_writel(bgc, 1, AT91_AIC5_ICCR);
}
- irq_gc_unlock(bgc);
}
#else
#define aic5_suspend NULL
@@ -277,7 +268,6 @@ static int aic5_irq_domain_xlate(struct
unsigned int *out_type)
{
struct irq_chip_generic *bgc = irq_get_domain_generic_chip(d, 0);
- unsigned long flags;
unsigned smr;
int ret;
@@ -289,13 +279,11 @@ static int aic5_irq_domain_xlate(struct
if (ret)
return ret;
- irq_gc_lock_irqsave(bgc, flags);
+ guard(raw_spinlock_irq)(&bgc->lock);
irq_reg_writel(bgc, *out_hwirq, AT91_AIC5_SSR);
smr = irq_reg_readl(bgc, AT91_AIC5_SMR);
aic_common_set_priority(intspec[2], &smr);
irq_reg_writel(bgc, smr, AT91_AIC5_SMR);
- irq_gc_unlock_irqrestore(bgc, flags);
-
return ret;
}
--- a/drivers/irqchip/irq-bcm7120-l2.c
+++ b/drivers/irqchip/irq-bcm7120-l2.c
@@ -63,16 +63,15 @@ static void bcm7120_l2_intc_irq_handle(s
for (idx = 0; idx < b->n_words; idx++) {
int base = idx * IRQS_PER_WORD;
- struct irq_chip_generic *gc =
- irq_get_domain_generic_chip(b->domain, base);
+ struct irq_chip_generic *gc;
unsigned long pending;
int hwirq;
- irq_gc_lock(gc);
- pending = irq_reg_readl(gc, b->stat_offset[idx]) &
- gc->mask_cache &
- data->irq_map_mask[idx];
- irq_gc_unlock(gc);
+ gc = irq_get_domain_generic_chip(b->domain, base);
+ scoped_guard (raw_spinlock, &gc->lock) {
+ pending = irq_reg_readl(gc, b->stat_offset[idx]) & gc->mask_cache &
+ data->irq_map_mask[idx];
+ }
for_each_set_bit(hwirq, &pending, IRQS_PER_WORD)
generic_handle_domain_irq(b->domain, base + hwirq);
@@ -86,11 +85,9 @@ static void bcm7120_l2_intc_suspend(stru
struct bcm7120_l2_intc_data *b = gc->private;
struct irq_chip_type *ct = gc->chip_types;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
if (b->can_wake)
- irq_reg_writel(gc, gc->mask_cache | gc->wake_active,
- ct->regs.mask);
- irq_gc_unlock(gc);
+ irq_reg_writel(gc, gc->mask_cache | gc->wake_active, ct->regs.mask);
}
static void bcm7120_l2_intc_resume(struct irq_chip_generic *gc)
@@ -98,9 +95,8 @@ static void bcm7120_l2_intc_resume(struc
struct irq_chip_type *ct = gc->chip_types;
/* Restore the saved mask */
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, gc->mask_cache, ct->regs.mask);
- irq_gc_unlock(gc);
}
static int bcm7120_l2_intc_init_one(struct device_node *dn,
--- a/drivers/irqchip/irq-brcmstb-l2.c
+++ b/drivers/irqchip/irq-brcmstb-l2.c
@@ -97,9 +97,8 @@ static void __brcmstb_l2_intc_suspend(st
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
struct irq_chip_type *ct = irq_data_get_chip_type(d);
struct brcmstb_l2_intc_data *b = gc->private;
- unsigned long flags;
- irq_gc_lock_irqsave(gc, flags);
+ guard(raw_spinlock_irqsave)(&gc->lock);
/* Save the current mask */
if (save)
b->saved_mask = irq_reg_readl(gc, ct->regs.mask);
@@ -109,7 +108,6 @@ static void __brcmstb_l2_intc_suspend(st
irq_reg_writel(gc, ~gc->wake_active, ct->regs.disable);
irq_reg_writel(gc, gc->wake_active, ct->regs.enable);
}
- irq_gc_unlock_irqrestore(gc, flags);
}
static void brcmstb_l2_intc_shutdown(struct irq_data *d)
@@ -127,9 +125,8 @@ static void brcmstb_l2_intc_resume(struc
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
struct irq_chip_type *ct = irq_data_get_chip_type(d);
struct brcmstb_l2_intc_data *b = gc->private;
- unsigned long flags;
- irq_gc_lock_irqsave(gc, flags);
+ guard(raw_spinlock_irqsave)(&gc->lock);
if (ct->chip.irq_ack) {
/* Clear unmasked non-wakeup interrupts */
irq_reg_writel(gc, ~b->saved_mask & ~gc->wake_active,
@@ -139,7 +136,6 @@ static void brcmstb_l2_intc_resume(struc
/* Restore the saved mask */
irq_reg_writel(gc, b->saved_mask, ct->regs.disable);
irq_reg_writel(gc, ~b->saved_mask, ct->regs.enable);
- irq_gc_unlock_irqrestore(gc, flags);
}
static int __init brcmstb_l2_intc_of_init(struct device_node *np,
--- a/drivers/irqchip/irq-csky-apb-intc.c
+++ b/drivers/irqchip/irq-csky-apb-intc.c
@@ -50,11 +50,10 @@ static void irq_ck_mask_set_bit(struct i
unsigned long ifr = ct->regs.mask - 8;
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
*ct->mask_cache |= mask;
irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask);
irq_reg_writel(gc, irq_reg_readl(gc, ifr) & ~mask, ifr);
- irq_gc_unlock(gc);
}
static void __init ck_set_gc(struct device_node *node, void __iomem *reg_base,
--- a/drivers/irqchip/irq-dw-apb-ictl.c
+++ b/drivers/irqchip/irq-dw-apb-ictl.c
@@ -101,10 +101,9 @@ static void dw_apb_ictl_resume(struct ir
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
struct irq_chip_type *ct = irq_data_get_chip_type(d);
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
writel_relaxed(~0, gc->reg_base + ct->regs.enable);
writel_relaxed(*ct->mask_cache, gc->reg_base + ct->regs.mask);
- irq_gc_unlock(gc);
}
#else
#define dw_apb_ictl_resume NULL
--- a/drivers/irqchip/irq-ingenic-tcu.c
+++ b/drivers/irqchip/irq-ingenic-tcu.c
@@ -52,11 +52,10 @@ static void ingenic_tcu_gc_unmask_enable
struct regmap *map = gc->private;
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
regmap_write(map, ct->regs.ack, mask);
regmap_write(map, ct->regs.enable, mask);
*ct->mask_cache |= mask;
- irq_gc_unlock(gc);
}
static void ingenic_tcu_gc_mask_disable_reg(struct irq_data *d)
@@ -66,10 +65,9 @@ static void ingenic_tcu_gc_mask_disable_
struct regmap *map = gc->private;
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
regmap_write(map, ct->regs.disable, mask);
*ct->mask_cache &= ~mask;
- irq_gc_unlock(gc);
}
static void ingenic_tcu_gc_mask_disable_reg_and_ack(struct irq_data *d)
@@ -79,10 +77,9 @@ static void ingenic_tcu_gc_mask_disable_
struct regmap *map = gc->private;
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
regmap_write(map, ct->regs.ack, mask);
regmap_write(map, ct->regs.disable, mask);
- irq_gc_unlock(gc);
}
static int __init ingenic_tcu_irq_init(struct device_node *np,
--- a/drivers/irqchip/irq-lan966x-oic.c
+++ b/drivers/irqchip/irq-lan966x-oic.c
@@ -71,14 +71,12 @@ static unsigned int lan966x_oic_irq_star
struct lan966x_oic_chip_regs *chip_regs = gc->private;
u32 map;
- irq_gc_lock(gc);
-
- /* Map the source interrupt to the destination */
- map = irq_reg_readl(gc, chip_regs->reg_off_map);
- map |= data->mask;
- irq_reg_writel(gc, map, chip_regs->reg_off_map);
-
- irq_gc_unlock(gc);
+ scoped_guard (raw_spinlock, &gc->lock) {
+ /* Map the source interrupt to the destination */
+ map = irq_reg_readl(gc, chip_regs->reg_off_map);
+ map |= data->mask;
+ irq_reg_writel(gc, map, chip_regs->reg_off_map);
+ }
ct->chip.irq_ack(data);
ct->chip.irq_unmask(data);
@@ -95,14 +93,12 @@ static void lan966x_oic_irq_shutdown(str
ct->chip.irq_mask(data);
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
/* Unmap the interrupt */
map = irq_reg_readl(gc, chip_regs->reg_off_map);
map &= ~data->mask;
irq_reg_writel(gc, map, chip_regs->reg_off_map);
-
- irq_gc_unlock(gc);
}
static int lan966x_oic_irq_set_type(struct irq_data *data,
--- a/drivers/irqchip/irq-loongson-liointc.c
+++ b/drivers/irqchip/irq-loongson-liointc.c
@@ -116,9 +116,8 @@ static int liointc_set_type(struct irq_d
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data);
u32 mask = data->mask;
- unsigned long flags;
- irq_gc_lock_irqsave(gc, flags);
+ guard(raw_spinlock)(&gc->lock);
switch (type) {
case IRQ_TYPE_LEVEL_HIGH:
liointc_set_bit(gc, LIOINTC_REG_INTC_EDGE, mask, false);
@@ -137,10 +136,8 @@ static int liointc_set_type(struct irq_d
liointc_set_bit(gc, LIOINTC_REG_INTC_POL, mask, true);
break;
default:
- irq_gc_unlock_irqrestore(gc, flags);
return -EINVAL;
}
- irq_gc_unlock_irqrestore(gc, flags);
irqd_set_trigger_type(data, type);
return 0;
@@ -157,10 +154,9 @@ static void liointc_suspend(struct irq_c
static void liointc_resume(struct irq_chip_generic *gc)
{
struct liointc_priv *priv = gc->private;
- unsigned long flags;
int i;
- irq_gc_lock_irqsave(gc, flags);
+ guard(raw_spinlock_irqsave)(&gc->lock);
/* Disable all at first */
writel(0xffffffff, gc->reg_base + LIOINTC_REG_INTC_DISABLE);
/* Restore map cache */
@@ -170,7 +166,6 @@ static void liointc_resume(struct irq_ch
writel(priv->int_edge, gc->reg_base + LIOINTC_REG_INTC_EDGE);
/* Restore mask cache */
writel(gc->mask_cache, gc->reg_base + LIOINTC_REG_INTC_ENABLE);
- irq_gc_unlock_irqrestore(gc, flags);
}
static int parent_irq[LIOINTC_NUM_PARENT];
--- a/drivers/irqchip/irq-mscc-ocelot.c
+++ b/drivers/irqchip/irq-mscc-ocelot.c
@@ -83,7 +83,7 @@ static void ocelot_irq_unmask(struct irq
unsigned int mask = data->mask;
u32 val;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
/*
* Clear sticky bits for edge mode interrupts.
* Serval has only one trigger register replication, but the adjacent
@@ -97,7 +97,6 @@ static void ocelot_irq_unmask(struct irq
*ct->mask_cache &= ~mask;
irq_reg_writel(gc, mask, p->reg_off_ena_set);
- irq_gc_unlock(gc);
}
static void ocelot_irq_handler(struct irq_desc *desc)
--- a/drivers/irqchip/irq-stm32-exti.c
+++ b/drivers/irqchip/irq-stm32-exti.c
@@ -169,22 +169,18 @@ static int stm32_irq_set_type(struct irq
u32 rtsr, ftsr;
int err;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
rtsr = irq_reg_readl(gc, stm32_bank->rtsr_ofst);
ftsr = irq_reg_readl(gc, stm32_bank->ftsr_ofst);
err = stm32_exti_set_type(d, type, &rtsr, &ftsr);
if (err)
- goto unlock;
+ return err;
irq_reg_writel(gc, rtsr, stm32_bank->rtsr_ofst);
irq_reg_writel(gc, ftsr, stm32_bank->ftsr_ofst);
-
-unlock:
- irq_gc_unlock(gc);
-
- return err;
+ return 0;
}
static void stm32_chip_suspend(struct stm32_exti_chip_data *chip_data,
@@ -217,18 +213,16 @@ static void stm32_irq_suspend(struct irq
{
struct stm32_exti_chip_data *chip_data = gc->private;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
stm32_chip_suspend(chip_data, gc->wake_active);
- irq_gc_unlock(gc);
}
static void stm32_irq_resume(struct irq_chip_generic *gc)
{
struct stm32_exti_chip_data *chip_data = gc->private;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
stm32_chip_resume(chip_data, gc->mask_cache);
- irq_gc_unlock(gc);
}
static int stm32_exti_alloc(struct irq_domain *d, unsigned int virq,
@@ -265,11 +259,8 @@ static void stm32_irq_ack(struct irq_dat
struct stm32_exti_chip_data *chip_data = gc->private;
const struct stm32_exti_bank *stm32_bank = chip_data->reg_bank;
- irq_gc_lock(gc);
-
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, d->mask, stm32_bank->rpr_ofst);
-
- irq_gc_unlock(gc);
}
static struct
--- a/drivers/irqchip/irq-sunxi-nmi.c
+++ b/drivers/irqchip/irq-sunxi-nmi.c
@@ -102,7 +102,7 @@ static int sunxi_sc_nmi_set_type(struct
unsigned int src_type;
unsigned int i;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
switch (flow_type & IRQF_TRIGGER_MASK) {
case IRQ_TYPE_EDGE_FALLING:
@@ -119,9 +119,7 @@ static int sunxi_sc_nmi_set_type(struct
src_type = SUNXI_SRC_TYPE_LEVEL_LOW;
break;
default:
- irq_gc_unlock(gc);
- pr_err("Cannot assign multiple trigger modes to IRQ %d.\n",
- data->irq);
+ pr_err("Cannot assign multiple trigger modes to IRQ %d.\n", data->irq);
return -EBADR;
}
@@ -136,9 +134,6 @@ static int sunxi_sc_nmi_set_type(struct
src_type_reg &= ~SUNXI_NMI_SRC_TYPE_MASK;
src_type_reg |= src_type;
sunxi_sc_nmi_write(gc, ctrl_off, src_type_reg);
-
- irq_gc_unlock(gc);
-
return IRQ_SET_MASK_OK;
}
--- a/drivers/irqchip/irq-tb10x.c
+++ b/drivers/irqchip/irq-tb10x.c
@@ -41,11 +41,9 @@ static inline u32 ab_irqctl_readreg(stru
static int tb10x_irq_set_type(struct irq_data *data, unsigned int flow_type)
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data);
- uint32_t im, mod, pol;
+ uint32_t mod, pol, im = data->mask;
- im = data->mask;
-
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
mod = ab_irqctl_readreg(gc, AB_IRQCTL_SRC_MODE) | im;
pol = ab_irqctl_readreg(gc, AB_IRQCTL_SRC_POLARITY) | im;
@@ -67,9 +65,7 @@ static int tb10x_irq_set_type(struct irq
case IRQ_TYPE_EDGE_RISING:
break;
default:
- irq_gc_unlock(gc);
- pr_err("%s: Cannot assign multiple trigger modes to IRQ %d.\n",
- __func__, data->irq);
+ pr_err("%s: Cannot assign multiple trigger modes to IRQ %d.\n", __func__, data->irq);
return -EBADR;
}
@@ -79,9 +75,6 @@ static int tb10x_irq_set_type(struct irq
ab_irqctl_writereg(gc, AB_IRQCTL_SRC_MODE, mod);
ab_irqctl_writereg(gc, AB_IRQCTL_SRC_POLARITY, pol);
ab_irqctl_writereg(gc, AB_IRQCTL_INT_STATUS, im);
-
- irq_gc_unlock(gc);
-
return IRQ_SET_MASK_OK;
}
^ permalink raw reply [flat|nested] 26+ messages in thread
* [patch 7/7] genirq/generic-chip: Remove unused lock wrappers
2025-03-13 14:31 [patch 0/7] genirq/generic_chip: Convert locking to guards Thomas Gleixner
` (5 preceding siblings ...)
2025-03-13 14:31 ` [patch 6/7] irqchip: Convert generic irqchip locking to guards Thomas Gleixner
@ 2025-03-13 14:31 ` Thomas Gleixner
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2025-03-16 8:50 ` [patch 0/7] genirq/generic_chip: Convert locking to guards Markus Elfring
7 siblings, 1 reply; 26+ messages in thread
From: Thomas Gleixner @ 2025-03-13 14:31 UTC (permalink / raw)
To: LKML
Cc: Jiri Slaby, Andrew Lunn, Sebastian Hesselbarth, Gregory Clement,
Uwe Kleine-König, Linus Walleij, Bartosz Golaszewski,
Talel Shenhar, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Florian Fainelli, Guo Ren, Herve Codina, Huacai Chen, Jiaxun Yang,
Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
All users are converted to lock guards.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/irq.h | 20 --------------------
1 file changed, 20 deletions(-)
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -1219,26 +1219,6 @@ static inline struct irq_chip_type *irq_
#define IRQ_MSK(n) (u32)((n) < 32 ? ((1 << (n)) - 1) : UINT_MAX)
-static inline void irq_gc_lock(struct irq_chip_generic *gc)
-{
- raw_spin_lock(&gc->lock);
-}
-
-static inline void irq_gc_unlock(struct irq_chip_generic *gc)
-{
- raw_spin_unlock(&gc->lock);
-}
-
-/*
- * The irqsave variants are for usage in non interrupt code. Do not use
- * them in irq_chip callbacks. Use irq_gc_lock() instead.
- */
-#define irq_gc_lock_irqsave(gc, flags) \
- raw_spin_lock_irqsave(&(gc)->lock, flags)
-
-#define irq_gc_unlock_irqrestore(gc, flags) \
- raw_spin_unlock_irqrestore(&(gc)->lock, flags)
-
static inline void irq_reg_writel(struct irq_chip_generic *gc,
u32 val, int reg_offset)
{
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch 3/7] soc: dove: Convert generic irqchip locking to guard()
2025-03-13 14:31 ` [patch 3/7] soc: dove: Convert generic irqchip locking to guard() Thomas Gleixner
@ 2025-03-13 14:48 ` Andrew Lunn
2025-03-14 10:57 ` Linus Walleij
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2 siblings, 0 replies; 26+ messages in thread
From: Andrew Lunn @ 2025-03-13 14:48 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Jiri Slaby, Sebastian Hesselbarth, Gregory Clement,
Uwe Kleine-König, Linus Walleij, Bartosz Golaszewski,
Talel Shenhar, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Florian Fainelli, Guo Ren, Herve Codina, Huacai Chen, Jiaxun Yang,
Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
On Thu, Mar 13, 2025 at 03:31:21PM +0100, Thomas Gleixner wrote:
> Conversion was done with Coccinelle. No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> Cc: Gregory Clement <gregory.clement@bootlin.com>
> ---
> drivers/soc/dove/pmu.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> --- a/drivers/soc/dove/pmu.c
> +++ b/drivers/soc/dove/pmu.c
> @@ -257,10 +257,9 @@ static void pmu_irq_handler(struct irq_d
> * So, let's structure the code so that the window is as small as
> * possible.
> */
> - irq_gc_lock(gc);
> + guard(raw_spinlock)(&gc->lock);
> done &= readl_relaxed(base + PMC_IRQ_CAUSE);
> writel_relaxed(done, base + PMC_IRQ_CAUSE);
> - irq_gc_unlock(gc);
> }
My personal preference would be a scoped_guard() rather than this
magical guard() construct which looks nothing like C. But whatever.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch 5/7] gpio: mvebu: Convert generic irqchip locking to guard()
2025-03-13 14:31 ` [patch 5/7] gpio: mvebu: " Thomas Gleixner
@ 2025-03-14 10:19 ` Bartosz Golaszewski
2025-03-14 11:07 ` Linus Walleij
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2 siblings, 0 replies; 26+ messages in thread
From: Bartosz Golaszewski @ 2025-03-14 10:19 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Jiri Slaby, Uwe Kleine-König, Linus Walleij,
Andrew Lunn, Sebastian Hesselbarth, Gregory Clement,
Talel Shenhar, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Florian Fainelli, Guo Ren, Herve Codina, Huacai Chen, Jiaxun Yang,
Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
On Thu, Mar 13, 2025 at 3:31 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: "Uwe Kleine-König" <ukleinek@kernel.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Bartosz Golaszewski <brgl@bgdev.pl>
> ---
Is it ok to take this through the GPIO tree separately from the rest
of the series?
Bartosz
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch 2/7] genirq/generic-chip: Convert core code to lock guards
2025-03-13 14:31 ` [patch 2/7] genirq/generic-chip: Convert core code to lock guards Thomas Gleixner
@ 2025-03-14 10:55 ` Linus Walleij
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2025-04-08 18:10 ` [patch 2/7] " Geert Uytterhoeven
2 siblings, 0 replies; 26+ messages in thread
From: Linus Walleij @ 2025-03-14 10:55 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Jiri Slaby, Andrew Lunn, Sebastian Hesselbarth,
Gregory Clement, Uwe Kleine-König, Bartosz Golaszewski,
Talel Shenhar, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Florian Fainelli, Guo Ren, Herve Codina, Huacai Chen, Jiaxun Yang,
Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
On Thu, Mar 13, 2025 at 3:31 PM Thomas Gleixner <tglx@linutronix.de> wrote:
> Replace the irq_gc_lock/unlock() pairs with guards. There is no point to
> implement a guard wrapper for them as they just wrap around raw_spin_lock*().
>
> Switch the other lock instances in the core code to guards as well.
>
> Conversion was done with Coccinelle plus manual fixups.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch 4/7] ARM: orion/gpio:: Convert generic irqchip locking to guard()
2025-03-13 14:31 ` [patch 4/7] ARM: orion/gpio:: " Thomas Gleixner
@ 2025-03-14 10:56 ` Linus Walleij
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2025-04-14 14:29 ` [patch 4/7] " Gregory CLEMENT
2 siblings, 0 replies; 26+ messages in thread
From: Linus Walleij @ 2025-03-14 10:56 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Jiri Slaby, Andrew Lunn, Sebastian Hesselbarth,
Gregory Clement, Uwe Kleine-König, Bartosz Golaszewski,
Talel Shenhar, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Florian Fainelli, Guo Ren, Herve Codina, Huacai Chen, Jiaxun Yang,
Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
On Thu, Mar 13, 2025 at 3:31 PM Thomas Gleixner <tglx@linutronix.de> wrote:
> Conversion was done with Coccinelle. No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> Cc: Gregory Clement <gregory.clement@bootlin.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch 6/7] irqchip: Convert generic irqchip locking to guards
2025-03-13 14:31 ` [patch 6/7] irqchip: Convert generic irqchip locking to guards Thomas Gleixner
@ 2025-03-14 10:56 ` Linus Walleij
2025-03-14 17:20 ` Herve Codina
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2 siblings, 0 replies; 26+ messages in thread
From: Linus Walleij @ 2025-03-14 10:56 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Jiri Slaby, Talel Shenhar, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, Florian Fainelli, Guo Ren, Herve Codina,
Huacai Chen, Jiaxun Yang, Maxime Coquelin, Alexandre Torgue,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Uwe Kleine-König,
Bartosz Golaszewski
On Thu, Mar 13, 2025 at 3:31 PM Thomas Gleixner <tglx@linutronix.de> wrote:
> Conversion was done with Coccinelle and a few manual fixups.
>
> In a few interrupt chip callbacks this changes replaces
> raw_spin_lock_irqsave() with a guard(raw_spinlock). That's intended and
> correct because those interrupt chip callbacks are invoked with the
> interrupt descriptor lock held and interrupts disabled. No point in using
> the irqsave variant.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Talel Shenhar <talel@amazon.com>
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> Cc: Florian Fainelli <florian.fainelli@broadcom.com>
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Herve Codina <herve.codina@bootlin.com>
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
> Cc: Chen-Yu Tsai <wens@csie.org>
> Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
> Cc: Samuel Holland <samuel@sholland.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch 3/7] soc: dove: Convert generic irqchip locking to guard()
2025-03-13 14:31 ` [patch 3/7] soc: dove: Convert generic irqchip locking to guard() Thomas Gleixner
2025-03-13 14:48 ` Andrew Lunn
@ 2025-03-14 10:57 ` Linus Walleij
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2 siblings, 0 replies; 26+ messages in thread
From: Linus Walleij @ 2025-03-14 10:57 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Jiri Slaby, Andrew Lunn, Sebastian Hesselbarth,
Gregory Clement, Uwe Kleine-König, Bartosz Golaszewski,
Talel Shenhar, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Florian Fainelli, Guo Ren, Herve Codina, Huacai Chen, Jiaxun Yang,
Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
On Thu, Mar 13, 2025 at 3:31 PM Thomas Gleixner <tglx@linutronix.de> wrote:
> Conversion was done with Coccinelle. No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> Cc: Gregory Clement <gregory.clement@bootlin.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch 5/7] gpio: mvebu: Convert generic irqchip locking to guard()
2025-03-13 14:31 ` [patch 5/7] gpio: mvebu: " Thomas Gleixner
2025-03-14 10:19 ` Bartosz Golaszewski
@ 2025-03-14 11:07 ` Linus Walleij
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2 siblings, 0 replies; 26+ messages in thread
From: Linus Walleij @ 2025-03-14 11:07 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Jiri Slaby, Uwe Kleine-König, Bartosz Golaszewski,
Andrew Lunn, Sebastian Hesselbarth, Gregory Clement,
Talel Shenhar, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Florian Fainelli, Guo Ren, Herve Codina, Huacai Chen, Jiaxun Yang,
Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
On Thu, Mar 13, 2025 at 3:31 PM Thomas Gleixner <tglx@linutronix.de> wrote:
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: "Uwe Kleine-König" <ukleinek@kernel.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch 6/7] irqchip: Convert generic irqchip locking to guards
2025-03-13 14:31 ` [patch 6/7] irqchip: Convert generic irqchip locking to guards Thomas Gleixner
2025-03-14 10:56 ` Linus Walleij
@ 2025-03-14 17:20 ` Herve Codina
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2 siblings, 0 replies; 26+ messages in thread
From: Herve Codina @ 2025-03-14 17:20 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Jiri Slaby, Talel Shenhar, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, Florian Fainelli, Guo Ren, Huacai Chen,
Jiaxun Yang, Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai,
Jernej Skrabec, Samuel Holland, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Uwe Kleine-König,
Linus Walleij, Bartosz Golaszewski
Hi Thomas,
On Thu, 13 Mar 2025 15:31:27 +0100 (CET)
Thomas Gleixner <tglx@linutronix.de> wrote:
> Conversion was done with Coccinelle and a few manual fixups.
>
> In a few interrupt chip callbacks this changes replaces
> raw_spin_lock_irqsave() with a guard(raw_spinlock). That's intended and
> correct because those interrupt chip callbacks are invoked with the
> interrupt descriptor lock held and interrupts disabled. No point in using
> the irqsave variant.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Talel Shenhar <talel@amazon.com>
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> Cc: Florian Fainelli <florian.fainelli@broadcom.com>
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Herve Codina <herve.codina@bootlin.com>
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
> Cc: Chen-Yu Tsai <wens@csie.org>
> Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
> Cc: Samuel Holland <samuel@sholland.org>
> ---
> drivers/irqchip/irq-al-fic.c | 18 +++++-------------
> drivers/irqchip/irq-atmel-aic.c | 19 ++++++-------------
> drivers/irqchip/irq-atmel-aic5.c | 28 ++++++++--------------------
> drivers/irqchip/irq-bcm7120-l2.c | 22 +++++++++-------------
> drivers/irqchip/irq-brcmstb-l2.c | 8 ++------
> drivers/irqchip/irq-csky-apb-intc.c | 3 +--
> drivers/irqchip/irq-dw-apb-ictl.c | 3 +--
> drivers/irqchip/irq-ingenic-tcu.c | 9 +++------
> drivers/irqchip/irq-lan966x-oic.c | 18 +++++++-----------
> drivers/irqchip/irq-loongson-liointc.c | 9 ++-------
> drivers/irqchip/irq-mscc-ocelot.c | 3 +--
> drivers/irqchip/irq-stm32-exti.c | 21 ++++++---------------
> drivers/irqchip/irq-sunxi-nmi.c | 9 ++-------
> drivers/irqchip/irq-tb10x.c | 13 +++----------
> 14 files changed, 56 insertions(+), 127 deletions(-)
>
...
> --- a/drivers/irqchip/irq-lan966x-oic.c
> +++ b/drivers/irqchip/irq-lan966x-oic.c
> @@ -71,14 +71,12 @@ static unsigned int lan966x_oic_irq_star
> struct lan966x_oic_chip_regs *chip_regs = gc->private;
> u32 map;
>
> - irq_gc_lock(gc);
> -
> - /* Map the source interrupt to the destination */
> - map = irq_reg_readl(gc, chip_regs->reg_off_map);
> - map |= data->mask;
> - irq_reg_writel(gc, map, chip_regs->reg_off_map);
> -
> - irq_gc_unlock(gc);
> + scoped_guard (raw_spinlock, &gc->lock) {
> + /* Map the source interrupt to the destination */
> + map = irq_reg_readl(gc, chip_regs->reg_off_map);
> + map |= data->mask;
> + irq_reg_writel(gc, map, chip_regs->reg_off_map);
> + }
>
> ct->chip.irq_ack(data);
> ct->chip.irq_unmask(data);
> @@ -95,14 +93,12 @@ static void lan966x_oic_irq_shutdown(str
>
> ct->chip.irq_mask(data);
>
> - irq_gc_lock(gc);
> + guard(raw_spinlock)(&gc->lock);
>
> /* Unmap the interrupt */
> map = irq_reg_readl(gc, chip_regs->reg_off_map);
> map &= ~data->mask;
> irq_reg_writel(gc, map, chip_regs->reg_off_map);
> -
> - irq_gc_unlock(gc);
> }
Here, I would really prefer a scoped_guard() to clearly identify what is
protected such as:
scoped_guard (raw_spinlock, &gc->lock) {
/* Unmap the interrupt */
map = irq_reg_readl(gc, chip_regs->reg_off_map);
map &= ~data->mask;
irq_reg_writel(gc, map, chip_regs->reg_off_map);
}
IMHO, guard() is nice when it protects an entire function but it can be
missed when it is present in a middle of code (looks too much like a
simple C function call).
Best regards,
Hervé
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch 0/7] genirq/generic_chip: Convert locking to guards
2025-03-13 14:31 [patch 0/7] genirq/generic_chip: Convert locking to guards Thomas Gleixner
` (6 preceding siblings ...)
2025-03-13 14:31 ` [patch 7/7] genirq/generic-chip: Remove unused lock wrappers Thomas Gleixner
@ 2025-03-16 8:50 ` Markus Elfring
7 siblings, 0 replies; 26+ messages in thread
From: Markus Elfring @ 2025-03-16 8:50 UTC (permalink / raw)
To: Thomas Gleixner, cocci
Cc: LKML, kernel-janitors, Alexandre Belloni, Alexandre Torgue,
Andrew Lunn, Bartosz Golaszewski, Chen-Yu Tsai, Claudiu Beznea,
Florian Fainelli, Gregory Clement, Guo Ren, Herve Codina,
Huacai Chen, Jernej Skrabec, Jiaxun Yang, Jiri Slaby,
Linus Walleij, Maxime Coquelin, Nicolas Ferre, Samuel Holland,
Sebastian Hesselbarth, Talel Shenhar, Uwe Kleine-König
> The following series converts the generic chip locking to lock guards,
> which reduces code size and improves readability.
>
> The conversion was largely done with Coccinelle.
Would you like to share any more from your evolving collection of scripts
for the semantic patch language?
Regards,
Markus
^ permalink raw reply [flat|nested] 26+ messages in thread
* [tip: irq/drivers] genirq/generic-chip: Remove unused lock wrappers
2025-03-13 14:31 ` [patch 7/7] genirq/generic-chip: Remove unused lock wrappers Thomas Gleixner
@ 2025-04-07 7:53 ` tip-bot2 for Thomas Gleixner
0 siblings, 0 replies; 26+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2025-04-07 7:53 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the irq/drivers branch of tip:
Commit-ID: 7ae844a6650c5c15ccfbf76ed767e7f2cc61ec1d
Gitweb: https://git.kernel.org/tip/7ae844a6650c5c15ccfbf76ed767e7f2cc61ec1d
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 13 Mar 2025 15:31:28 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 07 Apr 2025 09:43:20 +02:00
genirq/generic-chip: Remove unused lock wrappers
All users are converted to lock guards.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250313142524.388478168@linutronix.de
---
include/linux/irq.h | 20 --------------------
1 file changed, 20 deletions(-)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 5007729..d896d3a 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -1222,26 +1222,6 @@ static inline struct irq_chip_type *irq_data_get_chip_type(struct irq_data *d)
#define IRQ_MSK(n) (u32)((n) < 32 ? ((1 << (n)) - 1) : UINT_MAX)
-static inline void irq_gc_lock(struct irq_chip_generic *gc)
-{
- raw_spin_lock(&gc->lock);
-}
-
-static inline void irq_gc_unlock(struct irq_chip_generic *gc)
-{
- raw_spin_unlock(&gc->lock);
-}
-
-/*
- * The irqsave variants are for usage in non interrupt code. Do not use
- * them in irq_chip callbacks. Use irq_gc_lock() instead.
- */
-#define irq_gc_lock_irqsave(gc, flags) \
- raw_spin_lock_irqsave(&(gc)->lock, flags)
-
-#define irq_gc_unlock_irqrestore(gc, flags) \
- raw_spin_unlock_irqrestore(&(gc)->lock, flags)
-
static inline void irq_reg_writel(struct irq_chip_generic *gc,
u32 val, int reg_offset)
{
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [tip: irq/drivers] irqchip: Convert generic irqchip locking to guards
2025-03-13 14:31 ` [patch 6/7] irqchip: Convert generic irqchip locking to guards Thomas Gleixner
2025-03-14 10:56 ` Linus Walleij
2025-03-14 17:20 ` Herve Codina
@ 2025-04-07 7:53 ` tip-bot2 for Thomas Gleixner
2 siblings, 0 replies; 26+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2025-04-07 7:53 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Thomas Gleixner, Linus Walleij, x86, linux-kernel
The following commit has been merged into the irq/drivers branch of tip:
Commit-ID: b00bee8afaca47fd4f716488eb3663ac1f0abc31
Gitweb: https://git.kernel.org/tip/b00bee8afaca47fd4f716488eb3663ac1f0abc31
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 13 Mar 2025 15:31:27 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 07 Apr 2025 09:43:20 +02:00
irqchip: Convert generic irqchip locking to guards
Conversion was done with Coccinelle and a few manual fixups.
In a few interrupt chip callbacks this changes replaces
raw_spin_lock_irqsave() with a guard(raw_spinlock). That's intended and
correct because those interrupt chip callbacks are invoked with the
interrupt descriptor lock held and interrupts disabled. No point in using
the irqsave variant.
No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/all/20250313142524.325627746@linutronix.de
---
drivers/irqchip/irq-al-fic.c | 18 ++++------------
drivers/irqchip/irq-atmel-aic.c | 19 +++++------------
drivers/irqchip/irq-atmel-aic5.c | 28 +++++++------------------
drivers/irqchip/irq-bcm7120-l2.c | 22 ++++++++------------
drivers/irqchip/irq-brcmstb-l2.c | 8 +------
drivers/irqchip/irq-csky-apb-intc.c | 3 +--
drivers/irqchip/irq-dw-apb-ictl.c | 3 +--
drivers/irqchip/irq-ingenic-tcu.c | 9 ++------
drivers/irqchip/irq-lan966x-oic.c | 18 ++++++----------
drivers/irqchip/irq-loongson-liointc.c | 9 +-------
drivers/irqchip/irq-mscc-ocelot.c | 3 +--
drivers/irqchip/irq-stm32-exti.c | 21 +++++--------------
drivers/irqchip/irq-sunxi-nmi.c | 9 +-------
drivers/irqchip/irq-tb10x.c | 13 ++----------
14 files changed, 56 insertions(+), 127 deletions(-)
diff --git a/drivers/irqchip/irq-al-fic.c b/drivers/irqchip/irq-al-fic.c
index dfb761e..7308b8d 100644
--- a/drivers/irqchip/irq-al-fic.c
+++ b/drivers/irqchip/irq-al-fic.c
@@ -65,15 +65,13 @@ static int al_fic_irq_set_type(struct irq_data *data, unsigned int flow_type)
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data);
struct al_fic *fic = gc->private;
enum al_fic_state new_state;
- int ret = 0;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
if (((flow_type & IRQ_TYPE_SENSE_MASK) != IRQ_TYPE_LEVEL_HIGH) &&
((flow_type & IRQ_TYPE_SENSE_MASK) != IRQ_TYPE_EDGE_RISING)) {
pr_debug("fic doesn't support flow type %d\n", flow_type);
- ret = -EINVAL;
- goto err;
+ return -EINVAL;
}
new_state = (flow_type & IRQ_TYPE_LEVEL_HIGH) ?
@@ -91,16 +89,10 @@ static int al_fic_irq_set_type(struct irq_data *data, unsigned int flow_type)
if (fic->state == AL_FIC_UNCONFIGURED) {
al_fic_set_trigger(fic, gc, new_state);
} else if (fic->state != new_state) {
- pr_debug("fic %s state already configured to %d\n",
- fic->name, fic->state);
- ret = -EINVAL;
- goto err;
+ pr_debug("fic %s state already configured to %d\n", fic->name, fic->state);
+ return -EINVAL;
}
-
-err:
- irq_gc_unlock(gc);
-
- return ret;
+ return 0;
}
static void al_fic_irq_handler(struct irq_desc *desc)
diff --git a/drivers/irqchip/irq-atmel-aic.c b/drivers/irqchip/irq-atmel-aic.c
index 3839ad7..03aeed3 100644
--- a/drivers/irqchip/irq-atmel-aic.c
+++ b/drivers/irqchip/irq-atmel-aic.c
@@ -78,9 +78,8 @@ static int aic_retrigger(struct irq_data *d)
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
/* Enable interrupt on AIC5 */
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, d->mask, AT91_AIC_ISCR);
- irq_gc_unlock(gc);
return 1;
}
@@ -106,30 +105,27 @@ static void aic_suspend(struct irq_data *d)
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, gc->mask_cache, AT91_AIC_IDCR);
irq_reg_writel(gc, gc->wake_active, AT91_AIC_IECR);
- irq_gc_unlock(gc);
}
static void aic_resume(struct irq_data *d)
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, gc->wake_active, AT91_AIC_IDCR);
irq_reg_writel(gc, gc->mask_cache, AT91_AIC_IECR);
- irq_gc_unlock(gc);
}
static void aic_pm_shutdown(struct irq_data *d)
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, 0xffffffff, AT91_AIC_IDCR);
irq_reg_writel(gc, 0xffffffff, AT91_AIC_ICCR);
- irq_gc_unlock(gc);
}
#else
#define aic_suspend NULL
@@ -175,10 +171,8 @@ static int aic_irq_domain_xlate(struct irq_domain *d,
{
struct irq_domain_chip_generic *dgc = d->gc;
struct irq_chip_generic *gc;
- unsigned long flags;
unsigned smr;
- int idx;
- int ret;
+ int idx, ret;
if (!dgc)
return -EINVAL;
@@ -194,11 +188,10 @@ static int aic_irq_domain_xlate(struct irq_domain *d,
gc = dgc->gc[idx];
- irq_gc_lock_irqsave(gc, flags);
+ guard(raw_spinlock_irq)(&gc->lock);
smr = irq_reg_readl(gc, AT91_AIC_SMR(*out_hwirq));
aic_common_set_priority(intspec[2], &smr);
irq_reg_writel(gc, smr, AT91_AIC_SMR(*out_hwirq));
- irq_gc_unlock_irqrestore(gc, flags);
return ret;
}
diff --git a/drivers/irqchip/irq-atmel-aic5.c b/drivers/irqchip/irq-atmel-aic5.c
index e98c287..60b00d2 100644
--- a/drivers/irqchip/irq-atmel-aic5.c
+++ b/drivers/irqchip/irq-atmel-aic5.c
@@ -92,11 +92,10 @@ static void aic5_mask(struct irq_data *d)
* Disable interrupt on AIC5. We always take the lock of the
* first irq chip as all chips share the same registers.
*/
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
irq_reg_writel(gc, d->hwirq, AT91_AIC5_SSR);
irq_reg_writel(gc, 1, AT91_AIC5_IDCR);
gc->mask_cache &= ~d->mask;
- irq_gc_unlock(bgc);
}
static void aic5_unmask(struct irq_data *d)
@@ -109,11 +108,10 @@ static void aic5_unmask(struct irq_data *d)
* Enable interrupt on AIC5. We always take the lock of the
* first irq chip as all chips share the same registers.
*/
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
irq_reg_writel(gc, d->hwirq, AT91_AIC5_SSR);
irq_reg_writel(gc, 1, AT91_AIC5_IECR);
gc->mask_cache |= d->mask;
- irq_gc_unlock(bgc);
}
static int aic5_retrigger(struct irq_data *d)
@@ -122,11 +120,9 @@ static int aic5_retrigger(struct irq_data *d)
struct irq_chip_generic *bgc = irq_get_domain_generic_chip(domain, 0);
/* Enable interrupt on AIC5 */
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
irq_reg_writel(bgc, d->hwirq, AT91_AIC5_SSR);
irq_reg_writel(bgc, 1, AT91_AIC5_ISCR);
- irq_gc_unlock(bgc);
-
return 1;
}
@@ -137,14 +133,12 @@ static int aic5_set_type(struct irq_data *d, unsigned type)
unsigned int smr;
int ret;
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
irq_reg_writel(bgc, d->hwirq, AT91_AIC5_SSR);
smr = irq_reg_readl(bgc, AT91_AIC5_SMR);
ret = aic_common_set_type(d, type, &smr);
if (!ret)
irq_reg_writel(bgc, smr, AT91_AIC5_SMR);
- irq_gc_unlock(bgc);
-
return ret;
}
@@ -166,7 +160,7 @@ static void aic5_suspend(struct irq_data *d)
smr_cache[i] = irq_reg_readl(bgc, AT91_AIC5_SMR);
}
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
for (i = 0; i < dgc->irqs_per_chip; i++) {
mask = 1 << i;
if ((mask & gc->mask_cache) == (mask & gc->wake_active))
@@ -178,7 +172,6 @@ static void aic5_suspend(struct irq_data *d)
else
irq_reg_writel(bgc, 1, AT91_AIC5_IDCR);
}
- irq_gc_unlock(bgc);
}
static void aic5_resume(struct irq_data *d)
@@ -190,7 +183,7 @@ static void aic5_resume(struct irq_data *d)
int i;
u32 mask;
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
if (smr_cache) {
irq_reg_writel(bgc, 0xffffffff, AT91_AIC5_SPU);
@@ -214,7 +207,6 @@ static void aic5_resume(struct irq_data *d)
else
irq_reg_writel(bgc, 1, AT91_AIC5_IDCR);
}
- irq_gc_unlock(bgc);
}
static void aic5_pm_shutdown(struct irq_data *d)
@@ -225,13 +217,12 @@ static void aic5_pm_shutdown(struct irq_data *d)
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
int i;
- irq_gc_lock(bgc);
+ guard(raw_spinlock)(&bgc->lock);
for (i = 0; i < dgc->irqs_per_chip; i++) {
irq_reg_writel(bgc, i + gc->irq_base, AT91_AIC5_SSR);
irq_reg_writel(bgc, 1, AT91_AIC5_IDCR);
irq_reg_writel(bgc, 1, AT91_AIC5_ICCR);
}
- irq_gc_unlock(bgc);
}
#else
#define aic5_suspend NULL
@@ -277,7 +268,6 @@ static int aic5_irq_domain_xlate(struct irq_domain *d,
unsigned int *out_type)
{
struct irq_chip_generic *bgc = irq_get_domain_generic_chip(d, 0);
- unsigned long flags;
unsigned smr;
int ret;
@@ -289,13 +279,11 @@ static int aic5_irq_domain_xlate(struct irq_domain *d,
if (ret)
return ret;
- irq_gc_lock_irqsave(bgc, flags);
+ guard(raw_spinlock_irq)(&bgc->lock);
irq_reg_writel(bgc, *out_hwirq, AT91_AIC5_SSR);
smr = irq_reg_readl(bgc, AT91_AIC5_SMR);
aic_common_set_priority(intspec[2], &smr);
irq_reg_writel(bgc, smr, AT91_AIC5_SMR);
- irq_gc_unlock_irqrestore(bgc, flags);
-
return ret;
}
diff --git a/drivers/irqchip/irq-bcm7120-l2.c b/drivers/irqchip/irq-bcm7120-l2.c
index 1e9dab6..90909f8 100644
--- a/drivers/irqchip/irq-bcm7120-l2.c
+++ b/drivers/irqchip/irq-bcm7120-l2.c
@@ -63,16 +63,15 @@ static void bcm7120_l2_intc_irq_handle(struct irq_desc *desc)
for (idx = 0; idx < b->n_words; idx++) {
int base = idx * IRQS_PER_WORD;
- struct irq_chip_generic *gc =
- irq_get_domain_generic_chip(b->domain, base);
+ struct irq_chip_generic *gc;
unsigned long pending;
int hwirq;
- irq_gc_lock(gc);
- pending = irq_reg_readl(gc, b->stat_offset[idx]) &
- gc->mask_cache &
- data->irq_map_mask[idx];
- irq_gc_unlock(gc);
+ gc = irq_get_domain_generic_chip(b->domain, base);
+ scoped_guard (raw_spinlock, &gc->lock) {
+ pending = irq_reg_readl(gc, b->stat_offset[idx]) & gc->mask_cache &
+ data->irq_map_mask[idx];
+ }
for_each_set_bit(hwirq, &pending, IRQS_PER_WORD)
generic_handle_domain_irq(b->domain, base + hwirq);
@@ -86,11 +85,9 @@ static void bcm7120_l2_intc_suspend(struct irq_chip_generic *gc)
struct bcm7120_l2_intc_data *b = gc->private;
struct irq_chip_type *ct = gc->chip_types;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
if (b->can_wake)
- irq_reg_writel(gc, gc->mask_cache | gc->wake_active,
- ct->regs.mask);
- irq_gc_unlock(gc);
+ irq_reg_writel(gc, gc->mask_cache | gc->wake_active, ct->regs.mask);
}
static void bcm7120_l2_intc_resume(struct irq_chip_generic *gc)
@@ -98,9 +95,8 @@ static void bcm7120_l2_intc_resume(struct irq_chip_generic *gc)
struct irq_chip_type *ct = gc->chip_types;
/* Restore the saved mask */
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, gc->mask_cache, ct->regs.mask);
- irq_gc_unlock(gc);
}
static int bcm7120_l2_intc_init_one(struct device_node *dn,
diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c
index db4c972..aa4e123 100644
--- a/drivers/irqchip/irq-brcmstb-l2.c
+++ b/drivers/irqchip/irq-brcmstb-l2.c
@@ -97,9 +97,8 @@ static void __brcmstb_l2_intc_suspend(struct irq_data *d, bool save)
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
struct irq_chip_type *ct = irq_data_get_chip_type(d);
struct brcmstb_l2_intc_data *b = gc->private;
- unsigned long flags;
- irq_gc_lock_irqsave(gc, flags);
+ guard(raw_spinlock_irqsave)(&gc->lock);
/* Save the current mask */
if (save)
b->saved_mask = irq_reg_readl(gc, ct->regs.mask);
@@ -109,7 +108,6 @@ static void __brcmstb_l2_intc_suspend(struct irq_data *d, bool save)
irq_reg_writel(gc, ~gc->wake_active, ct->regs.disable);
irq_reg_writel(gc, gc->wake_active, ct->regs.enable);
}
- irq_gc_unlock_irqrestore(gc, flags);
}
static void brcmstb_l2_intc_shutdown(struct irq_data *d)
@@ -127,9 +125,8 @@ static void brcmstb_l2_intc_resume(struct irq_data *d)
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
struct irq_chip_type *ct = irq_data_get_chip_type(d);
struct brcmstb_l2_intc_data *b = gc->private;
- unsigned long flags;
- irq_gc_lock_irqsave(gc, flags);
+ guard(raw_spinlock_irqsave)(&gc->lock);
if (ct->chip.irq_ack) {
/* Clear unmasked non-wakeup interrupts */
irq_reg_writel(gc, ~b->saved_mask & ~gc->wake_active,
@@ -139,7 +136,6 @@ static void brcmstb_l2_intc_resume(struct irq_data *d)
/* Restore the saved mask */
irq_reg_writel(gc, b->saved_mask, ct->regs.disable);
irq_reg_writel(gc, ~b->saved_mask, ct->regs.enable);
- irq_gc_unlock_irqrestore(gc, flags);
}
static int __init brcmstb_l2_intc_of_init(struct device_node *np,
diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c
index 6710691..6e17186 100644
--- a/drivers/irqchip/irq-csky-apb-intc.c
+++ b/drivers/irqchip/irq-csky-apb-intc.c
@@ -50,11 +50,10 @@ static void irq_ck_mask_set_bit(struct irq_data *d)
unsigned long ifr = ct->regs.mask - 8;
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
*ct->mask_cache |= mask;
irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask);
irq_reg_writel(gc, irq_reg_readl(gc, ifr) & ~mask, ifr);
- irq_gc_unlock(gc);
}
static void __init ck_set_gc(struct device_node *node, void __iomem *reg_base,
diff --git a/drivers/irqchip/irq-dw-apb-ictl.c b/drivers/irqchip/irq-dw-apb-ictl.c
index d5c1c75..6874ec8 100644
--- a/drivers/irqchip/irq-dw-apb-ictl.c
+++ b/drivers/irqchip/irq-dw-apb-ictl.c
@@ -101,10 +101,9 @@ static void dw_apb_ictl_resume(struct irq_data *d)
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
struct irq_chip_type *ct = irq_data_get_chip_type(d);
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
writel_relaxed(~0, gc->reg_base + ct->regs.enable);
writel_relaxed(*ct->mask_cache, gc->reg_base + ct->regs.mask);
- irq_gc_unlock(gc);
}
#else
#define dw_apb_ictl_resume NULL
diff --git a/drivers/irqchip/irq-ingenic-tcu.c b/drivers/irqchip/irq-ingenic-tcu.c
index 3363f83..945fd57 100644
--- a/drivers/irqchip/irq-ingenic-tcu.c
+++ b/drivers/irqchip/irq-ingenic-tcu.c
@@ -52,11 +52,10 @@ static void ingenic_tcu_gc_unmask_enable_reg(struct irq_data *d)
struct regmap *map = gc->private;
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
regmap_write(map, ct->regs.ack, mask);
regmap_write(map, ct->regs.enable, mask);
*ct->mask_cache |= mask;
- irq_gc_unlock(gc);
}
static void ingenic_tcu_gc_mask_disable_reg(struct irq_data *d)
@@ -66,10 +65,9 @@ static void ingenic_tcu_gc_mask_disable_reg(struct irq_data *d)
struct regmap *map = gc->private;
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
regmap_write(map, ct->regs.disable, mask);
*ct->mask_cache &= ~mask;
- irq_gc_unlock(gc);
}
static void ingenic_tcu_gc_mask_disable_reg_and_ack(struct irq_data *d)
@@ -79,10 +77,9 @@ static void ingenic_tcu_gc_mask_disable_reg_and_ack(struct irq_data *d)
struct regmap *map = gc->private;
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
regmap_write(map, ct->regs.ack, mask);
regmap_write(map, ct->regs.disable, mask);
- irq_gc_unlock(gc);
}
static int __init ingenic_tcu_irq_init(struct device_node *np,
diff --git a/drivers/irqchip/irq-lan966x-oic.c b/drivers/irqchip/irq-lan966x-oic.c
index 41ac880..f77bd2a 100644
--- a/drivers/irqchip/irq-lan966x-oic.c
+++ b/drivers/irqchip/irq-lan966x-oic.c
@@ -71,14 +71,12 @@ static unsigned int lan966x_oic_irq_startup(struct irq_data *data)
struct lan966x_oic_chip_regs *chip_regs = gc->private;
u32 map;
- irq_gc_lock(gc);
-
- /* Map the source interrupt to the destination */
- map = irq_reg_readl(gc, chip_regs->reg_off_map);
- map |= data->mask;
- irq_reg_writel(gc, map, chip_regs->reg_off_map);
-
- irq_gc_unlock(gc);
+ scoped_guard (raw_spinlock, &gc->lock) {
+ /* Map the source interrupt to the destination */
+ map = irq_reg_readl(gc, chip_regs->reg_off_map);
+ map |= data->mask;
+ irq_reg_writel(gc, map, chip_regs->reg_off_map);
+ }
ct->chip.irq_ack(data);
ct->chip.irq_unmask(data);
@@ -95,14 +93,12 @@ static void lan966x_oic_irq_shutdown(struct irq_data *data)
ct->chip.irq_mask(data);
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
/* Unmap the interrupt */
map = irq_reg_readl(gc, chip_regs->reg_off_map);
map &= ~data->mask;
irq_reg_writel(gc, map, chip_regs->reg_off_map);
-
- irq_gc_unlock(gc);
}
static int lan966x_oic_irq_set_type(struct irq_data *data,
diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
index 2b1bd4a..61c0b47 100644
--- a/drivers/irqchip/irq-loongson-liointc.c
+++ b/drivers/irqchip/irq-loongson-liointc.c
@@ -116,9 +116,8 @@ static int liointc_set_type(struct irq_data *data, unsigned int type)
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data);
u32 mask = data->mask;
- unsigned long flags;
- irq_gc_lock_irqsave(gc, flags);
+ guard(raw_spinlock)(&gc->lock);
switch (type) {
case IRQ_TYPE_LEVEL_HIGH:
liointc_set_bit(gc, LIOINTC_REG_INTC_EDGE, mask, false);
@@ -137,10 +136,8 @@ static int liointc_set_type(struct irq_data *data, unsigned int type)
liointc_set_bit(gc, LIOINTC_REG_INTC_POL, mask, true);
break;
default:
- irq_gc_unlock_irqrestore(gc, flags);
return -EINVAL;
}
- irq_gc_unlock_irqrestore(gc, flags);
irqd_set_trigger_type(data, type);
return 0;
@@ -157,10 +154,9 @@ static void liointc_suspend(struct irq_chip_generic *gc)
static void liointc_resume(struct irq_chip_generic *gc)
{
struct liointc_priv *priv = gc->private;
- unsigned long flags;
int i;
- irq_gc_lock_irqsave(gc, flags);
+ guard(raw_spinlock_irqsave)(&gc->lock);
/* Disable all at first */
writel(0xffffffff, gc->reg_base + LIOINTC_REG_INTC_DISABLE);
/* Restore map cache */
@@ -170,7 +166,6 @@ static void liointc_resume(struct irq_chip_generic *gc)
writel(priv->int_edge, gc->reg_base + LIOINTC_REG_INTC_EDGE);
/* Restore mask cache */
writel(gc->mask_cache, gc->reg_base + LIOINTC_REG_INTC_ENABLE);
- irq_gc_unlock_irqrestore(gc, flags);
}
static int parent_irq[LIOINTC_NUM_PARENT];
diff --git a/drivers/irqchip/irq-mscc-ocelot.c b/drivers/irqchip/irq-mscc-ocelot.c
index 3dc745b..d69c5f1 100644
--- a/drivers/irqchip/irq-mscc-ocelot.c
+++ b/drivers/irqchip/irq-mscc-ocelot.c
@@ -83,7 +83,7 @@ static void ocelot_irq_unmask(struct irq_data *data)
unsigned int mask = data->mask;
u32 val;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
/*
* Clear sticky bits for edge mode interrupts.
* Serval has only one trigger register replication, but the adjacent
@@ -97,7 +97,6 @@ static void ocelot_irq_unmask(struct irq_data *data)
*ct->mask_cache &= ~mask;
irq_reg_writel(gc, mask, p->reg_off_ena_set);
- irq_gc_unlock(gc);
}
static void ocelot_irq_handler(struct irq_desc *desc)
diff --git a/drivers/irqchip/irq-stm32-exti.c b/drivers/irqchip/irq-stm32-exti.c
index 7c6a008..477046d 100644
--- a/drivers/irqchip/irq-stm32-exti.c
+++ b/drivers/irqchip/irq-stm32-exti.c
@@ -169,22 +169,18 @@ static int stm32_irq_set_type(struct irq_data *d, unsigned int type)
u32 rtsr, ftsr;
int err;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
rtsr = irq_reg_readl(gc, stm32_bank->rtsr_ofst);
ftsr = irq_reg_readl(gc, stm32_bank->ftsr_ofst);
err = stm32_exti_set_type(d, type, &rtsr, &ftsr);
if (err)
- goto unlock;
+ return err;
irq_reg_writel(gc, rtsr, stm32_bank->rtsr_ofst);
irq_reg_writel(gc, ftsr, stm32_bank->ftsr_ofst);
-
-unlock:
- irq_gc_unlock(gc);
-
- return err;
+ return 0;
}
static void stm32_chip_suspend(struct stm32_exti_chip_data *chip_data,
@@ -217,18 +213,16 @@ static void stm32_irq_suspend(struct irq_chip_generic *gc)
{
struct stm32_exti_chip_data *chip_data = gc->private;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
stm32_chip_suspend(chip_data, gc->wake_active);
- irq_gc_unlock(gc);
}
static void stm32_irq_resume(struct irq_chip_generic *gc)
{
struct stm32_exti_chip_data *chip_data = gc->private;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
stm32_chip_resume(chip_data, gc->mask_cache);
- irq_gc_unlock(gc);
}
static int stm32_exti_alloc(struct irq_domain *d, unsigned int virq,
@@ -265,11 +259,8 @@ static void stm32_irq_ack(struct irq_data *d)
struct stm32_exti_chip_data *chip_data = gc->private;
const struct stm32_exti_bank *stm32_bank = chip_data->reg_bank;
- irq_gc_lock(gc);
-
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, d->mask, stm32_bank->rpr_ofst);
-
- irq_gc_unlock(gc);
}
static struct
diff --git a/drivers/irqchip/irq-sunxi-nmi.c b/drivers/irqchip/irq-sunxi-nmi.c
index 01b0d83..4c977ac 100644
--- a/drivers/irqchip/irq-sunxi-nmi.c
+++ b/drivers/irqchip/irq-sunxi-nmi.c
@@ -111,7 +111,7 @@ static int sunxi_sc_nmi_set_type(struct irq_data *data, unsigned int flow_type)
unsigned int src_type;
unsigned int i;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
switch (flow_type & IRQF_TRIGGER_MASK) {
case IRQ_TYPE_EDGE_FALLING:
@@ -128,9 +128,7 @@ static int sunxi_sc_nmi_set_type(struct irq_data *data, unsigned int flow_type)
src_type = SUNXI_SRC_TYPE_LEVEL_LOW;
break;
default:
- irq_gc_unlock(gc);
- pr_err("Cannot assign multiple trigger modes to IRQ %d.\n",
- data->irq);
+ pr_err("Cannot assign multiple trigger modes to IRQ %d.\n", data->irq);
return -EBADR;
}
@@ -145,9 +143,6 @@ static int sunxi_sc_nmi_set_type(struct irq_data *data, unsigned int flow_type)
src_type_reg &= ~SUNXI_NMI_SRC_TYPE_MASK;
src_type_reg |= src_type;
sunxi_sc_nmi_write(gc, ctrl_off, src_type_reg);
-
- irq_gc_unlock(gc);
-
return IRQ_SET_MASK_OK;
}
diff --git a/drivers/irqchip/irq-tb10x.c b/drivers/irqchip/irq-tb10x.c
index d59bfbe..aa80944 100644
--- a/drivers/irqchip/irq-tb10x.c
+++ b/drivers/irqchip/irq-tb10x.c
@@ -41,11 +41,9 @@ static inline u32 ab_irqctl_readreg(struct irq_chip_generic *gc, u32 reg)
static int tb10x_irq_set_type(struct irq_data *data, unsigned int flow_type)
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data);
- uint32_t im, mod, pol;
+ uint32_t mod, pol, im = data->mask;
- im = data->mask;
-
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
mod = ab_irqctl_readreg(gc, AB_IRQCTL_SRC_MODE) | im;
pol = ab_irqctl_readreg(gc, AB_IRQCTL_SRC_POLARITY) | im;
@@ -67,9 +65,7 @@ static int tb10x_irq_set_type(struct irq_data *data, unsigned int flow_type)
case IRQ_TYPE_EDGE_RISING:
break;
default:
- irq_gc_unlock(gc);
- pr_err("%s: Cannot assign multiple trigger modes to IRQ %d.\n",
- __func__, data->irq);
+ pr_err("%s: Cannot assign multiple trigger modes to IRQ %d.\n", __func__, data->irq);
return -EBADR;
}
@@ -79,9 +75,6 @@ static int tb10x_irq_set_type(struct irq_data *data, unsigned int flow_type)
ab_irqctl_writereg(gc, AB_IRQCTL_SRC_MODE, mod);
ab_irqctl_writereg(gc, AB_IRQCTL_SRC_POLARITY, pol);
ab_irqctl_writereg(gc, AB_IRQCTL_INT_STATUS, im);
-
- irq_gc_unlock(gc);
-
return IRQ_SET_MASK_OK;
}
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [tip: irq/drivers] gpio: mvebu: Convert generic irqchip locking to guard()
2025-03-13 14:31 ` [patch 5/7] gpio: mvebu: " Thomas Gleixner
2025-03-14 10:19 ` Bartosz Golaszewski
2025-03-14 11:07 ` Linus Walleij
@ 2025-04-07 7:53 ` tip-bot2 for Thomas Gleixner
2 siblings, 0 replies; 26+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2025-04-07 7:53 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Thomas Gleixner, Linus Walleij, x86, linux-kernel
The following commit has been merged into the irq/drivers branch of tip:
Commit-ID: 9949aec666eb3e55522409f243fa6e873424fdc5
Gitweb: https://git.kernel.org/tip/9949aec666eb3e55522409f243fa6e873424fdc5
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 13 Mar 2025 15:31:25 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 07 Apr 2025 09:43:20 +02:00
gpio: mvebu: Convert generic irqchip locking to guard()
Conversion was done with coccinelle.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/all/20250313142524.262678485@linutronix.de
---
drivers/gpio/gpio-mvebu.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 3604abc..2581fbb 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -408,9 +408,8 @@ static void mvebu_gpio_irq_ack(struct irq_data *d)
struct mvebu_gpio_chip *mvchip = gc->private;
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
mvebu_gpio_write_edge_cause(mvchip, ~mask);
- irq_gc_unlock(gc);
}
static void mvebu_gpio_edge_irq_mask(struct irq_data *d)
@@ -420,10 +419,9 @@ static void mvebu_gpio_edge_irq_mask(struct irq_data *d)
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
ct->mask_cache_priv &= ~mask;
mvebu_gpio_write_edge_mask(mvchip, ct->mask_cache_priv);
- irq_gc_unlock(gc);
}
static void mvebu_gpio_edge_irq_unmask(struct irq_data *d)
@@ -433,11 +431,10 @@ static void mvebu_gpio_edge_irq_unmask(struct irq_data *d)
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
mvebu_gpio_write_edge_cause(mvchip, ~mask);
ct->mask_cache_priv |= mask;
mvebu_gpio_write_edge_mask(mvchip, ct->mask_cache_priv);
- irq_gc_unlock(gc);
}
static void mvebu_gpio_level_irq_mask(struct irq_data *d)
@@ -447,10 +444,9 @@ static void mvebu_gpio_level_irq_mask(struct irq_data *d)
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
ct->mask_cache_priv &= ~mask;
mvebu_gpio_write_level_mask(mvchip, ct->mask_cache_priv);
- irq_gc_unlock(gc);
}
static void mvebu_gpio_level_irq_unmask(struct irq_data *d)
@@ -460,10 +456,9 @@ static void mvebu_gpio_level_irq_unmask(struct irq_data *d)
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
ct->mask_cache_priv |= mask;
mvebu_gpio_write_level_mask(mvchip, ct->mask_cache_priv);
- irq_gc_unlock(gc);
}
/*****************************************************************************
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [tip: irq/drivers] ARM: orion/gpio:: Convert generic irqchip locking to guard()
2025-03-13 14:31 ` [patch 4/7] ARM: orion/gpio:: " Thomas Gleixner
2025-03-14 10:56 ` Linus Walleij
@ 2025-04-07 7:53 ` tip-bot2 for Thomas Gleixner
2025-04-14 14:29 ` [patch 4/7] " Gregory CLEMENT
2 siblings, 0 replies; 26+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2025-04-07 7:53 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Thomas Gleixner, Linus Walleij, x86, linux-kernel
The following commit has been merged into the irq/drivers branch of tip:
Commit-ID: 73989a38268dd80f7f2c945b8e3097b7c9ee95f5
Gitweb: https://git.kernel.org/tip/73989a38268dd80f7f2c945b8e3097b7c9ee95f5
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 13 Mar 2025 15:31:23 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 07 Apr 2025 09:43:20 +02:00
ARM: orion/gpio:: Convert generic irqchip locking to guard()
Conversion was done with Coccinelle. No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/all/20250313142524.200515896@linutronix.de
---
arch/arm/plat-orion/gpio.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/arm/plat-orion/gpio.c b/arch/arm/plat-orion/gpio.c
index 595e9cb..47d411d 100644
--- a/arch/arm/plat-orion/gpio.c
+++ b/arch/arm/plat-orion/gpio.c
@@ -496,11 +496,10 @@ static void orion_gpio_unmask_irq(struct irq_data *d)
u32 reg_val;
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
reg_val = irq_reg_readl(gc, ct->regs.mask);
reg_val |= mask;
irq_reg_writel(gc, reg_val, ct->regs.mask);
- irq_gc_unlock(gc);
}
static void orion_gpio_mask_irq(struct irq_data *d)
@@ -510,11 +509,10 @@ static void orion_gpio_mask_irq(struct irq_data *d)
u32 mask = d->mask;
u32 reg_val;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
reg_val = irq_reg_readl(gc, ct->regs.mask);
reg_val &= ~mask;
irq_reg_writel(gc, reg_val, ct->regs.mask);
- irq_gc_unlock(gc);
}
void __init orion_gpio_init(int gpio_base, int ngpio,
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [tip: irq/drivers] soc: dove: Convert generic irqchip locking to guard()
2025-03-13 14:31 ` [patch 3/7] soc: dove: Convert generic irqchip locking to guard() Thomas Gleixner
2025-03-13 14:48 ` Andrew Lunn
2025-03-14 10:57 ` Linus Walleij
@ 2025-04-07 7:53 ` tip-bot2 for Thomas Gleixner
2 siblings, 0 replies; 26+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2025-04-07 7:53 UTC (permalink / raw)
To: linux-tip-commits
Cc: Thomas Gleixner, Andrew Lunn, Linus Walleij, x86, linux-kernel
The following commit has been merged into the irq/drivers branch of tip:
Commit-ID: b54bd5a29b428afff4a37c7b6e1df67e43c327c3
Gitweb: https://git.kernel.org/tip/b54bd5a29b428afff4a37c7b6e1df67e43c327c3
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 13 Mar 2025 15:31:21 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 07 Apr 2025 09:43:19 +02:00
soc: dove: Convert generic irqchip locking to guard()
Conversion was done with Coccinelle. No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/all/20250313142524.137040686@linutronix.de
---
drivers/soc/dove/pmu.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/soc/dove/pmu.c b/drivers/soc/dove/pmu.c
index 6202dbc..795802b 100644
--- a/drivers/soc/dove/pmu.c
+++ b/drivers/soc/dove/pmu.c
@@ -257,10 +257,9 @@ static void pmu_irq_handler(struct irq_desc *desc)
* So, let's structure the code so that the window is as small as
* possible.
*/
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
done &= readl_relaxed(base + PMC_IRQ_CAUSE);
writel_relaxed(done, base + PMC_IRQ_CAUSE);
- irq_gc_unlock(gc);
}
static int __init dove_init_pmu_irq(struct pmu_data *pmu, int irq)
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [tip: irq/drivers] genirq/generic-chip: Make locking unconditional
2025-03-13 14:31 ` [patch 1/7] genirq/generic-chip: Make locking unconditional Thomas Gleixner
@ 2025-04-07 7:53 ` tip-bot2 for Thomas Gleixner
0 siblings, 0 replies; 26+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2025-04-07 7:53 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the irq/drivers branch of tip:
Commit-ID: 06f2f68a670aae28b825065439301831e74da880
Gitweb: https://git.kernel.org/tip/06f2f68a670aae28b825065439301831e74da880
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 13 Mar 2025 15:31:15 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 07 Apr 2025 09:43:19 +02:00
genirq/generic-chip: Make locking unconditional
The SMP conditional wrappers around raw_spin_[un]lock() have no real
value. On !SMP kernels the lock operations are NOOPs except for a
preempt_disable/enable() pair on PREEMPT enabled kernels, which are not
really worth to optimize for. Aside of that this evades lockdep on !SMP
kernels.
Remove the !SMP stubs and make it unconditional.
No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250313142524.011345765@linutronix.de
---
include/linux/irq.h | 5 -----
1 file changed, 5 deletions(-)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index dd5df1e..5007729 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -1222,7 +1222,6 @@ static inline struct irq_chip_type *irq_data_get_chip_type(struct irq_data *d)
#define IRQ_MSK(n) (u32)((n) < 32 ? ((1 << (n)) - 1) : UINT_MAX)
-#ifdef CONFIG_SMP
static inline void irq_gc_lock(struct irq_chip_generic *gc)
{
raw_spin_lock(&gc->lock);
@@ -1232,10 +1231,6 @@ static inline void irq_gc_unlock(struct irq_chip_generic *gc)
{
raw_spin_unlock(&gc->lock);
}
-#else
-static inline void irq_gc_lock(struct irq_chip_generic *gc) { }
-static inline void irq_gc_unlock(struct irq_chip_generic *gc) { }
-#endif
/*
* The irqsave variants are for usage in non interrupt code. Do not use
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [tip: irq/drivers] genirq/generic-chip: Convert core code to lock guards
2025-03-13 14:31 ` [patch 2/7] genirq/generic-chip: Convert core code to lock guards Thomas Gleixner
2025-03-14 10:55 ` Linus Walleij
@ 2025-04-07 7:53 ` tip-bot2 for Thomas Gleixner
2025-04-08 18:10 ` [patch 2/7] " Geert Uytterhoeven
2 siblings, 0 replies; 26+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2025-04-07 7:53 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Thomas Gleixner, Linus Walleij, x86, linux-kernel
The following commit has been merged into the irq/drivers branch of tip:
Commit-ID: 195298c3b11628a6c52c515c31470e673cf259a9
Gitweb: https://git.kernel.org/tip/195298c3b11628a6c52c515c31470e673cf259a9
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 13 Mar 2025 15:31:17 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 07 Apr 2025 09:43:19 +02:00
genirq/generic-chip: Convert core code to lock guards
Replace the irq_gc_lock/unlock() pairs with guards. There is no point to
implement a guard wrapper for them as they just wrap around raw_spin_lock*().
Switch the other lock instances in the core code to guards as well.
Conversion was done with Coccinelle plus manual fixups.
No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/all/20250313142524.073826193@linutronix.de
---
kernel/irq/generic-chip.c | 47 ++++++++++++--------------------------
1 file changed, 16 insertions(+), 31 deletions(-)
diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index c4a8bca..8014bfe 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -40,10 +40,9 @@ void irq_gc_mask_disable_reg(struct irq_data *d)
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, mask, ct->regs.disable);
*ct->mask_cache &= ~mask;
- irq_gc_unlock(gc);
}
EXPORT_SYMBOL_GPL(irq_gc_mask_disable_reg);
@@ -60,10 +59,9 @@ void irq_gc_mask_set_bit(struct irq_data *d)
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
*ct->mask_cache |= mask;
irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask);
- irq_gc_unlock(gc);
}
EXPORT_SYMBOL_GPL(irq_gc_mask_set_bit);
@@ -80,10 +78,9 @@ void irq_gc_mask_clr_bit(struct irq_data *d)
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
*ct->mask_cache &= ~mask;
irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask);
- irq_gc_unlock(gc);
}
EXPORT_SYMBOL_GPL(irq_gc_mask_clr_bit);
@@ -100,10 +97,9 @@ void irq_gc_unmask_enable_reg(struct irq_data *d)
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, mask, ct->regs.enable);
*ct->mask_cache |= mask;
- irq_gc_unlock(gc);
}
EXPORT_SYMBOL_GPL(irq_gc_unmask_enable_reg);
@@ -117,9 +113,8 @@ void irq_gc_ack_set_bit(struct irq_data *d)
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, mask, ct->regs.ack);
- irq_gc_unlock(gc);
}
EXPORT_SYMBOL_GPL(irq_gc_ack_set_bit);
@@ -133,9 +128,8 @@ void irq_gc_ack_clr_bit(struct irq_data *d)
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = ~d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, mask, ct->regs.ack);
- irq_gc_unlock(gc);
}
/**
@@ -156,11 +150,10 @@ void irq_gc_mask_disable_and_ack_set(struct irq_data *d)
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, mask, ct->regs.disable);
*ct->mask_cache &= ~mask;
irq_reg_writel(gc, mask, ct->regs.ack);
- irq_gc_unlock(gc);
}
EXPORT_SYMBOL_GPL(irq_gc_mask_disable_and_ack_set);
@@ -174,9 +167,8 @@ void irq_gc_eoi(struct irq_data *d)
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
irq_reg_writel(gc, mask, ct->regs.eoi);
- irq_gc_unlock(gc);
}
/**
@@ -196,12 +188,11 @@ int irq_gc_set_wake(struct irq_data *d, unsigned int on)
if (!(mask & gc->wake_enabled))
return -EINVAL;
- irq_gc_lock(gc);
+ guard(raw_spinlock)(&gc->lock);
if (on)
gc->wake_active |= mask;
else
gc->wake_active &= ~mask;
- irq_gc_unlock(gc);
return 0;
}
EXPORT_SYMBOL_GPL(irq_gc_set_wake);
@@ -288,7 +279,6 @@ int irq_domain_alloc_generic_chips(struct irq_domain *d,
{
struct irq_domain_chip_generic *dgc;
struct irq_chip_generic *gc;
- unsigned long flags;
int numchips, i;
size_t dgc_sz;
size_t gc_sz;
@@ -340,9 +330,8 @@ int irq_domain_alloc_generic_chips(struct irq_domain *d,
goto err;
}
- raw_spin_lock_irqsave(&gc_lock, flags);
- list_add_tail(&gc->list, &gc_list);
- raw_spin_unlock_irqrestore(&gc_lock, flags);
+ scoped_guard (raw_spinlock, &gc_lock)
+ list_add_tail(&gc->list, &gc_list);
/* Calc pointer to the next generic chip */
tmp += gc_sz;
}
@@ -459,7 +448,6 @@ int irq_map_generic_chip(struct irq_domain *d, unsigned int virq,
struct irq_chip_generic *gc;
struct irq_chip_type *ct;
struct irq_chip *chip;
- unsigned long flags;
int idx;
gc = __irq_get_domain_generic_chip(d, hw_irq);
@@ -479,9 +467,8 @@ int irq_map_generic_chip(struct irq_domain *d, unsigned int virq,
/* We only init the cache for the first mapping of a generic chip */
if (!gc->installed) {
- raw_spin_lock_irqsave(&gc->lock, flags);
+ guard(raw_spinlock_irq)(&gc->lock);
irq_gc_init_mask_cache(gc, dgc->gc_flags);
- raw_spin_unlock_irqrestore(&gc->lock, flags);
}
/* Mark the interrupt as installed */
@@ -548,9 +535,8 @@ void irq_setup_generic_chip(struct irq_chip_generic *gc, u32 msk,
struct irq_chip *chip = &ct->chip;
unsigned int i;
- raw_spin_lock(&gc_lock);
- list_add_tail(&gc->list, &gc_list);
- raw_spin_unlock(&gc_lock);
+ scoped_guard (raw_spinlock, &gc_lock)
+ list_add_tail(&gc->list, &gc_list);
irq_gc_init_mask_cache(gc, flags);
@@ -616,9 +602,8 @@ void irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk,
{
unsigned int i, virq;
- raw_spin_lock(&gc_lock);
- list_del(&gc->list);
- raw_spin_unlock(&gc_lock);
+ scoped_guard (raw_spinlock, &gc_lock)
+ list_del(&gc->list);
for (i = 0; msk; msk >>= 1, i++) {
if (!(msk & 0x01))
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [patch 2/7] genirq/generic-chip: Convert core code to lock guards
2025-03-13 14:31 ` [patch 2/7] genirq/generic-chip: Convert core code to lock guards Thomas Gleixner
2025-03-14 10:55 ` Linus Walleij
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
@ 2025-04-08 18:10 ` Geert Uytterhoeven
2 siblings, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2025-04-08 18:10 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Jiri Slaby, Andrew Lunn, Sebastian Hesselbarth,
Gregory Clement, Uwe Kleine-König, Linus Walleij,
Bartosz Golaszewski, Talel Shenhar, Nicolas Ferre,
Alexandre Belloni, Claudiu Beznea, Florian Fainelli, Guo Ren,
Herve Codina, Huacai Chen, Jiaxun Yang, Maxime Coquelin,
Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Hi Thomas,
On Thu, 13 Mar 2025 at 15:37, Thomas Gleixner <tglx@linutronix.de> wrote:
> Replace the irq_gc_lock/unlock() pairs with guards. There is no point to
> implement a guard wrapper for them as they just wrap around raw_spin_lock*().
>
> Switch the other lock instances in the core code to guards as well.
>
> Conversion was done with Coccinelle plus manual fixups.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Thanks for your patch, which is now commit 195298c3b11628a6
("genirq/generic-chip: Convert core code to lock guards") in
irqchip/irq/drivers.
> --- a/kernel/irq/generic-chip.c
> +++ b/kernel/irq/generic-chip.c
> @@ -340,9 +330,8 @@ int irq_domain_alloc_generic_chips(struc
> goto err;
> }
>
> - raw_spin_lock_irqsave(&gc_lock, flags);
> - list_add_tail(&gc->list, &gc_list);
> - raw_spin_unlock_irqrestore(&gc_lock, flags);
> + scoped_guard (raw_spinlock, &gc_lock)
> + list_add_tail(&gc->list, &gc_list);
> /* Calc pointer to the next generic chip */
> tmp += gc_sz;
> }
> @@ -459,7 +448,6 @@ int irq_map_generic_chip(struct irq_doma
> struct irq_chip_generic *gc;
> struct irq_chip_type *ct;
> struct irq_chip *chip;
> - unsigned long flags;
> int idx;
>
> gc = __irq_get_domain_generic_chip(d, hw_irq);
> @@ -479,9 +467,8 @@ int irq_map_generic_chip(struct irq_doma
>
> /* We only init the cache for the first mapping of a generic chip */
> if (!gc->installed) {
> - raw_spin_lock_irqsave(&gc->lock, flags);
> + guard(raw_spinlock_irq)(&gc->lock);
> irq_gc_init_mask_cache(gc, dgc->gc_flags);
> - raw_spin_unlock_irqrestore(&gc->lock, flags);
> }
>
> /* Mark the interrupt as installed */
These two conversions are wrong. I have sent a patch:
https://lore.kernel.org/514f94c5891c61ac0a4a7fdad113e75db1eea367.1744135467.git.geert+renesas@glider.be
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch 4/7] ARM: orion/gpio:: Convert generic irqchip locking to guard()
2025-03-13 14:31 ` [patch 4/7] ARM: orion/gpio:: " Thomas Gleixner
2025-03-14 10:56 ` Linus Walleij
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
@ 2025-04-14 14:29 ` Gregory CLEMENT
2 siblings, 0 replies; 26+ messages in thread
From: Gregory CLEMENT @ 2025-04-14 14:29 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Jiri Slaby, Andrew Lunn, Sebastian Hesselbarth,
Uwe Kleine-König, Linus Walleij, Bartosz Golaszewski,
Talel Shenhar, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Florian Fainelli, Guo Ren, Herve Codina, Huacai Chen, Jiaxun Yang,
Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
Hello Thomas,
> Conversion was done with Coccinelle. No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> Cc: Gregory Clement <gregory.clement@bootlin.com>
Applied on mvebu/arm
Thanks,
Gregory
> ---
> arch/arm/plat-orion/gpio.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> --- a/arch/arm/plat-orion/gpio.c
> +++ b/arch/arm/plat-orion/gpio.c
> @@ -496,11 +496,10 @@ static void orion_gpio_unmask_irq(struct
> u32 reg_val;
> u32 mask = d->mask;
>
> - irq_gc_lock(gc);
> + guard(raw_spinlock)(&gc->lock);
> reg_val = irq_reg_readl(gc, ct->regs.mask);
> reg_val |= mask;
> irq_reg_writel(gc, reg_val, ct->regs.mask);
> - irq_gc_unlock(gc);
> }
>
> static void orion_gpio_mask_irq(struct irq_data *d)
> @@ -510,11 +509,10 @@ static void orion_gpio_mask_irq(struct i
> u32 mask = d->mask;
> u32 reg_val;
>
> - irq_gc_lock(gc);
> + guard(raw_spinlock)(&gc->lock);
> reg_val = irq_reg_readl(gc, ct->regs.mask);
> reg_val &= ~mask;
> irq_reg_writel(gc, reg_val, ct->regs.mask);
> - irq_gc_unlock(gc);
> }
>
> void __init orion_gpio_init(int gpio_base, int ngpio,
>
--
Grégory CLEMENT, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2025-04-14 14:29 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-13 14:31 [patch 0/7] genirq/generic_chip: Convert locking to guards Thomas Gleixner
2025-03-13 14:31 ` [patch 1/7] genirq/generic-chip: Make locking unconditional Thomas Gleixner
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2025-03-13 14:31 ` [patch 2/7] genirq/generic-chip: Convert core code to lock guards Thomas Gleixner
2025-03-14 10:55 ` Linus Walleij
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2025-04-08 18:10 ` [patch 2/7] " Geert Uytterhoeven
2025-03-13 14:31 ` [patch 3/7] soc: dove: Convert generic irqchip locking to guard() Thomas Gleixner
2025-03-13 14:48 ` Andrew Lunn
2025-03-14 10:57 ` Linus Walleij
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2025-03-13 14:31 ` [patch 4/7] ARM: orion/gpio:: " Thomas Gleixner
2025-03-14 10:56 ` Linus Walleij
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2025-04-14 14:29 ` [patch 4/7] " Gregory CLEMENT
2025-03-13 14:31 ` [patch 5/7] gpio: mvebu: " Thomas Gleixner
2025-03-14 10:19 ` Bartosz Golaszewski
2025-03-14 11:07 ` Linus Walleij
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2025-03-13 14:31 ` [patch 6/7] irqchip: Convert generic irqchip locking to guards Thomas Gleixner
2025-03-14 10:56 ` Linus Walleij
2025-03-14 17:20 ` Herve Codina
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2025-03-13 14:31 ` [patch 7/7] genirq/generic-chip: Remove unused lock wrappers Thomas Gleixner
2025-04-07 7:53 ` [tip: irq/drivers] " tip-bot2 for Thomas Gleixner
2025-03-16 8:50 ` [patch 0/7] genirq/generic_chip: Convert locking to guards Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox