Skip to contentSkip to conversation

gpiolib: acpi: Make set-debounce-timeout failures non fatal

PATCH Superseded Hans de Goede 5 participants 8 messages Aug 16, 2021 – Sep 22, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpiolib: acpi: Make set-debounce-timeout failures non fatal

Commit 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings") made the gpiolib-acpi code call gpio_set_debounce_timeout() when requesting GPIOs.

This in itself is fine, but it also made gpio_set_debounce_timeout() errors fatal, causing the requesting of the GPIO to fail. This is causing regressions. E.g. on a HP ElitePad 1000 G2 various _AEI specified GPIO ACPI event sources specify a debouncy timeout of 20 ms, but the pinctrl-baytrail.c only supports certain fixed values, the closest ones being 12 or 14 ms and pinctrl-baytrail.c responds with -EINVAL when specified a value which is not one of the fixed values.

This is causing the acpi_request_own_gpiod() call to fail for 3 ACPI event sources on the HP ElitePad 1000 G2, which in turn is causing e.g. the battery charging vs discharging status to never get updated, even though a charger has been plugged-in or unplugged.

Make gpio_set_debounce_timeout() errors non fatal, warning about the failure instead, to fix this regression.

Note we should probably also fix various pinctrl drivers to just pick the first bigger discrete value rather then returning -EINVAL but this will need to be done on a per driver basis, where as this fix at least gets us back to where things were before and thus restores functionality on devices where this was lost due to gpio_set_debounce_timeout() errors.

Fixes 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings")
---
 drivers/gpio/gpiolib-acpi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-acpi.c +4 -2
index 411525ac4cc4..47712b6903b5 100644
@@ -313,9 +313,11 @@ static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip,
 
 	ret = gpio_set_debounce_timeout(desc, agpio->debounce_timeout);
 	if (ret)
-		gpiochip_free_own_desc(desc);
+		dev_warn(chip->parent,
+			 "Failed to set debounce-timeout for pin 0x%04X, err %d\n",
+			 pin, ret);
 
-	return ret ? ERR_PTR(ret) : desc;
+	return desc;
 }
 
 static bool acpi_gpio_in_ignore_list(const char *controller_in, int pin_in)
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · Hans de Goede

Commit 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings") made the gpiolib-acpi code call gpio_set_debounce_timeout() when requesting GPIOs.

This in itself is fine, but it also made gpio_set_debounce_timeout() errors fatal, causing the requesting of the GPIO to fail. This is causing regressions. E.g. on a HP ElitePad 1000 G2 various _AEI specified GPIO ACPI event sources specify a debouncy timeout of 20 ms, but the pinctrl-baytrail.c only supports certain fixed values, the closest ones being 12 or 14 ms and pinctrl-baytrail.c responds with -EINVAL when specified a value which is not one of the fixed values.

This is causing the acpi_request_own_gpiod() call to fail for 3 ACPI event sources on the HP ElitePad 1000 G2, which in turn is causing e.g. the battery charging vs discharging status to never get updated, even though a charger has been plugged-in or unplugged.

Make gpio_set_debounce_timeout() errors non fatal, warning about the failure instead, to fix this regression.

Note we should probably also fix various pinctrl drivers to just pick the first bigger discrete value rather then returning -EINVAL but this will need to be done on a per driver basis, where as this fix at least gets us back to where things were before and thus restores functionality on devices where this was lost due to gpio_set_debounce_timeout() errors.

Quoted 2 lines
Fixes 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings")
#2 lore raw

Hi,

Quoted 11 lines · Mika Westerberg
Quoted 10 lines · Hans de Goede

Commit 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings") made the gpiolib-acpi code call gpio_set_debounce_timeout() when requesting GPIOs.

This in itself is fine, but it also made gpio_set_debounce_timeout() errors fatal, causing the requesting of the GPIO to fail. This is causing regressions. E.g. on a HP ElitePad 1000 G2 various _AEI specified GPIO ACPI event sources specify a debouncy timeout of 20 ms, but the pinctrl-baytrail.c only supports certain fixed values, the closest ones being 12 or 14 ms and pinctrl-baytrail.c responds with -EINVAL

