2023-02-16 09:37:11

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 00/17] Mass convert GPIO IRQ chips to be immutable

We are getting tired of these irq_chips not getting converted
to be immutable, so I just take out the big hammer and fix
some that I deem not too complex as best I can.

I stopped after doing some, I will take another sweep at some
point I guess.

Please test if you have the hardware. The OMAP patch especially,
hi Tony ;)

I don't expect this to be merged to v6.3, but as Bartosz may
feel it is fixes material they are of course fine to trickle
in on a case-by-case basis.

Signed-off-by: Linus Walleij <[email protected]>
---
Linus Walleij (17):
gpio: altera: Convert to immutable irq_chip
gpio: adnp: Convert to immutable irq_chip
gpio: aspeed: Convert to immutable irq_chip
gpio: aspeed-sgpio: Convert to immutable irq_chip
gpio: ath79: Convert to immutable irq_chip
gpio: cadence: Convert to immutable irq_chip
gpio: eic_sprd: Convert to immutable irq_chip
gpio: hisi: Convert to immutable irq_chip
gpio: hlwd: Convert to immutable irq_chip
gpio: idt3243x: Convert to immutable irq_chip
gpio: msc313: Convert to immutable irq_chip
gpio: mlxbf2: Convert to immutable irq_chip
gpio: max732x: Convert to immutable irq_chip
gpio: omap: Drop irq_base
gpio: omap: Convert to immutable irq_chip
gpio: pci-idio-16: Convert to immutable irq_chip
gpio: pcie-idio-24: Convert to immutable irq_chip

drivers/gpio/gpio-adnp.c | 9 ++++-
drivers/gpio/gpio-altera.c | 25 +++++++-----
drivers/gpio/gpio-aspeed-sgpio.c | 44 +++++++++++++++++----
drivers/gpio/gpio-aspeed.c | 44 ++++++++++++++++++---
drivers/gpio/gpio-ath79.c | 8 +++-
drivers/gpio/gpio-cadence.c | 10 +++--
drivers/gpio/gpio-eic-sprd.c | 33 +++++++++++-----
drivers/gpio/gpio-hisi.c | 25 +++++++-----
drivers/gpio/gpio-hlwd.c | 33 ++++++++++++----
drivers/gpio/gpio-idt3243x.c | 11 ++++--
drivers/gpio/gpio-max732x.c | 8 +++-
drivers/gpio/gpio-mlxbf2.c | 32 ++++++++++++----
drivers/gpio/gpio-msc313.c | 26 +++++++++++--
drivers/gpio/gpio-omap.c | 83 ++++++++++++++++++++++------------------
drivers/gpio/gpio-pci-idio-16.c | 12 ++++--
drivers/gpio/gpio-pcie-idio-24.c | 12 ++++--
16 files changed, 297 insertions(+), 118 deletions(-)
---
base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2
change-id: 20230215-immutable-chips-762922277f1e

Best regards,
--
Linus Walleij <[email protected]>



2023-02-16 09:37:14

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 01/17] gpio: altera: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-altera.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c
index b59fae993626..c1599edb3453 100644
--- a/drivers/gpio/gpio-altera.c
+++ b/drivers/gpio/gpio-altera.c
@@ -24,14 +24,12 @@
* @interrupt_trigger : specifies the hardware configured IRQ trigger type
* (rising, falling, both, high)
* @mapped_irq : kernel mapped irq number.
-* @irq_chip : IRQ chip configuration
*/
struct altera_gpio_chip {
struct of_mm_gpio_chip mmchip;
raw_spinlock_t gpio_lock;
int interrupt_trigger;
int mapped_irq;
- struct irq_chip irq_chip;
};

static void altera_gpio_irq_unmask(struct irq_data *d)
@@ -43,6 +41,7 @@ static void altera_gpio_irq_unmask(struct irq_data *d)

altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d));
mm_gc = &altera_gc->mmchip;
+ gpiochip_enable_irq(&mm_gc->gc, irqd_to_hwirq(d));

raw_spin_lock_irqsave(&altera_gc->gpio_lock, flags);
intmask = readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK);
@@ -68,6 +67,7 @@ static void altera_gpio_irq_mask(struct irq_data *d)
intmask &= ~BIT(irqd_to_hwirq(d));
writel(intmask, mm_gc->regs + ALTERA_GPIO_IRQ_MASK);
raw_spin_unlock_irqrestore(&altera_gc->gpio_lock, flags);
+ gpiochip_disable_irq(&mm_gc->gc, irqd_to_hwirq(d));
}

/*
@@ -233,6 +233,17 @@ static void altera_gpio_irq_leveL_high_handler(struct irq_desc *desc)
chained_irq_exit(chip, desc);
}

+static const struct irq_chip altera_gpio_irq_chip = {
+ .name = "altera-gpio",
+ .irq_mask = altera_gpio_irq_mask,
+ .irq_unmask = altera_gpio_irq_unmask,
+ .irq_set_type = altera_gpio_irq_set_type,
+ .irq_startup = altera_gpio_irq_startup,
+ .irq_shutdown = altera_gpio_irq_mask,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
static int altera_gpio_probe(struct platform_device *pdev)
{
struct device_node *node = pdev->dev.of_node;
@@ -278,15 +289,9 @@ static int altera_gpio_probe(struct platform_device *pdev)
}
altera_gc->interrupt_trigger = reg;

- altera_gc->irq_chip.name = "altera-gpio";
- altera_gc->irq_chip.irq_mask = altera_gpio_irq_mask;
- altera_gc->irq_chip.irq_unmask = altera_gpio_irq_unmask;
- altera_gc->irq_chip.irq_set_type = altera_gpio_irq_set_type;
- altera_gc->irq_chip.irq_startup = altera_gpio_irq_startup;
- altera_gc->irq_chip.irq_shutdown = altera_gpio_irq_mask;
-
girq = &altera_gc->mmchip.gc.irq;
- girq->chip = &altera_gc->irq_chip;
+ gpio_irq_chip_set_chip(girq, &altera_gpio_irq_chip);
+
if (altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH)
girq->parent_handler = altera_gpio_irq_leveL_high_handler;
else

--
2.34.1


2023-02-16 09:37:16

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 02/17] gpio: adnp: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-adnp.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c
index a6439e3daff0..9b01c391efce 100644
--- a/drivers/gpio/gpio-adnp.c
+++ b/drivers/gpio/gpio-adnp.c
@@ -307,6 +307,7 @@ static void adnp_irq_mask(struct irq_data *d)
unsigned int pos = d->hwirq & 7;

adnp->irq_enable[reg] &= ~BIT(pos);
+ gpiochip_disable_irq(gc, irqd_to_hwirq(d));
}

static void adnp_irq_unmask(struct irq_data *d)
@@ -316,6 +317,7 @@ static void adnp_irq_unmask(struct irq_data *d)
unsigned int reg = d->hwirq >> adnp->reg_shift;
unsigned int pos = d->hwirq & 7;

+ gpiochip_enable_irq(gc, irqd_to_hwirq(d));
adnp->irq_enable[reg] |= BIT(pos);
}

@@ -372,13 +374,15 @@ static void adnp_irq_bus_unlock(struct irq_data *d)
mutex_unlock(&adnp->irq_lock);
}

-static struct irq_chip adnp_irq_chip = {
+static const struct irq_chip adnp_irq_chip = {
.name = "gpio-adnp",
.irq_mask = adnp_irq_mask,
.irq_unmask = adnp_irq_unmask,
.irq_set_type = adnp_irq_set_type,
.irq_bus_lock = adnp_irq_bus_lock,
.irq_bus_sync_unlock = adnp_irq_bus_unlock,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};

static int adnp_irq_setup(struct adnp *adnp)
@@ -469,7 +473,8 @@ static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios,
return err;

girq = &chip->irq;
- girq->chip = &adnp_irq_chip;
+ gpio_irq_chip_set_chip(girq, &adnp_irq_chip);
+
/* This will let us handle the parent IRQ in the driver */
girq->parent_handler = NULL;
girq->num_parents = 0;

--
2.34.1


2023-02-16 09:37:25

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 03/17] gpio: aspeed: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-aspeed.c | 44 ++++++++++++++++++++++++++++++++++++++------
1 file changed, 38 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
index a94da80d3a95..9c4852de2733 100644
--- a/drivers/gpio/gpio-aspeed.c
+++ b/drivers/gpio/gpio-aspeed.c
@@ -15,6 +15,7 @@
#include <linux/module.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
+#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/string.h>

@@ -53,7 +54,7 @@ struct aspeed_gpio_config {
*/
struct aspeed_gpio {
struct gpio_chip chip;
- struct irq_chip irqc;
+ struct device *dev;
raw_spinlock_t lock;
void __iomem *base;
int irq;
@@ -566,6 +567,10 @@ static void aspeed_gpio_irq_set_mask(struct irq_data *d, bool set)

addr = bank_reg(gpio, bank, reg_irq_enable);

+ /* Unmasking the IRQ */
+ if (set)
+ gpiochip_enable_irq(&gpio->chip, irqd_to_hwirq(d));
+
raw_spin_lock_irqsave(&gpio->lock, flags);
copro = aspeed_gpio_copro_request(gpio, offset);

@@ -579,6 +584,10 @@ static void aspeed_gpio_irq_set_mask(struct irq_data *d, bool set)
if (copro)
aspeed_gpio_copro_release(gpio, offset);
raw_spin_unlock_irqrestore(&gpio->lock, flags);
+
+ /* Masking the IRQ */
+ if (!set)
+ gpiochip_disable_irq(&gpio->chip, irqd_to_hwirq(d));
}

static void aspeed_gpio_irq_mask(struct irq_data *d)
@@ -1080,6 +1089,30 @@ int aspeed_gpio_copro_release_gpio(struct gpio_desc *desc)
}
EXPORT_SYMBOL_GPL(aspeed_gpio_copro_release_gpio);

