From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: LKML <linux-kernel@vger.kernel.org>
Cc: 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>,
Huang Ying <ying.huang@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: [PATCH 2/2] platform / ACPI: Attach/detach ACPI PM during probe/remove/shutdown
Date: Sun, 25 Nov 2012 15:58:14 +0100 [thread overview]
Message-ID: <6227446.8xPtqi6yHi@vostro.rjw.lan> (raw)
In-Reply-To: <1672179.qgDUs0YdYu@vostro.rjw.lan>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Drivers usually expect that the devices they are supposed to handle
will be operational when their .probe() routines are called, but that
need not be the case on some ACPI-based systems with ACPI-based
device enumeration where the BIOSes don't put devices into D0 by
default. To work around this problem it is sufficient to change
bus type .probe() routines to ensure that devices will be powered
on before the drivers' .probe() routines run (and their .remove()
and .shutdown() routines accordingly).
Modify platform_drv_probe() to run acpi_dev_pm_attach() for devices
whose ACPI handles are present, so that ACPI power management is used
to change their power states and change their power states to D0
before driver probing. Analogously, modify platform_drv_remove() and
platform_drv_shutdown() to call acpi_dev_pm_detach() for those
devices, so that they are not subject to ACPI PM any more.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/base/platform.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
Index: linux/drivers/base/platform.c
===================================================================
--- linux.orig/drivers/base/platform.c
+++ linux/drivers/base/platform.c
@@ -484,8 +484,16 @@ static int platform_drv_probe(struct dev
{
struct platform_driver *drv = to_platform_driver(_dev->driver);
struct platform_device *dev = to_platform_device(_dev);
+ int ret;
- return drv->probe(dev);
+ if (ACPI_HANDLE(_dev))
+ acpi_dev_pm_attach(_dev, true);
+
+ ret = drv->probe(dev);
+ if (ret && ACPI_HANDLE(_dev))
+ acpi_dev_pm_detach(_dev, true);
+
+ return ret;
}
static int platform_drv_probe_fail(struct device *_dev)
@@ -497,8 +505,13 @@ static int platform_drv_remove(struct de
{
struct platform_driver *drv = to_platform_driver(_dev->driver);
struct platform_device *dev = to_platform_device(_dev);
+ int ret;
+
+ ret = drv->remove(dev);
+ if (ACPI_HANDLE(_dev))
+ acpi_dev_pm_detach(_dev, true);
- return drv->remove(dev);
+ return ret;
}
static void platform_drv_shutdown(struct device *_dev)
@@ -507,6 +520,8 @@ static void platform_drv_shutdown(struct
struct platform_device *dev = to_platform_device(_dev);
drv->shutdown(dev);
+ if (ACPI_HANDLE(_dev))
+ acpi_dev_pm_detach(_dev, true);
}
/**
next prev parent reply other threads:[~2012-11-25 14:54 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
2012-11-26 1:16 ` Rafael J. Wysocki
2012-11-26 1:25 ` Huang Ying
2012-11-25 14:58 ` Rafael J. Wysocki [this message]
2012-11-25 18:42 ` [PATCH 2/2] platform / ACPI: Attach/detach ACPI PM during probe/remove/shutdown 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=6227446.8xPtqi6yHi@vostro.rjw.lan \
--to=rjw@sisk.pl \
--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=rui.zhang@intel.com \
--cc=tianyu.lan@intel.com \
--cc=ying.huang@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
all inboxes | Powered by JetHome®