Re: Assign line names at runtime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 11, 2024 at 04:10:39PM +0100, Bartosz Golaszewski wrote:
> On Thu, Jan 11, 2024 at 11:43 AM Westermann, Oliver
> <Oliver.Westermann@xxxxxxxxxx> wrote:
> >
> > Hey,
> >
> > I hope that this is the right place to ask a question in regards to gpiod, if not, feel free to point me the right way. We're transitioning from using the old sysfs interface to using gpiod and named lines. For most devices, we specify line names at boot time using gpio-line-names.
> >
> > On some devices we have small differences between revisions or hardware variants, which causes lines to be swapped on GPIO expanders or just being used differently for between revisions. We started to handle this by overlays, but that requires to distinguish during the bootloader phase, which is hard to service and often unneeded. Especially when we want to rename a single line, the overlay needs to override all entries, which leads to duplication of those line name lists.
> >
> > Is there a way to assign or change the line-name value at runtime?
> > If not today, would that be a desired feature (as we're looking for way to test contributing back)?
> >
> > Best regards, Olli
>
> Interesting. There's no way to do this with the current uAPI. We do
> however have a way of doing it in the kernel. I also see a use-case
> where udev could rename GPIOs on dynamic expanders according to
> user-space rules.
>
> Cc'ing Kent who's the author of most of the uAPI code.
>
> I'm in general open to enabling it but the problem here is that this
> would open a real can of worms with *global* and *persistent* state
> controlled from user-space going against the design of the character
> device.
>

I don't have a problem with it in principle, though I would have to
consider the implications.

Obviously changing line names while another process is doing a name
lookup is racy, so the search could produce an unexpected result.
e.g. say you want to swap two line names, as was one of your use cases.
If the set is per line then there will be a period where one name applies
to two lines and the other applies to none.  Is that a problem?
Perhaps an operation to apply a set of changes atomically?
Or do we need to move the lookup into the kernel?
Or do we trust userspace to not do lookups while setting names?

And would the name be set through the chip or line request?
If chip, then do we need to notify the user holding the line that
the name changed?
OTOH, is requiring the user to request the line to rename it too
restrictive?

So, yeah, interesting idea that I'm not averse to, but requires some
thought as to what wrinkles it might introduce and how best to iron
them out.

Alternatively, are named lines the right solution to your problem?
Is it important to you that the lines are correctly named, or are you
just using the name for the chip/offset lookup?  If the latter perhaps
roll your own pinout lookup based on the platform configuration?

Cheers,
Kent.






[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux