Message ID | 20211217153555.9413-1-marcelo.jimenez@gmail.com |
---|---|
State | Accepted |
Commit | fc328a7d1fcce263db0b046917a66f3aa6e68719 |
Headers | show |
Series | gpio: Revert regression in sysfs-gpio (gpiolib.c) | expand |
On Sat, Dec 18, 2021 at 7:28 AM Thorsten Leemhuis <regressions@leemhuis.info> wrote: > > [TLDR: I'm adding this regression to regzbot, the Linux kernel > regression tracking bot; most text you find below is compiled from a few > templates paragraphs some of you might have seen already.] > > On 17.12.21 16:35, Marcelo Roberto Jimenez wrote: > > Some GPIO lines have stopped working after the patch > > commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges") > > > > And this has supposedly been fixed in the following patches > > commit 89ad556b7f96a ("gpio: Avoid using pin ranges with !PINCTRL") > > commit 6dbbf84603961 ("gpiolib: Don't free if pin ranges are not defined") > > There seems to be a backstory here. Are there any entries and bug > trackers or earlier discussions everyone that looks into this should be > aware of? > Agreed with Thorsten. I'd like to first try to determine what's wrong before reverting those, as they are correct in theory but maybe the implementation missed something. Have you tried tracing the execution on your platform in order to see what the driver is doing? Bart
Hi Geert, On Mon, Dec 20, 2021 at 12:14 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > On Mon, Dec 20, 2021 at 3:57 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote: > > On Sat, Dec 18, 2021 at 7:28 AM Thorsten Leemhuis > > <regressions@leemhuis.info> wrote: > > > [TLDR: I'm adding this regression to regzbot, the Linux kernel > > > regression tracking bot; most text you find below is compiled from a few > > > templates paragraphs some of you might have seen already.] > > > > > > On 17.12.21 16:35, Marcelo Roberto Jimenez wrote: > > > > Some GPIO lines have stopped working after the patch > > > > commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges") > > > > > > > > And this has supposedly been fixed in the following patches > > > > commit 89ad556b7f96a ("gpio: Avoid using pin ranges with !PINCTRL") > > > > commit 6dbbf84603961 ("gpiolib: Don't free if pin ranges are not defined") > > > > > > There seems to be a backstory here. Are there any entries and bug > > > trackers or earlier discussions everyone that looks into this should be > > > aware of? > > > > > > > Agreed with Thorsten. I'd like to first try to determine what's wrong > > before reverting those, as they are correct in theory but maybe the > > implementation missed something. > > > > Have you tried tracing the execution on your platform in order to see > > what the driver is doing? > > Looking at commits that have related Fixes tags: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bf781869e5cf3e4ec1a47dad69b6f0df97629cbd > https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/commit/?id=e8f24c58d1b69ecf410a673c22f546dc732bb879 > Interesting. These seem to imply that gpiolib-sysfs.c should be allocating a pinctrl list. That seems very easy to do in the DTD, although I don't really know if that is the right thing to do. Doing it in the code seems more appropriate, what do you think? > Gr{oetje,eeting}s, > > Geert Regards, Marcelo.
Hi, this is your Linux kernel regression tracker speaking. Top-posting for once, to make this easy accessible to everyone. GPIO Maintainers and developers, what the status of this regression and getting it fixed? It looks like there was no progress for quite a while. Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) P.S.: As the Linux kernel's regression tracker I'm getting a lot of reports on my table. I can only look briefly into most of them and lack knowledge about most of the areas they concern. I thus unfortunately will sometimes get things wrong or miss something important. I hope that's not the case here; if you think it is, don't hesitate to tell me in a public reply, it's in everyone's interest to set the public record straight. #regzbot poke On 12.01.22 01:09, Marcelo Roberto Jimenez wrote: > Hi, > > On Mon, Jan 10, 2022 at 4:02 AM Thorsten Leemhuis > <regressions@leemhuis.info> wrote: >> >> Hi, this is your Linux kernel regression tracker speaking. >> >> On 20.12.21 21:41, Marcelo Roberto Jimenez wrote: >>> On Mon, Dec 20, 2021 at 11:57 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote: >>>> On Sat, Dec 18, 2021 at 7:28 AM Thorsten Leemhuis >>>> <regressions@leemhuis.info> wrote: >>>>> >>>>> [TLDR: I'm adding this regression to regzbot, the Linux kernel >>>>> regression tracking bot; most text you find below is compiled from a few >>>>> templates paragraphs some of you might have seen already.] >>>>> >>>>> On 17.12.21 16:35, Marcelo Roberto Jimenez wrote: >>>>>> Some GPIO lines have stopped working after the patch >>>>>> commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges") >>>>>> >>>>>> And this has supposedly been fixed in the following patches >>>>>> commit 89ad556b7f96a ("gpio: Avoid using pin ranges with !PINCTRL") >>>>>> commit 6dbbf84603961 ("gpiolib: Don't free if pin ranges are not defined") >>>>> >>>>> There seems to be a backstory here. Are there any entries and bug >>>>> trackers or earlier discussions everyone that looks into this should be >>>>> aware of? >>>> >>>> Agreed with Thorsten. I'd like to first try to determine what's wrong >>>> before reverting those, as they are correct in theory but maybe the >>>> implementation missed something. >>>> >>>> Have you tried tracing the execution on your platform in order to see >>>> what the driver is doing? >>> >>> Yes. The problem is that there is no list defined for the sysfs-gpio >>> interface. The driver will not perform pinctrl_gpio_request() and will >>> return zero (failure). >>> >>> I don't know if this is the case to add something to a global DTD or >>> to fix it in the sysfs-gpio code. >> >> Out of interest, has any progress been made on this front? >> >> BTW, there was a last-minute commit for 5.16 yesterday that referenced >> the culprit Marcelo specified: >> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=master&id=c8013355ead68dce152cf426686f8a5f80d88b40 >> >> This was for a BCM283x and BCM2711 devices, so I assume it won't help. >> Wild guess (I don't know anything about this area of the kernel): >> Marcelo, do the dts files for your hardware maybe need a similar fix? > > I have tried to add "gpio-ranges" to the gpio-controllers in > at91sam9x5.dtsi, but the system deadlocks, because in pinctrl-at91.c, > function at91_pinctrl_probe() we have: > > /* > * We need all the GPIO drivers to probe FIRST, or we will not be able > * to obtain references to the struct gpio_chip * for them, and we > * need this to proceed. > */ > for (i = 0; i < gpio_banks; i++) > if (gpio_chips[i]) > ngpio_chips_enabled++; > > if (ngpio_chips_enabled < info->nactive_banks) { > dev_warn(&pdev->dev, > "All GPIO chips are not registered yet (%d/%d)\n", > ngpio_chips_enabled, info->nactive_banks); > devm_kfree(&pdev->dev, info); > return -EPROBE_DEFER; > } > > On the other hand, in gpiolib-of.c, function > of_gpiochip_add_pin_range() we have: > > if (!pctldev) > return -EPROBE_DEFER; > > In other words, the pinctrl needs all the gpio-controllers, and the > gpio-controllers need the pinctrl. Each returns -EPROBE_DEFER and the > system deadlocks. > >> >> Ciao, Thorsten >> >> P.S.: As a Linux kernel regression tracker I'm getting a lot of reports >> on my table. I can only look briefly into most of them. Unfortunately >> therefore I sometimes will get things wrong or miss something important. >> I hope that's not the case here; if you think it is, don't hesitate to >> tell me about it in a public reply, that's in everyone's interest. >> >> BTW, I have no personal interest in this issue, which is tracked using >> regzbot, my Linux kernel regression tracking bot >> (https://linux-regtracking.leemhuis.info/regzbot/). I'm only posting >> this mail to get things rolling again and hence don't need to be CC on >> all further activities wrt to this regression. >> >> #regzbot poke >> > > Regards, > Marcelo. > >
On Fri, Dec 17, 2021 at 4:36 PM Marcelo Roberto Jimenez
<marcelo.jimenez@gmail.com> wrote:
> My system is ARM926EJ-S rev 5 (v5l) (AT91SAM9G25), the board is an ACME Systems Arietta.
Which devicetree or boardfile in the upstream Linux kernel is this system
using?
Yours,
Linus Walleij
On Thu, Feb 10, 2022 at 9:02 PM Linus Walleij <linus.walleij@linaro.org> wrote: > > On Fri, Dec 17, 2021 at 4:36 PM Marcelo Roberto Jimenez > <marcelo.jimenez@gmail.com> wrote: > > > My system is ARM926EJ-S rev 5 (v5l) (AT91SAM9G25), the board is an ACME Systems Arietta. > > Which devicetree or boardfile in the upstream Linux kernel is this system > using? arch/arm/boot/dts/at91-ariettag25.dts But it is worth noting that the first lines in this file are: /* * Device Tree file for Arietta G25 * This device tree is minimal, to activate more peripherals, see: * http://dts.acmesystems.it/arietta/ */ And also that the URL in the comment above is old and now it should read: http://linux.tanzilli.com/ In any case, the upstream file should be enough to test the issue reported here. > Yours, > Linus Walleij Regards, Marcelo.
On Fri, Feb 11, 2022 at 11:36 PM Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com> wrote: > > Which devicetree or boardfile in the upstream Linux kernel is this system > > using? > > arch/arm/boot/dts/at91-ariettag25.dts So this system was added in 2015 which is the same year that we marked the GPIO sysfs ABI obsolete: commit fe95046e960b4b76e73dc1486955d93f47276134 Author: Linus Walleij <linus.walleij@linaro.org> Date: Thu Oct 22 09:58:34 2015 +0200 gpio: ABI: mark the sysfs ABI as obsolete Why is this system which was clearly developed while we deprecated the sysfs ABI so dependent on it? I am curious about the usecases and how deeply you have built yourselves into this. > In any case, the upstream file should be enough to test the issue reported here. The thing is that upstream isn't super happy that you have been making yourselves dependent on features that we are actively discouraging and then demanding that we support these features. Anyway, what is wrong with using the GPIO character device and libgpiod on this system? What kind of userspace are you creating that absolutely requires that you use sysfs? I hope not one of these? https://docs.kernel.org/driver-api/gpio/drivers-on-gpio.html Here is some info about what we have been doing with the GPIO character device: https://docs.kernel.org/driver-api/gpio/using-gpio.html https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/ Here is Bartosz presenting it: https://www.youtube.com/watch?v=BK6gOLVRKuU Since I patched the kernel such that you cannot activate the sysfs ABI without also activating the character device I *know* that you have it on your system. Yours, Linus Walleij
On Sat, Feb 12, 2022 at 1:55 PM Linus Walleij <linus.walleij@linaro.org> wrote: > > On Fri, Feb 11, 2022 at 11:36 PM Marcelo Roberto Jimenez > <marcelo.jimenez@gmail.com> wrote: > > > > Which devicetree or boardfile in the upstream Linux kernel is this system > > > using? > > > > arch/arm/boot/dts/at91-ariettag25.dts > > So this system was added in 2015 which is the same year that > we marked the GPIO sysfs ABI obsolete: > > commit fe95046e960b4b76e73dc1486955d93f47276134 > Author: Linus Walleij <linus.walleij@linaro.org> > Date: Thu Oct 22 09:58:34 2015 +0200 > > gpio: ABI: mark the sysfs ABI as obsolete > > Why is this system which was clearly developed while we deprecated > the sysfs ABI so dependent on it? The date when the device tree file was committed upstream is not the same date when the product has been released. The product was originally released in about January, 2014, as can be seen, e.g, from a post here from January 30, 2014: https://www.open-electronics.org/acme-system-launched-arietta-g25-a-new-micro-linux-board/ This is almost two years before the API has been marked obsolete. The company that produces the board (which I am not affiliated to) gave their users access to a different device tree file. > I am curious about the usecases and how deeply you have built > yourselves into this. I don't know if I understand what you mean, sorry. > > In any case, the upstream file should be enough to test the issue reported here. > > The thing is that upstream isn't super happy that you have been > making yourselves dependent on features that we are actively > discouraging and then demanding that we support these features. Hum, demanding seems to be a strong word for what I am doing here. Deprecated should not mean broken. My point is: the API seems to be currently broken. User space apps got broken, that's a fact. I even took the time to bisect the kernel and show you which commit broke it. So, no, I am not demanding. More like reporting and providing a temporary solution to those with a similar problem. Maybe it is time to remove the API, but this is up to "upstream". Leaving the API broken seems pointless and unproductive. Sorry for the "not super happiness of upstream", but maybe upstream got me wrong. We are not "making ourselves dependent on features ...". The API was there. We used it. Now it is deprecated, ok, we should move on. I got the message. > Anyway, what is wrong with using the GPIO character device and libgpiod > on this system? What kind of userspace are you creating that > absolutely requires that you use sysfs? There is nothing wrong, except for a matter of causality that seems to have been inverted here and has been explained above. > I hope not one of these? > https://docs.kernel.org/driver-api/gpio/drivers-on-gpio.html > > Here is some info about what we have been doing with the GPIO > character device: > > https://docs.kernel.org/driver-api/gpio/using-gpio.html > https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/ > > Here is Bartosz presenting it: > https://www.youtube.com/watch?v=BK6gOLVRKuU Please, don't get me wrong. I find the work done in GPIO amazing. Thanks for all the valuable information, I sincerely appreciate it and will read it all carefully. And I will also tell the dev team that they must use the GPIO char dev and libgpiod from now on and must port everything to it. And we will likely have another group of people who are not super happy, but that's life... :) > Since I patched the kernel such that you cannot activate the sysfs > ABI without also activating the character device I *know* that you > have it on your system. Smart move! > Yours, > Linus Walleij Best regards, Marcelo.
On Mon, Feb 14, 2022 at 12:24 AM Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com> wrote: > On Sat, Feb 12, 2022 at 1:55 PM Linus Walleij <linus.walleij@linaro.org> wrote: > > I am curious about the usecases and how deeply you have built > > yourselves into this. > > I don't know if I understand what you mean, sorry. Why does the user need the sysfs ABI? What is it used for? I.e what is the actual use case? > > > In any case, the upstream file should be enough to test the issue reported here. > > > > The thing is that upstream isn't super happy that you have been > > making yourselves dependent on features that we are actively > > discouraging and then demanding that we support these features. > > Hum, demanding seems to be a strong word for what I am doing here. > > Deprecated should not mean broken. My point is: the API seems to be > currently broken. User space apps got broken, that's a fact. I even > took the time to bisect the kernel and show you which commit broke it. > So, no, I am not demanding. More like reporting and providing a > temporary solution to those with a similar problem. > > Maybe it is time to remove the API, but this is up to "upstream". > Leaving the API broken seems pointless and unproductive. > > Sorry for the "not super happiness of upstream", but maybe upstream > got me wrong. > > We are not "making ourselves dependent on features ...". The API was > there. We used it. Now it is deprecated, ok, we should move on. I got > the message. Ouch I deserved some slamming for this. I'm sorry if I came across as harsh :( I just don't know how to properly push for this. I have even pushed the option of the deprecated sysfs ABI behind the CONFIG_EXPERT option, which should mean that the kernel config has been made by someone who has checked the option "yes I am an expert I know what I am doing" yet failed to observe that this ABI is obsoleted since 5 years and hence failed to be an expert. Of course the ABI (not API really) needs to be fixed if we can find the problem. It's frustrating that fixing it seems to fix broken other features which are not deprecated, hence the annoyance on my part. > And I will also tell the dev team that they must use the GPIO char dev > and libgpiod from now on and must port everything to it. And we will > likely have another group of people who are not super happy, but > that's life... :) I'm happy to hear this! Yours, Linus Walleij
On Tue, Feb 15, 2022 at 10:56 PM Linus Walleij <linus.walleij@linaro.org> wrote: > > On Mon, Feb 14, 2022 at 12:24 AM Marcelo Roberto Jimenez > <marcelo.jimenez@gmail.com> wrote: > > On Sat, Feb 12, 2022 at 1:55 PM Linus Walleij <linus.walleij@linaro.org> wrote: > > > > I am curious about the usecases and how deeply you have built > > > yourselves into this. > > > > I don't know if I understand what you mean, sorry. > > Why does the user need the sysfs ABI? What is it used for? > > I.e what is the actual use case? > > > > > In any case, the upstream file should be enough to test the issue reported here. > > > > > > The thing is that upstream isn't super happy that you have been > > > making yourselves dependent on features that we are actively > > > discouraging and then demanding that we support these features. > > > > Hum, demanding seems to be a strong word for what I am doing here. > > > > Deprecated should not mean broken. My point is: the API seems to be > > currently broken. User space apps got broken, that's a fact. I even > > took the time to bisect the kernel and show you which commit broke it. > > So, no, I am not demanding. More like reporting and providing a > > temporary solution to those with a similar problem. > > > > Maybe it is time to remove the API, but this is up to "upstream". > > Leaving the API broken seems pointless and unproductive. > > > > Sorry for the "not super happiness of upstream", but maybe upstream > > got me wrong. > > > > We are not "making ourselves dependent on features ...". The API was > > there. We used it. Now it is deprecated, ok, we should move on. I got > > the message. > > Ouch I deserved some slamming for this. > > I'm sorry if I came across as harsh :( > > I just don't know how to properly push for this. > > I have even pushed the option of the deprecated sysfs ABI > behind the CONFIG_EXPERT option, which should mean that > the kernel config has been made by someone who has checked > the option "yes I am an expert I know what I am doing" > yet failed to observe that this ABI is obsoleted since 5 years > and hence failed to be an expert. > > Of course the ABI (not API really) needs to be fixed if we can find the > problem. It's frustrating that fixing it seems to fix broken other > features which are not deprecated, hence the annoyance on my > part. > I'm afraid we'll earn ourselves a good old LinusRant if we keep pushing the character device as a solution to the problem here. Marcelo is right after all: he used an existing user interface, the interface broke, it must be fixed. I would prefer to find a solution that fixes Marcelo's issue while keeping the offending patches in tree but it seems like the issue is more complicated and will require some rework of the sysfs interface. In which case unless there are objections I lean towards reverting the relevant commits. Bart > > And I will also tell the dev team that they must use the GPIO char dev > > and libgpiod from now on and must port everything to it. And we will > > likely have another group of people who are not super happy, but > > that's life... :) > > I'm happy to hear this! > > Yours, > Linus Walleij
On Tue, Jan 11, 2022 at 09:09:15PM -0300, Marcelo Roberto Jimenez wrote: > Hi, > > On Mon, Jan 10, 2022 at 4:02 AM Thorsten Leemhuis > <regressions@leemhuis.info> wrote: > > > > Hi, this is your Linux kernel regression tracker speaking. > > > > On 20.12.21 21:41, Marcelo Roberto Jimenez wrote: > > > On Mon, Dec 20, 2021 at 11:57 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote: > > >> On Sat, Dec 18, 2021 at 7:28 AM Thorsten Leemhuis > > >> <regressions@leemhuis.info> wrote: > > >>> > > >>> [TLDR: I'm adding this regression to regzbot, the Linux kernel > > >>> regression tracking bot; most text you find below is compiled from a few > > >>> templates paragraphs some of you might have seen already.] > > >>> > > >>> On 17.12.21 16:35, Marcelo Roberto Jimenez wrote: > > >>>> Some GPIO lines have stopped working after the patch > > >>>> commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges") > > >>>> > > >>>> And this has supposedly been fixed in the following patches > > >>>> commit 89ad556b7f96a ("gpio: Avoid using pin ranges with !PINCTRL") > > >>>> commit 6dbbf84603961 ("gpiolib: Don't free if pin ranges are not defined") > > >>> > > >>> There seems to be a backstory here. Are there any entries and bug > > >>> trackers or earlier discussions everyone that looks into this should be > > >>> aware of? > > >> > > >> Agreed with Thorsten. I'd like to first try to determine what's wrong > > >> before reverting those, as they are correct in theory but maybe the > > >> implementation missed something. > > >> > > >> Have you tried tracing the execution on your platform in order to see > > >> what the driver is doing? > > > > > > Yes. The problem is that there is no list defined for the sysfs-gpio > > > interface. The driver will not perform pinctrl_gpio_request() and will > > > return zero (failure). > > > > > > I don't know if this is the case to add something to a global DTD or > > > to fix it in the sysfs-gpio code. > > > > Out of interest, has any progress been made on this front? > > > > BTW, there was a last-minute commit for 5.16 yesterday that referenced > > the culprit Marcelo specified: > > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=master&id=c8013355ead68dce152cf426686f8a5f80d88b40 > > > > This was for a BCM283x and BCM2711 devices, so I assume it won't help. > > Wild guess (I don't know anything about this area of the kernel): > > Marcelo, do the dts files for your hardware maybe need a similar fix? > > I have tried to add "gpio-ranges" to the gpio-controllers in > at91sam9x5.dtsi, but the system deadlocks, because in pinctrl-at91.c, > function at91_pinctrl_probe() we have: > > /* > * We need all the GPIO drivers to probe FIRST, or we will not be able > * to obtain references to the struct gpio_chip * for them, and we > * need this to proceed. > */ > for (i = 0; i < gpio_banks; i++) > if (gpio_chips[i]) > ngpio_chips_enabled++; > > if (ngpio_chips_enabled < info->nactive_banks) { > dev_warn(&pdev->dev, > "All GPIO chips are not registered yet (%d/%d)\n", > ngpio_chips_enabled, info->nactive_banks); > devm_kfree(&pdev->dev, info); > return -EPROBE_DEFER; > } > > On the other hand, in gpiolib-of.c, function > of_gpiochip_add_pin_range() we have: > > if (!pctldev) > return -EPROBE_DEFER; > > In other words, the pinctrl needs all the gpio-controllers, and the > gpio-controllers need the pinctrl. Each returns -EPROBE_DEFER and the > system deadlocks. Ugh, yeah, this sounds like a really bad idea. Conceptually GPIO drivers are consumers of a pinctrl device and by now making the pinctrl device depend on GPIO chips you make the dependency recursive, which is exactly what you're observing here. And it's honestly not a surprise that this breaks. It is rather surprising that this has worked before in the first place. Now, looking through some of the pin control documentation, I see that this kind of setup is actually encouraged (see "Interaction with the GPIO subsystem" in Documentation/driver-api/pin-control.rst). This may make sense for cases where the GPIO chips can be hard-coded, but I don't see how that would work in practice. Looking at a random sampling of drivers, I see a lot of those that are calling pinctrl_add_gpio_range() are setting the .gc field to point at a GPIO controller. However, in the cases that I've seen, they are all very tightly integrated with the pinctrl such that they don't have to do that same dance that AT91 does (where pinctrl and GPIO drivers are separate), so they avoid the circular dependency. A couple of examples are here: - bcm/pinctrl-bcm2835.c - pinctrl-starfive.c - pinctrl-st.c - renesas/pinctrl-rza1.c - renesas/pinctrl-rza2.c - samsung/pinctrl-samsung.c - stm32/pinctrl-stm32.c pinctrl-xway.c is another, slightly different variant that references a file-scoped struct gpio_chip, so it's again in that "tightly coupled" category. tegra/pinctrl-tegra.c gets away without setting the .gc field and instead uses a hard-coded number of GPIO lines in the range. The same goes for mvebu/pinctrl-mvebu.c which uses platform data to pass GPIO ranges information. Given all of the above, it sounds to me like the right way to fix this would be to do two things: 1) avoid the circular dependency by not waiting for all GPIO chips to get probed within the pinctrl driver's ->probe() 2) use the standard, DT-based mechanism to register GPIO ranges with the pinctrl Typically 2) would involve adding the gpio-ranges properties to the GPIO controllers' DT nodes. However, it looks like it might also be possible to avoid this in the AT91 driver by making it register the GPIO ranges from the GPIO driver's ->probe() function. That would typically be slightly tricky because you don't typically have a back-reference to the pinctrl device from the GPIO chip. *However*, it looks like on AT91- based platforms the GPIO controllers are actually children of the pin controller, which would nicely solve that problem (you can get the reference to the pin controller via the GPIO controllers' parent). I have not checked exhaustively if that's always the case, just for a couple of AT91-based DTS files, but I suspect that this is a common scheme for this type of device. Note that the fact that GPIO controllers are children of the pin controller is another indicator for why the circular dependency is a bad idea. After all you can't have children without a parent. Parents need to be "fully initialized" before they can procreate. If you wanted to make this really complicated you could perhaps achieve what that driver is currently trying by using the component driver infrastructure. That would basically involve initializing the pin controller fully so that it's ready to be used by the GPIO controllers and then once all GPIO controllers have been added, a special callback will be called, allowing you to complete the initialization of all the components (which could then be used to add the GPIO ranges). I don't think that's necessary in this case, though. Thierry > > Ciao, Thorsten > > > > P.S.: As a Linux kernel regression tracker I'm getting a lot of reports > > on my table. I can only look briefly into most of them. Unfortunately > > therefore I sometimes will get things wrong or miss something important. > > I hope that's not the case here; if you think it is, don't hesitate to > > tell me about it in a public reply, that's in everyone's interest. > > > > BTW, I have no personal interest in this issue, which is tracked using > > regzbot, my Linux kernel regression tracking bot > > (https://linux-regtracking.leemhuis.info/regzbot/). I'm only posting > > this mail to get things rolling again and hence don't need to be CC on > > all further activities wrt to this regression. > > > > #regzbot poke > > > > Regards, > Marcelo.
Hi, this is your Linux kernel regression tracker. On 16.02.22 15:40, Bartosz Golaszewski wrote: > On Tue, Feb 15, 2022 at 10:56 PM Linus Walleij <linus.walleij@linaro.org> wrote: >> >> On Mon, Feb 14, 2022 at 12:24 AM Marcelo Roberto Jimenez >> <marcelo.jimenez@gmail.com> wrote: >>> On Sat, Feb 12, 2022 at 1:55 PM Linus Walleij <linus.walleij@linaro.org> wrote: >> >>>> I am curious about the usecases and how deeply you have built >>>> yourselves into this. >>> >>> I don't know if I understand what you mean, sorry. >> >> Why does the user need the sysfs ABI? What is it used for? >> >> I.e what is the actual use case? >> >>>>> In any case, the upstream file should be enough to test the issue reported here. >>>> >>>> The thing is that upstream isn't super happy that you have been >>>> making yourselves dependent on features that we are actively >>>> discouraging and then demanding that we support these features. >>> >>> Hum, demanding seems to be a strong word for what I am doing here. >>> >>> Deprecated should not mean broken. My point is: the API seems to be >>> currently broken. User space apps got broken, that's a fact. I even >>> took the time to bisect the kernel and show you which commit broke it. >>> So, no, I am not demanding. More like reporting and providing a >>> temporary solution to those with a similar problem. >>> >>> Maybe it is time to remove the API, but this is up to "upstream". >>> Leaving the API broken seems pointless and unproductive. >>> >>> Sorry for the "not super happiness of upstream", but maybe upstream >>> got me wrong. >>> >>> We are not "making ourselves dependent on features ...". The API was >>> there. We used it. Now it is deprecated, ok, we should move on. I got >>> the message. >> >> Ouch I deserved some slamming for this. >> >> I'm sorry if I came across as harsh :( >> >> I just don't know how to properly push for this. >> >> I have even pushed the option of the deprecated sysfs ABI >> behind the CONFIG_EXPERT option, which should mean that >> the kernel config has been made by someone who has checked >> the option "yes I am an expert I know what I am doing" >> yet failed to observe that this ABI is obsoleted since 5 years >> and hence failed to be an expert. >> >> Of course the ABI (not API really) needs to be fixed if we can find the >> problem. It's frustrating that fixing it seems to fix broken other >> features which are not deprecated, hence the annoyance on my >> part. >> > > I'm afraid we'll earn ourselves a good old LinusRant if we keep > pushing the character device as a solution to the problem here. > Marcelo is right after all: he used an existing user interface, the > interface broke, it must be fixed. > > I would prefer to find a solution that fixes Marcelo's issue while > keeping the offending patches in tree but it seems like the issue is > more complicated and will require some rework of the sysfs interface. > > In which case unless there are objections I lean towards reverting the > relevant commits. Sounds good to me, but that was two weeks ago and afaics nothing happened since then. Or did the discussion continue somewhere else? >>> And I will also tell the dev team that they must use the GPIO char dev >>> and libgpiod from now on and must port everything to it. And we will >>> likely have another group of people who are not super happy, but >>> that's life... :) >> >> I'm happy to hear this! Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) P.S.: As the Linux kernel's regression tracker I'm getting a lot of reports on my table. I can only look briefly into most of them and lack knowledge about most of the areas they concern. I thus unfortunately will sometimes get things wrong or miss something important. I hope that's not the case here; if you think it is, don't hesitate to tell me in a public reply, it's in everyone's interest to set the public record straight. #regzbot poke
On Fri, Mar 4, 2022 at 8:13 AM Thorsten Leemhuis <regressions@leemhuis.info> wrote: > > Hi, this is your Linux kernel regression tracker. > > On 16.02.22 15:40, Bartosz Golaszewski wrote: > > On Tue, Feb 15, 2022 at 10:56 PM Linus Walleij <linus.walleij@linaro.org> wrote: > >> > >> On Mon, Feb 14, 2022 at 12:24 AM Marcelo Roberto Jimenez > >> <marcelo.jimenez@gmail.com> wrote: > >>> On Sat, Feb 12, 2022 at 1:55 PM Linus Walleij <linus.walleij@linaro.org> wrote: > >> > >>>> I am curious about the usecases and how deeply you have built > >>>> yourselves into this. > >>> > >>> I don't know if I understand what you mean, sorry. > >> > >> Why does the user need the sysfs ABI? What is it used for? > >> > >> I.e what is the actual use case? > >> > >>>>> In any case, the upstream file should be enough to test the issue reported here. > >>>> > >>>> The thing is that upstream isn't super happy that you have been > >>>> making yourselves dependent on features that we are actively > >>>> discouraging and then demanding that we support these features. > >>> > >>> Hum, demanding seems to be a strong word for what I am doing here. > >>> > >>> Deprecated should not mean broken. My point is: the API seems to be > >>> currently broken. User space apps got broken, that's a fact. I even > >>> took the time to bisect the kernel and show you which commit broke it. > >>> So, no, I am not demanding. More like reporting and providing a > >>> temporary solution to those with a similar problem. > >>> > >>> Maybe it is time to remove the API, but this is up to "upstream". > >>> Leaving the API broken seems pointless and unproductive. > >>> > >>> Sorry for the "not super happiness of upstream", but maybe upstream > >>> got me wrong. > >>> > >>> We are not "making ourselves dependent on features ...". The API was > >>> there. We used it. Now it is deprecated, ok, we should move on. I got > >>> the message. > >> > >> Ouch I deserved some slamming for this. > >> > >> I'm sorry if I came across as harsh :( > >> > >> I just don't know how to properly push for this. > >> > >> I have even pushed the option of the deprecated sysfs ABI > >> behind the CONFIG_EXPERT option, which should mean that > >> the kernel config has been made by someone who has checked > >> the option "yes I am an expert I know what I am doing" > >> yet failed to observe that this ABI is obsoleted since 5 years > >> and hence failed to be an expert. > >> > >> Of course the ABI (not API really) needs to be fixed if we can find the > >> problem. It's frustrating that fixing it seems to fix broken other > >> features which are not deprecated, hence the annoyance on my > >> part. > >> > > > > I'm afraid we'll earn ourselves a good old LinusRant if we keep > > pushing the character device as a solution to the problem here. > > Marcelo is right after all: he used an existing user interface, the > > interface broke, it must be fixed. > > > > I would prefer to find a solution that fixes Marcelo's issue while > > keeping the offending patches in tree but it seems like the issue is > > more complicated and will require some rework of the sysfs interface. > > > > In which case unless there are objections I lean towards reverting the > > relevant commits. > > Sounds good to me, but that was two weeks ago and afaics nothing > happened since then. Or did the discussion continue somewhere else? > Now queued for fixes, thanks for the reminder. Bart > >>> And I will also tell the dev team that they must use the GPIO char dev > >>> and libgpiod from now on and must port everything to it. And we will > >>> likely have another group of people who are not super happy, but > >>> that's life... :) > >> > >> I'm happy to hear this! > > Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) > > P.S.: As the Linux kernel's regression tracker I'm getting a lot of > reports on my table. I can only look briefly into most of them and lack > knowledge about most of the areas they concern. I thus unfortunately > will sometimes get things wrong or miss something important. I hope > that's not the case here; if you think it is, don't hesitate to tell me > in a public reply, it's in everyone's interest to set the public record > straight. > > #regzbot poke
On 07.03.22 10:58, Bartosz Golaszewski wrote: > On Fri, Mar 4, 2022 at 8:13 AM Thorsten Leemhuis > <regressions@leemhuis.info> wrote: >> On 16.02.22 15:40, Bartosz Golaszewski wrote: >>> On Tue, Feb 15, 2022 at 10:56 PM Linus Walleij <linus.walleij@linaro.org> wrote: >>>> >>>> On Mon, Feb 14, 2022 at 12:24 AM Marcelo Roberto Jimenez >>>> <marcelo.jimenez@gmail.com> wrote: >>>>> On Sat, Feb 12, 2022 at 1:55 PM Linus Walleij <linus.walleij@linaro.org> wrote: >>>> >>>>>> I am curious about the usecases and how deeply you have built >>>>>> yourselves into this. >>>>> >>>>> I don't know if I understand what you mean, sorry. >>>> >>>> Why does the user need the sysfs ABI? What is it used for? >>>> >>>> I.e what is the actual use case? >>>> >>>>>>> In any case, the upstream file should be enough to test the issue reported here. >>>>>> >>>>>> The thing is that upstream isn't super happy that you have been >>>>>> making yourselves dependent on features that we are actively >>>>>> discouraging and then demanding that we support these features. >>>>> >>>>> Hum, demanding seems to be a strong word for what I am doing here. >>>>> >>>>> Deprecated should not mean broken. My point is: the API seems to be >>>>> currently broken. User space apps got broken, that's a fact. I even >>>>> took the time to bisect the kernel and show you which commit broke it. >>>>> So, no, I am not demanding. More like reporting and providing a >>>>> temporary solution to those with a similar problem. >>>>> >>>>> Maybe it is time to remove the API, but this is up to "upstream". >>>>> Leaving the API broken seems pointless and unproductive. >>>>> >>>>> Sorry for the "not super happiness of upstream", but maybe upstream >>>>> got me wrong. >>>>> >>>>> We are not "making ourselves dependent on features ...". The API was >>>>> there. We used it. Now it is deprecated, ok, we should move on. I got >>>>> the message. >>>> >>>> Ouch I deserved some slamming for this. >>>> >>>> I'm sorry if I came across as harsh :( >>>> >>>> I just don't know how to properly push for this. >>>> >>>> I have even pushed the option of the deprecated sysfs ABI >>>> behind the CONFIG_EXPERT option, which should mean that >>>> the kernel config has been made by someone who has checked >>>> the option "yes I am an expert I know what I am doing" >>>> yet failed to observe that this ABI is obsoleted since 5 years >>>> and hence failed to be an expert. >>>> >>>> Of course the ABI (not API really) needs to be fixed if we can find the >>>> problem. It's frustrating that fixing it seems to fix broken other >>>> features which are not deprecated, hence the annoyance on my >>>> part. >>>> >>> >>> I'm afraid we'll earn ourselves a good old LinusRant if we keep >>> pushing the character device as a solution to the problem here. >>> Marcelo is right after all: he used an existing user interface, the >>> interface broke, it must be fixed. >>> >>> I would prefer to find a solution that fixes Marcelo's issue while >>> keeping the offending patches in tree but it seems like the issue is >>> more complicated and will require some rework of the sysfs interface. >>> >>> In which case unless there are objections I lean towards reverting the >>> relevant commits. >> >> Sounds good to me, but that was two weeks ago and afaics nothing >> happened since then. Or did the discussion continue somewhere else? > > Now queued for fixes, thanks for the reminder. thx, and yw, that's what I'm here for ;-) Sadly that commit didn't use 'Link:' tags pointing to the report (the start of this thread) using lore.kernel.org/r/, as explained in 'Documentation/process/submitting-patches.rst' and 'Documentation/process/5.Posting.rst'. I'd say that would have been really wise here if someone sooner or later needs to look into the backstory of the fix. And is also means that I have to tell my regression tracking bot about this issue manually now. :-/ #regzbot fixed-by: 86528d306d1826cfe59481001d63761ba793317a But whatever, thx for taking care of this! Have a nice week everyone! Ciao, Thorsten >>>>> And I will also tell the dev team that they must use the GPIO char dev >>>>> and libgpiod from now on and must port everything to it. And we will >>>>> likely have another group of people who are not super happy, but >>>>> that's life... :) >>>> >>>> I'm happy to hear this! >> >> Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) >> >> P.S.: As the Linux kernel's regression tracker I'm getting a lot of >> reports on my table. I can only look briefly into most of them and lack >> knowledge about most of the areas they concern. I thus unfortunately >> will sometimes get things wrong or miss something important. I hope >> that's not the case here; if you think it is, don't hesitate to tell me >> in a public reply, it's in everyone's interest to set the public record >> straight. >> >> #regzbot poke >
Hi, > Some GPIO lines have stopped working after the patch > commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges") > > And this has supposedly been fixed in the following patches > commit 89ad556b7f96a ("gpio: Avoid using pin ranges with !PINCTRL") > commit 6dbbf84603961 ("gpiolib: Don't free if pin ranges are not defined") > > But an erratic behavior where some GPIO lines work while others do not work > has been introduced. > > This patch reverts those changes so that the sysfs-gpio interface works > properly again. > > Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com> This breaks the pinctrl-microchip-sgpio driver as far as I can see. I tried to debug it and this is what I have discovered so far: (1) the sgpio driver will use the gpio_stub_drv for its child nodes. Looks like a workaround, see [1]. (2) these will have an empty gpio range (3) with the changes of this patch, pinctrl_gpio_request() will now be called and will fail with -EPROBE_DEFER. I'm not exactly sure what to do here. Saravana Kannan once suggested to use devm_of_platform_populate() to probe the child nodes [2]. But I haven't found any other driver doing that. Also, I'm not sure if there are any other other driver which get broken by this. I.e. ones falling into the gpio_stub_drv category. [1] https://lore.kernel.org/lkml/20210122193600.1415639-1-saravanak@google.com/ [2] https://lore.kernel.org/lkml/CAGETcx9PiX==mLxB9PO8Myyk6u2vhPVwTMsA5NkD-ywH5xhusw@mail.gmail.com/ -michael NB. this patch doesn't contain a Fixes tag. Was this on purpose?
On Mon, Mar 14, 2022 at 4:55 PM Michael Walle <michael@walle.cc> wrote: > > Hi, > > > Some GPIO lines have stopped working after the patch > > commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges") > > > > And this has supposedly been fixed in the following patches > > commit 89ad556b7f96a ("gpio: Avoid using pin ranges with !PINCTRL") > > commit 6dbbf84603961 ("gpiolib: Don't free if pin ranges are not defined") > > > > But an erratic behavior where some GPIO lines work while others do not work > > has been introduced. > > > > This patch reverts those changes so that the sysfs-gpio interface works > > properly again. > > > > Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com> > > This breaks the pinctrl-microchip-sgpio driver as far as I can see. > > I tried to debug it and this is what I have discovered so far: > (1) the sgpio driver will use the gpio_stub_drv for its child nodes. > Looks like a workaround, see [1]. > (2) these will have an empty gpio range > (3) with the changes of this patch, pinctrl_gpio_request() will now > be called and will fail with -EPROBE_DEFER. > > I'm not exactly sure what to do here. Saravana Kannan once suggested > to use devm_of_platform_populate() to probe the child nodes [2]. But > I haven't found any other driver doing that. > TI AEMIF driver (drivers/memory/ti-aemif.c) does something like this: 406 if (np) { 407 for_each_available_child_of_node(np, child_np) { 408 ret = of_platform_populate(child_np, NULL, 409 dev_lookup, dev); 410 if (ret < 0) { 411 of_node_put(child_np); 412 goto error; 413 } 414 } 415 } else if (pdata) { 416 for (i = 0; i < pdata->num_sub_devices; i++) { 417 pdata->sub_devices[i].dev.parent = dev; 418 ret = platform_device_register(&pdata->sub_devices[i]); 419 if (ret) { 420 dev_warn(dev, "Error register sub device %s\n", 421 pdata->sub_devices[i].name); 422 } 423 } 424 } A bunch of different devices (like NAND) get instantiated this way. Would this work? Bart > Also, I'm not sure if there are any other other driver which get > broken by this. I.e. ones falling into the gpio_stub_drv category. > > [1] https://lore.kernel.org/lkml/20210122193600.1415639-1-saravanak@google.com/ > [2] https://lore.kernel.org/lkml/CAGETcx9PiX==mLxB9PO8Myyk6u2vhPVwTMsA5NkD-ywH5xhusw@mail.gmail.com/ > > -michael > > NB. this patch doesn't contain a Fixes tag. Was this on purpose?
[+ Saravana ] Am 2022-03-15 16:32, schrieb Bartosz Golaszewski: > On Mon, Mar 14, 2022 at 4:55 PM Michael Walle <michael@walle.cc> wrote: >> > Some GPIO lines have stopped working after the patch >> > commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges") >> > >> > And this has supposedly been fixed in the following patches >> > commit 89ad556b7f96a ("gpio: Avoid using pin ranges with !PINCTRL") >> > commit 6dbbf84603961 ("gpiolib: Don't free if pin ranges are not defined") >> > >> > But an erratic behavior where some GPIO lines work while others do not work >> > has been introduced. >> > >> > This patch reverts those changes so that the sysfs-gpio interface works >> > properly again. >> > >> > Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com> >> >> This breaks the pinctrl-microchip-sgpio driver as far as I can see. >> >> I tried to debug it and this is what I have discovered so far: >> (1) the sgpio driver will use the gpio_stub_drv for its child nodes. >> Looks like a workaround, see [1]. >> (2) these will have an empty gpio range >> (3) with the changes of this patch, pinctrl_gpio_request() will now >> be called and will fail with -EPROBE_DEFER. >> >> I'm not exactly sure what to do here. Saravana Kannan once suggested >> to use devm_of_platform_populate() to probe the child nodes [2]. But >> I haven't found any other driver doing that. Oh I meant gpio/pinctrl drivers. > TI AEMIF driver (drivers/memory/ti-aemif.c) does something like this: > > 406 if (np) { > 407 for_each_available_child_of_node(np, child_np) { > 408 ret = of_platform_populate(child_np, NULL, > 409 dev_lookup, > dev); > 410 if (ret < 0) { > 411 of_node_put(child_np); > 412 goto error; > 413 } > 414 } > 415 } else if (pdata) { > 416 for (i = 0; i < pdata->num_sub_devices; i++) { > 417 pdata->sub_devices[i].dev.parent = dev; > 418 ret = > platform_device_register(&pdata->sub_devices[i]); > 419 if (ret) { > 420 dev_warn(dev, "Error register sub > device %s\n", > 421 > pdata->sub_devices[i].name); > 422 } > 423 } > 424 } > > A bunch of different devices (like NAND) get instantiated this way. > Would this work? I started to try this out, but then I was wondering if there weren't other gpio/pinctrl drivers with the same problem. And judging by the reports [1], I'd say there are. Then I wasn't sure if this is actually the correct fix here - or if that old workaround [2] doesn't work anymore because it might have that empty ranges "feature". To answer your question: I don't know. But I don't know if that is actually the correct way of fixing this either. >> Also, I'm not sure if there are any other other driver which get >> broken by this. I.e. ones falling into the gpio_stub_drv category. >> >> [1] >> https://lore.kernel.org/lkml/20210122193600.1415639-1-saravanak@google.com/ >> [2] >> https://lore.kernel.org/lkml/CAGETcx9PiX==mLxB9PO8Myyk6u2vhPVwTMsA5NkD-ywH5xhusw@mail.gmail.com/ >> >> -michael >> >> NB. this patch doesn't contain a Fixes tag. Was this on purpose? -michael [1] https://lore.kernel.org/lkml/20220314192522.GA3031157@roeck-us.net/ [2] https://lore.kernel.org/lkml/20210122193600.1415639-1-saravanak@google.com/
On Thu, Mar 17, 2022 at 7:36 AM Michael Walle <michael@walle.cc> wrote: > Am 2022-03-15 16:32, schrieb Bartosz Golaszewski: > > On Mon, Mar 14, 2022 at 4:55 PM Michael Walle <michael@walle.cc> wrote: ... > I started to try this out, but then I was wondering if there weren't > other gpio/pinctrl drivers with the same problem. And judging by the > reports [1], I'd say there are. Then I wasn't sure if this is actually > the correct fix here - or if that old workaround [2] doesn't work > anymore because it might have that empty ranges "feature". > > To answer your question: I don't know. But I don't know if that is > actually the correct way of fixing this either. > > >> Also, I'm not sure if there are any other other driver which get > >> broken by this. I.e. ones falling into the gpio_stub_drv category. I know that OF is a mess, but I want to understand why in ACPI we haven't experienced such an issue. Any pointers would be appreciated.
Am 2022-03-17 09:37, schrieb Andy Shevchenko: > On Thu, Mar 17, 2022 at 7:36 AM Michael Walle <michael@walle.cc> wrote: >> Am 2022-03-15 16:32, schrieb Bartosz Golaszewski: >> > On Mon, Mar 14, 2022 at 4:55 PM Michael Walle <michael@walle.cc> wrote: > > ... > >> I started to try this out, but then I was wondering if there weren't >> other gpio/pinctrl drivers with the same problem. And judging by the >> reports [1], I'd say there are. Then I wasn't sure if this is actually >> the correct fix here - or if that old workaround [2] doesn't work >> anymore because it might have that empty ranges "feature". >> >> To answer your question: I don't know. But I don't know if that is >> actually the correct way of fixing this either. >> >> >> Also, I'm not sure if there are any other other driver which get >> >> broken by this. I.e. ones falling into the gpio_stub_drv category. > > I know that OF is a mess, but I want to understand why in ACPI we > haven't experienced such an issue. Any pointers would be appreciated. During debugging I've seen that the pinctrl-microchip-sgpio will report itself as gpio_stub_drv. You'll find that this driver was added by the following commit: commit 4731210c09f5977300f439b6c56ba220c65b2348 Author: Saravana Kannan <saravanak@google.com> Date: Fri Jan 22 11:35:59 2021 -0800 gpiolib: Bind gpio_device to a driver to enable fw_devlink=on by default The microchip driver has actually a binding which was described in that commit message. Thus I concluded, that it makes sense this driver falls into that workaround. That is where I stopped and wrote this mail. Actually, I haven't found out yet where that fallback to gpio_stub_drv is happening. -michael
On 16.02.22 15:40, Bartosz Golaszewski wrote: > On Tue, Feb 15, 2022 at 10:56 PM Linus Walleij <linus.walleij@linaro.org> wrote: >> >> On Mon, Feb 14, 2022 at 12:24 AM Marcelo Roberto Jimenez >> <marcelo.jimenez@gmail.com> wrote: >>> On Sat, Feb 12, 2022 at 1:55 PM Linus Walleij <linus.walleij@linaro.org> wrote: >> >>>> I am curious about the usecases and how deeply you have built >>>> yourselves into this. >>> >>> I don't know if I understand what you mean, sorry. >> >> Why does the user need the sysfs ABI? What is it used for? >> >> I.e what is the actual use case? >> >>>>> In any case, the upstream file should be enough to test the issue reported here. >>>> >>>> The thing is that upstream isn't super happy that you have been >>>> making yourselves dependent on features that we are actively >>>> discouraging and then demanding that we support these features. >>> >>> Hum, demanding seems to be a strong word for what I am doing here. >>> >>> Deprecated should not mean broken. My point is: the API seems to be >>> currently broken. User space apps got broken, that's a fact. I even >>> took the time to bisect the kernel and show you which commit broke it. >>> So, no, I am not demanding. More like reporting and providing a >>> temporary solution to those with a similar problem. >>> >>> Maybe it is time to remove the API, but this is up to "upstream". >>> Leaving the API broken seems pointless and unproductive. >>> >>> Sorry for the "not super happiness of upstream", but maybe upstream >>> got me wrong. >>> >>> We are not "making ourselves dependent on features ...". The API was >>> there. We used it. Now it is deprecated, ok, we should move on. I got >>> the message. >> >> Ouch I deserved some slamming for this. >> >> I'm sorry if I came across as harsh :( >> >> I just don't know how to properly push for this. >> >> I have even pushed the option of the deprecated sysfs ABI >> behind the CONFIG_EXPERT option, which should mean that >> the kernel config has been made by someone who has checked >> the option "yes I am an expert I know what I am doing" >> yet failed to observe that this ABI is obsoleted since 5 years >> and hence failed to be an expert. >> >> Of course the ABI (not API really) needs to be fixed if we can find the >> problem. It's frustrating that fixing it seems to fix broken other >> features which are not deprecated, hence the annoyance on my >> part. >> > > I'm afraid we'll earn ourselves a good old LinusRant if we keep > pushing the character device as a solution to the problem here. > Marcelo is right after all: he used an existing user interface, the > interface broke, it must be fixed. > > I would prefer to find a solution that fixes Marcelo's issue while > keeping the offending patches in tree but it seems like the issue is > more complicated and will require some rework of the sysfs interface. > > In which case unless there are objections I lean towards reverting the > relevant commits. Reviving and old thread, hence a quick reminder: The patch at the start of this thread was applied and then reverted in 56e337f2cf13 with this text: ``` This commit - while attempting to fix a regression - has caused a number of other problems. As the fallout from it is more significant than the initial problem itself, revert it for now before we find a correct solution. ``` I still have this on my list of open regressions and that made me wonder: is anyone working on a "correct solution" (or was one even applied and I missed it)? Or is the situation so tricky that we better leave everything as it is? Marcelo, do you still care? Ciao, Thorsten
Hi Thorsten, On Fri, May 20, 2022 at 6:12 AM Thorsten Leemhuis <regressions@leemhuis.info> wrote: > > On 16.02.22 15:40, Bartosz Golaszewski wrote: > > On Tue, Feb 15, 2022 at 10:56 PM Linus Walleij <linus.walleij@linaro.org> wrote: > >> > >> On Mon, Feb 14, 2022 at 12:24 AM Marcelo Roberto Jimenez > >> <marcelo.jimenez@gmail.com> wrote: > >>> On Sat, Feb 12, 2022 at 1:55 PM Linus Walleij <linus.walleij@linaro.org> wrote: > >> > >>>> I am curious about the usecases and how deeply you have built > >>>> yourselves into this. > >>> > >>> I don't know if I understand what you mean, sorry. > >> > >> Why does the user need the sysfs ABI? What is it used for? > >> > >> I.e what is the actual use case? > >> > >>>>> In any case, the upstream file should be enough to test the issue reported here. > >>>> > >>>> The thing is that upstream isn't super happy that you have been > >>>> making yourselves dependent on features that we are actively > >>>> discouraging and then demanding that we support these features. > >>> > >>> Hum, demanding seems to be a strong word for what I am doing here. > >>> > >>> Deprecated should not mean broken. My point is: the API seems to be > >>> currently broken. User space apps got broken, that's a fact. I even > >>> took the time to bisect the kernel and show you which commit broke it. > >>> So, no, I am not demanding. More like reporting and providing a > >>> temporary solution to those with a similar problem. > >>> > >>> Maybe it is time to remove the API, but this is up to "upstream". > >>> Leaving the API broken seems pointless and unproductive. > >>> > >>> Sorry for the "not super happiness of upstream", but maybe upstream > >>> got me wrong. > >>> > >>> We are not "making ourselves dependent on features ...". The API was > >>> there. We used it. Now it is deprecated, ok, we should move on. I got > >>> the message. > >> > >> Ouch I deserved some slamming for this. > >> > >> I'm sorry if I came across as harsh :( > >> > >> I just don't know how to properly push for this. > >> > >> I have even pushed the option of the deprecated sysfs ABI > >> behind the CONFIG_EXPERT option, which should mean that > >> the kernel config has been made by someone who has checked > >> the option "yes I am an expert I know what I am doing" > >> yet failed to observe that this ABI is obsoleted since 5 years > >> and hence failed to be an expert. > >> > >> Of course the ABI (not API really) needs to be fixed if we can find the > >> problem. It's frustrating that fixing it seems to fix broken other > >> features which are not deprecated, hence the annoyance on my > >> part. > >> > > > > I'm afraid we'll earn ourselves a good old LinusRant if we keep > > pushing the character device as a solution to the problem here. > > Marcelo is right after all: he used an existing user interface, the > > interface broke, it must be fixed. > > > > I would prefer to find a solution that fixes Marcelo's issue while > > keeping the offending patches in tree but it seems like the issue is > > more complicated and will require some rework of the sysfs interface. > > > > In which case unless there are objections I lean towards reverting the > > relevant commits. > > Reviving and old thread, hence a quick reminder: The patch at the start > of this thread was applied and then reverted in 56e337f2cf13 with this text: > > ``` > This commit - while attempting to fix a regression - has caused a number > of other problems. As the fallout from it is more significant than the > initial problem itself, revert it for now before we find a correct > solution. > ``` > > I still have this on my list of open regressions and that made me > wonder: is anyone working on a "correct solution" (or was one even > applied and I missed it)? Or is the situation so tricky that we better > leave everything as it is? Marcelo, do you still care? The purpose of my patch was to revert the patch that was causing the hardware I work with to fail. But reverting that patch had bad consequences in other hardware, so I really do not think that my patch should go in. Following Linus Walleij's advice, we are stopping using sysfs for gpio, so in the near future that patch will be irrelevant for me. On the other hand, a few people using recent kernels have tried my patch successfully, so it can be used as a temporary transition hack. Also, the patch exposes a serious problem with the sysfs gpio, which is currently broken. Maybe we should consider removing the interface in a near future release, as it has been advocated several times before, since it has long been deprecated, has a much better substitute API and, the worse part, it is broken and no one seems to have a high priority in fixing it. IIRC, the last time I read, the kernel documentation said that the API would be removed in 2020, so we are a bit late :). I know that removing an API has lots of implications, so the consequences must be carefully balanced. > Ciao, Thorsten Best regards, Marcelo.
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index af5bb8fedfea..ac69ec8fb37a 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1804,11 +1804,6 @@ static inline void gpiochip_irqchip_free_valid_mask(struct gpio_chip *gc) */ int gpiochip_generic_request(struct gpio_chip *gc, unsigned offset) { -#ifdef CONFIG_PINCTRL - if (list_empty(&gc->gpiodev->pin_ranges)) - return 0; -#endif - return pinctrl_gpio_request(gc->gpiodev->base + offset); } EXPORT_SYMBOL_GPL(gpiochip_generic_request); @@ -1820,11 +1815,6 @@ EXPORT_SYMBOL_GPL(gpiochip_generic_request); */ void gpiochip_generic_free(struct gpio_chip *gc, unsigned offset) { -#ifdef CONFIG_PINCTRL - if (list_empty(&gc->gpiodev->pin_ranges)) - return; -#endif - pinctrl_gpio_free(gc->gpiodev->base + offset); } EXPORT_SYMBOL_GPL(gpiochip_generic_free);
Some GPIO lines have stopped working after the patch commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges") And this has supposedly been fixed in the following patches commit 89ad556b7f96a ("gpio: Avoid using pin ranges with !PINCTRL") commit 6dbbf84603961 ("gpiolib: Don't free if pin ranges are not defined") But an erratic behavior where some GPIO lines work while others do not work has been introduced. This patch reverts those changes so that the sysfs-gpio interface works properly again. Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com> --- Hi, My system is ARM926EJ-S rev 5 (v5l) (AT91SAM9G25), the board is an ACME Systems Arietta. The system used sysfs-gpio to manage a few gpio lines, and I have noticed that some have stopped working. The test script is very simple: #! /bin/bash cd /sys/class/gpio/ echo 24 > export cd pioA24 echo out > direction echo 0 > value cat value echo 1 > value cat value echo 0 > value cat value echo 1 > value cat value cd .. echo 24 > unexport In a "good" kernel, this script outputs 0, 1, 0, 1. In a bad kernel, the output result is 1, 1, 1, 1. Also it must be possible to run this script twice without errors, that was the issue with the gpiochip_generic_free() call that had been addressed in another patch. In my system PINCTRL is automatically selected by SOC_AT91SAM9 [=y] && ARCH_AT91 [=y] && ARCH_MULTI_V5 [=y] So it is not an option to disable it to make it work. Best regards, Marcelo. drivers/gpio/gpiolib.c | 10 ---------- 1 file changed, 10 deletions(-)