PM: runtime: Return -EINPROGRESS from rpm_resume() in the RPM_NOWAIT case
Subsystems (4)
PATCH 1/1 PM: runtime: Return -EINPROGRESS from rpm_resume() in the RPM_NOWAIT case
From: Rafael J. Wysocki <[email protected]>
The prospective callers of rpm_resume() passing RPM_NOWAIT to it may be confused when it returns 0 without actually resuming the device which may happen if the device is suspending at the given time and it will only resume when the suspend in progress has completed. To avoid that confusion, return -EINPROGRESS from rpm_resume() in that case.
Since none of the current callers passing RPM_NOWAIT to rpm_resume() check its return value, this change has no functional impact.
--- drivers/base/power/runtime.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/base/power/runtime.c +5 -2
@@ -792,10 +792,13 @@ static int rpm_resume(struct device *devDEFINE_WAIT (wait);if (rpmflags & (RPM_ASYNC |RPM_NOWAIT )) { -if (dev->power.runtime_status ==RPM_SUSPENDING ) +if (dev->power.runtime_status ==RPM_SUSPENDING ) { dev->power.deferred_resume = true; -else +if (rpmflags &RPM_NOWAIT ) + retval = -EINPROGRESS ; + }else { retval = -EINPROGRESS ; + } goto out; }
Quoted 21 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The prospective callers of
rpm_resume()passingRPM_NOWAITto it may be confused when it returns 0 without actually resuming the device which may happen if the device is suspending at the given time and it will only resume when the suspend in progress has completed. To avoid that confusion, return-EINPROGRESSfromrpm_resume()in that case.Since none of the current callers passing
RPM_NOWAITtorpm_resume()check its return value, this change has no functional impact.Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/base/power/runtime.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)Index:
linux-pm/drivers/base/power/runtime.c
===================================================================
drivers/base/power/runtime.c static int rpm_resume(struct device *dev · line 794
Quoted 3 lines
drivers/base/power/runtime.c +0
-0@@ -792,10 +792,13 @@ static int rpm_resume(struct device *devDEFINE_WAIT (wait);if (rpmflags & (RPM_ASYNC |RPM_NOWAIT )) {
Hmmm, and what if a caller sets both of these flags? I guess in that case he gets what he deserves.
drivers/base/power/runtime.c static int rpm_resume(struct device *dev · line 803
Quoted 11 lines
drivers/base/power/runtime.c +5
-2-if (dev->power.runtime_status ==RPM_SUSPENDING ) +if (dev->power.runtime_status ==RPM_SUSPENDING ) { dev->power.deferred_resume = true; -else +if (rpmflags &RPM_NOWAIT ) + retval = -EINPROGRESS ; + }else { retval = -EINPROGRESS ; + } goto out; }
Rafael J. Wysocki
maintainerQuoted 25 lines · Alan Stern
Quoted 23 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The prospective callers of
rpm_resume()passingRPM_NOWAITto it may be confused when it returns 0 without actually resuming the device which may happen if the device is suspending at the given time and it will only resume when the suspend in progress has completed. To avoid that confusion, return-EINPROGRESSfromrpm_resume()in that case.Since none of the current callers passing
RPM_NOWAITtorpm_resume()check its return value, this change has no functional impact.Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/base/power/runtime.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)Index:
linux-pm/drivers/base/power/runtime.c
===================================================================drivers/base/power/runtime.c +0
-0@@ -792,10 +792,13 @@ static int rpm_resume(struct device *devDEFINE_WAIT (wait);
Quoted 4 lines
drivers/base/power/runtime.c static int rpm_resume(struct device *dev · line 794
Quoted 1 line
drivers/base/power/runtime.c +0
-0if (rpmflags & (RPM_ASYNC |RPM_NOWAIT )) {Hmmm, and what if a caller sets both of these flags? I guess in that case he gets what he deserves.
Exactly.
Quoted 12 lines
drivers/base/power/runtime.c static int rpm_resume(struct device *dev · line 803
Quoted 11 lines
drivers/base/power/runtime.c +5
-2-if (dev->power.runtime_status ==RPM_SUSPENDING ) +if (dev->power.runtime_status ==RPM_SUSPENDING ) { dev->power.deferred_resume = true; -else +if (rpmflags &RPM_NOWAIT ) + retval = -EINPROGRESS ; + }else { retval = -EINPROGRESS ; + } goto out; }
Quoted 1 line
Acked-by Alan Stern <[email protected]>
Thanks!
Hi,
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The prospective callers of
rpm_resume()passingRPM_NOWAITto it may be confused when it returns 0 without actually resuming the device which may happen if the device is suspending at the given time and it will only resume when the suspend in progress has completed. To avoid that confusion, return-EINPROGRESSfromrpm_resume()in that case.
Quoted 7 lines
Since none of the current callers passing
RPM_NOWAITtorpm_resume()check its return value, this change has no functional impact.Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/base/power/runtime.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Seems reasonable to me.
Quoted 11 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The prospective callers of
rpm_resume()passingRPM_NOWAITto it may be confused when it returns 0 without actually resuming the device which may happen if the device is suspending at the given time and it will only resume when the suspend in progress has completed. To avoid that confusion, return-EINPROGRESSfromrpm_resume()in that case.Since none of the current callers passing
RPM_NOWAITtorpm_resume()check its return value, this change has no functional impact.
Sounds like there are additional improvements that can be made around this, right?
Quoted 2 lines
Signed-off-by Rafael J. Wysocki <[email protected]>
Looks good to me!
Kind regards
Uffe
Quoted 27 lines
--- drivers/base/power/runtime.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)Index:
linux-pm/drivers/base/power/runtime.c
===================================================================drivers/base/power/runtime.c +5
-2@@ -792,10 +792,13 @@ static int rpm_resume(struct device *devDEFINE_WAIT (wait);if (rpmflags & (RPM_ASYNC |RPM_NOWAIT )) { -if (dev->power.runtime_status ==RPM_SUSPENDING ) +if (dev->power.runtime_status ==RPM_SUSPENDING ) { dev->power.deferred_resume = true; -else +if (rpmflags &RPM_NOWAIT ) + retval = -EINPROGRESS ; + }else { retval = -EINPROGRESS ; + } goto out; }
Rafael J. Wysocki
maintainerQuoted 11 lines · Ulf Hansson
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The prospective callers of
rpm_resume()passingRPM_NOWAITto it may be confused when it returns 0 without actually resuming the device which may happen if the device is suspending at the given time and it will only resume when the suspend in progress has completed. To avoid that confusion, return-EINPROGRESSfromrpm_resume()in that case.
Quoted 5 lines
Quoted 2 lines
Since none of the current callers passing
RPM_NOWAITtorpm_resume()check its return value, this change has no functional impact.Sounds like there are additional improvements that can be made around this, right?
This allows RPM_NOWAIT to be used in places where the caller doesn't want to wait, because it might deadlock or similar, but they still need to know whether or not the device can be accessed safely.
Or do you mean something else?
Quoted 6 lines
Quoted 2 lines
Signed-off-by Rafael J. Wysocki <[email protected]>Looks good to me!
Reviewed-by Ulf Hansson <[email protected]>
Thanks!
Quoted 27 lines
Quoted 27 lines
--- drivers/base/power/runtime.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)Index:
linux-pm/drivers/base/power/runtime.c
===================================================================drivers/base/power/runtime.c +5
-2@@ -792,10 +792,13 @@ static int rpm_resume(struct device *devDEFINE_WAIT (wait);if (rpmflags & (RPM_ASYNC |RPM_NOWAIT )) { -if (dev->power.runtime_status ==RPM_SUSPENDING ) +if (dev->power.runtime_status ==RPM_SUSPENDING ) { dev->power.deferred_resume = true; -else +if (rpmflags &RPM_NOWAIT ) + retval = -EINPROGRESS ; + }else { retval = -EINPROGRESS ; + } goto out; }
Quoted 16 lines · Rafael J. Wysocki
Quoted 14 lines · Ulf Hansson
Quoted 11 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The prospective callers of
rpm_resume()passingRPM_NOWAITto it may be confused when it returns 0 without actually resuming the device which may happen if the device is suspending at the given time and it will only resume when the suspend in progress has completed. To avoid that confusion, return-EINPROGRESSfromrpm_resume()in that case.Since none of the current callers passing
RPM_NOWAITtorpm_resume()check its return value, this change has no functional impact.
Quoted 8 lines
Quoted 2 lines
Sounds like there are additional improvements that can be made around this, right?
This allows
RPM_NOWAITto be used in places where the caller doesn't want to wait, because it might deadlock or similar, but they still need to know whether or not the device can be accessed safely.Or do you mean something else?
Nope, I was mostly wondering if you are planning to make those improvements too. Sooner or later.
[...]
Kind regards
Uffe