stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: Revert regression in sysfs-gpio (gpiolib.c)
@ 2021-12-17 15:35 Marcelo Roberto Jimenez
  2021-12-18  6:28 ` Thorsten Leemhuis
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Marcelo Roberto Jimenez @ 2021-12-17 15:35 UTC (permalink / raw)
  To: stable, regressions, Linus Walleij, Bartosz Golaszewski,
	linux-gpio, Thierry Reding, Vidya Sagar, Geert Uytterhoeven,
	Stephen Rothwell, Edmond Chung, Andrew Chant, Will McVicker,
	Sergio Tanzilli
  Cc: 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")

But an erratic behavior where some GPIO lines work while others do not work
has been introduced.

This patch reverts those changes so that the sysfs-gpio interface works
properly again.

Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com>
---

Hi,

My system is ARM926EJ-S rev 5 (v5l) (AT91SAM9G25), the board is an ACME Systems Arietta.

The system used sysfs-gpio to manage a few gpio lines, and I have noticed that some have stopped working.

The test script is very simple:

	#! /bin/bash

	cd /sys/class/gpio/
	echo 24 > export 

	cd pioA24
	echo out > direction

	echo 0 > value
	cat value
	echo 1 > value
	cat value
	echo 0 > value
	cat value
	echo 1 > value
	cat value

	cd ..
	echo 24 > unexport

In a "good" kernel, this script outputs 0, 1, 0, 1. In a bad kernel, the output result is 1, 1, 1, 1. Also it must be possible to run this script twice without errors, that was the issue with the gpiochip_generic_free() call that had been addressed in another patch.

In my system PINCTRL is automatically selected by 
SOC_AT91SAM9 [=y] && ARCH_AT91 [=y] && ARCH_MULTI_V5 [=y]

So it is not an option to disable it to make it work.

Best regards,
Marcelo.


 drivers/gpio/gpiolib.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index af5bb8fedfea..ac69ec8fb37a 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1804,11 +1804,6 @@ static inline void gpiochip_irqchip_free_valid_mask(struct gpio_chip *gc)
  */
 int gpiochip_generic_request(struct gpio_chip *gc, unsigned offset)
 {
-#ifdef CONFIG_PINCTRL
-	if (list_empty(&gc->gpiodev->pin_ranges))
-		return 0;
-#endif
-
 	return pinctrl_gpio_request(gc->gpiodev->base + offset);
 }
 EXPORT_SYMBOL_GPL(gpiochip_generic_request);
@@ -1820,11 +1815,6 @@ EXPORT_SYMBOL_GPL(gpiochip_generic_request);
  */
 void gpiochip_generic_free(struct gpio_chip *gc, unsigned offset)
 {
-#ifdef CONFIG_PINCTRL
-	if (list_empty(&gc->gpiodev->pin_ranges))
-		return;
-#endif
-
 	pinctrl_gpio_free(gc->gpiodev->base + offset);
 }
 EXPORT_SYMBOL_GPL(gpiochip_generic_free);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2022-05-20 17:28 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-17 15:35 [PATCH] gpio: Revert regression in sysfs-gpio (gpiolib.c) Marcelo Roberto Jimenez
2021-12-18  6:28 ` Thorsten Leemhuis
2021-12-20 14:57   ` Bartosz Golaszewski
2021-12-20 15:14     ` Geert Uytterhoeven
2021-12-20 19:24       ` Will McVicker
2021-12-20 20:41         ` Marcelo Roberto Jimenez
2021-12-20 20:41       ` Marcelo Roberto Jimenez
2021-12-20 20:41     ` Marcelo Roberto Jimenez
2022-01-10  7:02       ` Thorsten Leemhuis
2022-01-12  0:09         ` Marcelo Roberto Jimenez
2022-02-08 12:24           ` Thorsten Leemhuis
2022-02-17 19:11           ` Thierry Reding
2022-02-11  0:02 ` Linus Walleij
2022-02-11 22:36   ` Marcelo Roberto Jimenez
2022-02-12 16:54     ` Linus Walleij
2022-02-13 23:23       ` Marcelo Roberto Jimenez
2022-02-15 21:56         ` Linus Walleij
2022-02-16 14:40           ` Bartosz Golaszewski
2022-03-04  7:13             ` Thorsten Leemhuis
2022-03-07  9:58               ` Bartosz Golaszewski
2022-03-07 10:12                 ` Thorsten Leemhuis
2022-05-20  9:12             ` Thorsten Leemhuis
2022-05-20 17:28               ` Marcelo Roberto Jimenez
2022-03-14 15:55 ` Michael Walle
2022-03-15 15:32   ` Bartosz Golaszewski
2022-03-15 15:45     ` Michael Walle
2022-03-17  8:37       ` Andy Shevchenko
2022-03-17  8:48         ` Michael Walle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).