Message ID | 20220909095632.2056143-2-sergio.paracuellos@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | [1/2] gpio: mt7621: Switch to use fwnode instead of of_node | expand |
On Fri, Sep 9, 2022 at 11:56 AM Sergio Paracuellos <sergio.paracuellos@gmail.com> wrote: > > Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as > immutable") added a warning to indicate if the gpiolib is altering the > internals of irqchips. Following this change the following warnings > are now observed for the mt7621 driver: > > gpio gpiochip0: (1e000600.gpio-bank0): not an immutable chip, please consider fixing it! > gpio gpiochip1: (1e000600.gpio-bank1): not an immutable chip, please consider fixing it! > gpio gpiochip2: (1e000600.gpio-bank2): not an immutable chip, please consider fixing it! > > Fix this by making the irqchip in the mt7621 driver immutable. > > Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com> > Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> > --- > drivers/gpio/gpio-mt7621.c | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c > index 05891dd3f96e..729cc8f72343 100644 > --- a/drivers/gpio/gpio-mt7621.c > +++ b/drivers/gpio/gpio-mt7621.c > @@ -111,6 +111,8 @@ mediatek_gpio_irq_unmask(struct irq_data *d) > unsigned long flags; > u32 rise, fall, high, low; > > + gpiochip_enable_irq(gc, d->hwirq); > + > spin_lock_irqsave(&rg->lock, flags); > rise = mtk_gpio_r32(rg, GPIO_REG_REDGE); > fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE); > @@ -142,6 +144,8 @@ mediatek_gpio_irq_mask(struct irq_data *d) > mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~BIT(pin)); > mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~BIT(pin)); > spin_unlock_irqrestore(&rg->lock, flags); > + > + gpiochip_disable_irq(gc, d->hwirq); > } > > static int > @@ -203,6 +207,16 @@ mediatek_gpio_xlate(struct gpio_chip *chip, > return gpio % MTK_BANK_WIDTH; > } > > +static const struct irq_chip mt7621_irq_chip = { > + .name = "mt7621-gpio", > + .irq_mask_ack = mediatek_gpio_irq_mask, > + .irq_mask = mediatek_gpio_irq_mask, > + .irq_unmask = mediatek_gpio_irq_unmask, > + .irq_set_type = mediatek_gpio_irq_type, > + .flags = IRQCHIP_IMMUTABLE, > + GPIOCHIP_IRQ_RESOURCE_HELPERS, > +}; > + > static int > mediatek_gpio_bank_probe(struct device *dev, > struct fwnode_handle *fwnode, int bank) > @@ -239,11 +253,6 @@ mediatek_gpio_bank_probe(struct device *dev, > return -ENOMEM; > > rg->chip.offset = bank * MTK_BANK_WIDTH; > - rg->irq_chip.name = dev_name(dev); > - rg->irq_chip.irq_unmask = mediatek_gpio_irq_unmask; > - rg->irq_chip.irq_mask = mediatek_gpio_irq_mask; > - rg->irq_chip.irq_mask_ack = mediatek_gpio_irq_mask; > - rg->irq_chip.irq_set_type = mediatek_gpio_irq_type; > > if (mtk->gpio_irq) { > struct gpio_irq_chip *girq; > @@ -263,7 +272,7 @@ mediatek_gpio_bank_probe(struct device *dev, > } > > girq = &rg->chip.irq; > - girq->chip = &rg->irq_chip; > + gpio_irq_chip_set_chip(girq, &mt7621_irq_chip); > /* This will let us handle the parent IRQ in the driver */ > girq->parent_handler = NULL; > girq->num_parents = 0; > -- > 2.25.1 > This should go into fixes but depends on the other patch which is material for the next release cycle. Can you resend this separately? Bart
On Tue, Sep 13, 2022 at 4:43 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote: > > On Fri, Sep 9, 2022 at 11:56 AM Sergio Paracuellos > <sergio.paracuellos@gmail.com> wrote: > > > > Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as > > immutable") added a warning to indicate if the gpiolib is altering the > > internals of irqchips. Following this change the following warnings > > are now observed for the mt7621 driver: > > > > gpio gpiochip0: (1e000600.gpio-bank0): not an immutable chip, please consider fixing it! > > gpio gpiochip1: (1e000600.gpio-bank1): not an immutable chip, please consider fixing it! > > gpio gpiochip2: (1e000600.gpio-bank2): not an immutable chip, please consider fixing it! > > > > Fix this by making the irqchip in the mt7621 driver immutable. > > > > Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com> > > Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> > > --- > > drivers/gpio/gpio-mt7621.c | 21 +++++++++++++++------ > > 1 file changed, 15 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c > > index 05891dd3f96e..729cc8f72343 100644 > > --- a/drivers/gpio/gpio-mt7621.c > > +++ b/drivers/gpio/gpio-mt7621.c > > @@ -111,6 +111,8 @@ mediatek_gpio_irq_unmask(struct irq_data *d) > > unsigned long flags; > > u32 rise, fall, high, low; > > > > + gpiochip_enable_irq(gc, d->hwirq); > > + > > spin_lock_irqsave(&rg->lock, flags); > > rise = mtk_gpio_r32(rg, GPIO_REG_REDGE); > > fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE); > > @@ -142,6 +144,8 @@ mediatek_gpio_irq_mask(struct irq_data *d) > > mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~BIT(pin)); > > mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~BIT(pin)); > > spin_unlock_irqrestore(&rg->lock, flags); > > + > > + gpiochip_disable_irq(gc, d->hwirq); > > } > > > > static int > > @@ -203,6 +207,16 @@ mediatek_gpio_xlate(struct gpio_chip *chip, > > return gpio % MTK_BANK_WIDTH; > > } > > > > +static const struct irq_chip mt7621_irq_chip = { > > + .name = "mt7621-gpio", > > + .irq_mask_ack = mediatek_gpio_irq_mask, > > + .irq_mask = mediatek_gpio_irq_mask, > > + .irq_unmask = mediatek_gpio_irq_unmask, > > + .irq_set_type = mediatek_gpio_irq_type, > > + .flags = IRQCHIP_IMMUTABLE, > > + GPIOCHIP_IRQ_RESOURCE_HELPERS, > > +}; > > + > > static int > > mediatek_gpio_bank_probe(struct device *dev, > > struct fwnode_handle *fwnode, int bank) > > @@ -239,11 +253,6 @@ mediatek_gpio_bank_probe(struct device *dev, > > return -ENOMEM; > > > > rg->chip.offset = bank * MTK_BANK_WIDTH; > > - rg->irq_chip.name = dev_name(dev); > > - rg->irq_chip.irq_unmask = mediatek_gpio_irq_unmask; > > - rg->irq_chip.irq_mask = mediatek_gpio_irq_mask; > > - rg->irq_chip.irq_mask_ack = mediatek_gpio_irq_mask; > > - rg->irq_chip.irq_set_type = mediatek_gpio_irq_type; > > > > if (mtk->gpio_irq) { > > struct gpio_irq_chip *girq; > > @@ -263,7 +272,7 @@ mediatek_gpio_bank_probe(struct device *dev, > > } > > > > girq = &rg->chip.irq; > > - girq->chip = &rg->irq_chip; > > + gpio_irq_chip_set_chip(girq, &mt7621_irq_chip); > > /* This will let us handle the parent IRQ in the driver */ > > girq->parent_handler = NULL; > > girq->num_parents = 0; > > -- > > 2.25.1 > > > > This should go into fixes but depends on the other patch which is > material for the next release cycle. Can you resend this separately? Sure, I will! Thanks, Sergio Paracuellos > > Bart
diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c index 05891dd3f96e..729cc8f72343 100644 --- a/drivers/gpio/gpio-mt7621.c +++ b/drivers/gpio/gpio-mt7621.c @@ -111,6 +111,8 @@ mediatek_gpio_irq_unmask(struct irq_data *d) unsigned long flags; u32 rise, fall, high, low; + gpiochip_enable_irq(gc, d->hwirq); + spin_lock_irqsave(&rg->lock, flags); rise = mtk_gpio_r32(rg, GPIO_REG_REDGE); fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE); @@ -142,6 +144,8 @@ mediatek_gpio_irq_mask(struct irq_data *d) mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~BIT(pin)); mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~BIT(pin)); spin_unlock_irqrestore(&rg->lock, flags); + + gpiochip_disable_irq(gc, d->hwirq); } static int @@ -203,6 +207,16 @@ mediatek_gpio_xlate(struct gpio_chip *chip, return gpio % MTK_BANK_WIDTH; } +static const struct irq_chip mt7621_irq_chip = { + .name = "mt7621-gpio", + .irq_mask_ack = mediatek_gpio_irq_mask, + .irq_mask = mediatek_gpio_irq_mask, + .irq_unmask = mediatek_gpio_irq_unmask, + .irq_set_type = mediatek_gpio_irq_type, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + static int mediatek_gpio_bank_probe(struct device *dev, struct fwnode_handle *fwnode, int bank) @@ -239,11 +253,6 @@ mediatek_gpio_bank_probe(struct device *dev, return -ENOMEM; rg->chip.offset = bank * MTK_BANK_WIDTH; - rg->irq_chip.name = dev_name(dev); - rg->irq_chip.irq_unmask = mediatek_gpio_irq_unmask; - rg->irq_chip.irq_mask = mediatek_gpio_irq_mask; - rg->irq_chip.irq_mask_ack = mediatek_gpio_irq_mask; - rg->irq_chip.irq_set_type = mediatek_gpio_irq_type; if (mtk->gpio_irq) { struct gpio_irq_chip *girq; @@ -263,7 +272,7 @@ mediatek_gpio_bank_probe(struct device *dev, } girq = &rg->chip.irq; - girq->chip = &rg->irq_chip; + gpio_irq_chip_set_chip(girq, &mt7621_irq_chip); /* This will let us handle the parent IRQ in the driver */ girq->parent_handler = NULL; girq->num_parents = 0;