mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: birk.skyum@pm.me
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
Subject: Re: [PATCH] reset: gpio: Keep reset-gpio device under the GPIO controller device
Date: Tue, 01 Dec 2026 17:57:36 +0100	[thread overview]
Message-ID: <618fb869a169e5783a0e079f33db512b17b094ce.camel@pengutronix.de> (raw)
In-Reply-To: <20261201-reset-gpio-parent-devlink-v1-1-5195e8b377c4@pm.me>

On Di, 2026-12-01 at 17:28 +0100, Birk Skyum via B4 Relay wrote:
> 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);

This part is already covered by [1].

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

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

      reply	other threads:[~2026-12-01 16:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 16:28 Birk Skyum via B4 Relay
2026-12-01 16:57 ` Philipp Zabel [this message]

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=618fb869a169e5783a0e079f33db512b17b094ce.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --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 \
    /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®