Skip to contentSkip to conversation

PM: runtime: Update last_busy before calling rpm_suspend() in rpm_idle()

PATCH In review Rafael J. Wysocki 5 participants 8 messages Nov 13 – Nov 18

Subsystems (4)
lore
Share & tools
lore

Rafael J. Wysocki

author maintainer
#0 lore raw

PATCH 1/1 PM: runtime: Update last_busy before calling rpm_suspend() in rpm_idle()

From: "Rafael J. Wysocki" <[email protected]>

When rpm_idle() is about to call rpm_suspend(), there are no reasons preventing the device from being suspended, but if the device uses an autosuspend delay, it needs to be taken into account.

For this purpose, rpm_idle() adds RPM_AUTO to the flags passed to rpm_suspend(), but doing that alone is insufficient because the point in time from which the autosuspend delay is counted may be too early.

For example, if the device has children (or consumers) and the last of them goes into runtime suspend, the parent may now become eligible for suspending, but it may not be worthwhile for it to suspend until a certain time later.

Quoting Alan Stern [1]:

Let's say the last remaining active child goes into runtime suspend at time T. Let's also say that the parent expects none of the children will need to resume until time T + D. Is D sufficiently large to make it worthwhile for the parent to suspend and then resume? If not, the parent should remain active. If yes, the parent should autosuspend -- and the length of time the parent should wait before autosuspending is on the order of the value of D (let's call it D*) that corresponds to this crossover point. Thus the parent's autosuspend delay should be set to D*, or something close to it, in order to achieve both objectives.

Moreover, if the parent's autosuspend delay is set to D*, it should be counted from time T at which the last child has suspended, but that does not happen because the parent's last_busy timestamp is not updated at time T. That leads to undesirable parent suspends occurring between child suspend and resume [2].

To address this issue, make rpm_idle() update the last_busy timestamp of the device when it is about to call rpm_suspend() which most often is right after the device's last child (or consumer) has gone into runtime suspend.

Updating the last_busy timestamp when rpm_idle() returns an error without calling rpm_suspend() is not useful because the device is then going to remain active for an unknown amount of time and its autosuspend delay needs to take effect later.

---
 drivers/base/power/runtime.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/base/power/runtime.c +5 -1
@@ -560,7 +560,11 @@ static int rpm_idle(struct device *dev,
 
  out:
 	trace_rpm_return_int(dev, _THIS_IP_, retval);
-	return retval ? retval : rpm_suspend(dev, rpmflags | RPM_AUTO);
+	if (retval)
+		return retval;
+
+	pm_runtime_mark_last_busy(dev);
+	return rpm_suspend(dev, rpmflags | RPM_AUTO);
 }
 
 /**
Reviewed-by on v1 1/1
#1 lore raw
Quoted 34 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

When rpm_idle() is about to call rpm_suspend(), there are no reasons preventing the device from being suspended, but if the device uses an autosuspend delay, it needs to be taken into account.

For this purpose, rpm_idle() adds RPM_AUTO to the flags passed to rpm_suspend(), but doing that alone is insufficient because the point in time from which the autosuspend delay is counted may be too early.

For example, if the device has children (or consumers) and the last of them goes into runtime suspend, the parent may now become eligible for suspending, but it may not be worthwhile for it to suspend until a certain time later.

Quoting Alan Stern [1]:

Let's say the last remaining active child goes into runtime suspend at time T. Let's also say that the parent expects none of the children will need to resume until time T + D. Is D sufficiently large to make it worthwhile for the parent to suspend and then resume? If not, the parent should remain active. If yes, the parent should autosuspend -- and the length of time the parent should wait before autosuspending is on the order of the value of D (let's call it D*) that corresponds to this crossover point. Thus the parent's autosuspend delay should be set to D*, or something close to it, in order to achieve both objectives.

Moreover, if the parent's autosuspend delay is set to D*, it should be counted from time T at which the last child has suspended, but that does not happen because the parent's last_busy timestamp is not updated at time T. That leads to undesirable parent suspends occurring between child suspend and resume [2].

Quoted 4 lines

To address this issue, make rpm_idle() update the last_busy timestamp of the device when it is about to call rpm_suspend() which most often is right after the device's last child (or consumer) has gone into runtime suspend.

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.

In any case, the change looks good to me:

I meant to make time to test this out a bit more, but ran out; maybe next week.

Thanks,
Brian

Quoted 30 lines

Updating the last_busy timestamp when rpm_idle() returns an error without calling rpm_suspend() is not useful because the device is then going to remain active for an unknown amount of time and its autosuspend delay needs to take effect later.

---
 drivers/base/power/runtime.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/base/power/runtime.c +5 -1
@@ -560,7 +560,11 @@ static int rpm_idle(struct device *dev,
 
  out:
 	trace_rpm_return_int(dev, _THIS_IP_, retval);
-	return retval ? retval : rpm_suspend(dev, rpmflags | RPM_AUTO);
+	if (retval)
+		return retval;
+
+	pm_runtime_mark_last_busy(dev);
+	return rpm_suspend(dev, rpmflags | RPM_AUTO);
 }
 
 /**
author maintainer
#2 lore raw
Quoted 41 lines · Brian Norris
Quoted 34 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

When rpm_idle() is about to call rpm_suspend(), there are no reasons preventing the device from being suspended, but if the device uses an autosuspend delay, it needs to be taken into account.

For this purpose, rpm_idle() adds RPM_AUTO to the flags passed to rpm_suspend(), but doing that alone is insufficient because the point in time from which the autosuspend delay is counted may be too early.

For example, if the device has children (or consumers) and the last of them goes into runtime suspend, the parent may now become eligible for suspending, but it may not be worthwhile for it to suspend until a certain time later.

Quoting Alan Stern [1]:

Let's say the last remaining active child goes into runtime suspend at time T. Let's also say that the parent expects none of the children will need to resume until time T + D. Is D sufficiently large to make it worthwhile for the parent to suspend and then resume? If not, the parent should remain active. If yes, the parent should autosuspend -- and the length of time the parent should wait before autosuspending is on the order of the value of D (let's call it D*) that corresponds to this crossover point. Thus the parent's autosuspend delay should be set to D*, or something close to it, in order to achieve both objectives.

Moreover, if the parent's autosuspend delay is set to D*, it should be counted from time T at which the last child has suspended, but that does not happen because the parent's last_busy timestamp is not updated at time T. That leads to undesirable parent suspends occurring between child suspend and resume [2].

Quoted 4 lines

To address this issue, make rpm_idle() update the last_busy timestamp of the device when it is about to call rpm_suspend() which most often is right after the device's last child (or consumer) has gone into runtime suspend.

Quoted 6 lines

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 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."

Quoted 3 lines

In any case, the change looks good to me:

Thank you!

Quoted 2 lines

I meant to make time to test this out a bit more, but ran out; maybe next week.

That will be much appreciated.

Tested-by
#3 lore raw
Quoted 8 lines · Rafael J. Wysocki (Intel)
Quoted 6 lines · Brian Norris

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.

Quoted 5 lines

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

Quoted 11 lines

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.

Quoted 3 lines

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.

Quoted 10 lines
Quoted 3 lines

In any case, the change looks good to me:

Thank you!

Quoted 2 lines

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:

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/[email protected]/
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 <[email protected]>
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.

---

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(+)
drivers/base/power/runtime-test.c +103 -0
index 24865ce844fc..685a3504cd7b 100644
@@ -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),
 	{}
 };
 
Signature · 1 line
2.56.1.703.gf848ed807c-goog
author maintainer
#4 lore raw
Quoted 10 lines · Brian Norris
Quoted 8 lines · Rafael J. Wysocki (Intel)
Quoted 6 lines · Brian Norris

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.

Quoted 7 lines
Quoted 5 lines

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

I noticed that too and fixed it up. Not sure what happened here.

Quoted 49 lines
Quoted 11 lines

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.

Quoted 3 lines

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.

Quoted 10 lines
Quoted 3 lines

In any case, the change looks good to me:

Thank you!

Quoted 2 lines

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:

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)

Quoted 6 lines

[1] https://lore.kernel.org/all/[email protected]/
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/

Thank you!

Acked-by on v1 1/1
#5 lore raw
In reply to Rafael J. Wysocki
Quoted 44 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

When rpm_idle() is about to call rpm_suspend(), there are no reasons preventing the device from being suspended, but if the device uses an autosuspend delay, it needs to be taken into account.

For this purpose, rpm_idle() adds RPM_AUTO to the flags passed to rpm_suspend(), but doing that alone is insufficient because the point in time from which the autosuspend delay is counted may be too early.

For example, if the device has children (or consumers) and the last of them goes into runtime suspend, the parent may now become eligible for suspending, but it may not be worthwhile for it to suspend until a certain time later.

Quoting Alan Stern [1]:

Let's say the last remaining active child goes into runtime suspend at time T. Let's also say that the parent expects none of the children will need to resume until time T + D. Is D sufficiently large to make it worthwhile for the parent to suspend and then resume? If not, the parent should remain active. If yes, the parent should autosuspend -- and the length of time the parent should wait before autosuspending is on the order of the value of D (let's call it D*) that corresponds to this crossover point. Thus the parent's autosuspend delay should be set to D*, or something close to it, in order to achieve both objectives.

Moreover, if the parent's autosuspend delay is set to D*, it should be counted from time T at which the last child has suspended, but that does not happen because the parent's last_busy timestamp is not updated at time T. That leads to undesirable parent suspends occurring between child suspend and resume [2].

To address this issue, make rpm_idle() update the last_busy timestamp of the device when it is about to call rpm_suspend() which most often is right after the device's last child (or consumer) has gone into runtime suspend.

Updating the last_busy timestamp when rpm_idle() returns an error without calling rpm_suspend() is not useful because the device is then going to remain active for an unknown amount of time and its autosuspend delay needs to take effect later.

Quoted 4 lines

---

Quoted 18 lines
 drivers/base/power/runtime.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/base/power/runtime.c +5 -1
@@ -560,7 +560,11 @@ static int rpm_idle(struct device *dev,
 
  out:
 	trace_rpm_return_int(dev, _THIS_IP_, retval);
-	return retval ? retval : rpm_suspend(dev, rpmflags | RPM_AUTO);
+	if (retval)
+		return retval;
+
+	pm_runtime_mark_last_busy(dev);
+	return rpm_suspend(dev, rpmflags | RPM_AUTO);
 }
 
 /**
Reviewed-by on v1 1/1
#6 lore raw
In reply to Rafael J. Wysocki
Quoted 40 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

When rpm_idle() is about to call rpm_suspend(), there are no reasons preventing the device from being suspended, but if the device uses an autosuspend delay, it needs to be taken into account.

For this purpose, rpm_idle() adds RPM_AUTO to the flags passed to rpm_suspend(), but doing that alone is insufficient because the point in time from which the autosuspend delay is counted may be too early.

For example, if the device has children (or consumers) and the last of them goes into runtime suspend, the parent may now become eligible for suspending, but it may not be worthwhile for it to suspend until a certain time later.

Quoting Alan Stern [1]:

Let's say the last remaining active child goes into runtime suspend at time T. Let's also say that the parent expects none of the children will need to resume until time T + D. Is D sufficiently large to make it worthwhile for the parent to suspend and then resume? If not, the parent should remain active. If yes, the parent should autosuspend -- and the length of time the parent should wait before autosuspending is on the order of the value of D (let's call it D*) that corresponds to this crossover point. Thus the parent's autosuspend delay should be set to D*, or something close to it, in order to achieve both objectives.

Moreover, if the parent's autosuspend delay is set to D*, it should be counted from time T at which the last child has suspended, but that does not happen because the parent's last_busy timestamp is not updated at time T. That leads to undesirable parent suspends occurring between child suspend and resume [2].

To address this issue, make rpm_idle() update the last_busy timestamp of the device when it is about to call rpm_suspend() which most often is right after the device's last child (or consumer) has gone into runtime suspend.

Quoted 8 lines

Updating the last_busy timestamp when rpm_idle() returns an error without calling rpm_suspend() is not useful because the device is then going to remain active for an unknown amount of time and its autosuspend delay needs to take effect later.

I realized that I have joined these discussions a bit late. Thanks to all of you for working on this, it's been on my todo list for a long time! :-)

That said, please add:

Kind regards
Uffe

Quoted 22 lines
---
 drivers/base/power/runtime.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/base/power/runtime.c +5 -1
@@ -560,7 +560,11 @@ static int rpm_idle(struct device *dev,
 
  out:
        trace_rpm_return_int(dev, _THIS_IP_, retval);
-       return retval ? retval : rpm_suspend(dev, rpmflags | RPM_AUTO);
+       if (retval)
+               return retval;
+
+       pm_runtime_mark_last_busy(dev);
+       return rpm_suspend(dev, rpmflags | RPM_AUTO);
 }
 
 /**