While reviewing a patch on the mmc-list, I ended up inspecting the behaviour of
how we deal with the no callback case for runtime PM.
A couple of observations:
*) When pm_runtime_no_callbacks() have been called, it allows the PM core to
takes a quicker path, but at the same time, consumer/supplier device links are
being skipped in rpm_resume|suspend().
**) Calling pm_runtime_no_callbacks() to avoid boiler plate code (assigning
empty functions to ->runtime_suspend|resume()), doesn't work if there could be
consumer/supplier device link being used or a platform dependent PM domain that
could get attached to the device.
Therefore, this series suggests to change the behaviour in the PM core, to
allow the ->runtime_suspend|resume() callbacks to be unassigned. This is already
supported for ->runtime_idle() callbacks, so it would also move things into a
more consistent behaviour.
I have looked at various error paths, in the kernel of callers of
pm_runtime_get_sync(). I couldn't find anyone that made sense, that looked for
the special error code, -ENOSYS, which is the error code getting returned when a
callback is missing. Whether that is sufficient proof that these changes are
100% safe, I can't guarantee, but I think it would be worth a try as the
benefits of avoiding boilerplate code and the corresponding additional code
paths are quite nice, if you ask me.
Kind regards
Ulf Hansson
Ulf Hansson (3):
PM: runtime: Improve path in rpm_idle() when no callback
PM: runtime: Allow unassigned ->runtime_suspend|resume callbacks
PM: runtime: Clarify documentation when callbacks are unassigned
Documentation/power/runtime_pm.rst | 8 ++++++++
drivers/base/power/runtime.c | 18 ++++++++----------
2 files changed, 16 insertions(+), 10 deletions(-)
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
We are currently allowing ->runtime_idle() callbacks to be unassigned
without returning an error code from rpm_idle(). This has been useful to
avoid boilerplate code in drivers. Let's take this approach a step further,
by allowing also unassigned ->runtime_suspend|resume() callbacks.
In this way, a consumer/supplier device link can be used to let a consumer
device be power managed through its supplier device, without requiring
assigned ->runtime_suspend|resume() callbacks for the consumer device, for
example.
Signed-off-by: Ulf Hansson <redacted>
---
Changes in v2:
- Small updates to commit message.
---
drivers/base/power/runtime.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
When pm_runtime_no_callbacks() has been called for a struct device to set
the dev->power.no_callbacks flag for it, it enables rpm_idle() to take a
slightly quicker path by assuming that a ->runtime_idle() callback would
have returned 0 to indicate success.
A device that does not have the dev->power.no_callbacks flag set for it,
may still be missing a corresponding ->runtime_idle() callback, in which
case the slower path in rpm_idle() is taken. Let's improve the behaviour
for this case, by aligning code to the quicker path.
Signed-off-by: Ulf Hansson <redacted>
---
Changes in v2:
- None.
---
drivers/base/power/runtime.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
@@ -446,7 +446,10 @@ static int rpm_idle(struct device *dev, int rpmflags)/* Pending requests need to be canceled. */dev->power.request=RPM_REQ_NONE;-if(dev->power.no_callbacks)+callback=RPM_GET_CALLBACK(dev,runtime_idle);++/* If no callback assume success. */+if(!callback||dev->power.no_callbacks)gotoout;/* Carry out an asynchronous or a synchronous idle notification. */
@@ -462,10 +465,7 @@ static int rpm_idle(struct device *dev, int rpmflags)dev->power.idle_notification=true;-callback=RPM_GET_CALLBACK(dev,runtime_idle);--if(callback)-retval=__rpm_callback(callback,dev);+retval=__rpm_callback(callback,dev);dev->power.idle_notification=false;wake_up_all(&dev->power.wait_queue);
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Recent changes to the PM core allows ->runtime_suspend|resume callbacks to
be unassigned.
In the earlier behaviour the PM core would return -ENOSYS, when trying to
runtime resume a device, for example. Let's update the documentation to
clarify this.
Signed-off-by: Ulf Hansson <redacted>
---
Changes in v2:
- Added a new patch for the updating the docs, as pointed out by Alan.
---
Documentation/power/runtime_pm.rst | 8 ++++++++
1 file changed, 8 insertions(+)
@@ -827,6 +827,14 @@ or driver about runtime power changes. Instead, the driver for the device's parent must take responsibility for telling the device's driver when the parent's power state changes.+Note that, in some cases it may not be desirable for subsystems/drivers to call+pm_runtime_no_callbacks() for their devices. This could be because a subset of+the runtime PM callbacks needs to be implemented, a platform dependent PM+domain could get attached to the device or that the device is power manged+through a supplier device link. For these reasons and to avoid boilerplate code+in subsystems/drivers, the PM core allows runtime PM callbacks to be+unassigned.+9. Autosuspend, or automatically-delayed suspends =================================================
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Alan Stern <stern@rowland.harvard.edu> Date: 2021-06-08 14:23:28
On Tue, Jun 08, 2021 at 11:02:50AM +0200, Ulf Hansson wrote:
quoted hunk
Recent changes to the PM core allows ->runtime_suspend|resume callbacks to
be unassigned.
In the earlier behaviour the PM core would return -ENOSYS, when trying to
runtime resume a device, for example. Let's update the documentation to
clarify this.
Signed-off-by: Ulf Hansson <redacted>
---
Changes in v2:
- Added a new patch for the updating the docs, as pointed out by Alan.
---
Documentation/power/runtime_pm.rst | 8 ++++++++
1 file changed, 8 insertions(+)
@@ -827,6 +827,14 @@ or driver about runtime power changes. Instead, the driver for the device's parent must take responsibility for telling the device's driver when the parent's power state changes.+Note that, in some cases it may not be desirable for subsystems/drivers to call+pm_runtime_no_callbacks() for their devices. This could be because a subset of+the runtime PM callbacks needs to be implemented, a platform dependent PM+domain could get attached to the device or that the device is power manged+through a supplier device link. For these reasons and to avoid boilerplate code+in subsystems/drivers, the PM core allows runtime PM callbacks to be+unassigned.+
You should also mention that if a callback pointer is NULL, the
runtime PM core will act as though there was a callback and it
returned 0. That's an important consideration.
Also, notice that this file was carefully edited to make sure that
none of the lines exceed 80 characters. Your new addition should
be the same.
Alan Stern
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Alan Stern <stern@rowland.harvard.edu> Date: 2021-06-08 14:25:01
On Tue, Jun 08, 2021 at 11:02:47AM +0200, Ulf Hansson wrote:
While reviewing a patch on the mmc-list, I ended up inspecting the behaviour of
how we deal with the no callback case for runtime PM.
A couple of observations:
*) When pm_runtime_no_callbacks() have been called, it allows the PM core to
takes a quicker path, but at the same time, consumer/supplier device links are
being skipped in rpm_resume|suspend().
**) Calling pm_runtime_no_callbacks() to avoid boiler plate code (assigning
empty functions to ->runtime_suspend|resume()), doesn't work if there could be
consumer/supplier device link being used or a platform dependent PM domain that
could get attached to the device.
Therefore, this series suggests to change the behaviour in the PM core, to
allow the ->runtime_suspend|resume() callbacks to be unassigned. This is already
supported for ->runtime_idle() callbacks, so it would also move things into a
more consistent behaviour.
I have looked at various error paths, in the kernel of callers of
pm_runtime_get_sync(). I couldn't find anyone that made sense, that looked for
the special error code, -ENOSYS, which is the error code getting returned when a
callback is missing. Whether that is sufficient proof that these changes are
100% safe, I can't guarantee, but I think it would be worth a try as the
benefits of avoiding boilerplate code and the corresponding additional code
paths are quite nice, if you ask me.
In principle I have no objection to these changes. It's likely
that if any problems do crop up, we'll be able to fix them pretty
easily. For patches 1 and 2:
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Alan Stern
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Tue, 8 Jun 2021 at 16:23, Alan Stern [off-list ref] wrote:
On Tue, Jun 08, 2021 at 11:02:50AM +0200, Ulf Hansson wrote:
quoted
Recent changes to the PM core allows ->runtime_suspend|resume callbacks to
be unassigned.
In the earlier behaviour the PM core would return -ENOSYS, when trying to
runtime resume a device, for example. Let's update the documentation to
clarify this.
Signed-off-by: Ulf Hansson <redacted>
---
Changes in v2:
- Added a new patch for the updating the docs, as pointed out by Alan.
---
Documentation/power/runtime_pm.rst | 8 ++++++++
1 file changed, 8 insertions(+)
@@ -827,6 +827,14 @@ or driver about runtime power changes. Instead, the driver for the device's parent must take responsibility for telling the device's driver when the parent's power state changes.+Note that, in some cases it may not be desirable for subsystems/drivers to call+pm_runtime_no_callbacks() for their devices. This could be because a subset of+the runtime PM callbacks needs to be implemented, a platform dependent PM+domain could get attached to the device or that the device is power manged+through a supplier device link. For these reasons and to avoid boilerplate code+in subsystems/drivers, the PM core allows runtime PM callbacks to be+unassigned.+
You should also mention that if a callback pointer is NULL, the
runtime PM core will act as though there was a callback and it
returned 0. That's an important consideration.
Good point, let me add it.
I send a new version of $subject patch, unless Rafael is happy to do
the amending when/if applying?
Also, notice that this file was carefully edited to make sure that
none of the lines exceed 80 characters. Your new addition should
be the same.
From: Alan Stern <stern@rowland.harvard.edu> Date: 2021-06-08 14:49:07
On Tue, Jun 08, 2021 at 04:30:48PM +0200, Ulf Hansson wrote:
On Tue, 8 Jun 2021 at 16:23, Alan Stern [off-list ref] wrote:
quoted
On Tue, Jun 08, 2021 at 11:02:50AM +0200, Ulf Hansson wrote:
quoted
Recent changes to the PM core allows ->runtime_suspend|resume callbacks to
be unassigned.
In the earlier behaviour the PM core would return -ENOSYS, when trying to
runtime resume a device, for example. Let's update the documentation to
clarify this.
Signed-off-by: Ulf Hansson <redacted>
---
Changes in v2:
- Added a new patch for the updating the docs, as pointed out by Alan.
---
Documentation/power/runtime_pm.rst | 8 ++++++++
1 file changed, 8 insertions(+)
@@ -827,6 +827,14 @@ or driver about runtime power changes. Instead, the driver for the device's parent must take responsibility for telling the device's driver when the parent's power state changes.+Note that, in some cases it may not be desirable for subsystems/drivers to call
More than 80 chars.
quoted
quoted
+pm_runtime_no_callbacks() for their devices. This could be because a subset of
More than 80 chars.
quoted
quoted
+the runtime PM callbacks needs to be implemented, a platform dependent PM
+domain could get attached to the device or that the device is power manged
s/manged/managed/
quoted
quoted
+through a supplier device link. For these reasons and to avoid boilerplate code
More than 80 chars.
quoted
quoted
+in subsystems/drivers, the PM core allows runtime PM callbacks to be
+unassigned.
+
You should also mention that if a callback pointer is NULL, the
runtime PM core will act as though there was a callback and it
returned 0. That's an important consideration.
Good point, let me add it.
I send a new version of $subject patch, unless Rafael is happy to do
the amending when/if applying?
quoted
Also, notice that this file was carefully edited to make sure that
none of the lines exceed 80 characters. Your new addition should
be the same.
On Tue, 8 Jun 2021 at 16:49, Alan Stern [off-list ref] wrote:
On Tue, Jun 08, 2021 at 04:30:48PM +0200, Ulf Hansson wrote:
quoted
On Tue, 8 Jun 2021 at 16:23, Alan Stern [off-list ref] wrote:
quoted
On Tue, Jun 08, 2021 at 11:02:50AM +0200, Ulf Hansson wrote:
quoted
Recent changes to the PM core allows ->runtime_suspend|resume callbacks to
be unassigned.
In the earlier behaviour the PM core would return -ENOSYS, when trying to
runtime resume a device, for example. Let's update the documentation to
clarify this.
Signed-off-by: Ulf Hansson <redacted>
---
Changes in v2:
- Added a new patch for the updating the docs, as pointed out by Alan.
---
Documentation/power/runtime_pm.rst | 8 ++++++++
1 file changed, 8 insertions(+)
@@ -827,6 +827,14 @@ or driver about runtime power changes. Instead, the driver for the device's parent must take responsibility for telling the device's driver when the parent's power state changes.+Note that, in some cases it may not be desirable for subsystems/drivers to call
More than 80 chars.
Perhaps it's the email client that messes up the patch in some way.
This above line in the patch is 79 chars.
If you have a look at the patch in patchwork [1], you should see (I
hope) that it respects the 80 chars per line!?
quoted
quoted
quoted
+pm_runtime_no_callbacks() for their devices. This could be because a subset of
More than 80 chars.
quoted
quoted
quoted
+the runtime PM callbacks needs to be implemented, a platform dependent PM
+domain could get attached to the device or that the device is power manged
s/manged/managed/
Thanks for spotting this, my spell checker accepted "manged". :-)
quoted
quoted
quoted
+through a supplier device link. For these reasons and to avoid boilerplate code
More than 80 chars.
quoted
quoted
quoted
+in subsystems/drivers, the PM core allows runtime PM callbacks to be
+unassigned.
+
You should also mention that if a callback pointer is NULL, the
runtime PM core will act as though there was a callback and it
returned 0. That's an important consideration.
Good point, let me add it.
I send a new version of $subject patch, unless Rafael is happy to do
the amending when/if applying?
quoted
Also, notice that this file was carefully edited to make sure that
none of the lines exceed 80 characters. Your new addition should
be the same.