GPIO offsets used by userspace
Hi all,
Just a heads up that when the linked patch is pulled into the OpenBMC kernel it will break our userspace. We will need to synchronise the kernel bump with the fixes for the machine configs to update the magic GPIO offset number.
https://lkml.org/lkml/2017/1/26/786
The magic offset is essentially 512-(ngpios) (I don't know why, but that's the behaviour), and this now varies between AST2400 and AST2500 systems due to the AST2500 having an extra bank, and also because the AST2400 has a "hole" at the end of its GPIO number space.
Cheers,
Andrew
Quoted 7 lines · Andrew Jeffery
Hi all,
Just a heads up that when the linked patch is pulled into the OpenBMC kernel it will break our userspace. We will need to synchronise the kernel bump with the fixes for the machine configs to update the magic GPIO offset number.
Quoted 6 lines
https://lkml.org/lkml/2017/1/26/786
The magic offset is essentially 512-(ngpios) (I don't know why, but that's the behaviour), and this now varies between AST2400 and AST2500 systems due to the AST2500 having an extra bank, and also because the AST2400 has a "hole" at the end of its GPIO number space.
Can you suggest a way to detect this from userspace?
Would using the chardev api make this easier?
Cheers,
Joel
Correct me if I'm wrong, but I think the maintainers are moving away from literal gpio numbers to named descriptors ("disk_led") in the device tree, as we're moving to more dynamic hardware https://lwn.net/Articles/533632/. Linus Walleij's talk was helpful for me too: http://elinux.org/images/9/9b/GPIO_for_Engineers_and_Makers.pdf
Nolan
-----Original Message-----
From: openbmc [mailto:[email protected]] On Behalf Of Joel Stanley
Sent: Monday, January 30, 2017 4:26 PM
To: Andrew Jeffery <[email protected]>
Cc: OpenBMC <[email protected]>
Subject: Re: GPIO offsets used by userspace
Quoted 7 lines · Andrew Jeffery
Hi all,
Just a heads up that when the linked patch is pulled into the OpenBMC kernel it will break our userspace. We will need to synchronise the kernel bump with the fixes for the machine configs to update the magic GPIO offset number.
Quoted 6 lines
https://lkml.org/lkml/2017/1/26/786
The magic offset is essentially 512-(ngpios) (I don't know why, but that's the behaviour), and this now varies between AST2400 and AST2500 systems due to the AST2500 having an extra bank, and also because the AST2400 has a "hole" at the end of its GPIO number space.
Can you suggest a way to detect this from userspace?
Would using the chardev api make this easier?
Cheers,
Joel
_______________________________________________
openbmc mailing list
[email protected]
https://lists.ozlabs.org/listinfo/openbmc
Hi Nolan!
Quoted 6 lines · Nolan
Correct me if I'm wrong, but I think the maintainers are moving away from literal gpio numbers to named descriptors ("
disk_led") in the device tree, as we're moving to more dynamic hardware
https://lwn.net/Articles/533632/. Linus Walleij's talk was helpful for me too:
http://elinux.org/images/9/9b/GPIO_for_Engineers_and_Makers.pdf
You're right, and that's what we should be aiming for if someone has the time to do the work. In the short term, we *can* just change the hacky offset numbers that already exist in the userspace to work around the problem. It's distasteful, but not worse than what we already have.
Patrick: Did you have any plans for reworking the userspace bits?
Cheers,
Andrew
PS: please try to reply in-line rather than top-posting, that way the context of the conversation is a bit easier to track.
Quoted 44 lines
Nolan
-----Original Message-----
From: openbmc [mailto:[email protected] zlabs.org] On Behalf Of Joel Stanley
Sent: Monday, January 30, 2017 4:26 PM
To: Andrew Jeffery <[email protected]>
Cc: OpenBMC <[email protected]>
Subject: Re: GPIO offsets used by userspaceQuoted 12 lines · Andrew Jeffery
Hi all,
Just a heads up that when the linked patch is pulled into the OpenBMC
kernel it will break our userspace. We will need to synchronise the
kernel bump with the fixes for the machine configs to update the magic
GPIO offset number.Quoted 7 lines
The magic offset is essentially 512-(ngpios) (I don't know why, but
that's the behaviour), and this now varies between AST2400 and AST2500
systems due to the AST2500 having an extra bank, and also because the
AST2400 has a "hole" at the end of its GPIO number space.Can you suggest a way to detect this from userspace?
Would using the chardev api make this easier?
Cheers,
Joel
_______________________________________________
openbmc mailing list
[email protected]
https://lists.ozlabs.org/listinfo/openbmc
-----Original Message-----
From: Andrew Jeffery [mailto:[email protected]]
Sent: Monday, January 30, 2017 5:13 PM
To: Hergert, Nolan <[email protected]>; Joel Stanley <[email protected]>; Patrick Williams <[email protected]>
Cc: OpenBMC <[email protected]>
Subject: Re: GPIO offsets used by userspace
Hi Nolan!
Quoted 6 lines · Nolan
Correct me if I'm wrong, but I think the maintainers are moving away from literal gpio numbers to named descriptors ("
disk_led") in the device tree, as we're moving to more dynamic hardware
https://lwn.net/Articles/533632/. Linus Walleij's talk was helpful for me too:
http://elinux.org/images/9/9b/GPIO_for_Engineers_and_Makers.pdf
You're right, and that's what we should be aiming for if someone has the time to do the work. In the short term, we *can* just change the hacky offset numbers that already exist in the userspace to work around the problem. It's distasteful, but not worse than what we already have.
Patrick: Did you have any plans for reworking the userspace bits?
Cheers,
Andrew
PS: please try to reply in-line rather than top-posting, that way the context of the conversation is a bit easier to track.
Glad to, thanks for the heads up.
Quoted 40 lines
Nolan
-----Original Message-----
From: openbmc [mailto:[email protected] zlabs.org] On Behalf Of Joel Stanley
Sent: Monday, January 30, 2017 4:26 PM
To: Andrew Jeffery <[email protected]>
Cc: OpenBMC <[email protected]>
Subject: Re: GPIO offsets used by userspaceQuoted 7 lines · Andrew Jeffery
Hi all,
Just a heads up that when the linked patch is pulled into the OpenBMC kernel it will break our userspace. We will need to synchronise the kernel bump with the fixes for the machine configs to update the magic GPIO offset number.
Quoted 8 lines
https://lkml.org/lkml/2017/1/26/786
The magic offset is essentially 512-(ngpios) (I don't know why, but that's the behaviour), and this now varies between AST2400 and AST2500
systems due to the AST2500 having an extra bank, and also because the
AST2400 has a "hole" at the end of its GPIO number space.Can you suggest a way to detect this from userspace?
Would using the chardev api make this easier?
Cheers,
Joel
_______________________________________________
openbmc mailing list
[email protected]
https://lists.ozlabs.org/listinfo/openbmc
Quoted 1 line · Andrew Jeffery
Patrick: Did you have any plans for reworking the userspace bits?
Yes. Joel has previously talked about writing a proposal based on the kernel team's desires. I think we're getting close to queuing up the work to refactor anything using GPIOs.
Signature · 1 line
Patrick Williams
Quoted 8 lines · Joel Stanley
Quoted 8 lines · Andrew Jeffery
Hi all,
Just a heads up that when the linked patch is pulled into the OpenBMC kernel it will break our userspace. We will need to synchronise the kernel bump with the fixes for the machine configs to update the magic GPIO offset number.
Quoted 8 lines
Quoted 6 lines
https://lkml.org/lkml/2017/1/26/786
The magic offset is essentially 512-(ngpios) (I don't know why, but that's the behaviour), and this now varies between AST2400 and AST2500 systems due to the AST2500 having an extra bank, and also because the AST2400 has a "hole" at the end of its GPIO number space.
Can you suggest a way to detect this from userspace?
Not off the top of my head.
Quoted 2 lines
Would using the chardev api make this easier?
To a degree. I'm not sure if named gpios are exposed by the sysfs interface, but with the chardev API you can open the devices and request a GPIO by name. If that fails and you have multiple devices, I guess you can try the other gpiochips.
Andrew
Quoted 11 lines · Andrew Jeffery
Quoted 10 lines · Joel Stanley
Quoted 10 lines · Andrew Jeffery
Hi all,
Just a heads up that when the linked patch is pulled into the OpenBMC kernel it will break our userspace. We will need to synchronise the kernel bump with the fixes for the machine configs to update the magic GPIO offset number.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
The magic offset is essentially 512-(ngpios) (I don't know why, but that's the behaviour), and this now varies between AST2400 and AST2500 systems due to the AST2500 having an extra bank, and also because the AST2400 has a "hole" at the end of its GPIO number space.
Can you suggest a way to detect this from userspace?
Not off the top of my head.
I mentioned this on GitHub, but in theory we should have at least one /sys/class/gpio/gpiochipN directory, where N is the offset for GPIOs provided by that GPIO device.
On a BMC not attached to GPIO expanders this directory name could be parsed by the Python currently in use. Not foolproof, but it could be a working stopgap.
However I don't actually see a /sys/class/gpio/gpiochipN directory on the BMCs I touched. Any ideas?
cheers
xo
Quoted 2 lines · Xo Wang
However I don't actually see a
/sys/class/gpio/gpiochipNdirectory on the BMCs I touched. Any ideas?
That's strange. On the machines I looked at we do have that. I double checked on a Zaius running the v1.99.1 tag:
root@zaius5:~# ls /sys/class/gpio/gpiochip320/ base device label ngpio subsystem uevent
Quoted 7 lines
I mentioned this on GitHub, but in theory we should have at least one
/sys/class/gpio/gpiochipNdirectory, where N is the offset for GPIOs provided by that GPIO device.On a BMC not attached to GPIO expanders this directory name could be parsed by the Python currently in use. Not foolproof, but it could be a working stopgap.
You're right, we could find this one. This would break on Witherspoon though which will soon gain a driver for a GPIO expander.
We could write some python to iterate through the gpiochipN directories, and match against the label:
root@zaius5:~# cat /sys/class/gpio/gpiochip320/label 1e780000.gpio
This would be a stopgap until we could get something saner, like sysfs files named after the net or function.
Cheers,
Joel
Quoted 10 lines · Joel Stanley
Quoted 2 lines · Xo Wang
However I don't actually see a
/sys/class/gpio/gpiochipNdirectory on the BMCs I touched. Any ideas?That's strange. On the machines I looked at we do have that. I double checked on a Zaius running the v1.99.1 tag:
root@zaius5:~# ls /sys/class/gpio/gpiochip320/ base device label ngpio subsystem uevent
So it is! I checked again. Must be a gross malfunction on my part.
Quoted 11 lines
Quoted 7 lines
I mentioned this on GitHub, but in theory we should have at least one
/sys/class/gpio/gpiochipNdirectory, where N is the offset for GPIOs provided by that GPIO device.On a BMC not attached to GPIO expanders this directory name could be parsed by the Python currently in use. Not foolproof, but it could be a working stopgap.
You're right, we could find this one. This would break on Witherspoon though which will soon gain a driver for a GPIO expander.
Quoted 9 lines
We could write some python to iterate through the gpiochipN directories, and match against the label:
root@zaius5:~# cat /sys/class/gpio/gpiochip320/label 1e780000.gpioThis would be a stopgap until we could get something saner, like sysfs files named after the net or function.
Makes sense.
xo
Quoted 11 lines · Joel Stanley
Quoted 7 lines
I mentioned this on GitHub, but in theory we should have at least one
/sys/class/gpio/gpiochipNdirectory, where N is the offset for GPIOs provided by that GPIO device.On a BMC not attached to GPIO expanders this directory name could be parsed by the Python currently in use. Not foolproof, but it could be a working stopgap.
You're right, we could find this one. This would break on Witherspoon though which will soon gain a driver for a GPIO expander.
Quoted 8 lines
We could write some python to iterate through the gpiochipN directories, and match against the label:
root@zaius5:~# cat /sys/class/gpio/gpiochip320/label 1e780000.gpioThis would be a stopgap until we could get something saner, like sysfs files named after the net or function.
If we're going to change things so significantly we should move away from using sysfs given it's deprecated, even if the alternative isn't great.
Andrew
Quoted 7 lines · Andrew Jeffery
Hi all,
Just a heads up that when the linked patch is pulled into the OpenBMC kernel it will break our userspace. We will need to synchronise the kernel bump with the fixes for the machine configs to update the magic GPIO offset number.
Quoted 7 lines
https://lkml.org/lkml/2017/1/26/786
The magic offset is essentially 512-(ngpios) (I don't know why, but that's the behaviour), and this now varies between AST2400 and AST2500 systems due to the AST2500 having an extra bank, and also because the AST2400 has a "hole" at the end of its GPIO number space.
For those interested I've pushed a patch to skeleton that generalises assignment of the GPIO_BASE value (i.e. it now dynamically detects the chip base and so is also backwards compatible):
https://gerrit.openbmc-project.xyz/#/c/2261/
If you have any better ideas for an interim solution please speak up.
The rough plan is to apply that and then pull in the new kernel. Joel has a testing commit here:
https://gerrit.openbmc-project.xyz/#/c/2257/
Andrew