linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: mpc8xxx: Don't overwrite default irq_set_type callback
@ 2019-11-15 12:55 Vladimir Oltean
  2019-11-19 10:10 ` Michael Walle
  2019-11-21 13:29 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Vladimir Oltean @ 2019-11-15 12:55 UTC (permalink / raw)
  To: linus.walleij, bgolaszewski, linux-gpio, linux-kernel; +Cc: Vladimir Oltean

From: Vladimir Oltean <vladimir.oltean@nxp.com>

The per-SoC devtype structures can contain their own callbacks that
overwrite mpc8xxx_gpio_devtype_default.

The clear intention is that mpc8xxx_irq_set_type is used in case the SoC
does not specify a more specific callback. But what happens is that if
the SoC doesn't specify one, its .irq_set_type is de-facto NULL, and
this overwrites mpc8xxx_irq_set_type to a no-op. This means that the
following SoCs are affected:

- fsl,mpc8572-gpio
- fsl,ls1028a-gpio
- fsl,ls1088a-gpio

On these boards, the irq_set_type does exactly nothing, and the GPIO
controller keeps its GPICR register in the hardware-default state. On
the LS1028A, that is ACTIVE_BOTH, which means 2 interrupts are raised
even if the IRQ client requests LEVEL_HIGH. Another implication is that
the IRQs are not checked (e.g. level-triggered interrupts are not
rejected, although they are not supported).

Fixes: 82e39b0d8566 ("gpio: mpc8xxx: handle differences between incarnations at a single place")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/gpio/gpio-mpc8xxx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index 16a47de29c94..d88ebefb8147 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -377,7 +377,8 @@ static int mpc8xxx_probe(struct platform_device *pdev)
 	 * It's assumed that only a single type of gpio controller is available
 	 * on the current machine, so overwriting global data is fine.
 	 */
-	mpc8xxx_irq_chip.irq_set_type = devtype->irq_set_type;
+	if (devtype->irq_set_type)
+		mpc8xxx_irq_chip.irq_set_type = devtype->irq_set_type;
 
 	if (devtype->gpio_dir_out)
 		gc->direction_output = devtype->gpio_dir_out;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: mpc8xxx: Don't overwrite default irq_set_type callback
  2019-11-15 12:55 [PATCH] gpio: mpc8xxx: Don't overwrite default irq_set_type callback Vladimir Oltean
@ 2019-11-19 10:10 ` Michael Walle
  2019-11-21 13:29 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Walle @ 2019-11-19 10:10 UTC (permalink / raw)
  To: olteanv
  Cc: bgolaszewski, linus.walleij, linux-gpio, linux-kernel, vladimir.oltean

> The per-SoC devtype structures can contain their own callbacks that
> overwrite mpc8xxx_gpio_devtype_default.
> 
> The clear intention is that mpc8xxx_irq_set_type is used in case the 
> SoC
> does not specify a more specific callback. But what happens is that if
> the SoC doesn't specify one, its .irq_set_type is de-facto NULL, and
> this overwrites mpc8xxx_irq_set_type to a no-op. This means that the
> following SoCs are affected:
> 
> - fsl,mpc8572-gpio
> - fsl,ls1028a-gpio
> - fsl,ls1088a-gpio
> 
> On these boards, the irq_set_type does exactly nothing, and the GPIO
> controller keeps its GPICR register in the hardware-default state. On
> the LS1028A, that is ACTIVE_BOTH, which means 2 interrupts are raised
> even if the IRQ client requests LEVEL_HIGH. Another implication is that
> the IRQs are not checked (e.g. level-triggered interrupts are not
> rejected, although they are not supported).
> 
> Fixes: 82e39b0d8566 ("gpio: mpc8xxx: handle differences between 
> incarnations at a single place")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Tested-by: Michael Walle <michael@walle.cc>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: mpc8xxx: Don't overwrite default irq_set_type callback
  2019-11-15 12:55 [PATCH] gpio: mpc8xxx: Don't overwrite default irq_set_type callback Vladimir Oltean
  2019-11-19 10:10 ` Michael Walle
@ 2019-11-21 13:29 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2019-11-21 13:29 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: Bartosz Golaszewski, open list:GPIO SUBSYSTEM, linux-kernel,
	Vladimir Oltean

On Fri, Nov 15, 2019 at 1:56 PM Vladimir Oltean <olteanv@gmail.com> wrote:

> From: Vladimir Oltean <vladimir.oltean@nxp.com>
>
> The per-SoC devtype structures can contain their own callbacks that
> overwrite mpc8xxx_gpio_devtype_default.
>
> The clear intention is that mpc8xxx_irq_set_type is used in case the SoC
> does not specify a more specific callback. But what happens is that if
> the SoC doesn't specify one, its .irq_set_type is de-facto NULL, and
> this overwrites mpc8xxx_irq_set_type to a no-op. This means that the
> following SoCs are affected:
>
> - fsl,mpc8572-gpio
> - fsl,ls1028a-gpio
> - fsl,ls1088a-gpio
>
> On these boards, the irq_set_type does exactly nothing, and the GPIO
> controller keeps its GPICR register in the hardware-default state. On
> the LS1028A, that is ACTIVE_BOTH, which means 2 interrupts are raised
> even if the IRQ client requests LEVEL_HIGH. Another implication is that
> the IRQs are not checked (e.g. level-triggered interrupts are not
> rejected, although they are not supported).
>
> Fixes: 82e39b0d8566 ("gpio: mpc8xxx: handle differences between incarnations at a single place")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Patch applied with Michael's Tested tag.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-21 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-15 12:55 [PATCH] gpio: mpc8xxx: Don't overwrite default irq_set_type callback Vladimir Oltean
2019-11-19 10:10 ` Michael Walle
2019-11-21 13:29 ` 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).