From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752761AbbGNNTk (ORCPT ); Tue, 14 Jul 2015 09:19:40 -0400 Received: from mail-wg0-f48.google.com ([74.125.82.48]:36863 "EHLO mail-wg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752054AbbGNNTi (ORCPT ); Tue, 14 Jul 2015 09:19:38 -0400 MIME-Version: 1.0 In-Reply-To: References: <9291571.JSDgNsKidJ@vostro.rjw.lan> From: Tomeu Vizoso Date: Tue, 14 Jul 2015 15:19:16 +0200 X-Google-Sender-Auth: sGeT3pHf-36A5Vry8tO_6R7Ix-g Message-ID: Subject: Re: [PATCH v3 2/2] PM / Runtime: Add pm_runtime_enable_recursive To: Alan Stern Cc: "Rafael J. Wysocki" , "linux-pm@vger.kernel.org" , Laurent Pinchart , Dmitry Torokhov , Len Brown , Pavel Machek , Greg Kroah-Hartman , Ulf Hansson , Kevin Hilman , Russell King , Krzysztof Kozlowski , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8 July 2015 at 22:31, Alan Stern wrote: > On Wed, 8 Jul 2015, Rafael J. Wysocki wrote: > >> I seem to have lost the context here, sorry about that. >> >> The idea seems to be to rely on the fact that the RPM status for all devices >> is initially RPM_SUSPENDED and that never changes if runtime PM is never >> enabled for the device, so in that particular case it would be OK to treat >> the "power.direct_complete set + RPM status == RPM_SUSPENDED" combination >> as valid even though runtime PM has never been enabled for the device in >> question (provided that power.direct_complete will never be set for "real" >> devices that don't support runtime PM). Is that correct? > > I would have expressed it slightly differently, but yes, that's correct. > >> That seems to be fragile, but I have no strong opinion. > > In itself it's not all that bad, I think. In the presence of Tomeu's > new direct_complete_default flag, however, it does seem quite fragile. > > We may want to do the direct_complete_default thing in a different way. > For example, the PM core could automatically set the direct_complete > flag if a device has _none_ of the system suspend callbacks (i.e., no > prepare, suspend, suspend_late, suspend_noirq, resume_noirq, > resume_early, resume, or complete). Although it would be a little > awkward to check this, it would be safer than inheriting > direct_complete_default from the parent and it ought to solve Tomeu's > problem just as well. Yeah, I think this is an improvement. Will give it a try. >> Let's do that change if it allows us to make forward progress here. Please >> feel free to submit a documentation patch along the lines you've suggested. > > Here's a proposed patch to illustrate what I have in mind. Since it > removes the only usage of pm_runtime_suspended_if_enabled(), it also > removes the definition of that function. Will this patch be picked up as-is or should I add it to my series with a proper changelog? Thanks, Tomeu > Alan Stern > > > > Index: usb-4.1/drivers/base/power/main.c > =================================================================== > --- usb-4.1.orig/drivers/base/power/main.c > +++ usb-4.1/drivers/base/power/main.c > @@ -1374,7 +1374,7 @@ static int __device_suspend(struct devic > if (dev->power.direct_complete) { > if (pm_runtime_status_suspended(dev)) { > pm_runtime_disable(dev); > - if (pm_runtime_suspended_if_enabled(dev)) > + if (pm_runtime_status_suspended(dev)) > goto Complete; > > pm_runtime_enable(dev); > Index: usb-4.1/Documentation/power/devices.txt > =================================================================== > --- usb-4.1.orig/Documentation/power/devices.txt > +++ usb-4.1/Documentation/power/devices.txt > @@ -341,6 +341,13 @@ the phases are: > and is entirely responsible for bringing the device back to the > functional state as appropriate. > > + Note that this direct-complete procedure applies even if the device is > + disabled for runtime PM; only the runtime-PM status matters. It follows > + that if a device has system-sleep callbacks but does not support runtime > + PM, then its prepare callback must never return a positive value. This > + is because all devices are initially set to runtime-suspended with > + runtime PM disabled. > + > 2. The suspend methods should quiesce the device to stop it from performing > I/O. They also may save the device registers and put it into the > appropriate low-power state, depending on the bus type the device is on, > Index: usb-4.1/Documentation/power/runtime_pm.txt > =================================================================== > --- usb-4.1.orig/Documentation/power/runtime_pm.txt > +++ usb-4.1/Documentation/power/runtime_pm.txt > @@ -445,10 +445,6 @@ drivers/base/power/runtime.c and include > bool pm_runtime_status_suspended(struct device *dev); > - return true if the device's runtime PM status is 'suspended' > > - bool pm_runtime_suspended_if_enabled(struct device *dev); > - - return true if the device's runtime PM status is 'suspended' and its > - 'power.disable_depth' field is equal to 1 > - > void pm_runtime_allow(struct device *dev); > - set the power.runtime_auto flag for the device and decrease its usage > counter (used by the /sys/devices/.../power/control interface to > Index: usb-4.1/include/linux/pm_runtime.h > =================================================================== > --- usb-4.1.orig/include/linux/pm_runtime.h > +++ usb-4.1/include/linux/pm_runtime.h > @@ -98,11 +98,6 @@ static inline bool pm_runtime_status_sus > return dev->power.runtime_status == RPM_SUSPENDED; > } > > -static inline bool pm_runtime_suspended_if_enabled(struct device *dev) > -{ > - return pm_runtime_status_suspended(dev) && dev->power.disable_depth == 1; > -} > - > static inline bool pm_runtime_enabled(struct device *dev) > { > return !dev->power.disable_depth; > @@ -164,7 +159,6 @@ static inline void device_set_run_wake(s > static inline bool pm_runtime_suspended(struct device *dev) { return false; } > static inline bool pm_runtime_active(struct device *dev) { return true; } > static inline bool pm_runtime_status_suspended(struct device *dev) { return false; } > -static inline bool pm_runtime_suspended_if_enabled(struct device *dev) { return false; } > static inline bool pm_runtime_enabled(struct device *dev) { return false; } > > static inline void pm_runtime_no_callbacks(struct device *dev) {} > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/