linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] pinctrl: reg-fixed-voltage usb0-vbus: error -EINVAL: can't get GPIO
@ 2022-01-18 12:50 Corentin Labbe
  2022-01-18 14:13 ` Hans Verkuil
  0 siblings, 1 reply; 4+ messages in thread
From: Corentin Labbe @ 2022-01-18 12:50 UTC (permalink / raw)
  To: linus.walleij, mripard, wens, jernej.skrabec, hverkuil-cisco
  Cc: linux-gpio, linux-arm-kernel, linux-sunxi, linux-kernel, zhangn1985

Hello

As reported on old googlegroup sunxi mainling list, on linux-next-20220118, USB storage fail to bring up on orangepiPC.
We can see some error logs in dmesg:
reg-fixed-voltage usb0-vbus: error -EINVAL: can't get GPIO
reg-fixed-voltage: probe of usb0-vbus failed with error -22

This is bisected to: 8df89a7cbc63c7598c00611ad17b67e8d5b4fad3 pinctrl-sunxi: don't call pinctrl_gpio_direction()

Reverting this commit lead to a working USB storage being setuped.

Regards

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

* Re: [BUG] pinctrl: reg-fixed-voltage usb0-vbus: error -EINVAL: can't get GPIO
  2022-01-18 12:50 [BUG] pinctrl: reg-fixed-voltage usb0-vbus: error -EINVAL: can't get GPIO Corentin Labbe
@ 2022-01-18 14:13 ` Hans Verkuil
  2022-01-26 11:03   ` Hans Verkuil
  2022-01-28 17:20   ` Guenter Roeck
  0 siblings, 2 replies; 4+ messages in thread
From: Hans Verkuil @ 2022-01-18 14:13 UTC (permalink / raw)
  To: Corentin Labbe, linus.walleij, mripard, wens, jernej.skrabec
  Cc: linux-gpio, linux-arm-kernel, linux-sunxi, linux-kernel, zhangn1985

On 1/18/22 13:50, Corentin Labbe wrote:
> Hello
> 
> As reported on old googlegroup sunxi mainling list, on linux-next-20220118, USB storage fail to bring up on orangepiPC.
> We can see some error logs in dmesg:
> reg-fixed-voltage usb0-vbus: error -EINVAL: can't get GPIO
> reg-fixed-voltage: probe of usb0-vbus failed with error -22
> 
> This is bisected to: 8df89a7cbc63c7598c00611ad17b67e8d5b4fad3 pinctrl-sunxi: don't call pinctrl_gpio_direction()
> 
> Reverting this commit lead to a working USB storage being setuped.

Hmm, I'll bet it's EPROBE_DEFER related.

The original call (pre that commit) of pinctrl_gpio_direction_output() checks
if the pin controller could find the pin (pinctrl_get_device_gpio_range()).

That doesn't happen in the new code.

The sunxi appears to have two pincontrollers in the device tree (&pio and &r_pio),
that might be part of the reason this is an issue here.

Linus, should there be a check somewhere for a missing pincontroller in
gpiod_get_index()? I suspect that before my commit it was the gpiod_configure_flags
call in that function that returned -EPROBE_DEFER, but I'm not completely certain.

If someone can give me a hint about what should be done, then I can make a patch.

The alternative is to revert this sunxi patch, but perhaps this is a deeper
problem with these pincontroller drivers that set the direction directly
instead of going through pinctrl_gpio_direction_output().

Corentin, it would help me if you can figure out where the EPROBE_DEFER is
returned (pre-commit) in drivers/pinctrl/core.c. Probably pinctrl_get_device_gpio_range().

And I'd love to have the WARN_ON(1) output from just before the 'return -EPROBE_DEFER'.

Regards,

	Hans

> 
> Regards

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

* Re: [BUG] pinctrl: reg-fixed-voltage usb0-vbus: error -EINVAL: can't get GPIO
  2022-01-18 14:13 ` Hans Verkuil
@ 2022-01-26 11:03   ` Hans Verkuil
  2022-01-28 17:20   ` Guenter Roeck
  1 sibling, 0 replies; 4+ messages in thread
From: Hans Verkuil @ 2022-01-26 11:03 UTC (permalink / raw)
  To: Corentin Labbe, linus.walleij, mripard, wens, jernej.skrabec
  Cc: linux-gpio, linux-arm-kernel, linux-sunxi, linux-kernel, zhangn1985

On 18/01/2022 15:13, Hans Verkuil wrote:
> On 1/18/22 13:50, Corentin Labbe wrote:
>> Hello
>>
>> As reported on old googlegroup sunxi mainling list, on linux-next-20220118, USB storage fail to bring up on orangepiPC.
>> We can see some error logs in dmesg:
>> reg-fixed-voltage usb0-vbus: error -EINVAL: can't get GPIO
>> reg-fixed-voltage: probe of usb0-vbus failed with error -22
>>
>> This is bisected to: 8df89a7cbc63c7598c00611ad17b67e8d5b4fad3 pinctrl-sunxi: don't call pinctrl_gpio_direction()
>>
>> Reverting this commit lead to a working USB storage being setuped.

Hopefully this is resolved by this patch:

https://patchwork.linuxtv.org/project/linux-media/patch/0f536cd8-01db-5d16-2cec-ec6d19409a49@xs4all.nl/

Please test!

Regards,

	Hans

> 
> Hmm, I'll bet it's EPROBE_DEFER related.
> 
> The original call (pre that commit) of pinctrl_gpio_direction_output() checks
> if the pin controller could find the pin (pinctrl_get_device_gpio_range()).
> 
> That doesn't happen in the new code.
> 
> The sunxi appears to have two pincontrollers in the device tree (&pio and &r_pio),
> that might be part of the reason this is an issue here.
> 
> Linus, should there be a check somewhere for a missing pincontroller in
> gpiod_get_index()? I suspect that before my commit it was the gpiod_configure_flags
> call in that function that returned -EPROBE_DEFER, but I'm not completely certain.
> 
> If someone can give me a hint about what should be done, then I can make a patch.
> 
> The alternative is to revert this sunxi patch, but perhaps this is a deeper
> problem with these pincontroller drivers that set the direction directly
> instead of going through pinctrl_gpio_direction_output().
> 
> Corentin, it would help me if you can figure out where the EPROBE_DEFER is
> returned (pre-commit) in drivers/pinctrl/core.c. Probably pinctrl_get_device_gpio_range().
> 
> And I'd love to have the WARN_ON(1) output from just before the 'return -EPROBE_DEFER'.
> 
> Regards,
> 
> 	Hans
> 
>>
>> Regards


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

* Re: [BUG] pinctrl: reg-fixed-voltage usb0-vbus: error -EINVAL: can't get GPIO
  2022-01-18 14:13 ` Hans Verkuil
  2022-01-26 11:03   ` Hans Verkuil
@ 2022-01-28 17:20   ` Guenter Roeck
  1 sibling, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2022-01-28 17:20 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Corentin Labbe, linus.walleij, mripard, wens, jernej.skrabec,
	linux-gpio, linux-arm-kernel, linux-sunxi, linux-kernel,
	zhangn1985

On Tue, Jan 18, 2022 at 03:13:20PM +0100, Hans Verkuil wrote:
> On 1/18/22 13:50, Corentin Labbe wrote:
> > Hello
> > 
> > As reported on old googlegroup sunxi mainling list, on linux-next-20220118, USB storage fail to bring up on orangepiPC.
> > We can see some error logs in dmesg:
> > reg-fixed-voltage usb0-vbus: error -EINVAL: can't get GPIO
> > reg-fixed-voltage: probe of usb0-vbus failed with error -22
> > 
> > This is bisected to: 8df89a7cbc63c7598c00611ad17b67e8d5b4fad3 pinctrl-sunxi: don't call pinctrl_gpio_direction()
> > 
> > Reverting this commit lead to a working USB storage being setuped.
> 
> Hmm, I'll bet it's EPROBE_DEFER related.
> 

No. For me the problem is only seen if I try to boot from the second usb
interface with the orangepi-pc qemu emulation, but not when I try to boot
from the first usb interface. That alone makes it unlikely to be an
EPROBE_DEFER related problem.

Some debugging with your code in the tree:

