linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [REGRESSION] gpio hogging fails with pinctrl gpio drivers
@ 2020-02-06 17:32 Russell King - ARM Linux admin
  2020-02-20  8:17 ` Linus Walleij
  0 siblings, 1 reply; 5+ messages in thread
From: Russell King - ARM Linux admin @ 2020-02-06 17:32 UTC (permalink / raw)
  To: Linus Walleij, linux-arm-kernel

Hi Linus,

It seems that sometime between 4.20 and 5.5, something has broken the
ability to specify gpio-hogs in DT for GPIOs that are written around
pinctrl drivers.

For example:

        gpio6: sx1503@20 {
                compatible = "semtech,sx1503q";
...
                phy_rst {
                        gpio-hog;
                        gpios = <9 GPIO_ACTIVE_HIGH>;
                        output-high;
                        line-name = "10g-rstn";
                };
        };

fails with:

gpio gpiochip7: (sx1503q): setup of own GPIO 10g-rstn failed
requesting hog GPIO 10g-rstn (chip sx1503q, offset 9) failed, -517
gpiochip_add_data_with_key: GPIOs 480..495 (sx1503q) failed to register, -517

It appears that the reason for this failure is that the hogs are
requested in gpiochip_add_data_with_key(), called from
devm_gpiochip_add_data(), but as the set_config method points to
gpiochip_generic_config, it wants to look up the pinctrl pin range
via pinctrl_get_device_gpio_range(). However, that has not been setup
yet, as the following call to gpiochip_add_pin_range() has not been
reached:

        ret = devm_gpiochip_add_data(dev, &pctl->gpio, pctl);
        if (ret)
                return ret;

        ret = gpiochip_add_pin_range(&pctl->gpio, dev_name(dev),
                                     0, 0, pctl->data->npins);

and so pinctrl_get_device_gpio_range() returns -EPROBE_DEFER.

Consequently, adding a gpio-hog to DT for this driver results in the
driver endlessly returning -EPROBE_DEFER.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [REGRESSION] gpio hogging fails with pinctrl gpio drivers
  2020-02-06 17:32 [REGRESSION] gpio hogging fails with pinctrl gpio drivers Russell King - ARM Linux admin
@ 2020-02-20  8:17 ` Linus Walleij
  2020-02-20 10:12   ` Peter Rosin
  2020-02-20 17:28   ` Andrey Smirnov
  0 siblings, 2 replies; 5+ messages in thread
From: Linus Walleij @ 2020-02-20  8:17 UTC (permalink / raw)
  To: Russell King - ARM Linux admin, open list:GPIO SUBSYSTEM, Peter Rosin
  Cc: Andrey Smirnov, Linux ARM

On Thu, Feb 6, 2020 at 6:33 PM Russell King - ARM Linux admin
<linux@armlinux.org.uk> wrote:

> It seems that sometime between 4.20 and 5.5, something has broken the
> ability to specify gpio-hogs in DT for GPIOs that are written around
> pinctrl drivers.
(explanation that makes perfect sense)
> Consequently, adding a gpio-hog to DT for this driver results in the
> driver endlessly returning -EPROBE_DEFER.

I suspect this is sx150x-specific and suspect these two commits:

1a1d39e1b8dd pinctrl: sx150x: Register pinctrl before adding the gpiochip
b930151e5b55 pinctrl: sx150x: Add a static gpio/pinctrl pin range mapping

I suppose people weren't using hogs very much with the sx150x and
it didn't turn up in testing so far.

I don't think for example pinctrl-stmfx.c has this problem, as it registers
the pin ranges from the device tree as part of the core code.
But other drivers calling gpiochip_add_pin_range() may be experiencing
this.

