From: Birk Skyum via B4 Relay <devnull+birk.skyum.pm.me@kernel.org>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
linux-gpio@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Birk Skyum <birk.skyum@pm.me>
Subject: [PATCH] reset: gpio: Keep reset-gpio device under the GPIO controller device
Date: Tue, 01 Dec 2026 17:28:10 +0100 [thread overview]
Message-ID: <20261201-reset-gpio-parent-devlink-v1-1-5195e8b377c4@pm.me> (raw)
From: Birk Skyum <birk.skyum@pm.me>
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@pm.me>
---
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@pm.me>
next reply other threads:[~2026-12-01 16:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 16:28 Birk Skyum via B4 Relay [this message]
2026-12-01 16:57 ` Philipp Zabel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201-reset-gpio-parent-devlink-v1-1-5195e8b377c4@pm.me \
--to=devnull+birk.skyum.pm.me@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=birk.skyum@pm.me \
--cc=krzk@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®