+static void aspeed_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+ const struct aspeed_gpio_bank *bank;
+ struct aspeed_gpio *gpio;
+ u32 bit;
+ int rc, offset;
+
+ rc = irqd_to_aspeed_gpio_data(d, &gpio, &bank, &bit, &offset);
+ if (rc)
+ return;
+
+ seq_printf(p, dev_name(gpio->dev));
+}
+
+static const struct irq_chip aspeed_gpio_irq_chip = {
+ .irq_ack = aspeed_gpio_irq_ack,
+ .irq_mask = aspeed_gpio_irq_mask,
+ .irq_unmask = aspeed_gpio_irq_unmask,
+ .irq_set_type = aspeed_gpio_set_type,
+ .irq_print_chip = aspeed_gpio_irq_print_chip,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
/*
* Any banks not specified in a struct aspeed_bank_props array are assumed to
* have the properties:
@@ -1149,6 +1182,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
if (IS_ERR(gpio->base))
return PTR_ERR(gpio->base);

+ gpio->dev = &pdev->dev;
+
raw_spin_lock_init(&gpio->lock);

gpio_id = of_match_node(aspeed_gpio_of_table, pdev->dev.of_node);
@@ -1208,12 +1243,9 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)

gpio->irq = rc;
girq = &gpio->chip.irq;
- girq->chip = &gpio->irqc;
+ gpio_irq_chip_set_chip(girq, &aspeed_gpio_irq_chip);
girq->chip->name = dev_name(&pdev->dev);
- girq->chip->irq_ack = aspeed_gpio_irq_ack;
- girq->chip->irq_mask = aspeed_gpio_irq_mask;
- girq->chip->irq_unmask = aspeed_gpio_irq_unmask;
- girq->chip->irq_set_type = aspeed_gpio_set_type;
+
girq->parent_handler = aspeed_gpio_irq_handler;
girq->num_parents = 1;
girq->parents = devm_kcalloc(&pdev->dev, 1,

--
2.34.1


2023-02-16 09:37:27

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 04/17] gpio: aspeed-sgpio: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-aspeed-sgpio.c | 44 ++++++++++++++++++++++++++++++++--------
1 file changed, 36 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpio-aspeed-sgpio.c b/drivers/gpio/gpio-aspeed-sgpio.c
index 454cefbeecf0..3c1c0fc21fc5 100644
--- a/drivers/gpio/gpio-aspeed-sgpio.c
+++ b/drivers/gpio/gpio-aspeed-sgpio.c
@@ -14,6 +14,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
+#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/string.h>

@@ -29,7 +30,7 @@ struct aspeed_sgpio_pdata {

struct aspeed_sgpio {
struct gpio_chip chip;
- struct irq_chip intc;
+ struct device *dev;
struct clk *pclk;
raw_spinlock_t lock;
void __iomem *base;
@@ -296,6 +297,10 @@ static void aspeed_sgpio_irq_set_mask(struct irq_data *d, bool set)
irqd_to_aspeed_sgpio_data(d, &gpio, &bank, &bit, &offset);
addr = bank_reg(gpio, bank, reg_irq_enable);

+ /* Unmasking the IRQ */
+ if (set)
+ gpiochip_enable_irq(&gpio->chip, irqd_to_hwirq(d));
+
raw_spin_lock_irqsave(&gpio->lock, flags);

reg = ioread32(addr);
@@ -307,6 +312,12 @@ static void aspeed_sgpio_irq_set_mask(struct irq_data *d, bool set)
iowrite32(reg, addr);

raw_spin_unlock_irqrestore(&gpio->lock, flags);
+
+ /* Masking the IRQ */
+ if (!set)
+ gpiochip_disable_irq(&gpio->chip, irqd_to_hwirq(d));
+
+
}

static void aspeed_sgpio_irq_mask(struct irq_data *d)
@@ -401,6 +412,27 @@ static void aspeed_sgpio_irq_handler(struct irq_desc *desc)
chained_irq_exit(ic, desc);
}

+static void aspeed_sgpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+ const struct aspeed_sgpio_bank *bank;
+ struct aspeed_sgpio *gpio;
+ u32 bit;
+ int offset;
+
+ irqd_to_aspeed_sgpio_data(d, &gpio, &bank, &bit, &offset);
+ seq_printf(p, dev_name(gpio->dev));
+}
+
+static const struct irq_chip aspeed_sgpio_irq_chip = {
+ .irq_ack = aspeed_sgpio_irq_ack,
+ .irq_mask = aspeed_sgpio_irq_mask,
+ .irq_unmask = aspeed_sgpio_irq_unmask,
+ .irq_set_type = aspeed_sgpio_set_type,
+ .irq_print_chip = aspeed_sgpio_irq_print_chip,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
static int aspeed_sgpio_setup_irqs(struct aspeed_sgpio *gpio,
struct platform_device *pdev)
{
@@ -423,14 +455,8 @@ static int aspeed_sgpio_setup_irqs(struct aspeed_sgpio *gpio,
iowrite32(0xffffffff, bank_reg(gpio, bank, reg_irq_status));
}

- gpio->intc.name = dev_name(&pdev->dev);
- gpio->intc.irq_ack = aspeed_sgpio_irq_ack;
- gpio->intc.irq_mask = aspeed_sgpio_irq_mask;
- gpio->intc.irq_unmask = aspeed_sgpio_irq_unmask;
- gpio->intc.irq_set_type = aspeed_sgpio_set_type;
-
irq = &gpio->chip.irq;
- irq->chip = &gpio->intc;
+ gpio_irq_chip_set_chip(irq, &aspeed_sgpio_irq_chip);
irq->init_valid_mask = aspeed_sgpio_irq_init_valid_mask;
irq->handler = handle_bad_irq;
irq->default_type = IRQ_TYPE_NONE;
@@ -524,6 +550,8 @@ static int __init aspeed_sgpio_probe(struct platform_device *pdev)
if (IS_ERR(gpio->base))
return PTR_ERR(gpio->base);

+ gpio->dev = &pdev->dev;
+
pdata = device_get_match_data(&pdev->dev);
if (!pdata)
return -EINVAL;

--
2.34.1


2023-02-16 09:37:30

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 05/17] gpio: ath79: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-ath79.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c
index 3958c6d97639..aa0a954b8392 100644
--- a/drivers/gpio/gpio-ath79.c
+++ b/drivers/gpio/gpio-ath79.c
@@ -71,6 +71,7 @@ static void ath79_gpio_irq_unmask(struct irq_data *data)
u32 mask = BIT(irqd_to_hwirq(data));
unsigned long flags;

+ gpiochip_enable_irq(&ctrl->gc, irqd_to_hwirq(data));
raw_spin_lock_irqsave(&ctrl->lock, flags);
ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask);
raw_spin_unlock_irqrestore(&ctrl->lock, flags);
@@ -85,6 +86,7 @@ static void ath79_gpio_irq_mask(struct irq_data *data)
raw_spin_lock_irqsave(&ctrl->lock, flags);
ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0);
raw_spin_unlock_irqrestore(&ctrl->lock, flags);
+ gpiochip_disable_irq(&ctrl->gc, irqd_to_hwirq(data));
}

static void ath79_gpio_irq_enable(struct irq_data *data)
@@ -169,13 +171,15 @@ static int ath79_gpio_irq_set_type(struct irq_data *data,
return 0;
}

-static struct irq_chip ath79_gpio_irqchip = {
+static const struct irq_chip ath79_gpio_irqchip = {
.name = "gpio-ath79",
.irq_enable = ath79_gpio_irq_enable,
.irq_disable = ath79_gpio_irq_disable,
.irq_mask = ath79_gpio_irq_mask,
.irq_unmask = ath79_gpio_irq_unmask,
.irq_set_type = ath79_gpio_irq_set_type,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};

static void ath79_gpio_irq_handler(struct irq_desc *desc)
@@ -274,7 +278,7 @@ static int ath79_gpio_probe(struct platform_device *pdev)
/* Optional interrupt setup */
if (!np || of_property_read_bool(np, "interrupt-controller")) {
girq = &ctrl->gc.irq;
- girq->chip = &ath79_gpio_irqchip;
+ gpio_irq_chip_set_chip(girq, &ath79_gpio_irqchip);
girq->parent_handler = ath79_gpio_irq_handler;
girq->num_parents = 1;
girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),

--
2.34.1


2023-02-16 09:37:32

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 06/17] gpio: cadence: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-cadence.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-cadence.c b/drivers/gpio/gpio-cadence.c
index 137aea49ba02..3720b90cad10 100644
--- a/drivers/gpio/gpio-cadence.c
+++ b/drivers/gpio/gpio-cadence.c
@@ -70,6 +70,7 @@ static void cdns_gpio_irq_mask(struct irq_data *d)
struct cdns_gpio_chip *cgpio = gpiochip_get_data(chip);

