RE: [PATCH 1/1] PM / Runtime: let rpm_resume fail if rpm disabled and device suspended.

2014-06-19 Thread Allen Yu
On Thursday, June 19, 2014, Rafael J. Wysocki wrote: > On Thursday, June 19, 2014 04:23:29 PM Allen Yu wrote: > > On Thursday, June 19, 2014, Rafael J. Wysocki wrote: > > > On Wednesday, June 18, 2014 11:30:51 AM Alan Stern wrote: > > > > On Tue, 17 Jun

RE: [PATCH 1/1] PM / Runtime: let rpm_resume fail if rpm disabled and device suspended.

2014-06-19 Thread Allen Yu
and pm_request_resume() would still fail, but > > pm_runtime_get() and pm_runtime_get_sync() would work? I'm not sure > > about the reason for this distinction. > > The meaning of pm_runtime_get()/pm_runtime_get_sync() is "prevent the > device from being suspended from now on and resume it if necessary" while > "runtime PM disabled and runtime_status == RPM_ACTIVE" may be > interpreted as "not necessary to resume", so it is reasonable to special case > this particular situation for these particular routines IMHO. As Rafael mentioned above that runtime_sataus is not meaningful if runtime PM is disabled, so shouldn't we avoid using the runtime_staus here and instead use dev->power.is_suspended only to decide the return value? @@ -608,11 +608,13 @@ static int rpm_resume(struct device *dev, int rpmflags) repeat: if (dev->power.runtime_error) retval = -EINVAL; - else if (dev->power.disable_depth == 1 && dev->power.is_suspended - && dev->power.runtime_status == RPM_ACTIVE) - retval = 1; - else if (dev->power.disable_depth > 0) - retval = -EACCES; + else if (dev->power.disable_depth > 0) { + if (!dev->power.is_suspended) + retval = 1; + else + retval = -EACCES; + } + if (retval) goto out; However, this requires us to make sure device is in full functional state if it's not suspended before disabling runtime PM, just like the case runtime PM is not configured at all. And also requires device suspend routine to check dev->power.usage_count before suspending device. Thanks, Allen Yu N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a��� 0��h���i

RE: [PATCH 1/1] PM / Runtime: let rpm_resume fail if rpm disabled and device suspended.

2014-06-19 Thread Allen Yu
at all. And also requires device suspend routine to check dev-power.usage_count before suspending device. Thanks, Allen Yu N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�j:+v���zZ+��+zf���h���~i���z��w���?��)ߢf��^jǫy�m��@A�a��� 0��h���i

RE: [PATCH 1/1] PM / Runtime: let rpm_resume fail if rpm disabled and device suspended.

2014-06-19 Thread Allen Yu
On Thursday, June 19, 2014, Rafael J. Wysocki wrote: On Thursday, June 19, 2014 04:23:29 PM Allen Yu wrote: On Thursday, June 19, 2014, Rafael J. Wysocki wrote: On Wednesday, June 18, 2014 11:30:51 AM Alan Stern wrote: On Tue, 17 Jun 2014, Rafael J. Wysocki wrote: On Tuesday

RE: [PATCH 1/1] PM / Runtime: let rpm_resume fail if rpm disabled and device suspended.

2014-06-15 Thread Allen Yu
only allowing access to a device if it's not suspended (i.e. value of "is_suspneded" flag is false). > > Signed-off-by: Allen Yu > > --- > > drivers/base/power/runtime.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/d

RE: [PATCH 1/1] PM / Runtime: let rpm_resume fail if rpm disabled and device suspended.

2014-06-15 Thread Allen Yu
state. Whereas the case I mentioned above is before device is suspended. It's dangerous to access device if it's in suspended state, so I propose only allowing access to a device if it's not suspended (i.e. value of is_suspneded flag is false). Signed-off-by: Allen Yu all...@nvidia.com

[PATCH 1/1] PM / Runtime: let rpm_resume fail if rpm disabled and device suspended.

2014-06-14 Thread Allen Yu
wer transition. In this case, runtime PM status will be set to RPM_ACTIVE and then runtime PM is disabled. After that, device driver may call pm_runtime_get_sync() and rpm_resume() should return 1, because the device is still active as long as not been suspended. Signed-off-by: Allen Yu --- driv

[PATCH 1/1] PM / Runtime: let rpm_resume fail if rpm disabled and device suspended.

2014-06-14 Thread Allen Yu
transition. In this case, runtime PM status will be set to RPM_ACTIVE and then runtime PM is disabled. After that, device driver may call pm_runtime_get_sync() and rpm_resume() should return 1, because the device is still active as long as not been suspended. Signed-off-by: Allen Yu all...@nvidia.com