From: Jonathan Cameron <jic23@kernel.org>
To: Brian Norris <briannorris@chromium.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
"Fabrice Gasnier" <fabrice.gasnier@st.com>,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
"Ulf Hansson" <ulfh@kernel.org>,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
"Andy Shevchenko" <andy@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>
Subject: Re: [PATCH v2 4/5] PM: runtime: Add tests for last_busy propagation
Date: Tue, 3 Nov 2026 23:21:09 +0000 [thread overview]
Message-ID: <20261103232109.2e334027@jic23-hlaptop> (raw)
In-Reply-To: <20261103141442.v2.4.I8ab8b7f662fe1921c7084a47d554535597cc2702@changeid>
On Tue, 3 Nov 2026 14:14:42 -0800
Brian Norris <briannorris@chromium.org> wrote:
> This is a regression test for the problem fixed in "PM: runtime:
> Propagate last_busy from dependent to dependency".
>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
Trivial style stuff.
> ---
>
> Changes in v2:
> * Use device_move() instead of manual re-parenting
> * fsleep() instead of msleep()
>
> drivers/base/power/runtime-test.c | 99 +++++++++++++++++++++++++++++++
> 1 file changed, 99 insertions(+)
>
> diff --git a/drivers/base/power/runtime-test.c b/drivers/base/power/runtime-test.c
> index 24865ce844fc..00ca3b10543a 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,102 @@ 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 = kunit_device_register(test, DEVICE_NAME "_parent");
> + struct device *dev = kunit_device_register(test, DEVICE_NAME);
Similar style comment to below.
> + u64 expiry1, expiry2;
> +
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent);
> +
> + 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 = kunit_device_register(test, DEVICE_NAME "_supplier");
> + struct device *dev = kunit_device_register(test, DEVICE_NAME);
Having the assignment clear of the error check is never great, but now there are multiple
devs, I'd definitely move them.
struct device *supplier, *dev;
> + u64 expiry1, expiry2;
> +
supplier = kunit_device_register(test, DEVICE_NAME "_supplier");
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
dev = kunit_device_register(test, DEVICE_NAME);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, supplier);
> +
> + 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 +390,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),
> {}
> };
>
next prev parent reply other threads:[~2026-11-03 23:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 22:14 [PATCH v2 0/5] PM: runtime: Improve autosuspend child to parent propagation Brian Norris
2026-11-03 22:14 ` [PATCH v2 1/5] PM: runtime: Only queue an idle check for RPM-linked suppliers (part 2) Brian Norris
2026-11-03 22:14 ` [PATCH v2 2/5] PM: runtime: Convert last_busy to atomic64_t Brian Norris
2026-11-03 22:14 ` [PATCH v2 3/5] PM: runtime: Propagate last_busy from dependent to dependency Brian Norris
2026-11-03 23:17 ` Jonathan Cameron
2026-11-04 0:32 ` Brian Norris
2026-11-04 1:40 ` Jonathan Cameron
2026-11-03 22:14 ` [PATCH v2 4/5] PM: runtime: Add tests for last_busy propagation Brian Norris
2026-11-03 23:21 ` Jonathan Cameron [this message]
2026-11-03 22:14 ` [PATCH v2 5/5] iio: adc: stm32-adc: Drop runtime_idle() Brian Norris
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=20261103232109.2e334027@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andy@kernel.org \
--cc=briannorris@chromium.org \
--cc=dlechner@baylibre.com \
--cc=fabrice.gasnier@st.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mcoquelin.stm32@gmail.com \
--cc=nuno.sa@analog.com \
--cc=rafael@kernel.org \
--cc=ulfh@kernel.org \
/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®