[    7.076227] sun8i-h3-r-pinctrl 1f02c00.pinctrl: ########### sunxi_pmx_gpio_set_direction: offset=10, input=0
[    7.076567] sun8i-h3-r-pinctrl 1f02c00.pinctrl: ########### sunxi_pinctrl_gpio_direction_output: offset=10, value=1, ret=-22
[    7.076992] leds-gpio: probe of leds failed with error -22
[    7.081645] sun8i-h3-r-pinctrl 1f02c00.pinctrl: ########### sunxi_pmx_gpio_set_direction: offset=2, input=0
[    7.081887] sun8i-h3-r-pinctrl 1f02c00.pinctrl: ########### sunxi_pinctrl_gpio_direction_output: offset=2, value=0, ret=-22
[    7.082424] reg-fixed-voltage usb0-vbus: error -EINVAL: can't get GPIO
[    7.082793] reg-fixed-voltage: probe of usb0-vbus failed with error -22
[    7.129355] sun8i-h3-pinctrl 1c20800.pinctrl: ########### sunxi_pmx_gpio_set_direction: offset=166, input=1
[    7.129844] sun8i-h3-pinctrl 1c20800.pinctrl: ######### sunxi_pinctrl_gpio_direction_input: offset=166, ret=0
[    7.130788] sunxi-mmc 1c0f000.mmc: Got CD GPIO
[    7.169391] sun8i-h3-r-pinctrl 1f02c00.pinctrl: ########### sunxi_pmx_gpio_set_direction: offset=3, input=1
[    7.169663] sun8i-h3-r-pinctrl 1f02c00.pinctrl: ######### sunxi_pinctrl_gpio_direction_input: offset=3, ret=-22
[    7.170054] gpio-keys r_gpio_keys: failed to get gpio: -22
[    7.170262] gpio-keys: probe of r_gpio_keys failed with error -22

And after reverting it:

[    6.138097] sun8i-h3-r-pinctrl 1f02c00.pinctrl: ########### sunxi_pmx_gpio_set_direction: offset=362, input=0
[    6.138375] sun8i-h3-r-pinctrl 1f02c00.pinctrl: ########### sunxi_pinctrl_gpio_direction_output: offset=10, value=1, ret=0
[    6.140762] sun8i-h3-pinctrl 1c20800.pinctrl: ########### sunxi_pmx_gpio_set_direction: offset=15, input=0
[    6.140918] sun8i-h3-pinctrl 1c20800.pinctrl: ########### sunxi_pinctrl_gpio_direction_output: offset=15, value=0, ret=0
[    6.142808] sun8i-h3-pinctrl 1c20800.pinctrl: supply vcc-pf not found, using dummy regulator
[    6.148879] sun8i-h3-r-pinctrl 1f02c00.pinctrl: ########### sunxi_pmx_gpio_set_direction: offset=354, input=0
[    6.149086] sun8i-h3-r-pinctrl 1f02c00.pinctrl: ########### sunxi_pinctrl_gpio_direction_output: offset=2, value=0, ret=0
[    6.154485] sun8i-h3-pinctrl 1c20800.pinctrl: supply vcc-pg not found, using dummy regulator
[    6.155657] sun8i-h3-pinctrl 1c20800.pinctrl: ########### sunxi_pmx_gpio_set_direction: offset=204, input=1
[    6.155853] sun8i-h3-pinctrl 1c20800.pinctrl: ######### sunxi_pinctrl_gpio_direction_input: offset=204, ret=0
[    6.174411] ehci-platform 1c1b000.usb: EHCI Host Controller
[    6.174737] ehci-platform 1c1b000.usb: new USB bus registered, assigned bus number 3
[    6.188776] sun8i-h3-pinctrl 1c20800.pinctrl: ########### sunxi_pmx_gpio_set_direction: offset=166, input=1
[    6.189149] sun8i-h3-pinctrl 1c20800.pinctrl: ######### sunxi_pinctrl_gpio_direction_input: offset=166, ret=0
[    6.189720] sunxi-mmc 1c0f000.mmc: Got CD GPIO
...
[    6.674660] sun8i-h3-r-pinctrl 1f02c00.pinctrl: ########### sunxi_pmx_gpio_set_direction: offset=355, input=1
[    6.674796] sun8i-h3-r-pinctrl 1f02c00.pinctrl: ######### sunxi_pinctrl_gpio_direction_input: offset=3, ret=0

In other words, there is some offset translation missing with your patch,
causing -EINVAL returns.

Guenter

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

end of thread, other threads:[~2022-01-28 17:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 12:50 [BUG] pinctrl: reg-fixed-voltage usb0-vbus: error -EINVAL: can't get GPIO Corentin Labbe
2022-01-18 14:13 ` Hans Verkuil
2022-01-26 11:03   ` Hans Verkuil
2022-01-28 17:20   ` Guenter Roeck

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