From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Rose Wu <ya-jou.wu@mediatek.com>, linux-pm@vger.kernel.org
Cc: rafael.j.wysocki@intel.com, regressions@lists.linux.dev,
linux-kernel@vger.kernel.org,
wsd_upstream <wsd_upstream@mediatek.com>,
linux-mediatek@lists.infradead.org,
"士顏 邱" <artis.chiu@mediatek.com>,
"靖智 高" <Johnny-cc.Kao@mediatek.com>,
"Ulf Hansson" <ulf.hansson@linaro.org>
Subject: [PATCH v1] PM: sleep: core: Fix runtime PM enabling in device_resume_early()
Date: Mon, 17 Nov 2025 19:57:24 +0100 [thread overview]
Message-ID: <5940388.DvuYhMxLoT@rafael.j.wysocki> (raw)
In-Reply-To: <CAJZ5v0jjQgoa8eRyQ-MVQW=FeOEVQP6YTsY7o49LV2wnO=xEDw@mail.gmail.com>
On Monday, November 17, 2025 5:59:05 PM CET Rafael J. Wysocki wrote:
> Hi,
>
> On Mon, Nov 17, 2025 at 10:31 AM Rose Wu <ya-jou.wu@mediatek.com> wrote:
> >
> > Hi Rafael and All,
> >
> > I am reporting a regression introduced by the commit
> > 443046d1ad66607f324c604b9fbdf11266fa8aad (PM: sleep: Make suspend of
> > devices more asynchronous), which can lead to a kernel panic (data
> > abort) if a late suspend aborts.
> > The commit modifies list handling during suspend. When a device suspend
> > aborts at the "late" stage, `dpm_suspended_list` is spliced into
> > `dpm_late_early_list`.
> > This creates an imbalance. Devices on this list that had not yet
> > executed `pm_runtime_disable()` in `device_suspend_late()` are now
> > incorrectly subjected to `pm_runtime_enable()` during the subsequent
> > `device_resume_early()` sequence.
>
> Ah, obviously.
>
> Does the attached patch (that should apply on top of 6.18-rc6) help?
>
> If this patch doesn't apply to your kernel, making an analogous change
> to it should be straightforward enough.
That patch was incomplete because it was missing a complementary change
in device_suspend_late() to ensure that power.is_suspended will be set
for all devices with disabled runtime PM.
Please try the one below instead.
Thanks!
---
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Runtime PM should only be enabled in device_resume_early() if it has
been disabled for the given device by device_suspend_late(). Otherwise,
it may cause runtime PM callbacks to run prematurely in some cases
or cause runtime PM to be enabled for devices without runtime PM
support. That leads to further functional issues.
Make two changes to address this problem.
First, reorder device_suspend_late() to only disable runtime PM for a
device if the power.is_late_suspended flag is going to be set for it.
In all of the other cases, disabling runtime PM for the device is not
in fact necessary.
Second, make device_resume_early() only enable runtime PM for the
devices with the power.is_late_suspended flag set.
Fixes: 443046d1ad66 ("PM: sleep: Make suspend of devices more asynchronous")
Reported-by: Rose Wu <ya-jou.wu@mediatek.com>
Closes: https://lore.kernel.org/linux-pm/70b25dca6f8c2756d78f076f4a7dee7edaaffc33.camel@mediatek.com/
Cc: 6.16+ <stable@vger.kernel.org> # 6.16+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/base/power/main.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -941,11 +941,11 @@ Run:
Skip:
dev->power.is_late_suspended = false;
+ pm_runtime_enable(dev);
Out:
TRACE_RESUME(error);
- pm_runtime_enable(dev);
complete_all(&dev->power.completion);
if (error) {
@@ -1630,12 +1630,6 @@ static void device_suspend_late(struct d
TRACE_DEVICE(dev);
TRACE_SUSPEND(0);
- /*
- * Disable runtime PM for the device without checking if there is a
- * pending resume request for it.
- */
- __pm_runtime_disable(dev, false);
-
dpm_wait_for_subordinate(dev, async);
if (READ_ONCE(async_error))
@@ -1649,6 +1643,12 @@ static void device_suspend_late(struct d
if (dev->power.syscore || dev->power.direct_complete)
goto Complete;
+ /*
+ * Disable runtime PM for the device without checking if there is a
+ * pending resume request for it.
+ */
+ __pm_runtime_disable(dev, false);
+
if (dev->pm_domain) {
info = "late power domain ";
callback = pm_late_early_op(&dev->pm_domain->ops, state);
next prev parent reply other threads:[~2025-11-17 18:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 9:31 [REGRESSION] PM / sleep: Unbalanced suspend/resume on late abort causes data abort Rose Wu
2025-11-17 16:59 ` Rafael J. Wysocki
2025-11-17 18:57 ` Rafael J. Wysocki [this message]
2025-11-18 8:31 ` [PATCH v1] PM: sleep: core: Fix runtime PM enabling in device_resume_early() Rose Wu
2025-11-18 11:48 ` [PATCH v2] " Rafael J. Wysocki
2025-11-18 12:17 ` Ulf Hansson
2025-11-18 12:26 ` Rafael J. Wysocki
2025-11-18 12:45 ` [PATCH v3] " Rafael J. Wysocki
2025-11-18 12:57 ` Ulf Hansson
2025-11-18 13:01 ` Rafael J. Wysocki
2025-11-18 14:16 ` [PATCH v4] " Rafael J. Wysocki
2025-11-18 14:44 ` Ulf Hansson
2025-11-18 12:49 ` [PATCH v2] " Ulf Hansson
2025-11-18 12:52 ` Rafael J. Wysocki
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=5940388.DvuYhMxLoT@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=Johnny-cc.Kao@mediatek.com \
--cc=artis.chiu@mediatek.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=regressions@lists.linux.dev \
--cc=ulf.hansson@linaro.org \
--cc=wsd_upstream@mediatek.com \
--cc=ya-jou.wu@mediatek.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