iowrite32(BIT(d->hwirq), cgpio->regs + CDNS_GPIO_IRQ_DIS);
+ gpiochip_disable_irq(chip, irqd_to_hwirq(d));
}

static void cdns_gpio_irq_unmask(struct irq_data *d)
@@ -77,6 +78,7 @@ static void cdns_gpio_irq_unmask(struct irq_data *d)
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
struct cdns_gpio_chip *cgpio = gpiochip_get_data(chip);

+ gpiochip_enable_irq(chip, irqd_to_hwirq(d));
iowrite32(BIT(d->hwirq), cgpio->regs + CDNS_GPIO_IRQ_EN);
}

@@ -138,11 +140,13 @@ static void cdns_gpio_irq_handler(struct irq_desc *desc)
chained_irq_exit(irqchip, desc);
}

-static struct irq_chip cdns_gpio_irqchip = {
+static const struct irq_chip cdns_gpio_irqchip = {
.name = "cdns-gpio",
.irq_mask = cdns_gpio_irq_mask,
.irq_unmask = cdns_gpio_irq_unmask,
- .irq_set_type = cdns_gpio_irq_set_type
+ .irq_set_type = cdns_gpio_irq_set_type,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};

static int cdns_gpio_probe(struct platform_device *pdev)
@@ -222,7 +226,7 @@ static int cdns_gpio_probe(struct platform_device *pdev)
struct gpio_irq_chip *girq;

girq = &cgpio->gc.irq;
- girq->chip = &cdns_gpio_irqchip;
+ gpio_irq_chip_set_chip(girq, &cdns_gpio_irqchip);
girq->parent_handler = cdns_gpio_irq_handler;
girq->num_parents = 1;
girq->parents = devm_kcalloc(&pdev->dev, 1,

--
2.34.1


2023-02-16 09:37:36

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 08/17] gpio: hisi: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

The IRQ chip was unnamed which seems unwise, so we just
assign the name "HISI-GPIO".

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-hisi.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-hisi.c b/drivers/gpio/gpio-hisi.c
index 55bd69043bf4..29a03de37fd8 100644
--- a/drivers/gpio/gpio-hisi.c
+++ b/drivers/gpio/gpio-hisi.c
@@ -37,7 +37,6 @@ struct hisi_gpio {
struct device *dev;
void __iomem *reg_base;
unsigned int line_num;
- struct irq_chip irq_chip;
int irq;
};

@@ -100,12 +99,14 @@ static void hisi_gpio_irq_set_mask(struct irq_data *d)
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);

hisi_gpio_write_reg(chip, HISI_GPIO_INTMASK_SET_WX, BIT(irqd_to_hwirq(d)));
+ gpiochip_disable_irq(chip, irqd_to_hwirq(d));
}

static void hisi_gpio_irq_clr_mask(struct irq_data *d)
{
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);

+ gpiochip_enable_irq(chip, irqd_to_hwirq(d));
hisi_gpio_write_reg(chip, HISI_GPIO_INTMASK_CLR_WX, BIT(irqd_to_hwirq(d)));
}

@@ -191,20 +192,24 @@ static void hisi_gpio_irq_handler(struct irq_desc *desc)
chained_irq_exit(irq_c, desc);
}

+static const struct irq_chip hisi_gpio_irq_chip = {
+ .name = "HISI-GPIO",
+ .irq_ack = hisi_gpio_set_ack,
+ .irq_mask = hisi_gpio_irq_set_mask,
+ .irq_unmask = hisi_gpio_irq_clr_mask,
+ .irq_set_type = hisi_gpio_irq_set_type,
+ .irq_enable = hisi_gpio_irq_enable,
+ .irq_disable = hisi_gpio_irq_disable,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
static void hisi_gpio_init_irq(struct hisi_gpio *hisi_gpio)
{
struct gpio_chip *chip = &hisi_gpio->chip;
struct gpio_irq_chip *girq_chip = &chip->irq;

- /* Set hooks for irq_chip */
- hisi_gpio->irq_chip.irq_ack = hisi_gpio_set_ack;
- hisi_gpio->irq_chip.irq_mask = hisi_gpio_irq_set_mask;
- hisi_gpio->irq_chip.irq_unmask = hisi_gpio_irq_clr_mask;
- hisi_gpio->irq_chip.irq_set_type = hisi_gpio_irq_set_type;
- hisi_gpio->irq_chip.irq_enable = hisi_gpio_irq_enable;
- hisi_gpio->irq_chip.irq_disable = hisi_gpio_irq_disable;
-
- girq_chip->chip = &hisi_gpio->irq_chip;
+ gpio_irq_chip_set_chip(girq_chip, &hisi_gpio_irq_chip);
girq_chip->default_type = IRQ_TYPE_NONE;
girq_chip->num_parents = 1;
girq_chip->parents = &hisi_gpio->irq;

--
2.34.1


2023-02-16 09:37:39

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 07/17] gpio: eic_sprd: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-eic-sprd.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c
index 8d722e026e9c..695d74ba55f0 100644
--- a/drivers/gpio/gpio-eic-sprd.c
+++ b/drivers/gpio/gpio-eic-sprd.c
@@ -11,6 +11,7 @@
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
+#include <linux/seq_file.h>
#include <linux/spinlock.h>

/* EIC registers definition */
@@ -91,7 +92,7 @@ enum sprd_eic_type {

struct sprd_eic {
struct gpio_chip chip;
- struct irq_chip intc;
+ struct device *dev;
void __iomem *base[SPRD_EIC_MAX_BANK];
enum sprd_eic_type type;
spinlock_t lock;
@@ -255,6 +256,7 @@ static void sprd_eic_irq_mask(struct irq_data *data)
default:
dev_err(chip->parent, "Unsupported EIC type.\n");
}
+ gpiochip_disable_irq(chip, irqd_to_hwirq(data));
}

static void sprd_eic_irq_unmask(struct irq_data *data)
@@ -263,6 +265,7 @@ static void sprd_eic_irq_unmask(struct irq_data *data)
struct sprd_eic *sprd_eic = gpiochip_get_data(chip);
u32 offset = irqd_to_hwirq(data);

+ gpiochip_enable_irq(chip, irqd_to_hwirq(data));
switch (sprd_eic->type) {
case SPRD_EIC_DEBOUNCE:
sprd_eic_update(chip, offset, SPRD_EIC_DBNC_IE, 1);
@@ -564,6 +567,24 @@ static void sprd_eic_irq_handler(struct irq_desc *desc)
chained_irq_exit(ic, desc);
}

+static void sprd_eic_irq_print_chip(struct irq_data *data, struct seq_file *p)
+{
+ struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
+ struct sprd_eic *sprd_eic = gpiochip_get_data(chip);
+
+ seq_printf(p, dev_name(sprd_eic->dev));
+}
+
+static const struct irq_chip sprd_eic_irq_chip = {
+ .irq_ack = sprd_eic_irq_ack,
+ .irq_mask = sprd_eic_irq_mask,
+ .irq_unmask = sprd_eic_irq_unmask,
+ .irq_set_type = sprd_eic_irq_set_type,
+ .irq_print_chip = sprd_eic_irq_print_chip,
+ .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
static int sprd_eic_probe(struct platform_device *pdev)
{
const struct sprd_eic_variant_data *pdata;
@@ -584,6 +605,7 @@ static int sprd_eic_probe(struct platform_device *pdev)

spin_lock_init(&sprd_eic->lock);
sprd_eic->type = pdata->type;
+ sprd_eic->dev = &pdev->dev;

sprd_eic->irq = platform_get_irq(pdev, 0);
if (sprd_eic->irq < 0)
@@ -626,15 +648,8 @@ static int sprd_eic_probe(struct platform_device *pdev)
break;
}

- sprd_eic->intc.name = dev_name(&pdev->dev);
- sprd_eic->intc.irq_ack = sprd_eic_irq_ack;
- sprd_eic->intc.irq_mask = sprd_eic_irq_mask;
- sprd_eic->intc.irq_unmask = sprd_eic_irq_unmask;
- sprd_eic->intc.irq_set_type = sprd_eic_irq_set_type;
- sprd_eic->intc.flags = IRQCHIP_SKIP_SET_WAKE;
-
irq = &sprd_eic->chip.irq;
- irq->chip = &sprd_eic->intc;
+ gpio_irq_chip_set_chip(irq, &sprd_eic_irq_chip);
irq->handler = handle_bad_irq;
irq->default_type = IRQ_TYPE_NONE;
irq->parent_handler = sprd_eic_irq_handler;

--
2.34.1


2023-02-16 09:37:52

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 09/17] gpio: hlwd: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-hlwd.c | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpio-hlwd.c b/drivers/gpio/gpio-hlwd.c
index 4e13e937f832..c208ac1c54a6 100644
--- a/drivers/gpio/gpio-hlwd.c
+++ b/drivers/gpio/gpio-hlwd.c
@@ -11,6 +11,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
+#include <linux/seq_file.h>
#include <linux/slab.h>

/*
@@ -48,7 +49,7 @@

struct hlwd_gpio {
struct gpio_chip gpioc;
- struct irq_chip irqc;
+ struct device *dev;
void __iomem *regs;
int irq;
u32 edge_emulation;
@@ -123,6 +124,7 @@ static void hlwd_gpio_irq_mask(struct irq_data *data)
mask &= ~BIT(data->hwirq);
iowrite32be(mask, hlwd->regs + HW_GPIOB_INTMASK);
raw_spin_unlock_irqrestore(&hlwd->gpioc.bgpio_lock, flags);
+ gpiochip_disable_irq(&hlwd->gpioc, irqd_to_hwirq(data));
}

static void hlwd_gpio_irq_unmask(struct irq_data *data)
@@ -132,6 +134,7 @@ static void hlwd_gpio_irq_unmask(struct irq_data *data)
unsigned long flags;
u32 mask;

+ gpiochip_enable_irq(&hlwd->gpioc, irqd_to_hwirq(data));
raw_spin_lock_irqsave(&hlwd->gpioc.bgpio_lock, flags);
mask = ioread32be(hlwd->regs + HW_GPIOB_INTMASK);
mask |= BIT(data->hwirq);
@@ -202,6 +205,24 @@ static int hlwd_gpio_irq_set_type(struct irq_data *data, unsigned int flow_type)
return 0;
}

+static void hlwd_gpio_irq_print_chip(struct irq_data *data, struct seq_file *p)
+{
+ struct hlwd_gpio *hlwd =
+ gpiochip_get_data(irq_data_get_irq_chip_data(data));
+
+ seq_printf(p, dev_name(hlwd->dev));
+}
+
+static const struct irq_chip hlwd_gpio_irq_chip = {
+ .irq_mask = hlwd_gpio_irq_mask,
+ .irq_unmask = hlwd_gpio_irq_unmask,
+ .irq_enable = hlwd_gpio_irq_enable,
+ .irq_set_type = hlwd_gpio_irq_set_type,
+ .irq_print_chip = hlwd_gpio_irq_print_chip,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
static int hlwd_gpio_probe(struct platform_device *pdev)
{
struct hlwd_gpio *hlwd;
@@ -216,6 +237,8 @@ static int hlwd_gpio_probe(struct platform_device *pdev)
if (IS_ERR(hlwd->regs))
return PTR_ERR(hlwd->regs);

+ hlwd->dev = &pdev->dev;
+
/*
* Claim all GPIOs using the OWNER register. This will not work on
* systems where the AHBPROT memory firewall hasn't been configured to
@@ -259,14 +282,8 @@ static int hlwd_gpio_probe(struct platform_device *pdev)
return hlwd->irq;
}

- hlwd->irqc.name = dev_name(&pdev->dev);
- hlwd->irqc.irq_mask = hlwd_gpio_irq_mask;
- hlwd->irqc.irq_unmask = hlwd_gpio_irq_unmask;
- hlwd->irqc.irq_enable = hlwd_gpio_irq_enable;
- hlwd->irqc.irq_set_type = hlwd_gpio_irq_set_type;
-
girq = &hlwd->gpioc.irq;
- girq->chip = &hlwd->irqc;
+ gpio_irq_chip_set_chip(girq, &hlwd_gpio_irq_chip);
girq->parent_handler = hlwd_gpio_irqhandler;
girq->num_parents = 1;
girq->parents = devm_kcalloc(&pdev->dev, 1,

--
2.34.1


2023-02-16 09:37:55

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 10/17] gpio: idt3243x: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-idt3243x.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-idt3243x.c b/drivers/gpio/gpio-idt3243x.c
index 1cafdf46f875..00f547d26254 100644
--- a/drivers/gpio/gpio-idt3243x.c
+++ b/drivers/gpio/gpio-idt3243x.c
@@ -92,6 +92,8 @@ static void idt_gpio_mask(struct irq_data *d)
writel(ctrl->mask_cache, ctrl->pic + IDT_PIC_IRQ_MASK);

raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
+
+ gpiochip_disable_irq(gc, irqd_to_hwirq(d));
}

static void idt_gpio_unmask(struct irq_data *d)
@@ -100,6 +102,7 @@ static void idt_gpio_unmask(struct irq_data *d)
struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc);
unsigned long flags;

+ gpiochip_enable_irq(gc, irqd_to_hwirq(d));
raw_spin_lock_irqsave(&gc->bgpio_lock, flags);

ctrl->mask_cache &= ~BIT(d->hwirq);
@@ -119,12 +122,14 @@ static int idt_gpio_irq_init_hw(struct gpio_chip *gc)
return 0;
}

-static struct irq_chip idt_gpio_irqchip = {
+static const struct irq_chip idt_gpio_irqchip = {
.name = "IDTGPIO",
.irq_mask = idt_gpio_mask,
.irq_ack = idt_gpio_ack,
.irq_unmask = idt_gpio_unmask,
- .irq_set_type = idt_gpio_irq_set_type
+ .irq_set_type = idt_gpio_irq_set_type,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};

static int idt_gpio_probe(struct platform_device *pdev)
@@ -168,7 +173,7 @@ static int idt_gpio_probe(struct platform_device *pdev)
return parent_irq;

girq = &ctrl->gc.irq;
- girq->chip = &idt_gpio_irqchip;
+ gpio_irq_chip_set_chip(girq, &idt_gpio_irqchip);
girq->init_hw = idt_gpio_irq_init_hw;
girq->parent_handler = idt_gpio_dispatch;
girq->num_parents = 1;

--
2.34.1


2023-02-16 09:37:56

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 11/17] gpio: msc313: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

This conversion follows the pattern of the gpio-ixp4xx
hierarchical GPIO interrupt driver.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-msc313.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-msc313.c b/drivers/gpio/gpio-msc313.c
index 52d7b8d99170..57a6c43167f7 100644
--- a/drivers/gpio/gpio-msc313.c
+++ b/drivers/gpio/gpio-msc313.c
@@ -532,17 +532,35 @@ static int msc313_gpio_direction_output(struct gpio_chip *chip, unsigned int off
return 0;
}

+static void msc313_gpio_irq_mask(struct irq_data *d)
+{
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+
+ irq_chip_mask_parent(d);
+ gpiochip_disable_irq(gc, d->hwirq);
+}
+
+static void msc313_gpio_irq_unmask(struct irq_data *d)
+{
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+
+ gpiochip_enable_irq(gc, d->hwirq);
+ irq_chip_unmask_parent(d);
+}
+
/*
* The interrupt handling happens in the parent interrupt controller,
* we don't do anything here.
*/
-static struct irq_chip msc313_gpio_irqchip = {
+static const struct irq_chip msc313_gpio_irqchip = {
.name = "GPIO",
.irq_eoi = irq_chip_eoi_parent,
- .irq_mask = irq_chip_mask_parent,
- .irq_unmask = irq_chip_unmask_parent,
+ .irq_mask = msc313_gpio_irq_mask,
+ .irq_unmask = msc313_gpio_irq_unmask,
.irq_set_type = irq_chip_set_type_parent,
.irq_set_affinity = irq_chip_set_affinity_parent,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};

/*
@@ -644,7 +662,7 @@ static int msc313_gpio_probe(struct platform_device *pdev)
gpiochip->names = gpio->gpio_data->names;

gpioirqchip = &gpiochip->irq;
- gpioirqchip->chip = &msc313_gpio_irqchip;
+ gpio_irq_chip_set_chip(gpioirqchip, &msc313_gpio_irqchip);
gpioirqchip->fwnode = of_node_to_fwnode(dev->of_node);
gpioirqchip->parent_domain = parent_domain;
gpioirqchip->child_to_parent_hwirq = msc313e_gpio_child_to_parent_hwirq;

--
2.34.1


2023-02-16 09:38:09

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 12/17] gpio: mlxbf2: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-mlxbf2.c | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-mlxbf2.c b/drivers/gpio/gpio-mlxbf2.c
index 77a41151c921..6abe01bc39c3 100644
--- a/drivers/gpio/gpio-mlxbf2.c
+++ b/drivers/gpio/gpio-mlxbf2.c
@@ -17,6 +17,7 @@
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/resource.h>
+#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/types.h>

@@ -65,10 +66,10 @@ struct mlxbf2_gpio_context_save_regs {
/* BlueField-2 gpio block context structure. */
struct mlxbf2_gpio_context {
struct gpio_chip gc;
- struct irq_chip irq_chip;

/* YU GPIO blocks address */
void __iomem *gpio_io;
+ struct device *dev;

struct mlxbf2_gpio_context_save_regs *csave_regs;
};
@@ -237,6 +238,7 @@ static void mlxbf2_gpio_irq_enable(struct irq_data *irqd)
unsigned long flags;
u32 val;

+ gpiochip_enable_irq(gc, irqd_to_hwirq(irqd));
raw_spin_lock_irqsave(&gs->gc.bgpio_lock, flags);
val = readl(gs->gpio_io + YU_GPIO_CAUSE_OR_CLRCAUSE);
val |= BIT(offset);
@@ -261,6 +263,7 @@ static void mlxbf2_gpio_irq_disable(struct irq_data *irqd)
val &= ~BIT(offset);
writel(val, gs->gpio_io + YU_GPIO_CAUSE_OR_EVTEN0);
raw_spin_unlock_irqrestore(&gs->gc.bgpio_lock, flags);
+ gpiochip_disable_irq(gc, irqd_to_hwirq(irqd));
}

static irqreturn_t mlxbf2_gpio_irq_handler(int irq, void *ptr)
@@ -322,6 +325,24 @@ mlxbf2_gpio_irq_set_type(struct irq_data *irqd, unsigned int type)
return 0;
}

+static void mlxbf2_gpio_irq_print_chip(struct irq_data *irqd,
+ struct seq_file *p)
+{
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
+ struct mlxbf2_gpio_context *gs = gpiochip_get_data(gc);
+
+ seq_printf(p, dev_name(gs->dev));
+}
+
+static const struct irq_chip mlxbf2_gpio_irq_chip = {
+ .irq_set_type = mlxbf2_gpio_irq_set_type,
+ .irq_enable = mlxbf2_gpio_irq_enable,
+ .irq_disable = mlxbf2_gpio_irq_disable,
+ .irq_print_chip = mlxbf2_gpio_irq_print_chip,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
/* BlueField-2 GPIO driver initialization routine. */
static int
mlxbf2_gpio_probe(struct platform_device *pdev)
@@ -340,6 +361,8 @@ mlxbf2_gpio_probe(struct platform_device *pdev)
if (!gs)
return -ENOMEM;

+ gs->dev = dev;
+
/* YU GPIO block address */
gs->gpio_io = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(gs->gpio_io))
@@ -376,13 +399,8 @@ mlxbf2_gpio_probe(struct platform_device *pdev)

irq = platform_get_irq(pdev, 0);
if (irq >= 0) {
- gs->irq_chip.name = name;
- gs->irq_chip.irq_set_type = mlxbf2_gpio_irq_set_type;
- gs->irq_chip.irq_enable = mlxbf2_gpio_irq_enable;
- gs->irq_chip.irq_disable = mlxbf2_gpio_irq_disable;
-
girq = &gs->gc.irq;
- girq->chip = &gs->irq_chip;
+ gpio_irq_chip_set_chip(girq, &mlxbf2_gpio_irq_chip);
girq->handler = handle_simple_irq;
girq->default_type = IRQ_TYPE_NONE;
/* This will let us handle the parent IRQ in the driver */

--
2.34.1


2023-02-16 09:38:13

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 13/17] gpio: max732x: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-max732x.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c
index 68e982cdee73..7f2fde191755 100644
--- a/drivers/gpio/gpio-max732x.c
+++ b/drivers/gpio/gpio-max732x.c
@@ -351,6 +351,7 @@ static void max732x_irq_mask(struct irq_data *d)
struct max732x_chip *chip = gpiochip_get_data(gc);

chip->irq_mask_cur &= ~(1 << d->hwirq);
+ gpiochip_disable_irq(gc, irqd_to_hwirq(d));
}

static void max732x_irq_unmask(struct irq_data *d)
@@ -358,6 +359,7 @@ static void max732x_irq_unmask(struct irq_data *d)
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct max732x_chip *chip = gpiochip_get_data(gc);

+ gpiochip_enable_irq(gc, irqd_to_hwirq(d));
chip->irq_mask_cur |= 1 << d->hwirq;
}

@@ -429,7 +431,7 @@ static int max732x_irq_set_wake(struct irq_data *data, unsigned int on)
return 0;
}

-static struct irq_chip max732x_irq_chip = {
+static const struct irq_chip max732x_irq_chip = {
.name = "max732x",
.irq_mask = max732x_irq_mask,
.irq_unmask = max732x_irq_unmask,
@@ -437,6 +439,8 @@ static struct irq_chip max732x_irq_chip = {
.irq_bus_sync_unlock = max732x_irq_bus_sync_unlock,
.irq_set_type = max732x_irq_set_type,
.irq_set_wake = max732x_irq_set_wake,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};

static uint8_t max732x_irq_pending(struct max732x_chip *chip)
@@ -517,7 +521,7 @@ static int max732x_irq_setup(struct max732x_chip *chip,
}

girq = &chip->gpio_chip.irq;
- girq->chip = &max732x_irq_chip;
+ gpio_irq_chip_set_chip(girq, &max732x_irq_chip);
/* This will let us handle the parent IRQ in the driver */
girq->parent_handler = NULL;
girq->num_parents = 0;

--
2.34.1


2023-02-16 09:38:26

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 14/17] gpio: omap: Drop irq_base

The OMAP1 at one point was using static irqs but that time is gone,
OMAP1 uses sparse irqs like all other multiplatform targets so this
static allocation of descriptors should just go.

Cc: Janusz Krzysztofik <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Tony Lindgren <[email protected]>
Acked-by: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-omap.c | 15 ---------------
1 file changed, 15 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 80ddc43fd875..292e62c06008 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -992,7 +992,6 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc,
struct gpio_irq_chip *irq;
static int gpio;
const char *label;
- int irq_base = 0;
int ret;

/*
@@ -1024,19 +1023,6 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc,
}
bank->chip.ngpio = bank->width;

-#ifdef CONFIG_ARCH_OMAP1
- /*
- * REVISIT: Once we have OMAP1 supporting SPARSE_IRQ, we can drop
- * irq_alloc_descs() since a base IRQ offset will no longer be needed.
- */
- irq_base = devm_irq_alloc_descs(bank->chip.parent,
- -1, 0, bank->width, 0);
- if (irq_base < 0) {
- dev_err(bank->chip.parent, "Couldn't allocate IRQ numbers\n");
- return -ENODEV;
- }
-#endif
-
/* MPUIO is a bit different, reading IRQ status clears it */
if (bank->is_mpuio && !bank->regs->wkup_en)
irqc->irq_set_wake = NULL;
@@ -1047,7 +1033,6 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc,
irq->default_type = IRQ_TYPE_NONE;
irq->num_parents = 1;
irq->parents = &bank->irq;
- irq->first = irq_base;

ret = gpiochip_add_data(&bank->chip, bank);
if (ret)

--
2.34.1


2023-02-16 09:38:37

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 16/17] gpio: pci-idio-16: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-pci-idio-16.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
index a86ce748384b..6726c32e31e6 100644
--- a/drivers/gpio/gpio-pci-idio-16.c
+++ b/drivers/gpio/gpio-pci-idio-16.c
@@ -107,6 +107,8 @@ static void idio_16_irq_mask(struct irq_data *data)

raw_spin_unlock_irqrestore(&idio16gpio->lock, flags);
}
+
+ gpiochip_disable_irq(chip, irqd_to_hwirq(data));
}

static void idio_16_irq_unmask(struct irq_data *data)
@@ -117,6 +119,8 @@ static void idio_16_irq_unmask(struct irq_data *data)
const unsigned long prev_irq_mask = idio16gpio->irq_mask;
unsigned long flags;

+ gpiochip_enable_irq(chip, irqd_to_hwirq(data));
+
idio16gpio->irq_mask |= mask;

if (!prev_irq_mask) {
@@ -138,12 +142,14 @@ static int idio_16_irq_set_type(struct irq_data *data, unsigned int flow_type)
return 0;
}

-static struct irq_chip idio_16_irqchip = {
+static const struct irq_chip idio_16_irqchip = {
.name = "pci-idio-16",
.irq_ack = idio_16_irq_ack,
.irq_mask = idio_16_irq_mask,
.irq_unmask = idio_16_irq_unmask,
- .irq_set_type = idio_16_irq_set_type
+ .irq_set_type = idio_16_irq_set_type,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};

static irqreturn_t idio_16_irq_handler(int irq, void *dev_id)
@@ -242,7 +248,7 @@ static int idio_16_probe(struct pci_dev *pdev, const struct pci_device_id *id)
idio_16_state_init(&idio16gpio->state);

girq = &idio16gpio->chip.irq;
- girq->chip = &idio_16_irqchip;
+ gpio_irq_chip_set_chip(girq, &idio_16_irqchip);
/* This will let us handle the parent IRQ in the driver */
girq->parent_handler = NULL;
girq->num_parents = 0;

--
2.34.1


2023-02-16 09:38:39

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 15/17] gpio: omap: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

This driver require some special care: .irq_ack() was copied
from dummy_irq_chip where it was defined as noop. This only
makes sense if using handle_edge_irq() that will unconditionally
call .irq_ack() to avoid a crash, but this driver is not ever
using handle_edge_irq() so just avoid assigning .irq_ack().

A separate chip had to be created for the non-wakeup instance.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-omap.c | 68 ++++++++++++++++++++++++++++++++----------------
1 file changed, 45 insertions(+), 23 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 292e62c06008..a5ee3ed31533 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -12,6 +12,7 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/interrupt.h>
+#include <linux/seq_file.h>
#include <linux/syscore_ops.h>
#include <linux/err.h>
#include <linux/clk.h>
@@ -47,6 +48,7 @@ struct gpio_regs {
struct gpio_bank {
void __iomem *base;
const struct omap_gpio_reg_offs *regs;
+ struct device *dev;

int irq;
u32 non_wakeup_gpios;
@@ -681,6 +683,7 @@ static void omap_gpio_mask_irq(struct irq_data *d)
omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE);
omap_set_gpio_irqenable(bank, offset, 0);
raw_spin_unlock_irqrestore(&bank->lock, flags);
+ gpiochip_disable_irq(&bank->chip, offset);
}

static void omap_gpio_unmask_irq(struct irq_data *d)
@@ -690,6 +693,7 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
u32 trigger = irqd_get_trigger_type(d);
unsigned long flags;

