[PATCH] reset: gpio: Keep reset-gpio device under the GPIO controller device
From: Birk Skyum via B4 Relay
Date: Tue Dec 01 2026 - 11:28:40 EST
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);
@@ -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
+ * descriptors of a removed chip.
+ */
+ if (parent != gdev_dev &&
+ !device_link_add(&rgpio_dev->adev.dev, parent,
+ DL_FLAG_AUTOPROBE_CONSUMER))
+ pr_warn("Failed to link reset-gpio device %s to its GPIO controller\n",
+ dev_name(&rgpio_dev->adev.dev));
+
reset_gpio_add_devlink(fwnode, rgpio_dev);
list_add(&rgpio_dev->list, &reset_gpio_lookup_list);
---
base-commit: ef922b721a5e99348fc1f5801fdeb427ee14ee9f
change-id: 20261201-reset-gpio-parent-devlink-4b1149416a5f
Best regards,
--
Birk Skyum <birk.skyum@xxxxx>