LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] gpio: pca953x: Clear irq trigger type on irq shutdown
@ 2018-05-04 16:53 Grigoryev Denis
2018-05-16 12:51 ` Linus Walleij
2018-05-23 9:48 ` Linus Walleij
0 siblings, 2 replies; 4+ messages in thread
From: Grigoryev Denis @ 2018-05-04 16:53 UTC (permalink / raw)
Cc: Grigoryev Denis, Linus Walleij, linux-gpio, linux-kernel
The driver stores the result of irq_set_type() in the internal variables
irq_trig_raise and irq_trig_fall, which later are used to determine
the GPIOs that must be re-configured as input. These variables retain their
value between gpiolib's export / unexport, resulting in an incorrect
state in some cases. The corresponding bits in the variables
irq_trig_raise and irq_trig_fall should be cleared in irq_shutdown().
Signed-off-by: Denis Grigoryev <grigoryev@fastwel.ru>
---
drivers/gpio/gpio-pca953x.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index d2ead4b..b41be8c 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -522,6 +522,15 @@ static int pca953x_irq_set_type(struct irq_data *d, unsigned int type)
return 0;
}
+static void pca953x_irq_shutdown(struct irq_data *d)
+{
+ struct pca953x_chip *chip = irq_data_get_irq_chip_data(d);
+ u8 mask = 1 << (d->hwirq % BANK_SZ);
+
+ chip->irq_trig_raise[d->hwirq / BANK_SZ] &= ~mask;
+ chip->irq_trig_fall[d->hwirq / BANK_SZ] &= ~mask;
+}
+
static struct irq_chip pca953x_irq_chip = {
.name = "pca953x",
.irq_mask = pca953x_irq_mask,
@@ -529,6 +538,7 @@ static struct irq_chip pca953x_irq_chip = {
.irq_bus_lock = pca953x_irq_bus_lock,
.irq_bus_sync_unlock = pca953x_irq_bus_sync_unlock,
.irq_set_type = pca953x_irq_set_type,
+ .irq_shutdown = pca953x_irq_shutdown,
};
static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending)
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: pca953x: Clear irq trigger type on irq shutdown
2018-05-04 16:53 [PATCH] gpio: pca953x: Clear irq trigger type on irq shutdown Grigoryev Denis
@ 2018-05-16 12:51 ` Linus Walleij
2018-05-16 13:14 ` Andy Shevchenko
2018-05-23 9:48 ` Linus Walleij
1 sibling, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2018-05-16 12:51 UTC (permalink / raw)
To: Grigoryev Denis, H. Nikolaus Schaller, Sergei Shtylyov,
Andy Shevchenko, Steve Longerbeam
Cc: linux-gpio, linux-kernel
On Fri, May 4, 2018 at 6:53 PM, Grigoryev Denis <grigoryev@fastwel.ru> wrote:
> The driver stores the result of irq_set_type() in the internal variables
> irq_trig_raise and irq_trig_fall, which later are used to determine
> the GPIOs that must be re-configured as input. These variables retain their
> value between gpiolib's export / unexport, resulting in an incorrect
> state in some cases. The corresponding bits in the variables
> irq_trig_raise and irq_trig_fall should be cleared in irq_shutdown().
>
> Signed-off-by: Denis Grigoryev <grigoryev@fastwel.ru>
> ---
> drivers/gpio/gpio-pca953x.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index d2ead4b..b41be8c 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -522,6 +522,15 @@ static int pca953x_irq_set_type(struct irq_data *d, unsigned int type)
> return 0;
> }
>
> +static void pca953x_irq_shutdown(struct irq_data *d)
> +{
> + struct pca953x_chip *chip = irq_data_get_irq_chip_data(d);
> + u8 mask = 1 << (d->hwirq % BANK_SZ);
> +
> + chip->irq_trig_raise[d->hwirq / BANK_SZ] &= ~mask;
> + chip->irq_trig_fall[d->hwirq / BANK_SZ] &= ~mask;
> +}
> +
> static struct irq_chip pca953x_irq_chip = {
> .name = "pca953x",
> .irq_mask = pca953x_irq_mask,
> @@ -529,6 +538,7 @@ static struct irq_chip pca953x_irq_chip = {
> .irq_bus_lock = pca953x_irq_bus_lock,
> .irq_bus_sync_unlock = pca953x_irq_bus_sync_unlock,
> .irq_set_type = pca953x_irq_set_type,
> + .irq_shutdown = pca953x_irq_shutdown,
> };
This driver has a big set of users, so putting some maintainers
in the loop so we can get some patch review.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: pca953x: Clear irq trigger type on irq shutdown
2018-05-16 12:51 ` Linus Walleij
@ 2018-05-16 13:14 ` Andy Shevchenko
0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2018-05-16 13:14 UTC (permalink / raw)
To: Linus Walleij, Grigoryev Denis, H. Nikolaus Schaller,
Sergei Shtylyov, Steve Longerbeam
Cc: linux-gpio, linux-kernel
On Wed, 2018-05-16 at 14:51 +0200, Linus Walleij wrote:
> On Fri, May 4, 2018 at 6:53 PM, Grigoryev Denis <grigoryev@fastwel.ru>
> wrote:
>
If it's full context below, the patch looks good enough to me (assuming
it works and doesn't break things on other chips like PCAL variants).
Though, I didn't read the code carefully (not enough time this week).
Thus, FWIW,
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
with above caveats in mind.
> > The driver stores the result of irq_set_type() in the internal
> > variables
> > irq_trig_raise and irq_trig_fall, which later are used to determine
> > the GPIOs that must be re-configured as input. These variables
> > retain their
> > value between gpiolib's export / unexport, resulting in an
> > incorrect
> > state in some cases. The corresponding bits in the variables
> > irq_trig_raise and irq_trig_fall should be cleared in
> > irq_shutdown().
> >
> > Signed-off-by: Denis Grigoryev <grigoryev@fastwel.ru>
> > ---
> > drivers/gpio/gpio-pca953x.c | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-
> > pca953x.c
> > index d2ead4b..b41be8c 100644
> > --- a/drivers/gpio/gpio-pca953x.c
> > +++ b/drivers/gpio/gpio-pca953x.c
> > @@ -522,6 +522,15 @@ static int pca953x_irq_set_type(struct irq_data
> > *d, unsigned int type)
> > return 0;
> > }
> >
> > +static void pca953x_irq_shutdown(struct irq_data *d)
> > +{
> > + struct pca953x_chip *chip = irq_data_get_irq_chip_data(d);
> > + u8 mask = 1 << (d->hwirq % BANK_SZ);
> > +
> > + chip->irq_trig_raise[d->hwirq / BANK_SZ] &= ~mask;
> > + chip->irq_trig_fall[d->hwirq / BANK_SZ] &= ~mask;
> > +}
> > +
> > static struct irq_chip pca953x_irq_chip = {
> > .name = "pca953x",
> > .irq_mask = pca953x_irq_mask,
> > @@ -529,6 +538,7 @@ static struct irq_chip pca953x_irq_chip = {
> > .irq_bus_lock = pca953x_irq_bus_lock,
> > .irq_bus_sync_unlock = pca953x_irq_bus_sync_unlock,
> > .irq_set_type = pca953x_irq_set_type,
> > + .irq_shutdown = pca953x_irq_shutdown,
> > };
>
> This driver has a big set of users, so putting some maintainers
> in the loop so we can get some patch review.
>
> Yours,
> Linus Walleij
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: pca953x: Clear irq trigger type on irq shutdown
2018-05-04 16:53 [PATCH] gpio: pca953x: Clear irq trigger type on irq shutdown Grigoryev Denis
2018-05-16 12:51 ` Linus Walleij
@ 2018-05-23 9:48 ` Linus Walleij
1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2018-05-23 9:48 UTC (permalink / raw)
To: Grigoryev Denis; +Cc: linux-gpio, linux-kernel
On Fri, May 4, 2018 at 6:53 PM, Grigoryev Denis <grigoryev@fastwel.ru> wrote:
> The driver stores the result of irq_set_type() in the internal variables
> irq_trig_raise and irq_trig_fall, which later are used to determine
> the GPIOs that must be re-configured as input. These variables retain their
> value between gpiolib's export / unexport, resulting in an incorrect
> state in some cases. The corresponding bits in the variables
> irq_trig_raise and irq_trig_fall should be cleared in irq_shutdown().
>
> Signed-off-by: Denis Grigoryev <grigoryev@fastwel.ru>
Patch applied with Andy's ACK.
If there are issues we can just revert it.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-05-23 9:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-04 16:53 [PATCH] gpio: pca953x: Clear irq trigger type on irq shutdown Grigoryev Denis
2018-05-16 12:51 ` Linus Walleij
2018-05-16 13:14 ` Andy Shevchenko
2018-05-23 9:48 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).