Type 14 should be 24.

Quoted 17 lines
Quoted 17 lines

when specified a value which is not one of the fixed values.

This is causing the acpi_request_own_gpiod() call to fail for 3 ACPI event sources on the HP ElitePad 1000 G2, which in turn is causing e.g. the battery charging vs discharging status to never get updated, even though a charger has been plugged-in or unplugged.

Make gpio_set_debounce_timeout() errors non fatal, warning about the failure instead, to fix this regression.

Note we should probably also fix various pinctrl drivers to just pick the first bigger discrete value rather then returning -EINVAL but this will need to be done on a per driver basis, where as this fix at least gets us back to where things were before and thus restores functionality on devices where this was lost due to gpio_set_debounce_timeout() errors.

Quoted 4 lines
Quoted 2 lines
Fixes 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings")

Thanks, I'll send a v2 with the typo fixed and your Reviewed-by added.

Regards,

Hans

Reviewed-by on v1 1/1
#3 lore raw
In reply to Hans de Goede
Quoted 27 lines · Hans de Goede

Commit 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings") made the gpiolib-acpi code call gpio_set_debounce_timeout() when requesting GPIOs.

This in itself is fine, but it also made gpio_set_debounce_timeout() errors fatal, causing the requesting of the GPIO to fail. This is causing regressions. E.g. on a HP ElitePad 1000 G2 various _AEI specified GPIO ACPI event sources specify a debouncy timeout of 20 ms, but the pinctrl-baytrail.c only supports certain fixed values, the closest ones being 12 or 14 ms and pinctrl-baytrail.c responds with -EINVAL when specified a value which is not one of the fixed values.

This is causing the acpi_request_own_gpiod() call to fail for 3 ACPI event sources on the HP ElitePad 1000 G2, which in turn is causing e.g. the battery charging vs discharging status to never get updated, even though a charger has been plugged-in or unplugged.

Make gpio_set_debounce_timeout() errors non fatal, warning about the failure instead, to fix this regression.

Note we should probably also fix various pinctrl drivers to just pick the first bigger discrete value rather then returning -EINVAL but this will need to be done on a per driver basis, where as this fix at least gets us back to where things were before and thus restores functionality on devices where this was lost due to gpio_set_debounce_timeout() errors.

Quoted 2 lines
Fixes 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings")

Bartosz will pick this up I think, I'm a bit off duty with GPIO right now.

Yours,
Linus Walleij

#4 lore raw

Hi,

Quoted 29 lines · Linus Walleij
Quoted 27 lines · Hans de Goede

Commit 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings") made the gpiolib-acpi code call gpio_set_debounce_timeout() when requesting GPIOs.

This in itself is fine, but it also made gpio_set_debounce_timeout() errors fatal, causing the requesting of the GPIO to fail. This is causing regressions. E.g. on a HP ElitePad 1000 G2 various _AEI specified GPIO ACPI event sources specify a debouncy timeout of 20 ms, but the pinctrl-baytrail.c only supports certain fixed values, the closest ones being 12 or 14 ms and pinctrl-baytrail.c responds with -EINVAL when specified a value which is not one of the fixed values.

This is causing the acpi_request_own_gpiod() call to fail for 3 ACPI event sources on the HP ElitePad 1000 G2, which in turn is causing e.g. the battery charging vs discharging status to never get updated, even though a charger has been plugged-in or unplugged.

Make gpio_set_debounce_timeout() errors non fatal, warning about the failure instead, to fix this regression.

Note we should probably also fix various pinctrl drivers to just pick the first bigger discrete value rather then returning -EINVAL but this will need to be done on a per driver basis, where as this fix at least gets us back to where things were before and thus restores functionality on devices where this was lost due to gpio_set_debounce_timeout() errors.

Quoted 6 lines
Quoted 2 lines
Fixes 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings")

