PM / Runtime: let rpm_resume() succeed if RPM_ACTIVE, even when disabled
Subsystems (4)
PATCH 1/1 PM / Runtime: let rpm_resume() succeed if RPM_ACTIVE, even when disabled
From: Kevin Hilman <[email protected]>
When runtime PM is disabled, what we want is for callbacks not to be called from then on. However, currently, when runtime PM is disabled, operations such as 'get' will also fail even if the device is currently active.
Since calling 'get' on a device that is already RPM_ACTIVE does not involve calling the callbacks, it should be allowed to succeed, even if runtime PM is disabled.
This is particularily useful in runtime PM enabled drivers that are used during system suspend. Because runtime PM is disabled during system suspend, currently any driver's use of pm_runtime_get* will fail with -EACCES. This is expected if the device was already runtime suspended, but if the device is actually active (due to recent usage, autosuspend timeout not expired, or pm_runtime_resume() called in ->suspend() method), the pm_runtime_get*() call should actually succeed.
To permit the usage described above, add a check to rpm_resume() so that success is returned in the case where a driver is suspended (it's ->suspend callback has been called) but is still RPM_ACTIVE.
This patch was developed in close collaboration with Rafael J. Wysocki <[email protected]>
Tested on AM3730/Beagle-xM where wakeup IRQ firing during the late suspend phase triggers runtime PM activity in the I2C driver since the wakeup IRQ is on an I2C-connected PMIC.
--- drivers/base/power/runtime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/power/runtime.c +2 -1
@@ -510,7 +510,8 @@ static int rpm_resume(struct device *dev, int rpmflags)if (dev->power.runtime_error) retval = -EINVAL ;else if (dev->power.disable_depth >0 ) - retval = -EACCES ; + retval = dev->power.is_suspended && + dev->power.runtime_status ==RPM_ACTIVE ?1 : -EACCES ;if (retval) goto out;
Signature · 1 line
1.7.9.2
Hi,
Quoted 24 lines · Kevin Hilman
From: Kevin Hilman <[email protected]>
When runtime PM is disabled, what we want is for callbacks not to be called from then on. However, currently, when runtime PM is disabled, operations such as 'get' will also fail even if the device is currently active.
Since calling 'get' on a device that is already
RPM_ACTIVEdoes not involve calling the callbacks, it should be allowed to succeed, even if runtime PM is disabled.This is particularily useful in runtime PM enabled drivers that are used during system suspend. Because runtime PM is disabled during system suspend, currently any driver's use of pm_runtime_get* will fail with
-EACCES. This is expected if the device was already runtime suspended, but if the device is actually active (due to recent usage, autosuspend timeout not expired, orpm_runtime_resume()called in ->suspend() method), the pm_runtime_get*() call should actually succeed.To permit the usage described above, add a check to
rpm_resume()so that success is returned in the case where a driver is suspended (it's ->suspend callback has been called) but is stillRPM_ACTIVE.
Quoted 6 lines
This patch was developed in close collaboration with Rafael J. Wysocki <[email protected]>
Tested on AM3730/Beagle-xM where wakeup IRQ firing during the late suspend phase triggers runtime PM activity in the I2C driver since the wakeup IRQ is on an I2C-connected PMIC.
Please resend it with a CC to [email protected]. Nobody reads [email protected] today, I suppose ...
Thanks,
Rafael
Quoted 21 lines
Cc Rafael J. Wysocki <[email protected]>Signed-off-by Kevin Hilman <[email protected]>--- drivers/base/power/runtime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/base/power/runtime.c +2
-1@@ -510,7 +510,8 @@ static int rpm_resume(struct device *dev, int rpmflags)if (dev->power.runtime_error) retval = -EINVAL ;else if (dev->power.disable_depth >0 ) - retval = -EACCES ; + retval = dev->power.is_suspended && + dev->power.runtime_status ==RPM_ACTIVE ?1 : -EACCES ;if (retval) goto out;