Re: [PATCH] reset: gpio: Keep reset-gpio device under the GPIO controller device

From: Philipp Zabel

Date: Tue Dec 01 2026 - 11:57:50 EST


On Di, 2026-12-01 at 17:28 +0100, Birk Skyum via B4 Relay wrote:
> From: Birk Skyum <birk.skyum@xxxxx>
>
> reset-gpio auxiliary devices are persistent subsystem devices that are
> never removed, but they are created as children of the GPIO device
> (gpiochipN). That GPIO device is unregistered whenever the GPIO
> controller's driver unbinds and recreated when it binds again.
>
> On a Lenovo Yoga Slim 7x (X1E80100), the WSA884x speaker amplifiers
> share reset GPIOs on the LPASS LPI pin controller. Because that
> controller depends on clocks supplied by the audio DSP, it unbinds and
> rebinds whenever the ADSP restarts (such as after crash recovery,
> driver reload, or resuming from hibernation). The reset-gpio auxiliary
> devices are then left attached to the deleted GPIO device, subsequent
> probes fail with "really_probe: driver_sysfs_add failed", the speakers
> never acquire their reset line, and the sound card cannot return.
>
> Parent the reset-gpio auxiliary device under the GPIO device's parent
> (the GPIO controller device, which persists across driver unbind/rebind)
> when available, and add a DL_FLAG_AUTOPROBE_CONSUMER device link to it
> so the reset-gpio driver unbinds with the controller and probes again
> once it returns. Tested on a Lenovo Yoga Slim 7x across ADSP reloads
> and five consecutive hibernation cycles.
>
> Fixes: 46dae84a90f9 ("reset: make the provider of reset-gpios the parent of the reset device")
> Signed-off-by: Birk Skyum <birk.skyum@xxxxx>
> ---
> drivers/reset/core.c | 28 +++++++++++++++++++++++++---
> 1 file changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
> index 38e189d04..09bb7784c 100644
> --- a/drivers/reset/core.c
> +++ b/drivers/reset/core.c
> @@ -1015,7 +1015,7 @@ static int __reset_add_reset_gpio_device(struct fwnode_handle *fwnode,
> struct property_entry properties[3] = { };
> unsigned int offset, flags, lflags;
> struct reset_gpio_lookup *rgpio_dev;
> - struct device *parent;
> + struct device *gdev_dev, *parent;
> int ret, prop = 0;
>
> /*
> @@ -1070,9 +1070,20 @@ static int __reset_add_reset_gpio_device(struct fwnode_handle *fwnode,
> }
>
> lflags = GPIO_PERSISTENT | (flags & GPIO_ACTIVE_LOW);
> - parent = gpio_device_to_device(gdev);
> + gdev_dev = gpio_device_to_device(gdev);
> properties[prop++] = PROPERTY_ENTRY_STRING("compatible", "reset-gpio");
> - properties[prop++] = PROPERTY_ENTRY_GPIO("reset-gpios", parent->fwnode, offset, lflags);
> + properties[prop++] = PROPERTY_ENTRY_GPIO("reset-gpios", gdev_dev->fwnode, offset, lflags);
> +
> + /*
> + * The reset-gpio device is never removed, but the GPIO device goes
> + * away whenever the GPIO controller's driver unbinds, for example the
> + * LPASS pin controller when the audio DSP restarts. A reset-gpio
> + * device left under the old GPIO device can never bind again
> + * ("driver_sysfs_add failed"). Put it under the device that provides
> + * the GPIO controller instead, which stays, and link it to that
> + * device below so it follows the controller's driver.
> + */
> + parent = gdev_dev->parent ?: gdev_dev;
>
> /* Not freed on success, because it is persisent subsystem data. */
> rgpio_dev = kzalloc_obj(*rgpio_dev);

This part is already covered by [1].

[1] https://lore.kernel.org/all/20261026-b4-reset-gpio-parent-to-gpio-controller-v1-1-11549e6ea930@xxxxxxxxxxxxxxxx/

Could you test if that fixes your issue?

> @@ -1097,6 +1108,17 @@ static int __reset_add_reset_gpio_device(struct fwnode_handle *fwnode,
> if (ret)
> goto err_del_swnode;
>
> + /*
> + * Unbind when the GPIO controller's driver unbinds and probe again
> + * when it is back, so the reset controller never holds GPIO

The comment above says reset-gpio is never removed. How can this be
true at the same time?

regards
Philipp