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 |
[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? > 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(-) > > 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); > Hi, this is your Linux kernel regression tracker speaking. Thanks for the report. To be sure this issue doesn't fall through the cracks unnoticed, I'm adding it to regzbot, my Linux kernel regression tracking bot: #regzbot ^introduced 2ab73c6d8323f #regzbot title gpio: some GPIO lines have stopped working #regzbot ignore-activity Reminder: when fixing the issue, please add a 'Link:' tag with the URL to the report (the parent of this mail), as explained in 'Documentation/process/submitting-patches.rst' (reminder: you should use the kernel.org redirector). Regzbot then will automatically mark the regression as resolved once the fix lands in the appropriate tree. For more details about regzbot see footer. Sending this to everyone that got the initial report, to make all aware of the tracking. I also hope that messages like this motivate people to directly get at least the regression mailing list and ideally even regzbot involved when dealing with regressions, as messages like this wouldn't be needed then. Don't worry, I'll send further messages wrt to this regression just to the lists (with a tag in the subject so people can filter them away), as long as they are intended just for regzbot. With a bit of luck no such messages will be needed anyway. Ciao, Thorsten (wearing his 'Linux kernel regression tracker' hat). 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, as what I wrote above might be misleading to everyone reading this; any suggestion I gave thus might sent someone reading this down the wrong rabbit hole, which none of us wants. 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. --- Additional information about regzbot: If you want to know more about regzbot, check out its web-interface, the getting start guide, and/or the references documentation: https://linux-regtracking.leemhuis.info/regzbot/ https://gitlab.com/knurd42/regzbot/-/blob/main/docs/getting_started.md https://gitlab.com/knurd42/regzbot/-/blob/main/docs/reference.md The last two documents will explain how you can interact with regzbot yourself if your want to. Hint for reporters: when reporting a regression it's in your interest to tell #regzbot about it in the report, as that will ensure the regression gets on the radar of regzbot and the regression tracker. That's in your interest, as they will make sure the report won't fall through the cracks unnoticed. Hint for developers: you normally don't need to care about regzbot once it's involved. Fix the issue as you normally would, just remember to include a 'Link:' tag to the report in the commit message, as explained in Documentation/process/submitting-patches.rst That aspect was recently was made more explicit in commit 1f57bd42b77c: https://git.kernel.org/linus/1f57bd42b77c
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
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 Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
On Mon, Dec 20, 2021 at 7:14 AM 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 > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds Hi Marcelo, Thanks for reporting this issue. I can give you a little context on why commit 6dbbf84603961 ("gpiolib: Don't free if pin ranges are not defined") was created. We were seeing a refcounting issue on Pixel 6. In our kernel CONFIG_PINCTRL is defined. Basically, the camera kernel module requests for a GPIO on sensor enable (when the camera sensor is turned on) and releases that GPIO on sensor disable (when the camera sensor is turned off). Before commit 6dbbf84603961, if we constantly switched between the front and back camera eventually we would hit the below error in drivers/pinctrl/pinmux.c:pin_request(): E samsung-pinctrl 10840000.pinctrl: could not increase module refcount for pin 134 In our kernel the sensor GPIOs don't have pin_ranges defined. So you would get these call stacks: Sensor Enable: gpiochip_generic_request() -> return 0 Sensor Disable: gpiochip_generic_free() -> pinctrl_gpio_free() This led to an imbalance of request vs free calls leading to the refcounting error. When we added commit 6dbbf84603961 ("gpiolib: Don't free if pin ranges are not defined"), this issue was resolved. My recommendation would be to drill down into your driver to figure out what happens in these functions to see why you're getting the results you reported. --Will
Hi Bart, 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. > Bart Regards, Marcelo.
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 Will, On Mon, Dec 20, 2021 at 4:25 PM Will McVicker <willmcvicker@google.com> wrote: > > On Mon, Dec 20, 2021 at 7:14 AM 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 > > > > Gr{oetje,eeting}s, > > > > Geert > > > > -- > > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > > > In personal conversations with technical people, I call myself a hacker. But > > when I'm talking to journalists I just say "programmer" or something like that. > > -- Linus Torvalds > > Hi Marcelo, > > Thanks for reporting this issue. I can give you a little context on > why commit 6dbbf84603961 ("gpiolib: Don't free if pin ranges are not > defined") was created. We were seeing a refcounting issue on Pixel 6. > In our kernel CONFIG_PINCTRL is defined. Basically, the camera kernel > module requests for a GPIO on sensor enable (when the camera sensor is > turned on) and releases that GPIO on sensor disable (when the camera > sensor is turned off). Before commit 6dbbf84603961, if we constantly > switched between the front and back camera eventually we would hit the > below error in drivers/pinctrl/pinmux.c:pin_request(): > > E samsung-pinctrl 10840000.pinctrl: could not increase module > refcount for pin 134 > > In our kernel the sensor GPIOs don't have pin_ranges defined. So you > would get these call stacks: > > Sensor Enable: > gpiochip_generic_request() > -> return 0 > > Sensor Disable: > gpiochip_generic_free() > -> pinctrl_gpio_free() > > This led to an imbalance of request vs free calls leading to the > refcounting error. When we added commit 6dbbf84603961 ("gpiolib: Don't > free if pin ranges are not defined"), this issue was resolved. My > recommendation would be to drill down into your driver to figure out > what happens in these functions to see why you're getting the results > you reported. Thanks for your reply. Commit 6dbbf84603961 ("gpiolib: Don't free if pin ranges are not defined") is perfectly fine in the context and fixes a serious issue. But to revert the original patch we need to revert this patch too, for the same reason, i.e., in order to not generate a *_free() imbalance. In my case the imbalance causes problems as soon as the test script is run a second time. > > --Will Regards, Marcelo.
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.
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 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
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/
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
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(-)