Re: [PATCH 4.13 015/109] pinctrl/amd: save pin registers over suspend/resume

From: Petr Mladek
Date: Tue Sep 26 2017 - 10:07:53 EST


On Sun 2017-09-24 22:32:36, Greg Kroah-Hartman wrote:
> 4.13-stable review patch. If anyone has any objections, please let me know.
>
> ------------------
>
> From: Daniel Drake <drake@xxxxxxxxxxxx>
>
> commit 79d2c8bede2c93f9432d7da0bc2f76a195c90fc0 upstream.
>
> The touchpad in the Asus laptop models X505BA/BP and X542BA/BP is
> unresponsive after suspend/resume. The following error appears during
> resume:
>
> i2c_hid i2c-ELAN1300:00: failed to reset device.
>
> The problem here is that i2c_hid does not notice the interrupt being
> generated at this point, because the GPIO is no longer configured
> for interrupts.
>
> Fix this by saving pinctrl-amd pin registers during suspend and
> restoring them at resume time.
>
> Based on code from pinctrl-intel.
>
> Signed-off-by: Daniel Drake <drake@xxxxxxxxxxxx>
> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
>
> --- a/drivers/pinctrl/pinctrl-amd.c
> +++ b/drivers/pinctrl/pinctrl-amd.c
> @@ -725,6 +726,69 @@ static const struct pinconf_ops amd_pinc
> .pin_config_group_set = amd_pinconf_group_set,
> };
>
> +#ifdef CONFIG_PM_SLEEP
> +static bool amd_gpio_should_save(struct amd_gpio *gpio_dev, unsigned int pin)
> +{
> + const struct pin_desc *pd = pin_desc_get(gpio_dev->pctrl, pin);
> +
> + if (!pd)
> + return false;
> +
> + /*
> + * Only restore the pin if it is actually in use by the kernel (or
> + * by userspace).
> + */
> + if (pd->mux_owner || pd->gpio_owner ||

This code causes a compilation error in the current Linus' tree
(4.14-rc2+). I guess that the same problem will be also in
older trees.

IMHO, we need to select CONFIG_PINMUX for when CONFIG_PINCTRL_AMD
is selected. The following patch helped here: