gpio desc flags being lost

From: Chris Packham
Date: Wed Jul 03 2019 - 01:36:11 EST


Hi LinusW, Bartosz,

I was debugging something else and I noticed a problem with the gpio
framework or the gpio-mmio driver (or both) in 5.2.0-rc6.

I have some gpio hogs in my device tree which seem to get requested at
startup as expected

...
GPIO line 456 (sw-reset) hogged as output/low
GPIO line 459 (phy-1g-reset) hogged as output/low
GPIO line 460 (i2c-reset) hogged as output/low
GPIO line 461 (lm81-reset) hogged as output/low
GPIO line 462 (phy-led-reset) hogged as output/low
GPIO line 448 (pcie-reset) hogged as output/low
..

I wanted to see what state these lines were in

# cat /sys/kernel/debug/gpio
gpiochip4: GPIOs 448-455, parent: platform/fffa00029.dev-reset-ctl-2,
fffa00029.dev-reset-ctl-2:

gpiochip3: GPIOs 456-463, parent: platform/fffa00020.dev-reset-ctl,
fffa00020.dev-reset-ctl:

I expected the hogs to show up here.

# echo 448 >/sys/class/gpio/export

Now I'm pretty sure I shouldn't be allowed to do that.

# cat /sys/kernel/debug/gpio
gpiochip4: GPIOs 448-455, parent: platform/fffa00029.dev-reset-ctl-2,
fffa00029.dev-reset-ctl-2:gpio-448 ( |sysfs
) in lo

Doing a bit of debugging so far I see that after startup the desc->flags
for those gpios is 0. But for the hogged ones it should be 0x800 (or 0x801).

I happen to have a 4.8.17 kernel for the board I'm using. Testing with
that seems to be OK.

[root@linuxbox ~]# uname -a
Linux linuxbox 4.8.17-at1+ #3 SMP Wed Jul 3 05:30:55 UTC 2019 ppc GNU/Linux
[root@linuxbox ~]# cat /sys/kernel/debug/gpio
gpiochip4: GPIOs 448-455, parent: platform/fffa00029.dev-reset-ctl-2,
fffa00029.dev-reset-ctl-2:
gpio-448 ( |pcie-reset ) out lo

gpiochip3: GPIOs 456-463, parent: platform/fffa00020.dev-reset-ctl,
fffa00020.dev-reset-ctl:
gpio-456 ( |sw-reset ) out lo
gpio-459 ( |phy-1g-reset ) out lo
gpio-460 ( |i2c-reset ) out lo
gpio-461 ( |lm81-reset ) out lo
gpio-462 ( |phy-led-reset ) out lo

[root@linuxbox ~]# echo 448 >/sys/class/gpio/export
sh: write error: Device or resource busy

I'll do some proper bisecting tomorrow, but figured you might want to
know sooner rather than later.