* [PATCH v2] i2c: xiic: restore runtime PM teardown in remove to fix clk WARN flood
@ 2026-08-14 18:04 Abdurrahman Hussain
2026-08-16 16:14 ` Andi Shyti
0 siblings, 1 reply; 6+ messages in thread
From: Abdurrahman Hussain @ 2026-08-14 18:04 UTC (permalink / raw)
To: Michal Simek, Andi Shyti, Andy Shevchenko
Cc: linux-arm-kernel, linux-i2c, linux-kernel, Abdurrahman Hussain
The devres conversion dropped the remove-time runtime PM trailer
(pm_runtime_disable + pm_runtime_set_suspended +
pm_runtime_dont_use_autosuspend). devm_pm_runtime_enable's release
action then calls pm_runtime_dont_use_autosuspend() while runtime PM
is still enabled, triggering an immediate runtime suspend: the suspend
callback clk_disable()s the clock that the devm_clk_get_enabled()
release is about to clk_disable_unprepare(), and every device teardown
WARNs in clk_core_disable() ("clkN already disabled").
Restore the trailer: with runtime PM disabled and the state forced to
suspended before devres runs, the suspend callback cannot fire and the
clock enable count stays balanced.
Fixes: 50c63491ff26 ("i2c: xiic: switch to devres managed APIs")
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
Changes in v2:
- Move the Signed-off-by into the commit message proper; v1 had it below
the '---' cutter line where it would be dropped on apply (Andy).
- Link to v1: https://patch.msgid.link/20260813-i2c-xiic-restore-runtime-pm-teardown-v1-1-0e7dfb206790@nexthop.ai
To: Michal Simek <michal.simek@amd.com>
To: Andi Shyti <andi.shyti@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Abdurrahman Hussain <abdurrahman@nexthop.ai>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-i2c@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/i2c/busses/i2c-xiic.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 3e7735e1dae0..89636ca36915 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1545,6 +1545,9 @@ static void xiic_i2c_remove(struct platform_device *pdev)
xiic_deinit(i2c);
pm_runtime_put_sync(dev);
+ pm_runtime_disable(dev);
+ pm_runtime_set_suspended(dev);
+ pm_runtime_dont_use_autosuspend(dev);
}
static const struct dev_pm_ops xiic_dev_pm_ops = {
---
base-commit: d58772d8520c7ef247c4b95c9bd76d3a25da9ff5
change-id: 20260813-i2c-xiic-restore-runtime-pm-teardown-dd0ab1db2c02
Best regards,
--
Abdurrahman Hussain <abdurrahman@nexthop.ai>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] i2c: xiic: restore runtime PM teardown in remove to fix clk WARN flood
2026-08-14 18:04 [PATCH v2] i2c: xiic: restore runtime PM teardown in remove to fix clk WARN flood Abdurrahman Hussain
@ 2026-08-16 16:14 ` Andi Shyti
2026-08-16 20:11 ` Abdurrahman Hussain
0 siblings, 1 reply; 6+ messages in thread
From: Andi Shyti @ 2026-08-16 16:14 UTC (permalink / raw)
To: Abdurrahman Hussain
Cc: Michal Simek, Andy Shevchenko, linux-arm-kernel, linux-i2c,
linux-kernel
Hi Abdurrahman,
On Fri, Aug 14, 2026 at 11:04:45AM -0700, Abdurrahman Hussain wrote:
> The devres conversion dropped the remove-time runtime PM trailer
> (pm_runtime_disable + pm_runtime_set_suspended +
> pm_runtime_dont_use_autosuspend). devm_pm_runtime_enable's release
> action then calls pm_runtime_dont_use_autosuspend() while runtime PM
> is still enabled, triggering an immediate runtime suspend: the suspend
> callback clk_disable()s the clock that the devm_clk_get_enabled()
> release is about to clk_disable_unprepare(), and every device teardown
> WARNs in clk_core_disable() ("clkN already disabled").
isn't devm_pm_runtime_set_active_enabled() calling
pm_runtime_disable() + pm_runtime_set_suspended() +
pm_runtime_dont_use_autosuspend() at teardown?
Thanks,
Andi
> Restore the trailer: with runtime PM disabled and the state forced to
> suspended before devres runs, the suspend callback cannot fire and the
> clock enable count stays balanced.
>
> Fixes: 50c63491ff26 ("i2c: xiic: switch to devres managed APIs")
> Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
> ---
> Changes in v2:
> - Move the Signed-off-by into the commit message proper; v1 had it below
> the '---' cutter line where it would be dropped on apply (Andy).
> - Link to v1: https://patch.msgid.link/20260813-i2c-xiic-restore-runtime-pm-teardown-v1-1-0e7dfb206790@nexthop.ai
>
> To: Michal Simek <michal.simek@amd.com>
> To: Andi Shyti <andi.shyti@kernel.org>
> To: Andy Shevchenko <andriy.shevchenko@intel.com>
> To: Abdurrahman Hussain <abdurrahman@nexthop.ai>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-i2c@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
> drivers/i2c/busses/i2c-xiic.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
> index 3e7735e1dae0..89636ca36915 100644
> --- a/drivers/i2c/busses/i2c-xiic.c
> +++ b/drivers/i2c/busses/i2c-xiic.c
> @@ -1545,6 +1545,9 @@ static void xiic_i2c_remove(struct platform_device *pdev)
> xiic_deinit(i2c);
>
> pm_runtime_put_sync(dev);
> + pm_runtime_disable(dev);
> + pm_runtime_set_suspended(dev);
> + pm_runtime_dont_use_autosuspend(dev);
> }
>
> static const struct dev_pm_ops xiic_dev_pm_ops = {
>
> ---
> base-commit: d58772d8520c7ef247c4b95c9bd76d3a25da9ff5
> change-id: 20260813-i2c-xiic-restore-runtime-pm-teardown-dd0ab1db2c02
>
> Best regards,
> --
> Abdurrahman Hussain <abdurrahman@nexthop.ai>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] i2c: xiic: restore runtime PM teardown in remove to fix clk WARN flood
2026-08-16 16:14 ` Andi Shyti
@ 2026-08-16 20:11 ` Abdurrahman Hussain
2026-08-17 19:20 ` Andi Shyti
0 siblings, 1 reply; 6+ messages in thread
From: Abdurrahman Hussain @ 2026-08-16 20:11 UTC (permalink / raw)
To: Andi Shyti, Abdurrahman Hussain
Cc: Michal Simek, Andy Shevchenko, linux-arm-kernel, linux-i2c,
linux-kernel
On Sun Aug 16, 2026 at 9:14 AM PDT, Andi Shyti wrote:
> Hi Abdurrahman,
>
Hi Andi,
On Sun, Aug 16, 2026 at 06:14:08PM +0200, Andi Shyti wrote:
> isn't devm_pm_runtime_set_active_enabled() calling
> pm_runtime_disable() + pm_runtime_set_suspended() +
> pm_runtime_dont_use_autosuspend() at teardown?
It does call all three, but the ordering defeats it, in two places:
1. Within the helper's own release, pm_runtime_disable_action() calls
pm_runtime_dont_use_autosuspend() *before* pm_runtime_disable() --
i.e. while runtime PM is still enabled.
2. devres is LIFO, and devm_clk_get_enabled() is registered before
devm_pm_runtime_set_active_enabled() in probe(), so the clock's
clk_disable_unprepare() release runs *after* the runtime-PM releases.
pm_runtime_put_sync() in remove() leaves the device RPM_ACTIVE with the
autosuspend timer armed: rpm_idle() falls through to
rpm_suspend(RPM_AUTO), the delay hasn't expired, so it just re-arms the
timer -- runtime_status stays ACTIVE and the clock stays enabled.
Then the devres teardown runs. pm_runtime_dont_use_autosuspend() clears
use_autosuspend; update_autosuspend() takes the else branch and calls
rpm_idle(RPM_AUTO), but now pm_runtime_autosuspend_expiration() returns
0, so rpm_suspend() no longer defers and suspends immediately --
xiic_i2c_runtime_suspend() clk_disable()s the clock, all while runtime
PM is still enabled. A moment later, further down the LIFO chain,
devm_clk_get_enabled()'s release does clk_disable_unprepare() on the
already-disabled clock and clk_core_disable() WARNs, once per device.
Calling pm_runtime_disable() in remove(), before any devres release
runs, closes that window: with runtime PM disabled the helper's
dont_use_autosuspend() can no longer trigger a suspend, so the clock
stays enabled and the clk release balances it cleanly.
You're right that set_suspended() and dont_use_autosuspend() are then
redundant with the helper -- pm_runtime_disable() is the only call that
has to happen early. So for v3 I'll drop those two and keep just
pm_runtime_disable() (with a short comment, and the full reasoning in
the commit log). Does that work for you?
Thanks,
Abdurrahman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] i2c: xiic: restore runtime PM teardown in remove to fix clk WARN flood
2026-08-16 20:11 ` Abdurrahman Hussain
@ 2026-08-17 19:20 ` Andi Shyti
2026-08-18 7:44 ` Abdurrahman Hussain
0 siblings, 1 reply; 6+ messages in thread
From: Andi Shyti @ 2026-08-17 19:20 UTC (permalink / raw)
To: Abdurrahman Hussain
Cc: Michal Simek, Andy Shevchenko, linux-arm-kernel, linux-i2c,
linux-kernel
Hi Abdurraham,
> On Sun, Aug 16, 2026 at 06:14:08PM +0200, Andi Shyti wrote:
> > isn't devm_pm_runtime_set_active_enabled() calling
> > pm_runtime_disable() + pm_runtime_set_suspended() +
> > pm_runtime_dont_use_autosuspend() at teardown?
>
> It does call all three, but the ordering defeats it, in two places:
>
> 1. Within the helper's own release, pm_runtime_disable_action() calls
> pm_runtime_dont_use_autosuspend() *before* pm_runtime_disable() --
> i.e. while runtime PM is still enabled.
>
> 2. devres is LIFO, and devm_clk_get_enabled() is registered before
> devm_pm_runtime_set_active_enabled() in probe(), so the clock's
> clk_disable_unprepare() release runs *after* the runtime-PM releases.
>
> pm_runtime_put_sync() in remove() leaves the device RPM_ACTIVE with the
> autosuspend timer armed: rpm_idle() falls through to
> rpm_suspend(RPM_AUTO), the delay hasn't expired, so it just re-arms the
> timer -- runtime_status stays ACTIVE and the clock stays enabled.
>
> Then the devres teardown runs. pm_runtime_dont_use_autosuspend() clears
> use_autosuspend; update_autosuspend() takes the else branch and calls
> rpm_idle(RPM_AUTO), but now pm_runtime_autosuspend_expiration() returns
> 0, so rpm_suspend() no longer defers and suspends immediately --
> xiic_i2c_runtime_suspend() clk_disable()s the clock, all while runtime
> PM is still enabled. A moment later, further down the LIFO chain,
> devm_clk_get_enabled()'s release does clk_disable_unprepare() on the
> already-disabled clock and clk_core_disable() WARNs, once per device.
>
> Calling pm_runtime_disable() in remove(), before any devres release
> runs, closes that window: with runtime PM disabled the helper's
> dont_use_autosuspend() can no longer trigger a suspend, so the clock
> stays enabled and the clk release balances it cleanly.
>
> You're right that set_suspended() and dont_use_autosuspend() are then
> redundant with the helper -- pm_runtime_disable() is the only call that
> has to happen early. So for v3 I'll drop those two and keep just
> pm_runtime_disable() (with a short comment, and the full reasoning in
> the commit log). Does that work for you?
I understand the logic, but this still leaves runtime PM
unbalanced. The explicit pm_runtime_disable() is followed by the
managed cleanup calling pm_runtime_disable() again.
A solution would be to drop the managed runtime-PM helper and
restore the non managed runtime PM setup and teardown. Otherwise,
this ordering issue needs to be addressed in the runtime-PM/clock
framework.
Does that work?
Andi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] i2c: xiic: restore runtime PM teardown in remove to fix clk WARN flood
2026-08-17 19:20 ` Andi Shyti
@ 2026-08-18 7:44 ` Abdurrahman Hussain
2026-08-18 10:16 ` Andi Shyti
0 siblings, 1 reply; 6+ messages in thread
From: Abdurrahman Hussain @ 2026-08-18 7:44 UTC (permalink / raw)
To: Andi Shyti, Abdurrahman Hussain
Cc: Michal Simek, Andy Shevchenko, linux-arm-kernel, linux-i2c,
linux-kernel
On Mon Aug 17, 2026 at 12:20 PM PDT, Andi Shyti wrote:
> A solution would be to drop the managed runtime-PM helper and
> restore the non managed runtime PM setup and teardown. Otherwise,
> this ordering issue needs to be addressed in the runtime-PM/clock
> framework.
>
> Does that work?
>
> Andi
Agreed — that's cleaner than special-casing the ordering. v3 drops
devm_pm_runtime_set_active_enabled() and restores the non-managed
setup/teardown.
Let me try it on hardware before sending v3.
Thanks for the feedback,
Abdurrahman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] i2c: xiic: restore runtime PM teardown in remove to fix clk WARN flood
2026-08-18 7:44 ` Abdurrahman Hussain
@ 2026-08-18 10:16 ` Andi Shyti
0 siblings, 0 replies; 6+ messages in thread
From: Andi Shyti @ 2026-08-18 10:16 UTC (permalink / raw)
To: Abdurrahman Hussain
Cc: Michal Simek, Andy Shevchenko, linux-arm-kernel, linux-i2c,
linux-kernel
Hi Abdurraham,
On Tue, Aug 18, 2026 at 12:44:27AM -0700, Abdurrahman Hussain wrote:
> On Mon Aug 17, 2026 at 12:20 PM PDT, Andi Shyti wrote:
> > A solution would be to drop the managed runtime-PM helper and
> > restore the non managed runtime PM setup and teardown. Otherwise,
> > this ordering issue needs to be addressed in the runtime-PM/clock
> > framework.
> >
> > Does that work?
> >
> > Andi
>
> Agreed — that's cleaner than special-casing the ordering. v3 drops
> devm_pm_runtime_set_active_enabled() and restores the non-managed
> setup/teardown.
>
> Let me try it on hardware before sending v3.
Please, also write a nice comment explaining why we won't use the
non managed runtime PM, I don't want to receive in the future a
patch adding the managed runtime PM.
Thanks,
Andi
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-08-18 10:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 18:04 [PATCH v2] i2c: xiic: restore runtime PM teardown in remove to fix clk WARN flood Abdurrahman Hussain
2026-08-16 16:14 ` Andi Shyti
2026-08-16 20:11 ` Abdurrahman Hussain
2026-08-17 19:20 ` Andi Shyti
2026-08-18 7:44 ` Abdurrahman Hussain
2026-08-18 10:16 ` Andi Shyti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox