Re: [PATCH 5.4 regression fix] Input: soc_button_array - partial revert of support for newer surface devices

From: Hans de Goede
Date: Sat Oct 05 2019 - 09:21:24 EST


Hi,

On 05-10-2019 14:17, Maximilian Luz wrote:
Hi,

sorry for the inconvenience this change has caused.

On 10/5/19 12:55 PM, Hans de Goede wrote:
Note ideally this seamingly unrelated change would have been made in a
separate commit, with a message explaining the what and why of this
change.

Would I have known the impact, then yes. This change was added due to
some reported instances where it seems that soc_button_array would
occasionally load on MSHW0040 before the GPIO controller was ready,
causing power and volume buttons to not work.

I guess this change may have been added to deal with -EPROBE_DEFER errors,

Correct. After a comment mentioned that gpiod_get() returning
-EPROBE_DEFER would be the proper way to detect this, I decided on this
change.

Ok, on x86 the GPIO drivers really should all be builtin because
various ACPI methods including device D0 / D3 (power-on/off) methods
may depend on them. So normally this should never happen.

If this (-EPROBE_DEFER on surface devices) somehow still is happening
please let me know and we will figure something out.

Might I suggest the following addition:

Signed-off-by: Maximilian Luz <luzmaximilian@xxxxxxxxx>

S-o-b is only for patches which pass through your hands, e.g. if
you make changes to my patch and submit a v2 of it.

I guess you mean / want one of:

Acked-by: ...

or

Reviewed-by: ...


?

Regards,

Hans



---
Âdrivers/input/misc/soc_button_array.c | 25 ++++++++++++++++++++-----
Â1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index 97e3639e99d0..a0f0c977b790 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -92,11 +92,18 @@ soc_button_device_create(struct platform_device *pdev,
ÂÂÂÂÂÂÂÂÂÂÂÂ continue;

ÂÂÂÂÂÂÂÂ gpio = soc_button_lookup_gpio(&pdev->dev, info->acpi_index);
-ÂÂÂÂÂÂÂ if (gpio < 0 && gpio != -ENOENT) {
-ÂÂÂÂÂÂÂÂÂÂÂ error = gpio;
-ÂÂÂÂÂÂÂÂÂÂÂ goto err_free_mem;
-ÂÂÂÂÂÂÂ } else if (!gpio_is_valid(gpio)) {
-ÂÂÂÂÂÂÂÂÂÂÂ /* Skip GPIO if not present */
+ÂÂÂÂÂÂÂ if (!gpio_is_valid(gpio)) {
+ÂÂÂÂÂÂÂÂÂÂÂ /*
+ÂÂÂÂÂÂÂÂÂÂÂÂ * Skip GPIO if not present. Note we deliberately
+ÂÂÂÂÂÂÂÂÂÂÂÂ * ignore -EPROBE_DEFER errors here. On some devices
+ÂÂÂÂÂÂÂÂÂÂÂÂ * Intel is using so called virtual GPIOs which are not
+ÂÂÂÂÂÂÂÂÂÂÂÂ * GPIOs at all but some way for AML code to check some
+ÂÂÂÂÂÂÂÂÂÂÂÂ * random status bits without need a custom opregion.
+ÂÂÂÂÂÂÂÂÂÂÂÂ * In some cases the resources table we parse points to
+ÂÂÂÂÂÂÂÂÂÂÂÂ * such a virtual GPIO, since these are not real GPIOs
+ÂÂÂÂÂÂÂÂÂÂÂÂ * we do not have a driver for these so they will never
+ÂÂÂÂÂÂÂÂÂÂÂÂ * show up, therefor we ignore -EPROBE_DEFER.
+ÂÂÂÂÂÂÂÂÂÂÂÂ */
ÂÂÂÂÂÂÂÂÂÂÂÂ continue;
ÂÂÂÂÂÂÂÂ }

@@ -429,6 +436,14 @@ static int soc_device_check_MSHW0040(struct device *dev)

ÂÂÂÂ dev_dbg(dev, "OEM Platform Revision %llu\n", oem_platform_rev);

+ÂÂÂ /*
+ÂÂÂÂ * Explicitly check if GPIO controller is ready. This check is done here
+ÂÂÂÂ * to avoid issues with virtual GPIOs on other chips, as elaborated above.
+ÂÂÂÂ * We are at least expecting one GPIO pin for the power button (index 0).
+ÂÂÂÂ */
+ÂÂÂ if (soc_button_lookup_gpio(dev, 0) == -EPROBE_DEFER)
+ÂÂÂÂÂÂÂ return -EPROBE_DEFER;
+
ÂÂÂÂ return 0;
Â}