From: Brian Norris <briannorris@chromium.org>
To: "Rafael J. Wysocki (Intel)" <rafael@kernel.org>
Cc: Linux PM <linux-pm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Alan Stern <stern@rowland.harvard.edu>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Ulf Hansson <ulf.hansson@oss.qualcomm.com>
Subject: Re: [PATCH v1] PM: runtime: Update last_busy before calling rpm_suspend() in rpm_idle()
Date: Mon, 16 Nov 2026 15:12:05 -0800 [thread overview]
Message-ID: <avuNxXw7YZ4ZeO-1@google.com> (raw)
In-Reply-To: <CAJZ5v0h3Q3ySm0BmHG80QAQReV-6mbj2A0J5cSG1Pwc_ziGyDw@mail.gmail.com>
On Sun, Nov 15, 2026 at 06:35:04PM +0100, Rafael J. Wysocki (Intel) wrote:
> On Sat, Nov 14, 2026 at 1:59 AM Brian Norris <briannorris@chromium.org> wrote:
> > Is it worthwhile to note (or at least hint at) how many other things
> > change along with this? e.g., how pm_runtime_allow() (and therefore
> > auto > control/power), all non-autosuspend pm_runtime_put() variants,
> > etc, also extend the autosuspend timer? I think we agreed these are
> > acceptable effects, and likely even desireable, but I'd say these are
> > fairly major changes.
>
> Fair enough, I'll add the following to the changelog when applying the patch:
>
> "This potentially changes observable behavior in all situations in
> which pm_runtime_put(), pm_runtime_put_sync(), pm_runtime_idle(), or
> pm_request() idle is used on a device with an autosuspend delay. That
nit: you split "pm_request_idle()" oddly
> includes changing a device's "power/control" sysfs attribute value
> from "on" to "auto" (if there are no other active runtime PM
> references to the given device), accessing PCI configuration space
> from user space etc. Namely, in all of those cases, the runtime
> suspend of the device following the runtime PM helper call (if it
> causes a runtime suspend to occur) will be deferred by the full
> autosuspend delay, which arguably is more consistent and predictable
> than deferring the runtime suspend in question by a more-or-less
> unknown (and basically random) time depending on when the most recent
> update of the device's last_busy timestamp has occurred.
>
> It will also cause the majority of the direct
> pm_runtime_mark_last_busy() calls to become redundant, and they will
> be taken care of later."
Seems good, thanks! Who knows if anybody will actually read the
changelogs, but at least it leaves a paper trail for future cleanups
that will likely reference this change.
> > In any case, the change looks good to me:
> >
> > Reviewed-by: Brian Norris <briannorris@chromium.org>
>
> Thank you!
>
> > I meant to make time to test this out a bit more, but ran out; maybe
> > next week.
>
> That will be much appreciated.
OK, I made some time:
Tested-by: Brian Norris <briannorris@chromium.org>
It tests out well (passing) with:
(a) the KUnit tests that try to imitate the stm32-adc parent/child
structure from commit c537d3457542 [1]
(b) my original KUnit test [2]. I've appended a slightly-updated v3, in
case you want to merge it
(c) some targeted PCIe tests on Pixel phones. Specifically, I see that
the portdrv.c 100ms autosuspend delay is now consistently applied
after both lspci (this used to work OK, simply because rpm_resume()
would also update last_busy) and after endpoint suspend (this
previously did not apply the autosuspend delay, as the endpoint
tended to stay active for a long time)
Thanks,
Brian
[1] https://lore.kernel.org/all/auzlLwlleGLPsLcw@google.com/
This test is inherently timing sensitive and therefore flaky. It
just serves as an example, not something to commit.
[2] [PATCH v2 4/5] PM: runtime: Add tests for last_busy propagation
https://lore.kernel.org/all/20261103141442.v2.4.I8ab8b7f662fe1921c7084a47d554535597cc2702@changeid/
From: Brian Norris <briannorris@chromium.org>
Date: Thu, 1 Oct 2026 11:53:49 -0700
Subject: [PATCH v3] PM: runtime: Add tests for dependency last_busy update
This is a regression test for the problem fixed in "PM: runtime: Update
last_busy before calling rpm_suspend() in rpm_idle()", ensuring that
when a child or consumer suspends, the corresponding parent or supplier
autosuspend timer expiration increases.
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
Changes in v3:
* Minor style changes
* Target
"PM: runtime: Update last_busy before calling rpm_suspend() in
rpm_idle()"
instead of prior patch
"PM: runtime: Propagate last_busy from dependent to dependency"
(both solve the same problem)
Changes in v2:
* Use device_move() instead of manual re-parenting
* fsleep() instead of msleep()
drivers/base/power/runtime-test.c | 103 ++++++++++++++++++++++++++++++
1 file changed, 103 insertions(+)
diff --git a/drivers/base/power/runtime-test.c b/drivers/base/power/runtime-test.c
index 24865ce844fc..685a3504cd7b 100644
--- a/drivers/base/power/runtime-test.c
+++ b/drivers/base/power/runtime-test.c
@@ -4,6 +4,7 @@
*/
#include <linux/cleanup.h>
+#include <linux/delay.h>
#include <linux/pm_runtime.h>
#include <linux/workqueue.h>
#include <kunit/device.h>
@@ -285,6 +286,106 @@ static void pm_runtime_supplier_suspend_test(struct kunit *test)
KUNIT_EXPECT_TRUE(test, pm_runtime_suspended(norpm_supplier));
}
+static void pm_runtime_parent_last_used_test(struct kunit *test)
+{
+ struct device *parent, *dev;
+ u64 expiry1, expiry2;
+
+ parent = kunit_device_register(test, DEVICE_NAME "_parent");
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent);
+
+ dev = kunit_device_register(test, DEVICE_NAME);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
+
+ KUNIT_ASSERT_EQ(test, 0, device_move(dev, parent, DPM_ORDER_NONE));
+
+ pm_runtime_set_active(parent);
+ pm_runtime_set_active(dev);
+ pm_runtime_use_autosuspend(parent);
+ pm_runtime_use_autosuspend(dev);
+
+ pm_runtime_set_autosuspend_delay(dev, 0);
+ /* Effectively infinite delay (prevent finishing autosuspend during this test). */
+ pm_runtime_set_autosuspend_delay(parent, 200000);
+
+ pm_runtime_mark_last_busy(dev);
+ pm_runtime_mark_last_busy(parent);
+
+ pm_runtime_get_noresume(dev);
+
+ pm_runtime_enable(parent);
+ pm_runtime_enable(dev);
+
+ expiry1 = pm_runtime_autosuspend_expiration(parent);
+ KUNIT_EXPECT_NE(test, 0, expiry1);
+
+ /* Make absolutely sure the clock advances. */
+ fsleep(1000);
+
+ KUNIT_EXPECT_EQ(test, 0, pm_runtime_put_sync_autosuspend(dev));
+
+ KUNIT_EXPECT_TRUE(test, pm_runtime_suspended(dev));
+
+ /* Flush, in case any request was pending. */
+ flush_workqueue(pm_wq);
+ KUNIT_EXPECT_FALSE(test, pm_runtime_suspended(parent));
+
+ expiry2 = pm_runtime_autosuspend_expiration(parent);
+ KUNIT_EXPECT_NE(test, 0, expiry2);
+ /* The child's last_busy time should have bumped up the parent's expiration. */
+ KUNIT_EXPECT_GT(test, expiry2, expiry1);
+}
+
+static void pm_runtime_supplier_last_used_test(struct kunit *test)
+{
+ struct device *supplier, *dev;
+ u64 expiry1, expiry2;
+
+ supplier = kunit_device_register(test, DEVICE_NAME "_supplier");
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, supplier);
+
+ dev = kunit_device_register(test, DEVICE_NAME);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
+
+ KUNIT_ASSERT_NOT_NULL(test, device_link_add(dev, supplier, DL_FLAG_PM_RUNTIME));
+
+ pm_runtime_set_active(supplier);
+ pm_runtime_set_active(dev);
+ pm_runtime_use_autosuspend(supplier);
+ pm_runtime_use_autosuspend(dev);
+
+ pm_runtime_set_autosuspend_delay(dev, 0);
+ /* Effectively infinite delay (prevent finishing autosuspend during this test). */
+ pm_runtime_set_autosuspend_delay(supplier, 200000);
+
+ pm_runtime_mark_last_busy(dev);
+ pm_runtime_mark_last_busy(supplier);
+
+ pm_runtime_get_noresume(dev);
+
+ pm_runtime_enable(supplier);
+ pm_runtime_enable(dev);
+
+ expiry1 = pm_runtime_autosuspend_expiration(supplier);
+ KUNIT_EXPECT_NE(test, 0, expiry1);
+
+ /* Make absolutely sure the clock advances. */
+ fsleep(1000);
+
+ KUNIT_EXPECT_EQ(test, 0, pm_runtime_put_sync_autosuspend(dev));
+
+ KUNIT_EXPECT_TRUE(test, pm_runtime_suspended(dev));
+
+ /* Flush, in case any request was pending. */
+ flush_workqueue(pm_wq);
+ KUNIT_EXPECT_FALSE(test, pm_runtime_suspended(supplier));
+
+ expiry2 = pm_runtime_autosuspend_expiration(supplier);
+ KUNIT_EXPECT_NE(test, 0, expiry2);
+ /* The consumer's last_busy time should have bumped up the supplier's expiration. */
+ KUNIT_EXPECT_GT(test, expiry2, expiry1);
+}
+
static struct kunit_case pm_runtime_test_cases[] = {
KUNIT_CASE(pm_runtime_depth_test),
KUNIT_CASE(pm_runtime_already_suspended_test),
@@ -293,6 +394,8 @@ static struct kunit_case pm_runtime_test_cases[] = {
KUNIT_CASE(pm_runtime_error_test),
KUNIT_CASE(pm_runtime_probe_active_test),
KUNIT_CASE(pm_runtime_supplier_suspend_test),
+ KUNIT_CASE(pm_runtime_parent_last_used_test),
+ KUNIT_CASE(pm_runtime_supplier_last_used_test),
{}
};
--
2.56.1.703.gf848ed807c-goog
next prev parent reply other threads:[~2026-11-16 23:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 13:27 Rafael J. Wysocki
2026-11-14 0:59 ` Brian Norris
2026-11-15 17:35 ` Rafael J. Wysocki (Intel)
2026-11-16 23:12 ` Brian Norris [this message]
2026-11-14 3:40 ` Alan Stern
2026-11-14 8:01 ` Ulf Hansson
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=avuNxXw7YZ4ZeO-1@google.com \
--to=briannorris@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=stern@rowland.harvard.edu \
--cc=ulf.hansson@oss.qualcomm.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
all inboxes | Powered by JetHome®