Bartosz will pick this up I think, I'm a bit off duty with GPIO right now.

Added Bartosz to the To: list, to make sure that he actually sees this. I somehow did not add him in the To/Cc when sending out the patch, sorry about that.

Regards,

Hans

#5 lore raw
Quoted 36 lines · Hans de Goede

Hi,

Quoted 32 lines · Linus Walleij
Quoted 29 lines · Hans de Goede

Commit 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings") made the gpiolib-acpi code call gpio_set_debounce_timeout() when requesting GPIOs.

This in itself is fine, but it also made gpio_set_debounce_timeout() errors fatal, causing the requesting of the GPIO to fail. This is causing regressions. E.g. on a HP ElitePad 1000 G2 various _AEI specified GPIO ACPI event sources specify a debouncy timeout of 20 ms, but the pinctrl-baytrail.c only supports certain fixed values, the closest ones being 12 or 14 ms and pinctrl-baytrail.c responds with -EINVAL when specified a value which is not one of the fixed values.

This is causing the acpi_request_own_gpiod() call to fail for 3 ACPI event sources on the HP ElitePad 1000 G2, which in turn is causing e.g. the battery charging vs discharging status to never get updated, even though a charger has been plugged-in or unplugged.

Make gpio_set_debounce_timeout() errors non fatal, warning about the failure instead, to fix this regression.

Note we should probably also fix various pinctrl drivers to just pick the first bigger discrete value rather then returning -EINVAL but this will need to be done on a per driver basis, where as this fix at least gets us back to where things were before and thus restores functionality on devices where this was lost due to gpio_set_debounce_timeout() errors.

Fixes 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings")
Quoted 8 lines
Quoted 3 lines

Bartosz will pick this up I think, I'm a bit off duty with GPIO right now.

Added Bartosz to the To: list, to make sure that he actually sees this. I somehow did not add him in the To/Cc when sending out the patch, sorry about that.

Yep, I only process patches that are directed to me personally (TO or CC).

Now applied but I'll only be able to send it out for v5.15-rc3.

Bart

#6 lore raw
Quoted 3 lines · Bartosz Golaszewski
Quoted 2 lines · Hans de Goede
Quoted 1 line · Linus Walleij

On Mon, Aug 16, 2021 at 11:39 AM Hans de Goede <[email protected]> wrote:

...

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Fixes 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings")
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Bartosz will pick this up I think, I'm a bit off duty with GPIO right now.

Added Bartosz to the To: list, to make sure that he actually sees this. I somehow did not add him in the To/Cc when sending out the patch, sorry about that.

Yep, I only process patches that are directed to me personally (TO or CC).

Hmm... It's then strange that GPIO lib ACPI is not listed for you in MAINTAINERS.
Perhaps we need to update MAINTAINERS as well.

Quoted 1 line

Now applied but I'll only be able to send it out for v5.15-rc3.

Thanks!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw
Quoted 20 lines · Andy Shevchenko
Quoted 3 lines · Bartosz Golaszewski
Quoted 2 lines · Hans de Goede
Quoted 1 line · Linus Walleij

On Mon, Aug 16, 2021 at 11:39 AM Hans de Goede <[email protected]> wrote:

...

Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
Quoted 2 lines
Fixes 8dcb7a15a585 ("gpiolib: acpi: Take into account debounce settings")

Bartosz will pick this up I think, I'm a bit off duty with GPIO right now.

Added Bartosz to the To: list, to make sure that he actually sees this. I somehow did not add him in the To/Cc when sending out the patch, sorry about that.

Quoted 6 lines
Quoted 1 line

Yep, I only process patches that are directed to me personally (TO or CC).

Hmm... It's then strange that GPIO lib ACPI is not listed for you in MAINTAINERS.
Perhaps we need to update MAINTAINERS as well.

With the following line in MAINTAINERS:

    7998 F:      drivers/gpio/

My name should pop up for all patches aimed at the GPIO subsystem if one uses scripts/get_maintainer.pl.

Bart