From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, "Uwe Kleine-König" <ukleinek@kernel.org>,
"Sai Masarapu" <Sai.Masarapu@imgtec.com>,
"Vladimir Zapolskiy" <vladimir_zapolskiy@mentor.com>,
"Naidu Tellapati" <naidu.tellapati@gmail.com>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Andrew Bresticker" <abrestic@chromium.org>,
linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH v2 5/5] pwm: img: Unregister PWM chip before disabling runtime PM and clocks
Date: Mon, 23 Nov 2026 07:52:55 +0000 [thread overview]
Message-ID: <20261123075320.379664-6-lee@kernel.org> (raw)
In-Reply-To: <20261123075320.379664-1-lee@kernel.org>
img_pwm_remove() disables runtime PM and gates the peripheral clocks via
img_pwm_runtime_suspend() before calling pwmchip_remove(). While the
PWM chip is still registered, a consumer can call img_pwm_apply(), where
pm_runtime_resume_and_get() fails with -EACCES or img_pwm_disable()
writes to unclocked registers after img_pwm_runtime_suspend() has gated
the clocks.
Call pwmchip_remove() before disabling runtime PM, clearing autosuspend,
and suspending the device. Because chip and its private data are
allocated with devm_pwmchip_alloc(), driver data remains valid for any
pending runtime PM callbacks invoked during pm_runtime_disable() and
img_pwm_runtime_suspend() until devres teardown runs after
img_pwm_remove() returns.
Fixes: 277bb6a29e00 ("pwm: Imagination Technologies PWM DAC driver")
Closes: https://sashiko.dev/#/bug/linux-b06bab8d-dbf2-4ba2-9f5d-c5e141076abd
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
v1 => v2:
- Clear autosuspend in img_pwm_remove() and document why driver data
remains valid for runtime PM callbacks after pwmchip_remove() (Uwe)
drivers/pwm/pwm-img.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
index 91e0b19f0c08..7bf086b127c2 100644
--- a/drivers/pwm/pwm-img.c
+++ b/drivers/pwm/pwm-img.c
@@ -338,11 +338,12 @@ static void img_pwm_remove(struct platform_device *pdev)
{
struct pwm_chip *chip = platform_get_drvdata(pdev);
- pm_runtime_disable(&pdev->dev);
- if (!pm_runtime_status_suspended(&pdev->dev))
- img_pwm_runtime_suspend(&pdev->dev);
-
pwmchip_remove(chip);
+
+ pm_runtime_disable(&pdev->dev);
+ pm_runtime_dont_use_autosuspend(&pdev->dev);
+ if (!pm_runtime_status_suspended(&pdev->dev))
+ img_pwm_runtime_suspend(&pdev->dev);
}
#ifdef CONFIG_PM_SLEEP
--
2.56.1.750.gf70dc682cf-goog
prev parent reply other threads:[~2026-11-23 7:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 7:52 [PATCH v2 0/5] pwm: Fix various bugs reported by Sashiko Lee Jones
2026-11-23 7:52 ` [PATCH v2 1/5] pwm: mxs: Return early when disabling and fix error-path clock leak Lee Jones
2026-11-23 7:52 ` [PATCH v2 2/5] pwm: fsl-ftm: Enable ipg_clk around regcache_sync() during resume Lee Jones
2026-11-23 7:52 ` [PATCH v2 3/5] pwm: omap-dmtimer: Propagate get_pwm_status() errors in apply() Lee Jones
2026-11-23 7:52 ` [PATCH v2 4/5] pwm: tiehrpwm: Enable runtime PM before registering PWM chip Lee Jones
2026-11-23 7:52 ` Lee Jones [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=20261123075320.379664-6-lee@kernel.org \
--to=lee@kernel.org \
--cc=Sai.Masarapu@imgtec.com \
--cc=abrestic@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=naidu.tellapati@gmail.com \
--cc=stable@vger.kernel.org \
--cc=thierry.reding@gmail.com \
--cc=ukleinek@kernel.org \
--cc=vladimir_zapolskiy@mentor.com \
/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