From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796036846; b=Wz+CzM8p7nuzkyXnsY1f0mMVmDjYu+FTjwQVcbAmIbNCl7+GQTJWvEgkqHZp6VW4qTjB Ts5xoBQkZaC30n1HD71iWU8/X7ydUwKCogywgTRVtCQmxCzofMgA1NqIjNIJ0MiWwRfTA kxJm9++W0o5v9XtfKeClpG7Oqcr0RXxvcaAO0vHeLDrCzZnIzdMThUC4LupBonqb3leLT 6AwwuoMyCEDC42s57k/sdtHv1YEfZiVrrh/hav17eLPcqkj7gp7e56Rrz+iQmaWNu1kzW dTQFbzmq/1Omn7rWVVqnNDTQ/SkvwP0Ocb8rZUInU5IDzBPd7iiMTrbjdiKeyn8+QQA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796036846; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=6VDzksuugGTPHVNdMjU+6c9yb9iGD9M8VOrsawN+JQg=; b=Tt5akI67YSpgihkFq7ehA7cvfI3r56hx1wkI1gmhxUZRd21KYsITwtMQ+Eh6F/kyE7pA XjbxyF2hzYjX5obQKo3vQnt23NqRvn4Dj6zf5J1GZFmsoBVZgrZXFNHYOlCKomVG1q3tr sp7DgAtyYenR8zgHGliERHVWIW7UlDVKTbUFbFlEp13KYmJdp/3ImeXGSINjCB+Suf0NM V71406yL6CC+UgI9Kz22KjnYk64+K0CyM3cvVqkP/uH196UW7+COH7jCCRXFHlxNacwe9 6B1ALtTCtH51758jkH5VCIbIrNPzGoVl10p6io7c1x1HC1fOiQiKFa4LUZosefgFZ3Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XGGQgmer; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id C9051606A31C; Mon, 30 Nov 2026 11:07:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XGGQgmer Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 913911F00896; Mon, 30 Nov 2026 11:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796036846; bh=6VDzksuugGTPHVNdMjU+6c9yb9iGD9M8VOrsawN+JQg=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=XGGQgmerlNpBrZdVc5GjIKTA0G+gzDavSj9wnJUwRl6o2ge+IqVaxE01uO3X6DSC+ IbtrSQO6VSvYhxUKm+IV+sfVRi8/jBRE7pTPdEB4+Fw0wRFqfNJYQBpg3A7UC4Xveh K7U4D/kW89K3avLuzou221oVl/YAyNLXxLhtMB0pldXyZmm3ZJGnwTaieGJdZqDJ4g rOGfENt+LmJppXfRdS+nIObv9rYJA2bsefYMWUaHHjrAtaUYu+ozVwTelzSsiudYKN a9SadsZbyDUFvge3EfMPoGe4A/BkEZC2jra9WsiCo5D+WTWpO+N8IsJu6u7Cwku/+X 3jfvM/w9d2NIg== Date: Mon, 30 Nov 2026 12:07:23 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Myeonghun Pak Cc: Thierry Reding , Jonathan Hunter , Mikko Perttunen , Dmitry Osipenko , Ulf Hansson , linux-pwm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Ijae Kim Subject: Re: [PATCH v2] pwm: tegra: Use managed runtime PM cleanup Message-ID: References: <20260914223512.31049-1-mhun512@gmail.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="r74bmhbzpupejghy" Content-Disposition: inline In-Reply-To: <20260914223512.31049-1-mhun512@gmail.com> --r74bmhbzpupejghy Content-Type: text/plain; protected-headers=v1; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH v2] pwm: tegra: Use managed runtime PM cleanup MIME-Version: 1.0 Hello, On Mon, Sep 14, 2026 at 06:35:12PM -0400, Myeonghun Pak wrote: > Runtime PM remains enabled if the initial resume fails or force-suspend > fails during probe unwind or removal. >=20 > Use devm_pm_runtime_enable() and replace the force-suspend calls with a > managed hardware cleanup action. Order cleanup so runtime PM is disabled > before turning off the clock and selecting sleep pinctrl for an active > device. Preserve the probe error and usage-count handling. >=20 > This issue was identified during our ongoing static-analysis research whi= le > reviewing kernel code. >=20 > Fixes: 3da9b0feaa16 ("pwm: tegra: Add runtime PM and OPP support") > Cc: stable@vger.kernel.org > Assisted-by: OpenAI:GPT-5.6 > Co-developed-by: Ijae Kim > Signed-off-by: Ijae Kim > Signed-off-by: Myeonghun Pak > --- > Changes in v2: > - Use devm_pm_runtime_enable(), as suggested by Mikko Perttunen. > - Replace probe/remove force-suspend calls with ordered managed cleanup. > - Retain clock cleanup for devices that remain active at teardown. >=20 > drivers/pwm/pwm-tegra.c | 26 ++++++++++++++++++++++---- > 1 file changed, 22 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c > index 5cdbe12..b68b690 100644 > --- a/drivers/pwm/pwm-tegra.c > +++ b/drivers/pwm/pwm-tegra.c > @@ -314,6 +314,19 @@ static const struct pwm_ops tegra_pwm_ops =3D { > .apply =3D tegra_pwm_apply, > }; > =20 > +static void tegra_pwm_cleanup(void *data) > +{ > + struct device *dev =3D data; > + struct pwm_chip *chip =3D dev_get_drvdata(dev); > + struct tegra_pwm_chip *pc =3D to_tegra_pwm_chip(chip); > + > + if (!IS_ENABLED(CONFIG_PM) || pm_runtime_status_suspended(dev)) > + return; > + > + clk_disable_unprepare(pc->clk); > + pinctrl_pm_select_sleep_state(dev); > +} > + > static int tegra_pwm_probe(struct platform_device *pdev) > { > struct pwm_chip *chip; > @@ -344,7 +357,15 @@ static int tegra_pwm_probe(struct platform_device *p= dev) > if (ret) > return ret; > =20 > - pm_runtime_enable(&pdev->dev); > + /* Disable runtime PM before cleaning up the hardware. */ > + ret =3D devm_add_action_or_reset(&pdev->dev, tegra_pwm_cleanup, &pdev->= dev); > + if (ret) > + return ret; > + > + ret =3D devm_pm_runtime_enable(&pdev->dev); > + if (ret) > + return ret; > + > ret =3D pm_runtime_resume_and_get(&pdev->dev); > if (ret) > return ret; > @@ -395,7 +416,6 @@ static int tegra_pwm_probe(struct platform_device *pd= ev) > return 0; > put_pm: > pm_runtime_put_sync_suspend(&pdev->dev); > - pm_runtime_force_suspend(&pdev->dev); > return ret; > } > =20 > @@ -407,8 +427,6 @@ static void tegra_pwm_remove(struct platform_device *= pdev) > pwmchip_remove(chip); > =20 > reset_control_assert(pc->rst); > - > - pm_runtime_force_suspend(&pdev->dev); > } > =20 > static int __maybe_unused tegra_pwm_runtime_suspend(struct device *dev) I admit that runtime PM is a blind spot for me but I wonder if the PWM core could be extended (e.g. by doing runtime PM on the chip's device) which could then simplify (and unify) power management for the individual drivers. This is on my todo list to evaluate, and I intend to postpone this patch until after that. But feel free to convince me that this fix is relevant enough in practise to not wait that long. Best regards Uwe --r74bmhbzpupejghy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmsNWOkACgkQj4D7WH0S /k7+8gf/Tzqnqo2ONzkrUtFBeeckaA0vMMI0kGYeN2THf0kJKyrI8SitcFVCqFoS hy0ceh67WrWS7PXOf/dBjA1nkmCUWEoI9kdRBcOoIPLPBSuXHW/DAULIP1cHfqB0 /oJplIcirLdMrgdI/1aLtRwVMd/l/SHG4mTIhgm8uDscsYc4y9kcyrNzz7Hu3xfD Vqj0zTsUBbsA76gUwEZE1TcEL0mjsO41ShHG3hiHMHu4zR06/eBpWIPJI+QGFzka EMPicv/zA+dbV6ac8EhQubxSkT2JccnDfAOF6Pb+8V2OGFdENBUrTtrHyVZrnNul xWjF7ck6RwG4mLr8cmdbua+8FCcFjQ== =WSDQ -----END PGP SIGNATURE----- --r74bmhbzpupejghy--