Peter/Andrey, do you have some idea? Have you tested this usecase (hogs)
with the sx150x?

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [REGRESSION] gpio hogging fails with pinctrl gpio drivers
  2020-02-20  8:17 ` Linus Walleij
@ 2020-02-20 10:12   ` Peter Rosin
  2020-02-20 17:28   ` Andrey Smirnov
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Rosin @ 2020-02-20 10:12 UTC (permalink / raw)
  To: Linus Walleij, Russell King - ARM Linux admin, open list:GPIO SUBSYSTEM
  Cc: Andrey Smirnov, Linux ARM

On 2020-02-20 09:17, Linus Walleij wrote:
> On Thu, Feb 6, 2020 at 6:33 PM Russell King - ARM Linux admin
> <linux@armlinux.org.uk> wrote:
> 
>> It seems that sometime between 4.20 and 5.5, something has broken the
>> ability to specify gpio-hogs in DT for GPIOs that are written around
>> pinctrl drivers.
> (explanation that makes perfect sense)
>> Consequently, adding a gpio-hog to DT for this driver results in the
>> driver endlessly returning -EPROBE_DEFER.
> 
> I suspect this is sx150x-specific and suspect these two commits:
> 
> 1a1d39e1b8dd pinctrl: sx150x: Register pinctrl before adding the gpiochip
> b930151e5b55 pinctrl: sx150x: Add a static gpio/pinctrl pin range mapping
> 
> I suppose people weren't using hogs very much with the sx150x and
> it didn't turn up in testing so far.
> 
> I don't think for example pinctrl-stmfx.c has this problem, as it registers
> the pin ranges from the device tree as part of the core code.
> But other drivers calling gpiochip_add_pin_range() may be experiencing
> this.
> 
> Peter/Andrey, do you have some idea? Have you tested this usecase (hogs)
> with the sx150x?

I have never created gpio hogs myself, so no, I haven't done any testing
with that. Sorry. I could of course spend some time looking at this, but I
don't know all that much about the wrinkles of the interactions between
pinctrl och gpio. Or plain gpio/pinctrl for that matter. Sure, I extended
this driver, but I haven't really looked at those sub-systems since. I
think others will come up with a solution for this with much less effort
and with less risk of introducing new problems...

Cheers,
Peter
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [REGRESSION] gpio hogging fails with pinctrl gpio drivers
  2020-02-20  8:17 ` Linus Walleij
  2020-02-20 10:12   ` Peter Rosin
@ 2020-02-20 17:28   ` Andrey Smirnov
  2020-02-20 18:19     ` Russell King - ARM Linux admin
  1 sibling, 1 reply; 5+ messages in thread
From: Andrey Smirnov @ 2020-02-20 17:28 UTC (permalink / raw)
  To: Linus Walleij
  Cc: open list:GPIO SUBSYSTEM, Russell King - ARM Linux admin,
	Linux ARM, Peter Rosin

On Thu, Feb 20, 2020 at 12:18 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Thu, Feb 6, 2020 at 6:33 PM Russell King - ARM Linux admin
> <linux@armlinux.org.uk> wrote:
>
> > It seems that sometime between 4.20 and 5.5, something has broken the
> > ability to specify gpio-hogs in DT for GPIOs that are written around
> > pinctrl drivers.
> (explanation that makes perfect sense)
> > Consequently, adding a gpio-hog to DT for this driver results in the
> > driver endlessly returning -EPROBE_DEFER.
>
> I suspect this is sx150x-specific and suspect these two commits:
>
> 1a1d39e1b8dd pinctrl: sx150x: Register pinctrl before adding the gpiochip
> b930151e5b55 pinctrl: sx150x: Add a static gpio/pinctrl pin range mapping
>
> I suppose people weren't using hogs very much with the sx150x and
> it didn't turn up in testing so far.
>
> I don't think for example pinctrl-stmfx.c has this problem, as it registers
> the pin ranges from the device tree as part of the core code.
> But other drivers calling gpiochip_add_pin_range() may be experiencing
> this.
>
> Peter/Andrey, do you have some idea? Have you tested this usecase (hogs)
> with the sx150x?
>

Haven't done any GPIO hogging on sx150x, unfortunately. My use-cases were:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/vf610-zii-dev-rev-c.dts

and

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/vf610-zii-scu4-aib.dts

which didn't have any hogs so far (there's a chance Russell is using
the former for his experiments, so maybe that'll change). I don't any
useful input on this regression, sorry. I do have Rev C. board readily
available, so I can provide Tested-by's if I am CC'd on fixes.

Thanks,
Andrey Smirnov

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [REGRESSION] gpio hogging fails with pinctrl gpio drivers
  2020-02-20 17:28   ` Andrey Smirnov
@ 2020-02-20 18:19     ` Russell King - ARM Linux admin
  0 siblings, 0 replies; 5+ messages in thread
From: Russell King - ARM Linux admin @ 2020-02-20 18:19 UTC (permalink / raw)
  To: Andrey Smirnov
  Cc: open list:GPIO SUBSYSTEM, Linus Walleij, Peter Rosin, Linux ARM

On Thu, Feb 20, 2020 at 09:28:14AM -0800, Andrey Smirnov wrote:
> On Thu, Feb 20, 2020 at 12:18 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> >
> > On Thu, Feb 6, 2020 at 6:33 PM Russell King - ARM Linux admin
> > <linux@armlinux.org.uk> wrote:
> >
> > > It seems that sometime between 4.20 and 5.5, something has broken the
> > > ability to specify gpio-hogs in DT for GPIOs that are written around
> > > pinctrl drivers.
> > (explanation that makes perfect sense)
> > > Consequently, adding a gpio-hog to DT for this driver results in the
> > > driver endlessly returning -EPROBE_DEFER.
> >
> > I suspect this is sx150x-specific and suspect these two commits:
> >
> > 1a1d39e1b8dd pinctrl: sx150x: Register pinctrl before adding the gpiochip
> > b930151e5b55 pinctrl: sx150x: Add a static gpio/pinctrl pin range mapping
> >
> > I suppose people weren't using hogs very much with the sx150x and
> > it didn't turn up in testing so far.
> >
> > I don't think for example pinctrl-stmfx.c has this problem, as it registers
> > the pin ranges from the device tree as part of the core code.
> > But other drivers calling gpiochip_add_pin_range() may be experiencing
> > this.
> >
> > Peter/Andrey, do you have some idea? Have you tested this usecase (hogs)
> > with the sx150x?
> >
> 
> Haven't done any GPIO hogging on sx150x, unfortunately. My use-cases were:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/vf610-zii-dev-rev-c.dts
> 
> and
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/vf610-zii-scu4-aib.dts
> 
> which didn't have any hogs so far (there's a chance Russell is using
> the former for his experiments, so maybe that'll change). I don't any
> useful input on this regression, sorry. I do have Rev C. board readily
> available, so I can provide Tested-by's if I am CC'd on fixes.

The ZII dev rev C is where I had the hog as a means of kicking the
88x3310 PHY out of reset.

I've now converted it to a proper MDIO bus-level reset, so I no
longer have the hog, and I no longer care about the regression - but
that's not to say it shouldn't be fixed, as the code is wrong.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2020-02-20 18:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-06 17:32 [REGRESSION] gpio hogging fails with pinctrl gpio drivers Russell King - ARM Linux admin
2020-02-20  8:17 ` Linus Walleij
2020-02-20 10:12   ` Peter Rosin
2020-02-20 17:28   ` Andrey Smirnov
2020-02-20 18:19     ` Russell King - ARM Linux admin

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).