From: Matthew Garrett <mjg59@srcf.ucam.org>
To: David Brownell <david-b@pacbell.net>
Cc: linux-kernel@vger.kernel.org, gregkh@suse.de
Subject: [PATCH] Fix /sys/device/.../power/state regression
Date: Thu, 25 Jan 2007 05:00:09 +0000 [thread overview]
Message-ID: <20070125050009.GA8672@srcf.ucam.org> (raw)
In-Reply-To: <20061221040648.GA1499@srcf.ucam.org>
In 2.6.19, support for splitting driver suspend and resume callbacks
into interrupt and non-interrupt contexts was added. Unfortunately, this
broke /sys/device/.../power/state support for all devices. In the long
run, this should be obsoleted by power management support in the
individual drivers - however, in the case of network drivers (for
example), currently only three drivers implement any sort of useful
run-time power management.
This patch allows the bus driver to check whether a specific driver
requires the split. If not, the 2.6.18 functionality is restored. It
also alters feature-removals.txt to note that the deprecated
functionality should not be removed until a replacement actually exists.
Signed-off-by: Matthew Garrett <mjg59@srcf.ucam.org>
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -9,7 +9,8 @@ be removed from this file.
What: /sys/devices/.../power/state
dev->power.power_state
dpm_runtime_{suspend,resume)()
-When: July 2007
+ bus->pm_has_noirq_stage()
+When: Once alternative functionality has been implemented
Why: Broken design for runtime control over driver power states, confusing
driver-internal runtime power management with: mechanisms to support
system-wide sleep state transitions; event codes that distinguish
diff --git a/Documentation/power/devices.txt b/Documentation/power/devices.txt
index d0e79d5..345cca4 100644
--- a/Documentation/power/devices.txt
+++ b/Documentation/power/devices.txt
@@ -79,6 +79,7 @@ struct bus_type {
int (*resume_early)(struct device *dev);
int (*resume)(struct device *dev);
+ int (*pm_has_noirq_stage)(struct device *dev);
};
Bus drivers implement those methods as appropriate for the hardware and
@@ -236,6 +237,10 @@ The phases are seen by driver notifications issued in this order:
may stay partly usable until this late. This "late" call may also
help when coping with hardware that behaves badly.
+ If a bus implements the suspend_late method, it must also provide a
+ pm_has_noirq_stage function in order to determine whether devices
+ may be suspended during runtime.
+
The pm_message_t parameter is currently used to refine those semantics
(described later).
@@ -348,7 +353,9 @@ The phases are seen by driver notifications issued in this order:
won't be supported on busses that require IRQs in order to
interact with devices.
- This reverses the effects of bus.suspend_late().
+ This reverses the effects of bus.suspend_late(). As with suspend_late,
+ if a bus implements this function it must provide a pm_has_noirq_stage
+ function.
2 bus.resume(dev) is called next. This may be morphed into a device
driver call with bus-specific parameters; implementations may sleep.
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f9c903b..6bf1218 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -597,6 +597,16 @@ static int platform_resume(struct device * dev)
return ret;
}
+static int platform_pm_has_noirq_stage(struct device * dev)
+{
+ int ret = 0;
+ struct platform_driver *drv = to_platform_driver(dev->driver);
+
+ if (dev->driver && (drv->resume_early || drv->suspend_late))
+ ret = 1;
+ return ret;
+}
+
struct bus_type platform_bus_type = {
.name = "platform",
.dev_attrs = platform_dev_attrs,
@@ -606,6 +616,7 @@ struct bus_type platform_bus_type = {
.suspend_late = platform_suspend_late,
.resume_early = platform_resume_early,
.resume = platform_resume,
+ .pm_has_noirq_stage = platform_pm_has_noirq_stage,
};
EXPORT_SYMBOL_GPL(platform_bus_type);
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 2d47517..c4ce060 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -46,7 +46,8 @@ static ssize_t state_store(struct device * dev, struct device_attribute *attr, c
int error = -EINVAL;
/* disallow incomplete suspend sequences */
- if (dev->bus && (dev->bus->suspend_late || dev->bus->resume_early))
+ if (dev->bus && dev->bus->pm_has_noirq_stage
+ && dev->bus->pm_has_noirq_stage(dev))
return error;
state.event = PM_EVENT_SUSPEND;
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index e5ae3a0..c0e4e7a 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -351,6 +351,17 @@ static int pci_device_resume(struct device * dev)
return error;
}
+static int pci_device_pm_has_noirq_stage(struct device * dev)
+{
+ int error = 0;
+ struct pci_dev * pci_dev = to_pci_dev(dev);
+ struct pci_driver * drv = pci_dev->driver;
+
+ if (drv && (drv->resume_early || drv->suspend_late))
+ error = 1;
+ return error;
+}
+
static int pci_device_resume_early(struct device * dev)
{
int error = 0;
@@ -569,6 +580,7 @@ struct bus_type pci_bus_type = {
.suspend_late = pci_device_suspend_late,
.resume_early = pci_device_resume_early,
.resume = pci_device_resume,
+ .pm_has_noirq_stage = pci_device_pm_has_noirq_stage,
.shutdown = pci_device_shutdown,
.dev_attrs = pci_dev_attrs,
};
diff --git a/include/linux/device.h b/include/linux/device.h
index 49ab53c..1c663c4 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -59,6 +59,7 @@ struct bus_type {
int (*suspend)(struct device * dev, pm_message_t state);
int (*suspend_late)(struct device * dev, pm_message_t state);
int (*resume_early)(struct device * dev);
+ int (*pm_has_noirq_stage)(struct device * dev);
int (*resume)(struct device * dev);
};
--
Matthew Garrett | mjg59@srcf.ucam.org
next prev parent reply other threads:[~2007-01-25 5:00 UTC|newest]
Thread overview: 119+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-19 18:52 Changes to sysfs PM layer break userspace Matthew Garrett
2006-12-19 19:34 ` Arjan van de Ven
2006-12-19 19:44 ` Matthew Garrett
2006-12-19 20:03 ` Arjan van de Ven
2006-12-19 20:08 ` Matthew Garrett
2006-12-19 20:23 ` Arjan van de Ven
2006-12-19 20:32 ` Matthew Garrett
2006-12-19 20:55 ` Arjan van de Ven
2006-12-21 0:08 ` Kyle Moffett
2006-12-19 21:34 ` David Brownell
2006-12-20 0:25 ` Matthew Garrett
2006-12-20 3:59 ` Changes to " David Brownell
2006-12-20 4:26 ` Matthew Garrett
2006-12-20 5:14 ` David Brownell
2006-12-20 5:34 ` Greg KH
2006-12-20 5:52 ` Matthew Garrett
2006-12-20 7:50 ` Arjan van de Ven
2006-12-20 12:53 ` Network drivers that don't suspend on interface down Matthew Garrett
2006-12-20 13:38 ` Arjan van de Ven
2006-12-20 14:31 ` Matthew Garrett
2006-12-20 15:51 ` Arjan van de Ven
2006-12-20 22:49 ` Stephen Hemminger
2006-12-20 23:37 ` Rick Jones
2006-12-19 23:51 ` Stephen Hemminger
2006-12-21 0:11 ` Francois Romieu
2006-12-20 0:26 ` Stephen Hemminger
2006-12-21 11:18 ` Francois Romieu
2006-12-21 1:12 ` Matthew Garrett
2006-12-21 2:05 ` Michael Wu
2006-12-21 2:18 ` Matthew Garrett
2006-12-21 2:38 ` Daniel Drake
2006-12-21 2:45 ` Matthew Garrett
2006-12-21 3:08 ` Daniel Drake
2006-12-21 3:25 ` Matthew Garrett
2006-12-21 3:37 ` Dan Williams
2006-12-21 3:29 ` Dan Williams
2006-12-21 3:14 ` Dan Williams
2006-12-21 13:14 ` jamal
2006-12-21 2:29 ` Daniel Drake
2006-12-21 2:10 ` Jesse Brandeburg
2006-12-21 8:54 ` Arjan van de Ven
2006-12-22 1:03 ` Herbert Xu
2006-12-23 8:54 ` Pavel Machek
2006-12-20 15:27 ` Olivier Galibert
2006-12-20 15:34 ` Arjan van de Ven
2006-12-20 16:40 ` Olivier Galibert
2006-12-20 17:21 ` Arjan van de Ven
2006-12-20 20:40 ` Benny Amorsen
2006-12-20 21:49 ` Arjan van de Ven
2006-12-20 21:15 ` Stefan Rompf
2006-12-20 14:00 ` Jiri Benc
2006-12-20 18:12 ` Dan Williams
2006-12-21 1:15 ` Matthew Garrett
2006-12-21 1:57 ` Michael Wu
2006-12-21 2:20 ` Matthew Garrett
2006-12-21 3:02 ` Dan Williams
2006-12-21 3:06 ` Dan Williams
2006-12-21 3:14 ` Matthew Garrett
2006-12-21 3:32 ` Dan Williams
2006-12-21 13:19 ` Sven-Haegar Koch
2006-12-21 17:16 ` Dan Williams
2006-12-21 18:27 ` Valdis.Kletnieks
2006-12-22 1:25 ` Matt Domsch
2006-12-20 16:04 ` Maciej W. Rozycki
2006-12-22 21:09 ` Changes to PM layer break userspace Pavel Machek
2006-12-24 7:02 ` David Brownell
2006-12-28 13:31 ` Alan
2006-12-28 16:04 ` Arjan van de Ven
2006-12-29 5:27 ` David Brownell
2006-12-20 2:15 ` Changes to sysfs " Andrew Morton
2006-12-20 2:35 ` Randy Dunlap
2006-12-20 3:49 ` Andrew Morton
2006-12-20 3:29 ` David Brownell
2006-12-21 3:51 ` Andrew Morton
2006-12-21 4:56 ` David Brownell
2006-12-21 5:02 ` Andrew Morton
2006-12-21 7:05 ` David Brownell
2006-12-21 8:27 ` Arjan van de Ven
2006-12-22 20:44 ` Pavel Machek
2006-12-23 14:02 ` Stefan Seyfried
2006-12-19 21:22 ` David Brownell
2006-12-19 22:57 ` Matthew Garrett
2006-12-19 23:36 ` Changes to " David Brownell
2006-12-20 0:09 ` Matthew Garrett
2006-12-20 3:19 ` David Brownell
2006-12-20 3:43 ` Matthew Garrett
2006-12-20 4:15 ` David Brownell
2006-12-20 4:56 ` [PATCH 1/2] Fix /sys/device/.../power/state Matthew Garrett
2006-12-20 21:18 ` David Brownell
2006-12-21 1:29 ` Matthew Garrett
2006-12-21 3:04 ` David Brownell
2006-12-21 4:06 ` Matthew Garrett
2006-12-21 4:51 ` David Brownell
2007-01-25 5:00 ` Matthew Garrett [this message]
2007-01-26 19:59 ` [PATCH] Fix /sys/device/.../power/state regression Andrew Morton
2007-01-26 20:42 ` Greg KH
2007-01-27 1:26 ` Matthew Garrett
2007-01-27 17:19 ` Pavel Machek
2007-01-26 20:41 ` Greg KH
2007-01-26 21:56 ` David Brownell
2007-01-26 22:19 ` Greg KH
2007-01-26 23:15 ` Matthew Garrett
2007-01-27 0:42 ` David Brownell
2007-01-27 0:56 ` Andrew Morton
2007-01-27 2:40 ` David Brownell
2007-01-27 17:38 ` Pavel Machek
2007-01-27 22:42 ` Matthew Garrett
2007-01-31 10:34 ` Pavel Machek
2007-01-27 1:19 ` Matthew Garrett
2007-01-27 3:02 ` David Brownell
2007-01-29 17:36 ` Stephen Hemminger
2007-01-27 13:17 ` Pavel Machek
2007-01-30 18:43 ` Eric Piel
2007-01-30 18:47 ` Oliver Neukum
2007-01-30 19:01 ` Eric Piel
2007-01-31 10:55 ` Jiri Kosina
2007-01-31 11:03 ` Oliver Neukum
2006-12-20 4:56 ` [PATCH 2/2] Update feature-removal-schedule.txt Matthew Garrett
2006-12-22 20:47 ` Changes to PM layer break userspace Pavel Machek
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=20070125050009.GA8672@srcf.ucam.org \
--to=mjg59@srcf.ucam.org \
--cc=david-b@pacbell.net \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
/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