* [PATCH RFC 1/9] gpio: bcm-kona: make irq_chip immutable
2025-05-09 4:45 [PATCH RFC 0/9] gpio: make irq_chip immutable Peng Fan (OSS)
@ 2025-05-09 4:45 ` Peng Fan (OSS)
2025-05-09 4:45 ` [PATCH RFC 2/9] gpio: grgpio: Make " Peng Fan (OSS)
` (10 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: Peng Fan (OSS) @ 2025-05-09 4:45 UTC (permalink / raw)
To: Ray Jui, Broadcom internal kernel review list, Linus Walleij,
Bartosz Golaszewski, Florian Fainelli, Scott Branden,
Vladimir Zapolskiy, Keerthy, Robert Jarzmik
Cc: linux-gpio, linux-kernel, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
The gpiolib is moving to make irq_chip immutable, otherwise
there is warning: "not an immutable chip, please consider fixing it!"
The bcm_gpio_irq_chip already has irq hooks configured correctly,
bcm_kona_gpio_irq_mask/bcm_kona_gpio_irq_unmask calls gpiochip_disable_irq/
gpiochip_enable_irq, and bcm_kona_gpio_irq_reqres/irq_release_resources
calls gpiochip_reqres_irq/gpiochip_relres_irq.
So just need to flag it as IRQCHIP_IMMUTABLE.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/gpio/gpio-bcm-kona.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
index 17c287dc747151c6217c11fe77d83e3542e830c2..8f22cb36004d4b27a3ca33352dd1ae176aee5331 100644
--- a/drivers/gpio/gpio-bcm-kona.c
+++ b/drivers/gpio/gpio-bcm-kona.c
@@ -516,6 +516,7 @@ static struct irq_chip bcm_gpio_irq_chip = {
.irq_set_type = bcm_kona_gpio_irq_set_type,
.irq_request_resources = bcm_kona_gpio_irq_reqres,
.irq_release_resources = bcm_kona_gpio_irq_relres,
+ .flags = IRQCHIP_IMMUTABLE,
};
static struct of_device_id const bcm_kona_gpio_of_match[] = {
--
2.37.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH RFC 2/9] gpio: grgpio: Make irq_chip immutable
2025-05-09 4:45 [PATCH RFC 0/9] gpio: make irq_chip immutable Peng Fan (OSS)
2025-05-09 4:45 ` [PATCH RFC 1/9] gpio: bcm-kona: " Peng Fan (OSS)
@ 2025-05-09 4:45 ` Peng Fan (OSS)
2025-05-09 4:45 ` [PATCH RFC 3/9] gpio: lpc18xx: " Peng Fan (OSS)
` (9 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: Peng Fan (OSS) @ 2025-05-09 4:45 UTC (permalink / raw)
To: Ray Jui, Broadcom internal kernel review list, Linus Walleij,
Bartosz Golaszewski, Florian Fainelli, Scott Branden,
Vladimir Zapolskiy, Keerthy, Robert Jarzmik
Cc: linux-gpio, linux-kernel, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Kernel warns about mutable irq_chips:
"not an immutable chip, please consider fixing!"
Constify grgpio_irq_chip, flag the irq_chip as IRQCHIP_IMMUTABLE, add the
new helper functions, and call the appropriate gpiolib functions.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/gpio/gpio-grgpio.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-grgpio.c b/drivers/gpio/gpio-grgpio.c
index 641df8f2fd3d3fc523acd5103cc77d50113599e5..d38a2d9854ca524f05164180601b1a936cc70983 100644
--- a/drivers/gpio/gpio-grgpio.c
+++ b/drivers/gpio/gpio-grgpio.c
@@ -170,6 +170,8 @@ static void grgpio_irq_mask(struct irq_data *d)
grgpio_set_imask(priv, offset, 0);
raw_spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags);
+
+ gpiochip_disable_irq(&priv->gc, d->hwirq);
}
static void grgpio_irq_unmask(struct irq_data *d)
@@ -178,6 +180,7 @@ static void grgpio_irq_unmask(struct irq_data *d)
int offset = d->hwirq;
unsigned long flags;
+ gpiochip_enable_irq(&priv->gc, d->hwirq);
raw_spin_lock_irqsave(&priv->gc.bgpio_lock, flags);
grgpio_set_imask(priv, offset, 1);
@@ -185,11 +188,13 @@ static void grgpio_irq_unmask(struct irq_data *d)
raw_spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags);
}
-static struct irq_chip grgpio_irq_chip = {
+static const struct irq_chip grgpio_irq_chip = {
.name = "grgpio",
.irq_mask = grgpio_irq_mask,
.irq_unmask = grgpio_irq_unmask,
.irq_set_type = grgpio_irq_set_type,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static irqreturn_t grgpio_irq_handler(int irq, void *dev)
--
2.37.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH RFC 3/9] gpio: lpc18xx: Make irq_chip immutable
2025-05-09 4:45 [PATCH RFC 0/9] gpio: make irq_chip immutable Peng Fan (OSS)
2025-05-09 4:45 ` [PATCH RFC 1/9] gpio: bcm-kona: " Peng Fan (OSS)
2025-05-09 4:45 ` [PATCH RFC 2/9] gpio: grgpio: Make " Peng Fan (OSS)
@ 2025-05-09 4:45 ` Peng Fan (OSS)
2025-05-09 4:45 ` [PATCH RFC 4/9] gpio: mpc8xxx: " Peng Fan (OSS)
` (8 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: Peng Fan (OSS) @ 2025-05-09 4:45 UTC (permalink / raw)
To: Ray Jui, Broadcom internal kernel review list, Linus Walleij,
Bartosz Golaszewski, Florian Fainelli, Scott Branden,
Vladimir Zapolskiy, Keerthy, Robert Jarzmik
Cc: linux-gpio, linux-kernel, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Kernel warns about mutable irq_chips:
"not an immutable chip, please consider fixing!"
Constify lpc18xx_gpio_pin_ic, flag the irq_chip as IRQCHIP_IMMUTABLE,
add the new helper functions, and call the appropriate gpiolib functions.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/gpio/gpio-lpc18xx.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-lpc18xx.c b/drivers/gpio/gpio-lpc18xx.c
index ae6182cce7234166fe94ab0c8d5e07c11bb71101..a2e316d9350b736e8bb89c17845d70cc74481d1b 100644
--- a/drivers/gpio/gpio-lpc18xx.c
+++ b/drivers/gpio/gpio-lpc18xx.c
@@ -42,6 +42,7 @@ struct lpc18xx_gpio_pin_ic {
void __iomem *base;
struct irq_domain *domain;
struct raw_spinlock lock;
+ struct gpio_chip *gpio;
};
struct lpc18xx_gpio_chip {
@@ -74,6 +75,7 @@ static void lpc18xx_gpio_pin_ic_mask(struct irq_data *d)
{
struct lpc18xx_gpio_pin_ic *ic = d->chip_data;
u32 type = irqd_get_trigger_type(d);
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
raw_spin_lock(&ic->lock);
@@ -88,12 +90,17 @@ static void lpc18xx_gpio_pin_ic_mask(struct irq_data *d)
raw_spin_unlock(&ic->lock);
irq_chip_mask_parent(d);
+
+ gpiochip_disable_irq(ic->gpio, hwirq);
}
static void lpc18xx_gpio_pin_ic_unmask(struct irq_data *d)
{
struct lpc18xx_gpio_pin_ic *ic = d->chip_data;
u32 type = irqd_get_trigger_type(d);
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
+
+ gpiochip_enable_irq(ic->gpio, hwirq);
raw_spin_lock(&ic->lock);
@@ -149,13 +156,14 @@ static int lpc18xx_gpio_pin_ic_set_type(struct irq_data *d, unsigned int type)
return 0;
}
-static struct irq_chip lpc18xx_gpio_pin_ic = {
+static const struct irq_chip lpc18xx_gpio_pin_ic = {
.name = "LPC18xx GPIO pin",
.irq_mask = lpc18xx_gpio_pin_ic_mask,
.irq_unmask = lpc18xx_gpio_pin_ic_unmask,
.irq_eoi = lpc18xx_gpio_pin_ic_eoi,
.irq_set_type = lpc18xx_gpio_pin_ic_set_type,
- .flags = IRQCHIP_SET_TYPE_MASKED,
+ .flags = IRQCHIP_IMMUTABLE | IRQCHIP_SET_TYPE_MASKED,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static int lpc18xx_gpio_pin_ic_domain_alloc(struct irq_domain *domain,
@@ -249,6 +257,7 @@ static int lpc18xx_gpio_pin_ic_probe(struct lpc18xx_gpio_chip *gc)
goto free_iomap;
}
+ ic->gpio = &gc->gpio;
gc->pin_ic = ic;
return 0;
--
2.37.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH RFC 4/9] gpio: mpc8xxx: Make irq_chip immutable
2025-05-09 4:45 [PATCH RFC 0/9] gpio: make irq_chip immutable Peng Fan (OSS)
` (2 preceding siblings ...)
2025-05-09 4:45 ` [PATCH RFC 3/9] gpio: lpc18xx: " Peng Fan (OSS)
@ 2025-05-09 4:45 ` Peng Fan (OSS)
2025-05-09 4:45 ` [PATCH RFC 5/9] gpio: davinci: Update irq chip data Peng Fan (OSS)
` (7 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: Peng Fan (OSS) @ 2025-05-09 4:45 UTC (permalink / raw)
To: Ray Jui, Broadcom internal kernel review list, Linus Walleij,
Bartosz Golaszewski, Florian Fainelli, Scott Branden,
Vladimir Zapolskiy, Keerthy, Robert Jarzmik
Cc: linux-gpio, linux-kernel, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Kernel warns about mutable irq_chips:
"not an immutable chip, please consider fixing!"
Flag the irq_chip as IRQCHIP_IMMUTABLE, add the new helper functions,
and call the appropriate gpiolib functions.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/gpio/gpio-mpc8xxx.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index 5415175364899ef621fab83748f4cea34f430556..121efdd71e451d4f992fa195b0d56d7146a6f3dd 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -123,9 +123,12 @@ static irqreturn_t mpc8xxx_gpio_irq_cascade(int irq, void *data)
static void mpc8xxx_irq_unmask(struct irq_data *d)
{
struct mpc8xxx_gpio_chip *mpc8xxx_gc = irq_data_get_irq_chip_data(d);
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
struct gpio_chip *gc = &mpc8xxx_gc->gc;
unsigned long flags;
+ gpiochip_enable_irq(gc, hwirq);
+
raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
gc->write_reg(mpc8xxx_gc->regs + GPIO_IMR,
@@ -138,6 +141,7 @@ static void mpc8xxx_irq_unmask(struct irq_data *d)
static void mpc8xxx_irq_mask(struct irq_data *d)
{
struct mpc8xxx_gpio_chip *mpc8xxx_gc = irq_data_get_irq_chip_data(d);
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
struct gpio_chip *gc = &mpc8xxx_gc->gc;
unsigned long flags;
@@ -148,6 +152,8 @@ static void mpc8xxx_irq_mask(struct irq_data *d)
& ~mpc_pin2mask(irqd_to_hwirq(d)));
raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
+
+ gpiochip_disable_irq(gc, hwirq);
}
static void mpc8xxx_irq_ack(struct irq_data *d)
@@ -244,6 +250,8 @@ static struct irq_chip mpc8xxx_irq_chip = {
.irq_ack = mpc8xxx_irq_ack,
/* this might get overwritten in mpc8xxx_probe() */
.irq_set_type = mpc8xxx_irq_set_type,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static int mpc8xxx_gpio_irq_map(struct irq_domain *h, unsigned int irq,
--
2.37.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH RFC 5/9] gpio: davinci: Update irq chip data
2025-05-09 4:45 [PATCH RFC 0/9] gpio: make irq_chip immutable Peng Fan (OSS)
` (3 preceding siblings ...)
2025-05-09 4:45 ` [PATCH RFC 4/9] gpio: mpc8xxx: " Peng Fan (OSS)
@ 2025-05-09 4:45 ` Peng Fan (OSS)
2025-05-09 4:45 ` [PATCH RFC 6/9] gpio: davinci: Make irq_chip immutable Peng Fan (OSS)
` (6 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: Peng Fan (OSS) @ 2025-05-09 4:45 UTC (permalink / raw)
To: Ray Jui, Broadcom internal kernel review list, Linus Walleij,
Bartosz Golaszewski, Florian Fainelli, Scott Branden,
Vladimir Zapolskiy, Keerthy, Robert Jarzmik
Cc: linux-gpio, linux-kernel, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Use "struct davinci_gpio_controller *chips" as irq chip data to prepare
for immutable irq chip, then it will be easy to get gpio_chip pointer in
irq mask/unmask.
No functional change.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/gpio/gpio-davinci.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 3c3b3ed46d9b480eb7916fa2402e5bbcc06cd563..4494acc14630bcc7cb75dc475b5ae7e0a595cc5c 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -68,15 +68,6 @@ static inline u32 __gpio_mask(unsigned gpio)
return 1 << (gpio % 32);
}
-static inline struct davinci_gpio_regs __iomem *irq2regs(struct irq_data *d)
-{
- struct davinci_gpio_regs __iomem *g;
-
- g = (__force struct davinci_gpio_regs __iomem *)irq_data_get_irq_chip_data(d);
-
- return g;
-}
-
static int davinci_gpio_irq_setup(struct platform_device *pdev);
/*--------------------------------------------------------------------------*/
@@ -255,7 +246,9 @@ static int davinci_gpio_probe(struct platform_device *pdev)
static void gpio_irq_mask(struct irq_data *d)
{
- struct davinci_gpio_regs __iomem *g = irq2regs(d);
+ struct davinci_gpio_controller *chips = irq_data_get_irq_chip_data(d);
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
+ struct davinci_gpio_regs __iomem *g = chips->regs[hwirq / 32];
uintptr_t mask = (uintptr_t)irq_data_get_irq_handler_data(d);
writel_relaxed(mask, &g->clr_falling);
@@ -264,7 +257,9 @@ static void gpio_irq_mask(struct irq_data *d)
static void gpio_irq_unmask(struct irq_data *d)
{
- struct davinci_gpio_regs __iomem *g = irq2regs(d);
+ struct davinci_gpio_controller *chips = irq_data_get_irq_chip_data(d);
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
+ struct davinci_gpio_regs __iomem *g = chips->regs[hwirq / 32];
uintptr_t mask = (uintptr_t)irq_data_get_irq_handler_data(d);
unsigned status = irqd_get_trigger_type(d);
@@ -399,12 +394,11 @@ davinci_gpio_irq_map(struct irq_domain *d, unsigned int irq,
{
struct davinci_gpio_controller *chips =
(struct davinci_gpio_controller *)d->host_data;
- struct davinci_gpio_regs __iomem *g = chips->regs[hw / 32];
irq_set_chip_and_handler_name(irq, &gpio_irqchip, handle_simple_irq,
"davinci_gpio");
irq_set_irq_type(irq, IRQ_TYPE_NONE);
- irq_set_chip_data(irq, (__force void *)g);
+ irq_set_chip_data(irq, (__force void *)chips);
irq_set_handler_data(irq, (void *)(uintptr_t)__gpio_mask(hw));
return 0;
--
2.37.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH RFC 6/9] gpio: davinci: Make irq_chip immutable
2025-05-09 4:45 [PATCH RFC 0/9] gpio: make irq_chip immutable Peng Fan (OSS)
` (4 preceding siblings ...)
2025-05-09 4:45 ` [PATCH RFC 5/9] gpio: davinci: Update irq chip data Peng Fan (OSS)
@ 2025-05-09 4:45 ` Peng Fan (OSS)
2025-05-09 4:45 ` [PATCH RFC 7/9] gpio: xgene-sb: " Peng Fan (OSS)
` (5 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: Peng Fan (OSS) @ 2025-05-09 4:45 UTC (permalink / raw)
To: Ray Jui, Broadcom internal kernel review list, Linus Walleij,
Bartosz Golaszewski, Florian Fainelli, Scott Branden,
Vladimir Zapolskiy, Keerthy, Robert Jarzmik
Cc: linux-gpio, linux-kernel, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Kernel warns about mutable irq_chips:
"not an immutable chip, please consider fixing!"
Constify gpio_irqchip, flag the irq_chip as IRQCHIP_IMMUTABLE, add the
new helper functions, and call the appropriate gpiolib functions.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/gpio/gpio-davinci.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 4494acc14630bcc7cb75dc475b5ae7e0a595cc5c..80a82492171e43876e617e86ba024aef095229e1 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -253,6 +253,8 @@ static void gpio_irq_mask(struct irq_data *d)
writel_relaxed(mask, &g->clr_falling);
writel_relaxed(mask, &g->clr_rising);
+
+ gpiochip_disable_irq(&chips->chip, hwirq);
}
static void gpio_irq_unmask(struct irq_data *d)
@@ -263,6 +265,8 @@ static void gpio_irq_unmask(struct irq_data *d)
uintptr_t mask = (uintptr_t)irq_data_get_irq_handler_data(d);
unsigned status = irqd_get_trigger_type(d);
+ gpiochip_enable_irq(&chips->chip, hwirq);
+
status &= IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING;
if (!status)
status = IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING;
@@ -281,12 +285,13 @@ static int gpio_irq_type(struct irq_data *d, unsigned trigger)
return 0;
}
-static struct irq_chip gpio_irqchip = {
+static const struct irq_chip gpio_irqchip = {
.name = "GPIO",
.irq_unmask = gpio_irq_unmask,
.irq_mask = gpio_irq_mask,
.irq_set_type = gpio_irq_type,
- .flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_SKIP_SET_WAKE,
+ .flags = IRQCHIP_IMMUTABLE | IRQCHIP_SET_TYPE_MASKED | IRQCHIP_SKIP_SET_WAKE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static void gpio_irq_handler(struct irq_desc *desc)
--
2.37.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH RFC 7/9] gpio: xgene-sb: Make irq_chip immutable
2025-05-09 4:45 [PATCH RFC 0/9] gpio: make irq_chip immutable Peng Fan (OSS)
` (5 preceding siblings ...)
2025-05-09 4:45 ` [PATCH RFC 6/9] gpio: davinci: Make irq_chip immutable Peng Fan (OSS)
@ 2025-05-09 4:45 ` Peng Fan (OSS)
2025-05-09 4:45 ` [PATCH RFC 8/9] gpio: timberdale: " Peng Fan (OSS)
` (4 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: Peng Fan (OSS) @ 2025-05-09 4:45 UTC (permalink / raw)
To: Ray Jui, Broadcom internal kernel review list, Linus Walleij,
Bartosz Golaszewski, Florian Fainelli, Scott Branden,
Vladimir Zapolskiy, Keerthy, Robert Jarzmik
Cc: linux-gpio, linux-kernel, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Kernel warns about mutable irq_chips:
"not an immutable chip, please consider fixing!"
Constify xgene_gpio_sb_irq_chip, flag the irq_chip as IRQCHIP_IMMUTABLE,
add the new helper functions, and call the appropriate gpiolib functions.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/gpio/gpio-xgene-sb.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-xgene-sb.c b/drivers/gpio/gpio-xgene-sb.c
index 48b829733b1509d9e0b409a0422f95ddb78d4525..b51b1fa726bb5ac6fce21f93e98035b5f684ee88 100644
--- a/drivers/gpio/gpio-xgene-sb.c
+++ b/drivers/gpio/gpio-xgene-sb.c
@@ -103,12 +103,32 @@ static int xgene_gpio_sb_irq_set_type(struct irq_data *d, unsigned int type)
return irq_chip_set_type_parent(d, IRQ_TYPE_LEVEL_HIGH);
}
-static struct irq_chip xgene_gpio_sb_irq_chip = {
+static void xgene_gpio_sb_irq_mask(struct irq_data *d)
+{
+ struct xgene_gpio_sb *priv = irq_data_get_irq_chip_data(d);
+
+ irq_chip_mask_parent(d);
+
+ gpiochip_disable_irq(&priv->gc, d->hwirq);
+}
+
+static void xgene_gpio_sb_irq_unmask(struct irq_data *d)
+{
+ struct xgene_gpio_sb *priv = irq_data_get_irq_chip_data(d);
+
+ gpiochip_enable_irq(&priv->gc, d->hwirq);
+
+ irq_chip_unmask_parent(d);
+}
+
+static const struct irq_chip xgene_gpio_sb_irq_chip = {
.name = "sbgpio",
.irq_eoi = irq_chip_eoi_parent,
- .irq_mask = irq_chip_mask_parent,
- .irq_unmask = irq_chip_unmask_parent,
+ .irq_mask = xgene_gpio_sb_irq_mask,
+ .irq_unmask = xgene_gpio_sb_irq_unmask,
.irq_set_type = xgene_gpio_sb_irq_set_type,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static int xgene_gpio_sb_to_irq(struct gpio_chip *gc, u32 gpio)
--
2.37.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH RFC 8/9] gpio: timberdale: Make irq_chip immutable
2025-05-09 4:45 [PATCH RFC 0/9] gpio: make irq_chip immutable Peng Fan (OSS)
` (6 preceding siblings ...)
2025-05-09 4:45 ` [PATCH RFC 7/9] gpio: xgene-sb: " Peng Fan (OSS)
@ 2025-05-09 4:45 ` Peng Fan (OSS)
2025-05-10 18:26 ` Andy Shevchenko
2025-05-09 4:45 ` [PATCH RFC 9/9] gpio: pxa: " Peng Fan (OSS)
` (3 subsequent siblings)
11 siblings, 1 reply; 16+ messages in thread
From: Peng Fan (OSS) @ 2025-05-09 4:45 UTC (permalink / raw)
To: Ray Jui, Broadcom internal kernel review list, Linus Walleij,
Bartosz Golaszewski, Florian Fainelli, Scott Branden,
Vladimir Zapolskiy, Keerthy, Robert Jarzmik
Cc: linux-gpio, linux-kernel, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Kernel warns about mutable irq_chips:
"not an immutable chip, please consider fixing!"
Constify timbgpio_irqchip, flag the irq_chip as IRQCHIP_IMMUTABLE,
add the new helper functions, and call the appropriate gpiolib functions.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/gpio/gpio-timberdale.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-timberdale.c b/drivers/gpio/gpio-timberdale.c
index fad979797486534d3cc6a1437fdca765baeb7b47..cb303a26f4d3cd77368b5bdac42aa42821b39345 100644
--- a/drivers/gpio/gpio-timberdale.c
+++ b/drivers/gpio/gpio-timberdale.c
@@ -103,20 +103,26 @@ static void timbgpio_irq_disable(struct irq_data *d)
{
struct timbgpio *tgpio = irq_data_get_irq_chip_data(d);
int offset = d->irq - tgpio->irq_base;
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
unsigned long flags;
spin_lock_irqsave(&tgpio->lock, flags);
tgpio->last_ier &= ~(1UL << offset);
iowrite32(tgpio->last_ier, tgpio->membase + TGPIO_IER);
spin_unlock_irqrestore(&tgpio->lock, flags);
+
+ gpiochip_disable_irq(&tgpio->gpio, hwirq);
}
static void timbgpio_irq_enable(struct irq_data *d)
{
struct timbgpio *tgpio = irq_data_get_irq_chip_data(d);
int offset = d->irq - tgpio->irq_base;
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
unsigned long flags;
+ gpiochip_enable_irq(&tgpio->gpio, hwirq);
+
spin_lock_irqsave(&tgpio->lock, flags);
tgpio->last_ier |= 1UL << offset;
iowrite32(tgpio->last_ier, tgpio->membase + TGPIO_IER);
@@ -205,11 +211,13 @@ static void timbgpio_irq(struct irq_desc *desc)
iowrite32(tgpio->last_ier, tgpio->membase + TGPIO_IER);
}
-static struct irq_chip timbgpio_irqchip = {
+static const struct irq_chip timbgpio_irqchip = {
.name = "GPIO",
.irq_enable = timbgpio_irq_enable,
.irq_disable = timbgpio_irq_disable,
.irq_set_type = timbgpio_irq_type,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static int timbgpio_probe(struct platform_device *pdev)
--
2.37.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 8/9] gpio: timberdale: Make irq_chip immutable
2025-05-09 4:45 ` [PATCH RFC 8/9] gpio: timberdale: " Peng Fan (OSS)
@ 2025-05-10 18:26 ` Andy Shevchenko
0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-05-10 18:26 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: Ray Jui, Broadcom internal kernel review list, Linus Walleij,
Bartosz Golaszewski, Florian Fainelli, Scott Branden,
Vladimir Zapolskiy, Keerthy, Robert Jarzmik, linux-gpio,
linux-kernel, linux-arm-kernel, Peng Fan
Fri, May 09, 2025 at 12:45:39PM +0800, Peng Fan (OSS) kirjoitti:
> From: Peng Fan <peng.fan@nxp.com>
>
> Kernel warns about mutable irq_chips:
> "not an immutable chip, please consider fixing!"
>
> Constify timbgpio_irqchip, flag the irq_chip as IRQCHIP_IMMUTABLE,
> add the new helper functions, and call the appropriate gpiolib functions.
...
> struct timbgpio *tgpio = irq_data_get_irq_chip_data(d);
> int offset = d->irq - tgpio->irq_base;
> + irq_hw_number_t hwirq = irqd_to_hwirq(d);
> unsigned long flags;
While at it, replace direct accesses to IRQ data `irq` member.
int offset = hwirq - tgpio->irq_base;
...
> static void timbgpio_irq_enable(struct irq_data *d)
> {
> struct timbgpio *tgpio = irq_data_get_irq_chip_data(d);
> int offset = d->irq - tgpio->irq_base;
> + irq_hw_number_t hwirq = irqd_to_hwirq(d);
> unsigned long flags;
Ditto.
> + gpiochip_enable_irq(&tgpio->gpio, hwirq);
> +
> spin_lock_irqsave(&tgpio->lock, flags);
> tgpio->last_ier |= 1UL << offset;
> iowrite32(tgpio->last_ier, tgpio->membase + TGPIO_IER);
> }
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH RFC 9/9] gpio: pxa: Make irq_chip immutable
2025-05-09 4:45 [PATCH RFC 0/9] gpio: make irq_chip immutable Peng Fan (OSS)
` (7 preceding siblings ...)
2025-05-09 4:45 ` [PATCH RFC 8/9] gpio: timberdale: " Peng Fan (OSS)
@ 2025-05-09 4:45 ` Peng Fan (OSS)
2025-05-10 18:29 ` [PATCH RFC 0/9] gpio: make " Andy Shevchenko
` (2 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: Peng Fan (OSS) @ 2025-05-09 4:45 UTC (permalink / raw)
To: Ray Jui, Broadcom internal kernel review list, Linus Walleij,
Bartosz Golaszewski, Florian Fainelli, Scott Branden,
Vladimir Zapolskiy, Keerthy, Robert Jarzmik
Cc: linux-gpio, linux-kernel, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Kernel warns about mutable irq_chips:
"not an immutable chip, please consider fixing!"
Constify pxa_muxed_gpio_chip, flag the irq_chip as IRQCHIP_IMMUTABLE,
add the new helper functions, and call the appropriate gpiolib functions.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/gpio/gpio-pxa.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index c3dfaed45c4319a54b545bd89b834253b77d369d..aead35ea090e6c37e80ae3c29e12c44cc8e930c7 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -497,6 +497,8 @@ static void pxa_mask_muxed_gpio(struct irq_data *d)
gfer = readl_relaxed(base + GFER_OFFSET) & ~GPIO_bit(gpio);
writel_relaxed(grer, base + GRER_OFFSET);
writel_relaxed(gfer, base + GFER_OFFSET);
+
+ gpiochip_disable_irq(&pchip->chip, gpio);
}
static int pxa_gpio_set_wake(struct irq_data *d, unsigned int on)
@@ -516,17 +518,21 @@ static void pxa_unmask_muxed_gpio(struct irq_data *d)
unsigned int gpio = irqd_to_hwirq(d);
struct pxa_gpio_bank *c = gpio_to_pxabank(&pchip->chip, gpio);
+ gpiochip_enable_irq(&pchip->chip, gpio);
+
c->irq_mask |= GPIO_bit(gpio);
update_edge_detect(c);
}
-static struct irq_chip pxa_muxed_gpio_chip = {
+static const struct irq_chip pxa_muxed_gpio_chip = {
.name = "GPIO",
.irq_ack = pxa_ack_muxed_gpio,
.irq_mask = pxa_mask_muxed_gpio,
.irq_unmask = pxa_unmask_muxed_gpio,
.irq_set_type = pxa_gpio_irq_type,
.irq_set_wake = pxa_gpio_set_wake,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static int pxa_gpio_nums(struct platform_device *pdev)
--
2.37.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/9] gpio: make irq_chip immutable
2025-05-09 4:45 [PATCH RFC 0/9] gpio: make irq_chip immutable Peng Fan (OSS)
` (8 preceding siblings ...)
2025-05-09 4:45 ` [PATCH RFC 9/9] gpio: pxa: " Peng Fan (OSS)
@ 2025-05-10 18:29 ` Andy Shevchenko
2025-05-13 13:13 ` Linus Walleij
2025-05-15 15:02 ` Bartosz Golaszewski
11 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-05-10 18:29 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: Ray Jui, Broadcom internal kernel review list, Linus Walleij,
Bartosz Golaszewski, Florian Fainelli, Scott Branden,
Vladimir Zapolskiy, Keerthy, Robert Jarzmik, linux-gpio,
linux-kernel, linux-arm-kernel, Peng Fan
Fri, May 09, 2025 at 12:45:31PM +0800, Peng Fan (OSS) kirjoitti:
> This might be a bit late to post this patchset, since it is almost rc6,
> but no rush here. Not expect this patchset be in 6.16.
Why not? These are mostly trivial ones and they fix the warning, they may
potentially be the fixes between -rc1 and -rc2,
> This is an effort to make irq_chip immutable to elimnate the kernel
> warning "not an immutable chip, please consider fixing!"
> The major changes
> - add "gpiochip_disable_irq(gc, hwirq)" to end of mask hook
> - add "gpiochip_enable_irq(gc, hwirq)" to start of unmask hook
> - add IMMUTABLE flag
> - add GPIOCHIP_IRQ_RESOURCE_HELPERS
No need to list the implementation details of IMMUTABLE flag. Just a summary
line is enough.
> For davinci, two patches are made, 1st is to update irq chip data, 2nd
> make irq_chip immutable.
> For xgene-sb, two functions are added, because previous driver directly
> use irq_chip_unmask_parent and irq_chip_mask_parent.
>
> In some patches, I use irqd_to_hwirq(d) to get hwirq; in others, I
> direclty use d->hwirq to align with previous code.
>
> Some Kconfig entries do not select GPILIB_IRQCHIP, but I tried
> to build pxa_defconfig lpc18xx_defconfig and multi_v7_defconfig,
> GPIOLIB_IRQCHIP is y.
> Not sure we should select GPIOLIB_IRQCHIP for them, because if
> deselect GPIOLIB_IRQCHIP, there will be build failure.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/9] gpio: make irq_chip immutable
2025-05-09 4:45 [PATCH RFC 0/9] gpio: make irq_chip immutable Peng Fan (OSS)
` (9 preceding siblings ...)
2025-05-10 18:29 ` [PATCH RFC 0/9] gpio: make " Andy Shevchenko
@ 2025-05-13 13:13 ` Linus Walleij
2025-05-15 15:02 ` Bartosz Golaszewski
11 siblings, 0 replies; 16+ messages in thread
From: Linus Walleij @ 2025-05-13 13:13 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: Ray Jui, Broadcom internal kernel review list,
Bartosz Golaszewski, Florian Fainelli, Scott Branden,
Vladimir Zapolskiy, Keerthy, Robert Jarzmik, linux-gpio,
linux-kernel, linux-arm-kernel, Peng Fan
On Fri, May 9, 2025 at 6:47 AM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:
> This might be a bit late to post this patchset, since it is almost rc6,
> but no rush here. Not expect this patchset be in 6.16.
The series:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
I agree with Andy, why not just apply this, these drivers have
had long time to adopt to immutable GPIO chip and your
patches are generously helping them to migrate. If things
break for these users they can fix it in the rc:s, and if there
are no users testing these, well that's a community problem.
But there can be some fallout, so it's your pick!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/9] gpio: make irq_chip immutable
2025-05-09 4:45 [PATCH RFC 0/9] gpio: make irq_chip immutable Peng Fan (OSS)
` (10 preceding siblings ...)
2025-05-13 13:13 ` Linus Walleij
@ 2025-05-15 15:02 ` Bartosz Golaszewski
2025-05-19 3:56 ` Peng Fan
11 siblings, 1 reply; 16+ messages in thread
From: Bartosz Golaszewski @ 2025-05-15 15:02 UTC (permalink / raw)
To: Ray Jui, Broadcom internal kernel review list, Linus Walleij,
Bartosz Golaszewski, Florian Fainelli, Scott Branden,
Vladimir Zapolskiy, Keerthy, Robert Jarzmik, Peng Fan (OSS)
Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, linux-arm-kernel,
Peng Fan
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
On Fri, 09 May 2025 12:45:31 +0800, Peng Fan (OSS) wrote:
> This might be a bit late to post this patchset, since it is almost rc6,
> but no rush here. Not expect this patchset be in 6.16.
>
> This is an effort to make irq_chip immutable to elimnate the kernel
> warning "not an immutable chip, please consider fixing!"
>
> The major changes
> - add "gpiochip_disable_irq(gc, hwirq)" to end of mask hook
> - add "gpiochip_enable_irq(gc, hwirq)" to start of unmask hook
> - add IMMUTABLE flag
> - add GPIOCHIP_IRQ_RESOURCE_HELPERS
>
> [...]
Applied, thanks!
[1/9] gpio: bcm-kona: make irq_chip immutable
https://git.kernel.org/brgl/linux/c/7b04f98027afd2cc329d00191dfc8284b382565d
[2/9] gpio: grgpio: Make irq_chip immutable
https://git.kernel.org/brgl/linux/c/a30be40bf1d4437646b6885e7e4e71530e6f82c1
[3/9] gpio: lpc18xx: Make irq_chip immutable
https://git.kernel.org/brgl/linux/c/289e42df1358abf85e49a140f7224c2abd170b2e
[4/9] gpio: mpc8xxx: Make irq_chip immutable
https://git.kernel.org/brgl/linux/c/7688a54d5b53f2e3160c00f19b00bc601fa3ec98
[5/9] gpio: davinci: Update irq chip data
https://git.kernel.org/brgl/linux/c/62be72bdb00ef52a0d0f02ce077e36b1f48ef0ae
[6/9] gpio: davinci: Make irq_chip immutable
https://git.kernel.org/brgl/linux/c/3f50bb3124d76653de0bcfe251faa357711e3ae6
[7/9] gpio: xgene-sb: Make irq_chip immutable
https://git.kernel.org/brgl/linux/c/580b3264cb252cae00fa62d58443af09c25f7d61
[8/9] gpio: timberdale: Make irq_chip immutable
https://git.kernel.org/brgl/linux/c/2993d2dd8ff4e8257a88d4d3f8ffc6df95928b94
[9/9] gpio: pxa: Make irq_chip immutable
https://git.kernel.org/brgl/linux/c/20117cf426b677e7aced4e7a1b2b37f6080a46dc
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: [PATCH RFC 0/9] gpio: make irq_chip immutable
2025-05-15 15:02 ` Bartosz Golaszewski
@ 2025-05-19 3:56 ` Peng Fan
2025-05-19 11:11 ` Bartosz Golaszewski
0 siblings, 1 reply; 16+ messages in thread
From: Peng Fan @ 2025-05-19 3:56 UTC (permalink / raw)
To: Bartosz Golaszewski, Ray Jui,
Broadcom internal kernel review list, Linus Walleij,
Florian Fainelli, Scott Branden, Vladimir Zapolskiy, Keerthy,
Robert Jarzmik, Peng Fan (OSS)
Cc: Bartosz Golaszewski, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Hi Bartosz,
> Subject: Re: [PATCH RFC 0/9] gpio: make irq_chip immutable
>
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
>
> On Fri, 09 May 2025 12:45:31 +0800, Peng Fan (OSS) wrote:
> > This might be a bit late to post this patchset, since it is almost
> > rc6, but no rush here. Not expect this patchset be in 6.16.
> >
> > This is an effort to make irq_chip immutable to elimnate the kernel
> > warning "not an immutable chip, please consider fixing!"
> >
> > The major changes
> > - add "gpiochip_disable_irq(gc, hwirq)" to end of mask hook
> > - add "gpiochip_enable_irq(gc, hwirq)" to start of unmask hook
> > - add IMMUTABLE flag
> > - add GPIOCHIP_IRQ_RESOURCE_HELPERS
> >
> > [...]
>
> Applied, thanks!
>
> [4/9] gpio: mpc8xxx: Make irq_chip immutable
> [9/9] gpio: pxa: Make irq_chip immutable
>
For the two patches, there are build failure
with powerpc-ppc64e_defconfig and
arm-am200epdkit_defconfig
GPIOLIB_IRQCHIP is not selected. I am not sure
how to address the build. You may need to drop
the two patches.
Thanks,
Peng.
>
> Best regards,
> --
> Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/9] gpio: make irq_chip immutable
2025-05-19 3:56 ` Peng Fan
@ 2025-05-19 11:11 ` Bartosz Golaszewski
0 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2025-05-19 11:11 UTC (permalink / raw)
To: Peng Fan
Cc: Ray Jui, Broadcom internal kernel review list, Linus Walleij,
Florian Fainelli, Scott Branden, Vladimir Zapolskiy, Keerthy,
Robert Jarzmik, Peng Fan (OSS), Bartosz Golaszewski,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
On Mon, May 19, 2025 at 5:56 AM Peng Fan <peng.fan@nxp.com> wrote:
>
> Hi Bartosz,
>
> > Subject: Re: [PATCH RFC 0/9] gpio: make irq_chip immutable
> >
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> >
> > On Fri, 09 May 2025 12:45:31 +0800, Peng Fan (OSS) wrote:
> > > This might be a bit late to post this patchset, since it is almost
> > > rc6, but no rush here. Not expect this patchset be in 6.16.
> > >
> > > This is an effort to make irq_chip immutable to elimnate the kernel
> > > warning "not an immutable chip, please consider fixing!"
> > >
> > > The major changes
> > > - add "gpiochip_disable_irq(gc, hwirq)" to end of mask hook
> > > - add "gpiochip_enable_irq(gc, hwirq)" to start of unmask hook
> > > - add IMMUTABLE flag
> > > - add GPIOCHIP_IRQ_RESOURCE_HELPERS
> > >
> > > [...]
> >
> > Applied, thanks!
> >
> > [4/9] gpio: mpc8xxx: Make irq_chip immutable
> > [9/9] gpio: pxa: Make irq_chip immutable
> >
>
> For the two patches, there are build failure
> with powerpc-ppc64e_defconfig and
> arm-am200epdkit_defconfig
>
> GPIOLIB_IRQCHIP is not selected. I am not sure
> how to address the build. You may need to drop
> the two patches.
No worries, I just sent out relevant fixes.
Bartosz
^ permalink raw reply [flat|nested] 16+ messages in thread