+ gpiochip_enable_irq(&bank->chip, offset);
raw_spin_lock_irqsave(&bank->lock, flags);
omap_set_gpio_irqenable(bank, offset, 1);

@@ -708,6 +712,40 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
raw_spin_unlock_irqrestore(&bank->lock, flags);
}

+static void omap_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+ struct gpio_bank *bank = omap_irq_data_get_bank(d);
+
+ seq_printf(p, dev_name(bank->dev));
+}
+
+static const struct irq_chip omap_gpio_irq_chip = {
+ .irq_startup = omap_gpio_irq_startup,
+ .irq_shutdown = omap_gpio_irq_shutdown,
+ .irq_mask = omap_gpio_mask_irq,
+ .irq_unmask = omap_gpio_unmask_irq,
+ .irq_set_type = omap_gpio_irq_type,
+ .irq_set_wake = omap_gpio_wake_enable,
+ .irq_bus_lock = omap_gpio_irq_bus_lock,
+ .irq_bus_sync_unlock = gpio_irq_bus_sync_unlock,
+ .irq_print_chip = omap_gpio_irq_print_chip,
+ .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
+static const struct irq_chip omap_gpio_irq_chip_nowake = {
+ .irq_startup = omap_gpio_irq_startup,
+ .irq_shutdown = omap_gpio_irq_shutdown,
+ .irq_mask = omap_gpio_mask_irq,
+ .irq_unmask = omap_gpio_unmask_irq,
+ .irq_set_type = omap_gpio_irq_type,
+ .irq_bus_lock = omap_gpio_irq_bus_lock,
+ .irq_bus_sync_unlock = gpio_irq_bus_sync_unlock,
+ .irq_print_chip = omap_gpio_irq_print_chip,
+ .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
/*---------------------------------------------------------------------*/

static int omap_mpuio_suspend_noirq(struct device *dev)
@@ -986,8 +1024,7 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
writel_relaxed(0, base + bank->regs->ctrl);
}

-static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc,
- struct device *pm_dev)
+static int omap_gpio_chip_init(struct gpio_bank *bank, struct device *pm_dev)
{
struct gpio_irq_chip *irq;
static int gpio;
@@ -1023,12 +1060,12 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc,
}
bank->chip.ngpio = bank->width;

+ irq = &bank->chip.irq;
/* MPUIO is a bit different, reading IRQ status clears it */
if (bank->is_mpuio && !bank->regs->wkup_en)
- irqc->irq_set_wake = NULL;
-
- irq = &bank->chip.irq;
- irq->chip = irqc;
+ gpio_irq_chip_set_chip(irq, &omap_gpio_irq_chip_nowake);
+ else
+ gpio_irq_chip_set_chip(irq, &omap_gpio_irq_chip);
irq->handler = handle_bad_irq;
irq->default_type = IRQ_TYPE_NONE;
irq->num_parents = 1;
@@ -1361,7 +1398,6 @@ static int omap_gpio_probe(struct platform_device *pdev)
struct device_node *node = dev->of_node;
const struct omap_gpio_platform_data *pdata;
struct gpio_bank *bank;
- struct irq_chip *irqc;
int ret;

pdata = device_get_match_data(dev);
@@ -1374,21 +1410,7 @@ static int omap_gpio_probe(struct platform_device *pdev)
if (!bank)
return -ENOMEM;

- irqc = devm_kzalloc(dev, sizeof(*irqc), GFP_KERNEL);
- if (!irqc)
- return -ENOMEM;
-
- irqc->irq_startup = omap_gpio_irq_startup,
- irqc->irq_shutdown = omap_gpio_irq_shutdown,
- irqc->irq_ack = dummy_irq_chip.irq_ack,
- irqc->irq_mask = omap_gpio_mask_irq,
- irqc->irq_unmask = omap_gpio_unmask_irq,
- irqc->irq_set_type = omap_gpio_irq_type,
- irqc->irq_set_wake = omap_gpio_wake_enable,
- irqc->irq_bus_lock = omap_gpio_irq_bus_lock,
- irqc->irq_bus_sync_unlock = gpio_irq_bus_sync_unlock,
- irqc->name = dev_name(&pdev->dev);
- irqc->flags = IRQCHIP_MASK_ON_SUSPEND;
+ bank->dev = dev;

bank->irq = platform_get_irq(pdev, 0);
if (bank->irq <= 0) {
@@ -1452,7 +1474,7 @@ static int omap_gpio_probe(struct platform_device *pdev)

omap_gpio_mod_init(bank);

- ret = omap_gpio_chip_init(bank, irqc, dev);
+ ret = omap_gpio_chip_init(bank, dev);
if (ret) {
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);

--
2.34.1


2023-02-16 09:38:42

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 17/17] gpio: pcie-idio-24: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/gpio/gpio-pcie-idio-24.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c
index 8a9b98fa418f..ac42150f4009 100644
--- a/drivers/gpio/gpio-pcie-idio-24.c
+++ b/drivers/gpio/gpio-pcie-idio-24.c
@@ -396,6 +396,8 @@ static void idio_24_irq_mask(struct irq_data *data)
}

raw_spin_unlock_irqrestore(&idio24gpio->lock, flags);
+
+ gpiochip_disable_irq(chip, irqd_to_hwirq(data));
}

static void idio_24_irq_unmask(struct irq_data *data)
@@ -408,6 +410,8 @@ static void idio_24_irq_unmask(struct irq_data *data)
const unsigned long bank_offset = bit_offset / 8;
unsigned char cos_enable_state;

+ gpiochip_enable_irq(chip, irqd_to_hwirq(data));
+
raw_spin_lock_irqsave(&idio24gpio->lock, flags);

prev_irq_mask = idio24gpio->irq_mask >> bank_offset * 8;
@@ -437,12 +441,14 @@ static int idio_24_irq_set_type(struct irq_data *data, unsigned int flow_type)
return 0;
}

