gpio: shared-proxy: open-drain regulators on ODROID-HC4 fail with -EPERM
Subsystems (3)
Since f918e3804498 ("arm64: enable HAVE_SHARED_GPIOS for all ARM64 platforms"), two of the three fixed regulators sharing GPIOH_8 (GPIO_OPEN_DRAIN) on ODROID-HC4 fail on every boot:
reg-fixed-voltage regulator-p12v-0: setup of GPIO (default) failed: -1 reg-fixed-voltage regulator-p12v-0: error -EPERM: can't get GPIO
The first user (vcc_5v) sets the line to output high in gpiod_configure_flags(). Its enable then goes through gpio_set_open_drain_value_commit(), which emulates high by calling direction_input on the proxy, and the proxy switches the shared line to input. The next users hit "Shared GPIO's direction already set to input, refusing to change" in gpio_shared_proxy_direction_output(). Stack from trace_trigger=gpio_direction.stacktrace:
gpiod_direction_input <- gpio_shared_proxy_direction_input <- gpio_set_open_drain_value_commit <- gpiod_set_value_cansleep <- _regulator_do_enable <- set_machine_constraints <- regulator_register
Armbian v7.4-rc2 (its patches don't touch gpiolib or these nodes); same with the five shared-proxy fixes from the v7.4-rc3 pull. The winner depends on probe order: without the fixes vcc_5v lost in 2 of 4 boots, leaving the SD card unpowered and no rootfs.
#regzbot introduced: f918e3804498
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
Bartosz Golaszewski
maintainerQuoted 15 lines · Igor Velkov
Since
f918e3804498("arm64: enableHAVE_SHARED_GPIOSfor all ARM64 platforms"), two of the three fixed regulators sharingGPIOH_8(GPIO_OPEN_DRAIN) on ODROID-HC4 fail on every boot:reg-fixed-voltage regulator-p12v-0: setup of GPIO (default) failed: -1 reg-fixed-voltage regulator-p12v-0: error
-EPERM: can't get GPIOThe first user (
vcc_5v) sets the line to output high ingpiod_configure_flags(). Its enable then goes throughgpio_set_open_drain_value_commit(), which emulates high by callingdirection_inputon the proxy, and the proxy switches the shared line to input. The next users hit "Shared GPIO's direction already set to input, refusing to change" ingpio_shared_proxy_direction_output(). Stack from trace_trigger=gpio_direction.stacktrace:
Quoted 9 lines
gpiod_direction_input<-gpio_shared_proxy_direction_input<-gpio_set_open_drain_value_commit<-gpiod_set_value_cansleep<-_regulator_do_enable<-set_machine_constraints<-regulator_registerArmbian v7.4-rc2 (its patches don't touch gpiolib or these nodes); same with the five shared-proxy fixes from the v7.4-rc3 pull. The winner depends on probe order: without the fixes
vcc_5vlost in 2 of 4 boots, leaving the SD card unpowered and no rootfs.
Thanks for the report, I'll send a fix proposal for you to test tomorrow.
Bartosz
Bartosz Golaszewski
maintainerQuoted 15 lines · Igor Velkov
Since
f918e3804498("arm64: enableHAVE_SHARED_GPIOSfor all ARM64 platforms"), two of the three fixed regulators sharingGPIOH_8(GPIO_OPEN_DRAIN) on ODROID-HC4 fail on every boot:reg-fixed-voltage regulator-p12v-0: setup of GPIO (default) failed: -1 reg-fixed-voltage regulator-p12v-0: error
-EPERM: can't get GPIOThe first user (
vcc_5v) sets the line to output high ingpiod_configure_flags(). Its enable then goes throughgpio_set_open_drain_value_commit(), which emulates high by callingdirection_inputon the proxy, and the proxy switches the shared line to input. The next users hit "Shared GPIO's direction already set to input, refusing to change" ingpio_shared_proxy_direction_output(). Stack from trace_trigger=gpio_direction.stacktrace:
Quoted 9 lines
gpiod_direction_input<-gpio_shared_proxy_direction_input<-gpio_set_open_drain_value_commit<-gpiod_set_value_cansleep<-_regulator_do_enable<-set_machine_constraints<-regulator_registerArmbian v7.4-rc2 (its patches don't touch gpiolib or these nodes); same with the five shared-proxy fixes from the v7.4-rc3 pull. The winner depends on probe order: without the fixes
vcc_5vlost in 2 of 4 boots, leaving the SD card unpowered and no rootfs.
I was wondering why does the second user even arrive in gpio_shared_proxy_direction_output() at all when it should take the emulation path. I think the issue is with the proxy driver not propagating the -ENOTSUPP error code in set_config(). While I did author that code, I have no idea why I did it and if I even had any reason at all. Could you try the following diff?
drivers/gpio/gpio-shared-proxy.c +1 -1
@@ -186,7 +186,7 @@ static int gpio_shared_proxy_set_config(struct gpio_chip *gc, } ret =gpiod_set_config (desc, cfg); -if (ret && ret != -ENOTSUPP ) +if (ret)return ret; shared_desc->cfg = cfg;
With it, both users should take the simulation route.
Thanks,
Bartosz
Igor Velkov
Tested-byQuoted 2 lines · Bartosz Golaszewski
I think the issue is with the proxy driver not propagating the
-ENOTSUPPerror code inset_config().
[...]
Quoted 1 line
Could you try the following diff?
Thanks, that fixes it. With the diff on v7.4-rc3, 4 of 4 cold boots:
no -EPERM, vcc_5v and both p12v regulators probe as open-drain outputs, and both SATA disks come up. Stock rc3 on the same board failed both p12v regulators on the boot before.