From: Huang Ying <ying.huang@intel.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: LKML <linux-kernel@vger.kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Linux PM list <linux-pm@vger.kernel.org>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
"Svahn, Kai" <kai.svahn@intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
"Lan, Tianyu" <tianyu.lan@intel.com>,
"Zheng, Lv" <lv.zheng@intel.com>, Aaron Lu <aaron.lu@intel.com>,
Grant Likely <grant.likely@secretlab.ca>
Subject: Re: [PATCH 1/2] ACPI / PM: Allow attach/detach routines to change device power states
Date: Mon, 26 Nov 2012 09:07:27 +0800 [thread overview]
Message-ID: <1353892047.28789.82.camel@yhuang-dev> (raw)
In-Reply-To: <4238031.sDhWdlxYNQ@vostro.rjw.lan>
On Mon, 2012-11-26 at 02:00 +0100, Rafael J. Wysocki wrote:
> On Monday, November 26, 2012 08:43:10 AM Huang Ying wrote:
> > On Sun, 2012-11-25 at 15:55 +0100, Rafael J. Wysocki wrote:
> > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > >
> > > Make it possible to ask the routines used for adding/removing devices
> > > to/from the general ACPI PM domain, acpi_dev_pm_attach() and
> > > acpi_dev_pm_detach(), respectively, to change the power states of
> > > devices so that they are put into the full-power state automatically
> > > by acpi_dev_pm_attach() and into the lowest-power state available
> > > automatically by acpi_dev_pm_detach().
> > >
> > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > > ---
> > > drivers/acpi/device_pm.c | 28 ++++++++++++++++++++++++----
> > > include/linux/acpi.h | 11 +++++++----
> > > 2 files changed, 31 insertions(+), 8 deletions(-)
> > >
> > > Index: linux/drivers/acpi/device_pm.c
> > > ===================================================================
> > > --- linux.orig/drivers/acpi/device_pm.c
> > > +++ linux/drivers/acpi/device_pm.c
> > > @@ -599,10 +599,12 @@ static struct dev_pm_domain acpi_general
> > > /**
> > > * acpi_dev_pm_attach - Prepare device for ACPI power management.
> > > * @dev: Device to prepare.
> > > + * @power_on: Whether or not to power on the device.
> > > *
> > > * If @dev has a valid ACPI handle that has a valid struct acpi_device object
> > > * attached to it, install a wakeup notification handler for the device and
> > > - * add it to the general ACPI PM domain.
> > > + * add it to the general ACPI PM domain. If @power_on is set, the device will
> > > + * be put into the ACPI D0 state before the function returns.
> > > *
> > > * This assumes that the @dev's bus type uses generic power management callbacks
> > > * (or doesn't use any power management callbacks at all).
> > > @@ -610,7 +612,7 @@ static struct dev_pm_domain acpi_general
> > > * Callers must ensure proper synchronization of this function with power
> > > * management callbacks.
> > > */
> > > -int acpi_dev_pm_attach(struct device *dev)
> > > +int acpi_dev_pm_attach(struct device *dev, bool power_on)
> > > {
> > > struct acpi_device *adev = acpi_dev_pm_get_node(dev);
> > >
> > > @@ -622,6 +624,10 @@ int acpi_dev_pm_attach(struct device *de
> > >
> > > acpi_add_pm_notifier(adev, acpi_wakeup_device, dev);
> > > dev->pm_domain = &acpi_general_pm_domain;
> > > + if (power_on) {
> > > + acpi_dev_pm_full_power(adev);
> > > + __acpi_device_run_wake(adev, false);
> > > + }
> > > return 0;
> > > }
> > > EXPORT_SYMBOL_GPL(acpi_dev_pm_attach);
> > > @@ -629,20 +635,34 @@ EXPORT_SYMBOL_GPL(acpi_dev_pm_attach);
> > > /**
> > > * acpi_dev_pm_detach - Remove ACPI power management from the device.
> > > * @dev: Device to take care of.
> > > + * @power_off: Whether or not to try to remove power from the device.
> > > *
> > > * Remove the device from the general ACPI PM domain and remove its wakeup
> > > - * notifier.
> > > + * notifier. If @power_off is set, additionally remove power from the device if
> > > + * possible.
> > > *
> > > * Callers must ensure proper synchronization of this function with power
> > > * management callbacks.
> > > */
> > > -void acpi_dev_pm_detach(struct device *dev)
> > > +void acpi_dev_pm_detach(struct device *dev, bool power_off)
> > > {
> > > struct acpi_device *adev = acpi_dev_pm_get_node(dev);
> > >
> > > if (adev && dev->pm_domain == &acpi_general_pm_domain) {
> > > dev->pm_domain = NULL;
> > > acpi_remove_pm_notifier(adev, acpi_wakeup_device);
> > > + if (power_off) {
> > > + /*
> > > + * If the device's PM QoS resume latency limit or flags
> > > + * have been exposed to user space, they have to be
> > > + * hidden at this point, so that they don't affect the
> > > + * choice of the low-power state to put the device into.
> > > + */
> > > + dev_pm_qos_hide_latency_limit(dev);
> > > + dev_pm_qos_hide_flags(dev);
> >
> > NO_POWER_OFF flag is ignored here. Is it possible for some device (or
> > corresponding ACPI method) has broken D3cold implementation, so that the
> > user need a way to disable it?
>
> We are removing the driver here and we haven't exposed the flags, have we?
IMHO, the flag may be exposed by the bus instead of device driver.
Because some bus can determine whether D3cold is supported by the
device. If the sysfs file for the flag is exposed by the bus, user set
it and we silently ignore it, will it cause confusing for the user?
Best Regards,
Huang Ying
> If the driver had exposed them and then left them behind, we need to clean up
> after it and that's why I added those two lines.
>
> In the future we may decide that the flags need to be exposed by the core,
> because of the broken hardware, for example, before the driver's .probe()
> routine is run and in that case we obviously won't be removing them here any
> more. For now, however, I think it's better to hide them here.
>
> Thanks,
> Rafael
>
>
next prev parent reply other threads:[~2012-11-26 1:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-25 14:54 [PATCH 0/2] ACPI / platform: Put devices enumerated via ACPI into D0 before probing drivers Rafael J. Wysocki
2012-11-25 14:55 ` [PATCH 1/2] ACPI / PM: Allow attach/detach routines to change device power states Rafael J. Wysocki
2012-11-26 0:43 ` Huang Ying
2012-11-26 1:00 ` Rafael J. Wysocki
2012-11-26 1:07 ` Huang Ying [this message]
2012-11-26 1:16 ` Rafael J. Wysocki
2012-11-26 1:25 ` Huang Ying
2012-11-25 14:58 ` [PATCH 2/2] platform / ACPI: Attach/detach ACPI PM during probe/remove/shutdown Rafael J. Wysocki
2012-11-25 18:42 ` Greg Kroah-Hartman
2012-11-25 19:57 ` Rafael J. Wysocki
2012-11-27 5:24 ` Zheng, Lv
2012-11-26 6:31 ` [PATCH 0/2] ACPI / platform: Put devices enumerated via ACPI into D0 before probing drivers Mika Westerberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1353892047.28789.82.camel@yhuang-dev \
--to=ying.huang@intel.com \
--cc=aaron.lu@intel.com \
--cc=grant.likely@secretlab.ca \
--cc=gregkh@linuxfoundation.org \
--cc=kai.svahn@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lv.zheng@intel.com \
--cc=mika.westerberg@linux.intel.com \
--cc=rjw@sisk.pl \
--cc=rui.zhang@intel.com \
--cc=tianyu.lan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).