Skip to contentSkip to conversation

gpio: Revert regression in sysfs-gpio (gpiolib.c)

PATCH In review Marcelo Roberto Jimenez 9 participants 30 messages Dec 17, 2021 – May 30, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: Revert regression in sysfs-gpio (gpiolib.c)

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.

---

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(-)
drivers/gpio/gpiolib.c +0 -10
index af5bb8fedfea..ac69ec8fb37a 100644
@@ -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);
Signature · 1 line
2.30.2
#1 lore raw

[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.]

Quoted 6 lines · Marcelo Roberto Jimenez

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?

Quoted 70 lines

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.

---

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(-)
drivers/gpio/gpiolib.c +0 -5
index af5bb8fedfea..ac69ec8fb37a 100644
@@ -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);
  */

drivers/gpio/gpiolib.c EXPORT_SYMBOL_GPL(gpiochip_generic_request); · line 1820

Quoted 10 lines
drivers/gpio/gpiolib.c +0 -5
 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

#2 lore raw
Quoted 9 lines · Thorsten Leemhuis

[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.]

Quoted 3 lines · Marcelo Roberto Jimenez

Some GPIO lines have stopped working after the patch
commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges")

Quoted 8 lines
Quoted 3 lines

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

#3 lore raw
Quoted 19 lines · Bartosz Golaszewski
Quoted 8 lines · Thorsten Leemhuis

[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.]

Quoted 3 lines · Marcelo Roberto Jimenez

Some GPIO lines have stopped working after the patch
commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges")

Quoted 8 lines
Quoted 3 lines

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?

Quoted 6 lines

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 -- [email protected]

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

#4 lore raw
Quoted 34 lines · Geert Uytterhoeven
Quoted 19 lines · Bartosz Golaszewski
Quoted 8 lines · Thorsten Leemhuis

[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.]

Quoted 3 lines · Marcelo Roberto Jimenez

Some GPIO lines have stopped working after the patch
commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges")

Quoted 8 lines
Quoted 3 lines

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?

Quoted 6 lines

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,

Quoted 8 lines

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

#5 lore raw

Hi Will,

Quoted 71 lines · Will McVicker
Quoted 34 lines · Geert Uytterhoeven
Quoted 19 lines · Bartosz Golaszewski
Quoted 8 lines · Thorsten Leemhuis

[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.]

Quoted 3 lines · Marcelo Roberto Jimenez

Some GPIO lines have stopped working after the patch
commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges")

Quoted 8 lines
Quoted 3 lines

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?

Quoted 6 lines

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,

Quoted 8 lines

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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()

Quoted 6 lines

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.

Quoted 2 lines

--Will

Regards,
Marcelo.

#6 lore raw
In reply to Geert Uytterhoeven

Hi Geert,

Quoted 25 lines · Geert Uytterhoeven
Quoted 23 lines · Bartosz Golaszewski
Quoted 8 lines · Thorsten Leemhuis

[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.]

Quoted 3 lines · Marcelo Roberto Jimenez

Some GPIO lines have stopped working after the patch
commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges")

Quoted 8 lines
Quoted 3 lines

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.

Quoted 7 lines
Quoted 2 lines

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?

Quoted 3 lines

Gr{oetje,eeting}s,

Geert

Regards,
Marcelo.

#7 lore raw
In reply to Bartosz Golaszewski

Hi Bart,

Quoted 21 lines · Bartosz Golaszewski
Quoted 9 lines · Thorsten Leemhuis

[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.]

Quoted 3 lines · Marcelo Roberto Jimenez

Some GPIO lines have stopped working after the patch
commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges")

Quoted 8 lines
Quoted 3 lines

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?

Quoted 6 lines

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.

Quoted 1 line

Bart

Regards,
Marcelo.

#8 lore raw

Hi, this is your Linux kernel regression tracker speaking.

Quoted 27 lines · Marcelo Roberto Jimenez
Quoted 19 lines · Bartosz Golaszewski
Quoted 9 lines · Thorsten Leemhuis

[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.]

Quoted 3 lines · Marcelo Roberto Jimenez

Some GPIO lines have stopped working after the patch
commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges")

Quoted 7 lines
Quoted 3 lines

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?

Quoted 6 lines

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?

Quoted 6 lines

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?

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

#9 lore raw

Hi,

Quoted 40 lines · Thorsten Leemhuis

Hi, this is your Linux kernel regression tracker speaking.

Quoted 27 lines · Marcelo Roberto Jimenez
Quoted 19 lines · Bartosz Golaszewski
Quoted 9 lines · Thorsten Leemhuis

[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.]

Quoted 3 lines · Marcelo Roberto Jimenez

Some GPIO lines have stopped working after the patch
commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges")

Quoted 7 lines
Quoted 3 lines

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?

Quoted 6 lines

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?

Quoted 6 lines

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?

Quoted 8 lines

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.

Quoted 9 lines

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.

Quoted 8 lines

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.

#10 lore raw

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

Quoted 106 lines · Marcelo Roberto Jimenez

Hi,

Quoted 40 lines · Thorsten Leemhuis

Hi, this is your Linux kernel regression tracker speaking.

Quoted 27 lines · Marcelo Roberto Jimenez
Quoted 19 lines · Bartosz Golaszewski
Quoted 9 lines · Thorsten Leemhuis

[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.]

Quoted 3 lines · Marcelo Roberto Jimenez

Some GPIO lines have stopped working after the patch
commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges")

Quoted 7 lines
Quoted 3 lines

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?

Quoted 6 lines

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?

Quoted 6 lines

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?

Quoted 8 lines

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.

Quoted 9 lines

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.

Quoted 8 lines

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.

#11 lore raw
In reply to Marcelo Roberto Jimenez
Quoted 77 lines · Marcelo Roberto Jimenez

Hi,

Quoted 40 lines · Thorsten Leemhuis

Hi, this is your Linux kernel regression tracker speaking.

Quoted 27 lines · Marcelo Roberto Jimenez
Quoted 19 lines · Bartosz Golaszewski
Quoted 9 lines · Thorsten Leemhuis

[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.]

Quoted 3 lines · Marcelo Roberto Jimenez

Some GPIO lines have stopped working after the patch
commit 2ab73c6d8323f ("gpio: Support GPIO controllers without pin-ranges")

Quoted 7 lines
Quoted 3 lines

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?

Quoted 6 lines

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?

Quoted 6 lines

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?

Quoted 8 lines

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:

Quoted 6 lines

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

Quoted 19 lines
Quoted 8 lines

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.

Quoted 8 lines

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.

#12 lore raw

Re: [PATCH] gpio: Revert regression in sysfs-gpio (gpiolib.c) #forregzbot

In reply to Thorsten Leemhuis

TWIMC: this mail is primarily send for documentation purposes and for regzbot, my Linux kernel regression tracking bot. These mails usually contain '#forregzbot' in the subject, to make them easy to spot and filter.

#regzbot invalid: tricky situation that likely can't be really solved by causing other regressions, so leave things as they are

For details see:
https://lore.kernel.org/stable/CACjc_5oRRHdCjbSEeMMY2DeJRyFDcbQ2Vk7vaFC9h%[email protected]/

Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)

P.S.: As the Linux kernel's regression tracker I deal with a lot of reports and sometimes miss something important when writing mails like this. If that's the case here, don't hesitate to tell me in a public reply, it's in everyone's interest to set the public record straight.

Quoted 168 lines · Thorsten Leemhuis

[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.]

Quoted 6 lines · Marcelo Roberto Jimenez

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?

Quoted 70 lines

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.

---

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(-)
drivers/gpio/gpiolib.c +0 -5
index af5bb8fedfea..ac69ec8fb37a 100644
@@ -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);
  */

drivers/gpio/gpiolib.c EXPORT_SYMBOL_GPL(gpiochip_generic_request); · line 1820

Quoted 10 lines
drivers/gpio/gpiolib.c +0 -5
 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

#13 lore raw
In reply to Marcelo Roberto Jimenez
Quoted 1 line · Marcelo Roberto Jimenez

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

#14 lore raw
Quoted 8 lines · Linus Walleij
Quoted 1 line · Marcelo Roberto Jimenez

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.

Quoted 2 lines

Yours,
Linus Walleij

Regards,
Marcelo.

#15 lore raw
Quoted 4 lines · Marcelo Roberto Jimenez
Quoted 2 lines

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 <[email protected]>
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.

Quoted 1 line

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

#16 lore raw
Quoted 12 lines · Linus Walleij
Quoted 4 lines · Marcelo Roberto Jimenez
Quoted 2 lines

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:

Quoted 8 lines

commit fe95046e960b4b76e73dc1486955d93f47276134

Author: Linus Walleij <[email protected]>
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.

Quoted 2 lines

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.

Quoted 5 lines
Quoted 1 line

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.

Quoted 3 lines

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.

Quoted 11 lines

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... :)

Quoted 3 lines

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!

Quoted 2 lines

Yours,
Linus Walleij

Best regards,
Marcelo.

#17 lore raw
Quoted 6 lines · Marcelo Roberto Jimenez
Quoted 2 lines · Linus Walleij

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?

Quoted 17 lines
Quoted 5 lines
Quoted 1 line

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.

Quoted 6 lines

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.

Quoted 4 lines

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

#18 lore raw
Quoted 51 lines · Linus Walleij
Quoted 6 lines · Marcelo Roberto Jimenez
Quoted 2 lines · Linus Walleij

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?

Quoted 17 lines
Quoted 5 lines
Quoted 1 line

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.

Quoted 6 lines

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.

Quoted 5 lines

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

Quoted 9 lines
Quoted 4 lines

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

#19 lore raw

Hi, this is your Linux kernel regression tracker.

Quoted 63 lines · Bartosz Golaszewski
Quoted 51 lines · Linus Walleij
Quoted 6 lines · Marcelo Roberto Jimenez
Quoted 2 lines · Linus Walleij

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?

Quoted 17 lines
Quoted 5 lines
Quoted 1 line

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.

Quoted 6 lines

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.

Quoted 5 lines

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.

Quoted 6 lines

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?

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

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

#20 lore raw
Quoted 71 lines · Thorsten Leemhuis

Hi, this is your Linux kernel regression tracker.

Quoted 67 lines · Bartosz Golaszewski
Quoted 51 lines · Linus Walleij
Quoted 6 lines · Marcelo Roberto Jimenez
Quoted 2 lines · Linus Walleij

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?

Quoted 17 lines
Quoted 5 lines
Quoted 1 line

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.

Quoted 6 lines

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.

Quoted 5 lines

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.

Quoted 6 lines
Quoted 2 lines

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

Quoted 18 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

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

#21 lore raw
Quoted 70 lines · Bartosz Golaszewski
Quoted 68 lines · Thorsten Leemhuis
Quoted 67 lines · Bartosz Golaszewski
Quoted 51 lines · Linus Walleij
Quoted 6 lines · Marcelo Roberto Jimenez
Quoted 2 lines · Linus Walleij

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?

Quoted 17 lines
Quoted 5 lines
Quoted 1 line

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.

Quoted 6 lines

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.

Quoted 5 lines

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.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

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

Quoted 19 lines
Quoted 18 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

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

#22 lore raw

Re: [PATCH] gpio: Revert regression in sysfs-gpio (gpiolib.c) #forregzbot

TWIMC: this mail is primarily send for documentation purposes and for regzbot, my Linux kernel regression tracking bot. These mails usually contain '#forregzbot' in the subject, to make them easy to spot and filter.

#regzbot fixed-by: fc328a7d1fcce263db0b046917a66f3aa6e68719 #regzbot monitor:
https://lore.kernel.org/lkml/[email protected]/

Quoted 116 lines · Thorsten Leemhuis
Quoted 70 lines · Bartosz Golaszewski
Quoted 68 lines · Thorsten Leemhuis
Quoted 67 lines · Bartosz Golaszewski
Quoted 51 lines · Linus Walleij
Quoted 6 lines · Marcelo Roberto Jimenez
Quoted 2 lines · Linus Walleij

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?

Quoted 17 lines
Quoted 5 lines
Quoted 1 line

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.

Quoted 6 lines

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.

Quoted 5 lines

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.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

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

Quoted 19 lines
Quoted 18 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

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

#23 lore raw
In reply to Bartosz Golaszewski
Quoted 63 lines · Bartosz Golaszewski
Quoted 51 lines · Linus Walleij
Quoted 6 lines · Marcelo Roberto Jimenez
Quoted 2 lines · Linus Walleij

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?

Quoted 17 lines
Quoted 5 lines
Quoted 1 line

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.

Quoted 6 lines

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.

Quoted 5 lines

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.

Quoted 6 lines

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

#24 lore raw

Hi Thorsten,

Quoted 82 lines · Thorsten Leemhuis
Quoted 63 lines · Bartosz Golaszewski
Quoted 51 lines · Linus Walleij
Quoted 6 lines · Marcelo Roberto Jimenez
Quoted 2 lines · Linus Walleij

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?

Quoted 17 lines
Quoted 5 lines
Quoted 1 line

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.

Quoted 6 lines

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.

Quoted 5 lines

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.

Quoted 6 lines

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.
```
Quoted 4 lines

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.

Quoted 1 line

Ciao, Thorsten

Best regards,
Marcelo.

#25 lore raw
In reply to Marcelo Roberto Jimenez

Hi,

Quoted 7 lines

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")

Quoted 7 lines

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.

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/[email protected]/
[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?

#26 lore raw
Quoted 27 lines · Michael Walle

Hi,

Quoted 7 lines

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")

Quoted 7 lines

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.

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.

Quoted 4 lines

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

Quoted 9 lines

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/[email protected]/
[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?

#27 lore raw

[+ Saravana ]

Am 2022-03-15 16:32, schrieb Bartosz Golaszewski:

Quoted 25 lines · Michael Walle
Quoted 24 lines
Quoted 7 lines

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")

Quoted 7 lines

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.

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.

Quoted 3 lines
Quoted 3 lines

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.

Quoted 24 lines

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 }

Quoted 2 lines

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.

Quoted 9 lines
Quoted 9 lines

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/[email protected]/
[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/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/

#28 lore raw
Quoted 2 lines · Michael Walle

Am 2022-03-15 16:32, schrieb Bartosz Golaszewski:

Quoted 1 line · Michael Walle

...

Quoted 11 lines

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.

Quoted 2 lines
Quoted 2 lines

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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#29 lore raw

Am 2022-03-17 09:37, schrieb Andy Shevchenko:

Quoted 12 lines · Michael Walle
Quoted 2 lines

Am 2022-03-15 16:32, schrieb Bartosz Golaszewski:

Quoted 1 line · Michael Walle

...

Quoted 6 lines

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".

Quoted 8 lines
Quoted 5 lines

To answer your question: I don't know. But I don't know if that is actually the correct way of fixing this either.

Quoted 2 lines
Quoted 2 lines

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 <[email protected]>
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