-static struct irq_chip idio_24_irqchip = {
+static const struct irq_chip idio_24_irqchip = {
.name = "pcie-idio-24",
.irq_ack = idio_24_irq_ack,
.irq_mask = idio_24_irq_mask,
.irq_unmask = idio_24_irq_unmask,
- .irq_set_type = idio_24_irq_set_type
+ .irq_set_type = idio_24_irq_set_type,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};

static irqreturn_t idio_24_irq_handler(int irq, void *dev_id)
@@ -535,7 +541,7 @@ static int idio_24_probe(struct pci_dev *pdev, const struct pci_device_id *id)
idio24gpio->chip.set_multiple = idio_24_gpio_set_multiple;

girq = &idio24gpio->chip.irq;
- girq->chip = &idio_24_irqchip;
+ gpio_irq_chip_set_chip(girq, &idio_24_irqchip);
/* This will let us handle the parent IRQ in the driver */
girq->parent_handler = NULL;
girq->num_parents = 0;

--
2.34.1


2023-02-16 10:48:36

by Marc Zyngier

[permalink] [raw]
Subject: Re: [PATCH 00/17] Mass convert GPIO IRQ chips to be immutable

On Thu, 16 Feb 2023 09:37:01 +0000,
Linus Walleij <[email protected]> wrote:
>
> We are getting tired of these irq_chips not getting converted
> to be immutable, so I just take out the big hammer and fix
> some that I deem not too complex as best I can.

Thanks for taking the hit on this one.

I had a cursory look, and they seem fine overall. only the omap one
looks a bit scary, but I take it that Tony can give that one a go
before it gets merged.

FWIW:

Acked-by: Marc Zyngier <[email protected]>

M.

--
Without deviation from the norm, progress is not possible.

2023-02-16 12:06:23

by William Breathitt Gray

[permalink] [raw]
Subject: Re: [PATCH 16/17] gpio: pci-idio-16: Convert to immutable irq_chip

On Thu, Feb 16, 2023 at 10:37:17AM +0100, Linus Walleij wrote:
> Convert the driver to immutable irq-chip with a bit of
> intuition.
>
> Cc: Marc Zyngier <[email protected]>
> Signed-off-by: Linus Walleij <[email protected]>

FYI, I'm migrating pci-idio-16 to the regmap-irq API soon, so this patch
might not be necessary once the code is removed. Anyway, here's my ack
in case this patch series is merged first.

Acked-by: William Breathitt Gray <[email protected]>

> ---
> drivers/gpio/gpio-pci-idio-16.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
> index a86ce748384b..6726c32e31e6 100644
> --- a/drivers/gpio/gpio-pci-idio-16.c
> +++ b/drivers/gpio/gpio-pci-idio-16.c
> @@ -107,6 +107,8 @@ static void idio_16_irq_mask(struct irq_data *data)
>
> raw_spin_unlock_irqrestore(&idio16gpio->lock, flags);
> }
> +
> + gpiochip_disable_irq(chip, irqd_to_hwirq(data));
> }
>
> static void idio_16_irq_unmask(struct irq_data *data)
> @@ -117,6 +119,8 @@ static void idio_16_irq_unmask(struct irq_data *data)
> const unsigned long prev_irq_mask = idio16gpio->irq_mask;
> unsigned long flags;
>
> + gpiochip_enable_irq(chip, irqd_to_hwirq(data));
> +
> idio16gpio->irq_mask |= mask;
>
> if (!prev_irq_mask) {
> @@ -138,12 +142,14 @@ static int idio_16_irq_set_type(struct irq_data *data, unsigned int flow_type)
> return 0;
> }
>
> -static struct irq_chip idio_16_irqchip = {
> +static const struct irq_chip idio_16_irqchip = {
> .name = "pci-idio-16",
> .irq_ack = idio_16_irq_ack,
> .irq_mask = idio_16_irq_mask,
> .irq_unmask = idio_16_irq_unmask,
> - .irq_set_type = idio_16_irq_set_type
> + .irq_set_type = idio_16_irq_set_type,
> + .flags = IRQCHIP_IMMUTABLE,
> + GPIOCHIP_IRQ_RESOURCE_HELPERS,
> };
>
> static irqreturn_t idio_16_irq_handler(int irq, void *dev_id)
> @@ -242,7 +248,7 @@ static int idio_16_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> idio_16_state_init(&idio16gpio->state);
>
> girq = &idio16gpio->chip.irq;
> - girq->chip = &idio_16_irqchip;
> + gpio_irq_chip_set_chip(girq, &idio_16_irqchip);
> /* This will let us handle the parent IRQ in the driver */
> girq->parent_handler = NULL;
> girq->num_parents = 0;
>
> --
> 2.34.1
>


Attachments:
(No filename) (2.29 kB)
signature.asc (228.00 B)
Download all attachments

2023-02-16 12:06:51

by William Breathitt Gray

[permalink] [raw]
Subject: Re: [PATCH 17/17] gpio: pcie-idio-24: Convert to immutable irq_chip

On Thu, Feb 16, 2023 at 10:37:18AM +0100, Linus Walleij wrote:
> Convert the driver to immutable irq-chip with a bit of
> intuition.
>
> Cc: Marc Zyngier <[email protected]>
> Signed-off-by: Linus Walleij <[email protected]>

Acked-by: William Breathitt Gray <[email protected]>

> ---
> drivers/gpio/gpio-pcie-idio-24.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c
> index 8a9b98fa418f..ac42150f4009 100644
> --- a/drivers/gpio/gpio-pcie-idio-24.c
> +++ b/drivers/gpio/gpio-pcie-idio-24.c
> @@ -396,6 +396,8 @@ static void idio_24_irq_mask(struct irq_data *data)
> }
>
> raw_spin_unlock_irqrestore(&idio24gpio->lock, flags);
> +
> + gpiochip_disable_irq(chip, irqd_to_hwirq(data));
> }
>
> static void idio_24_irq_unmask(struct irq_data *data)
> @@ -408,6 +410,8 @@ static void idio_24_irq_unmask(struct irq_data *data)
> const unsigned long bank_offset = bit_offset / 8;
> unsigned char cos_enable_state;
>
> + gpiochip_enable_irq(chip, irqd_to_hwirq(data));
> +
> raw_spin_lock_irqsave(&idio24gpio->lock, flags);
>
> prev_irq_mask = idio24gpio->irq_mask >> bank_offset * 8;
> @@ -437,12 +441,14 @@ static int idio_24_irq_set_type(struct irq_data *data, unsigned int flow_type)
> return 0;
> }
>
> -static struct irq_chip idio_24_irqchip = {
> +static const struct irq_chip idio_24_irqchip = {
> .name = "pcie-idio-24",
> .irq_ack = idio_24_irq_ack,
> .irq_mask = idio_24_irq_mask,
> .irq_unmask = idio_24_irq_unmask,
> - .irq_set_type = idio_24_irq_set_type
> + .irq_set_type = idio_24_irq_set_type,
> + .flags = IRQCHIP_IMMUTABLE,
> + GPIOCHIP_IRQ_RESOURCE_HELPERS,
> };
>
> static irqreturn_t idio_24_irq_handler(int irq, void *dev_id)
> @@ -535,7 +541,7 @@ static int idio_24_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> idio24gpio->chip.set_multiple = idio_24_gpio_set_multiple;
>
> girq = &idio24gpio->chip.irq;
> - girq->chip = &idio_24_irqchip;
> + gpio_irq_chip_set_chip(girq, &idio_24_irqchip);
> /* This will let us handle the parent IRQ in the driver */
> girq->parent_handler = NULL;
> girq->num_parents = 0;
>
> --
> 2.34.1
>


Attachments:
(No filename) (2.18 kB)
signature.asc (228.00 B)
Download all attachments

2023-02-17 05:58:09

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 14/17] gpio: omap: Drop irq_base

* Linus Walleij <[email protected]> [230216 09:37]:
> The OMAP1 at one point was using static irqs but that time is gone,
> OMAP1 uses sparse irqs like all other multiplatform targets so this
> static allocation of descriptors should just go.

Reviewed-by: Tony Lindgren <[email protected]>

2023-02-17 06:02:30

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 00/17] Mass convert GPIO IRQ chips to be immutable

* Linus Walleij <[email protected]> [230216 09:37]:
> Please test if you have the hardware. The OMAP patch especially,
> hi Tony ;)

Looking good so far, will do some more testing today.

Thanks,

Tony

2023-02-17 07:49:44

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 15/17] gpio: omap: Convert to immutable irq_chip

Hi,

* Linus Walleij <[email protected]> [230216 09:38]:
> Convert the driver to immutable irq-chip with a bit of
> intuition.
>
> This driver require some special care: .irq_ack() was copied
> from dummy_irq_chip where it was defined as noop. This only
> makes sense if using handle_edge_irq() that will unconditionally
> call .irq_ack() to avoid a crash, but this driver is not ever
> using handle_edge_irq() so just avoid assigning .irq_ack().
>
> A separate chip had to be created for the non-wakeup instance.

Nice, works for me.

BTW, I still see these warnings remaining on boot:

gpio gpiochip0: Static allocation of GPIO base is deprecated, use dynamic allocation.

Seems like we might be able to get rid of those too now or are
there still some dependencies with /sys/class/gpio for example?

Reviewed-by: Tony Lindgren <[email protected]>
Tested-by: Tony Lindgren <[email protected]>

2023-02-17 14:34:15

by Thomas Bogendoerfer

[permalink] [raw]
Subject: Re: [PATCH 10/17] gpio: idt3243x: Convert to immutable irq_chip

On Thu, Feb 16, 2023 at 10:37:11AM +0100, Linus Walleij wrote:
> Convert the driver to immutable irq-chip with a bit of
> intuition.
>
> Cc: Marc Zyngier <[email protected]>
> Signed-off-by: Linus Walleij <[email protected]>
> ---
> drivers/gpio/gpio-idt3243x.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-idt3243x.c b/drivers/gpio/gpio-idt3243x.c
> index 1cafdf46f875..00f547d26254 100644
> --- a/drivers/gpio/gpio-idt3243x.c
> +++ b/drivers/gpio/gpio-idt3243x.c
> @@ -92,6 +92,8 @@ static void idt_gpio_mask(struct irq_data *d)
> writel(ctrl->mask_cache, ctrl->pic + IDT_PIC_IRQ_MASK);
>
> raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
> +
> + gpiochip_disable_irq(gc, irqd_to_hwirq(d));
> }
>
> static void idt_gpio_unmask(struct irq_data *d)
> @@ -100,6 +102,7 @@ static void idt_gpio_unmask(struct irq_data *d)
> struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc);
> unsigned long flags;
>
> + gpiochip_enable_irq(gc, irqd_to_hwirq(d));
> raw_spin_lock_irqsave(&gc->bgpio_lock, flags);
>
> ctrl->mask_cache &= ~BIT(d->hwirq);
> @@ -119,12 +122,14 @@ static int idt_gpio_irq_init_hw(struct gpio_chip *gc)
> return 0;
> }
>
> -static struct irq_chip idt_gpio_irqchip = {
> +static const struct irq_chip idt_gpio_irqchip = {
> .name = "IDTGPIO",
> .irq_mask = idt_gpio_mask,
> .irq_ack = idt_gpio_ack,
> .irq_unmask = idt_gpio_unmask,
> - .irq_set_type = idt_gpio_irq_set_type
> + .irq_set_type = idt_gpio_irq_set_type,
> + .flags = IRQCHIP_IMMUTABLE,
> + GPIOCHIP_IRQ_RESOURCE_HELPERS,
> };
>
> static int idt_gpio_probe(struct platform_device *pdev)
> @@ -168,7 +173,7 @@ static int idt_gpio_probe(struct platform_device *pdev)
> return parent_irq;
>
> girq = &ctrl->gc.irq;
> - girq->chip = &idt_gpio_irqchip;
> + gpio_irq_chip_set_chip(girq, &idt_gpio_irqchip);
> girq->init_hw = idt_gpio_irq_init_hw;
> girq->parent_handler = idt_gpio_dispatch;
> girq->num_parents = 1;
>
> --
> 2.34.1

Tested-by: Thomas Bogendoerfer <[email protected]>


--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]

2023-02-17 16:32:44

by Andreas Kemnade

[permalink] [raw]
Subject: Re: [PATCH 15/17] gpio: omap: Convert to immutable irq_chip

On Fri, 17 Feb 2023 09:49:37 +0200
Tony Lindgren <[email protected]> wrote:

> Hi,
>
> * Linus Walleij <[email protected]> [230216 09:38]:
> > Convert the driver to immutable irq-chip with a bit of
> > intuition.
> >
> > This driver require some special care: .irq_ack() was copied
> > from dummy_irq_chip where it was defined as noop. This only
> > makes sense if using handle_edge_irq() that will unconditionally
> > call .irq_ack() to avoid a crash, but this driver is not ever
> > using handle_edge_irq() so just avoid assigning .irq_ack().
> >
> > A separate chip had to be created for the non-wakeup instance.
>
> Nice, works for me.
>
> BTW, I still see these warnings remaining on boot:
>
> gpio gpiochip0: Static allocation of GPIO base is deprecated, use dynamic allocation.
>
> Seems like we might be able to get rid of those too now or are
> there still some dependencies with /sys/class/gpio for example?
>
on what are you testing? on -next? I thought I have fixed theese warning with
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=92bf78b33b0b463b00c6b0203b49aea845daecc8

Regards,
Andreas

2023-02-27 00:44:37

by Joel Stanley

[permalink] [raw]
Subject: Re: [PATCH 03/17] gpio: aspeed: Convert to immutable irq_chip

On Thu, 16 Feb 2023 at 09:37, Linus Walleij <[email protected]> wrote:
>
> Convert the driver to immutable irq-chip with a bit of
> intuition.
>
> Cc: Marc Zyngier <[email protected]>
> Signed-off-by: Linus Walleij <[email protected]>

Tested-by: Joel Stanley <[email protected]>

I attempted the conversion but wasn't sure how to proceed because we
dynamically create the irqchip depending on the presence of the
interrupt in the device tree. However, every device tree contains this
interrupt so perhaps we should clean that up.

Cheers,

Joel

> ---
> drivers/gpio/gpio-aspeed.c | 44 ++++++++++++++++++++++++++++++++++++++------
> 1 file changed, 38 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
> index a94da80d3a95..9c4852de2733 100644
> --- a/drivers/gpio/gpio-aspeed.c
> +++ b/drivers/gpio/gpio-aspeed.c
> @@ -15,6 +15,7 @@
> #include <linux/module.h>
> #include <linux/pinctrl/consumer.h>
> #include <linux/platform_device.h>
> +#include <linux/seq_file.h>
> #include <linux/spinlock.h>
> #include <linux/string.h>
>
> @@ -53,7 +54,7 @@ struct aspeed_gpio_config {
> */
> struct aspeed_gpio {
> struct gpio_chip chip;
> - struct irq_chip irqc;
> + struct device *dev;
> raw_spinlock_t lock;
> void __iomem *base;
> int irq;
> @@ -566,6 +567,10 @@ static void aspeed_gpio_irq_set_mask(struct irq_data *d, bool set)
>
> addr = bank_reg(gpio, bank, reg_irq_enable);
>
> + /* Unmasking the IRQ */
> + if (set)
> + gpiochip_enable_irq(&gpio->chip, irqd_to_hwirq(d));
> +
> raw_spin_lock_irqsave(&gpio->lock, flags);
> copro = aspeed_gpio_copro_request(gpio, offset);
>
> @@ -579,6 +584,10 @@ static void aspeed_gpio_irq_set_mask(struct irq_data *d, bool set)
> if (copro)
> aspeed_gpio_copro_release(gpio, offset);
> raw_spin_unlock_irqrestore(&gpio->lock, flags);
> +
> + /* Masking the IRQ */
> + if (!set)
> + gpiochip_disable_irq(&gpio->chip, irqd_to_hwirq(d));
> }
>
> static void aspeed_gpio_irq_mask(struct irq_data *d)
> @@ -1080,6 +1089,30 @@ int aspeed_gpio_copro_release_gpio(struct gpio_desc *desc)
> }
> EXPORT_SYMBOL_GPL(aspeed_gpio_copro_release_gpio);
>
> +static void aspeed_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
> +{
> + const struct aspeed_gpio_bank *bank;
> + struct aspeed_gpio *gpio;
> + u32 bit;
> + int rc, offset;
> +
> + rc = irqd_to_aspeed_gpio_data(d, &gpio, &bank, &bit, &offset);
> + if (rc)
> + return;
> +
> + seq_printf(p, dev_name(gpio->dev));
> +}
> +
> +static const struct irq_chip aspeed_gpio_irq_chip = {
> + .irq_ack = aspeed_gpio_irq_ack,
> + .irq_mask = aspeed_gpio_irq_mask,
> + .irq_unmask = aspeed_gpio_irq_unmask,
> + .irq_set_type = aspeed_gpio_set_type,
> + .irq_print_chip = aspeed_gpio_irq_print_chip,
> + .flags = IRQCHIP_IMMUTABLE,
> + GPIOCHIP_IRQ_RESOURCE_HELPERS,
> +};
> +
> /*
> * Any banks not specified in a struct aspeed_bank_props array are assumed to
> * have the properties:
> @@ -1149,6 +1182,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
> if (IS_ERR(gpio->base))
> return PTR_ERR(gpio->base);
>
> + gpio->dev = &pdev->dev;
> +
> raw_spin_lock_init(&gpio->lock);
>
> gpio_id = of_match_node(aspeed_gpio_of_table, pdev->dev.of_node);
> @@ -1208,12 +1243,9 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
>
> gpio->irq = rc;
> girq = &gpio->chip.irq;
> - girq->chip = &gpio->irqc;
> + gpio_irq_chip_set_chip(girq, &aspeed_gpio_irq_chip);
> girq->chip->name = dev_name(&pdev->dev);
> - girq->chip->irq_ack = aspeed_gpio_irq_ack;
> - girq->chip->irq_mask = aspeed_gpio_irq_mask;
> - girq->chip->irq_unmask = aspeed_gpio_irq_unmask;
> - girq->chip->irq_set_type = aspeed_gpio_set_type;
> +
> girq->parent_handler = aspeed_gpio_irq_handler;
> girq->num_parents = 1;
> girq->parents = devm_kcalloc(&pdev->dev, 1,
>
> --
> 2.34.1
>

2023-03-06 07:28:58

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 15/17] gpio: omap: Convert to immutable irq_chip

* Andreas Kemnade <[email protected]> [230217 16:31]:
> On Fri, 17 Feb 2023 09:49:37 +0200
> Tony Lindgren <[email protected]> wrote:
>
> > Hi,
> >
> > * Linus Walleij <[email protected]> [230216 09:38]:
> > > Convert the driver to immutable irq-chip with a bit of
> > > intuition.
> > >
> > > This driver require some special care: .irq_ack() was copied
> > > from dummy_irq_chip where it was defined as noop. This only
> > > makes sense if using handle_edge_irq() that will unconditionally
> > > call .irq_ack() to avoid a crash, but this driver is not ever
> > > using handle_edge_irq() so just avoid assigning .irq_ack().
> > >
> > > A separate chip had to be created for the non-wakeup instance.
> >
> > Nice, works for me.
> >
> > BTW, I still see these warnings remaining on boot:
> >
> > gpio gpiochip0: Static allocation of GPIO base is deprecated, use dynamic allocation.
> >
> > Seems like we might be able to get rid of those too now or are
> > there still some dependencies with /sys/class/gpio for example?
> >
> on what are you testing? on -next? I thought I have fixed theese warning with
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=92bf78b33b0b463b00c6b0203b49aea845daecc8

You're right, sorry looks like I pasted the wrong line from the dmesg
output :)

I intended to paste this example instead of the static allocation line:

gpio gpiochip1: (gpio-32-63): not an immutable chip, please consider fixing it!

Regards,

Tony

2023-03-06 07:31:32

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 15/17] gpio: omap: Convert to immutable irq_chip

* Tony Lindgren <[email protected]> [230306 07:28]:
> * Andreas Kemnade <[email protected]> [230217 16:31]:
> > On Fri, 17 Feb 2023 09:49:37 +0200
> > Tony Lindgren <[email protected]> wrote:
> >
> > > Hi,
> > >
> > > * Linus Walleij <[email protected]> [230216 09:38]:
> > > > Convert the driver to immutable irq-chip with a bit of
> > > > intuition.
> > > >
> > > > This driver require some special care: .irq_ack() was copied
> > > > from dummy_irq_chip where it was defined as noop. This only
> > > > makes sense if using handle_edge_irq() that will unconditionally
> > > > call .irq_ack() to avoid a crash, but this driver is not ever
> > > > using handle_edge_irq() so just avoid assigning .irq_ack().
> > > >
> > > > A separate chip had to be created for the non-wakeup instance.
> > >
> > > Nice, works for me.
> > >
> > > BTW, I still see these warnings remaining on boot:
> > >
> > > gpio gpiochip0: Static allocation of GPIO base is deprecated, use dynamic allocation.
> > >
> > > Seems like we might be able to get rid of those too now or are
> > > there still some dependencies with /sys/class/gpio for example?
> > >
> > on what are you testing? on -next? I thought I have fixed theese warning with
> > https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=92bf78b33b0b463b00c6b0203b49aea845daecc8
>
> You're right, sorry looks like I pasted the wrong line from the dmesg
> output :)
>
> I intended to paste this example instead of the static allocation line:
>
> gpio gpiochip1: (gpio-32-63): not an immutable chip, please consider fixing it!

Hmm, nope, sorry it seems I was just confused between two patches.
Hopefully all the gpio warnings will be gone with this $subject patch
applied.

Regards,

Tony