Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1479531
| From | "Rafael J. Wysocki" <rjw@rjwysocki.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC/RFT][PATCH v2 3/7] PM / sleep: Make async suspend/resume of devices use device links |
| Date | 2016-09-08 23:30 +0200 |
| Message-ID | <sff3s-2Cw-23@gated-at.bofh.it> (permalink) |
| References | <sff3r-2Cw-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Make the device suspend/resume part of the core system
suspend/resume code use device links to ensure that supplier
and consumer devices will be suspended and resumed in the right
order in case of async suspend/resume.
The idea, roughly, is to use dpm_wait() to wait for all consumers
before a supplier device suspend and to wait for all suppliers
before a consumer device resume.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/base/base.h | 2 +
drivers/base/core.c | 4 +-
drivers/base/power/main.c | 68 +++++++++++++++++++++++++++++++++++++++++-----
3 files changed, 66 insertions(+), 8 deletions(-)
Index: linux-pm/drivers/base/base.h
===================================================================
--- linux-pm.orig/drivers/base/base.h
+++ linux-pm/drivers/base/base.h
@@ -163,3 +163,5 @@ extern void device_links_driver_gone(str
extern void device_links_no_driver(struct device *dev);
extern bool device_links_busy(struct device *dev);
extern void device_links_unbind_consumers(struct device *dev);
+extern int device_links_read_lock(void);
+extern void device_links_read_unlock(int idx);
Index: linux-pm/drivers/base/core.c
===================================================================
--- linux-pm.orig/drivers/base/core.c
+++ linux-pm/drivers/base/core.c
@@ -198,12 +198,12 @@ void device_link_del(struct device_link
}
EXPORT_SYMBOL_GPL(device_link_del);
-static int device_links_read_lock(void)
+int device_links_read_lock(void)
{
return srcu_read_lock(&device_links_srcu);
}
-static void device_links_read_unlock(int idx)
+void device_links_read_unlock(int idx)
{
return srcu_read_unlock(&device_links_srcu, idx);
}
Index: linux-pm/drivers/base/power/main.c
===================================================================
--- linux-pm.orig/drivers/base/power/main.c
+++ linux-pm/drivers/base/power/main.c
@@ -244,6 +244,62 @@ static void dpm_wait_for_children(struct
device_for_each_child(dev, &async, dpm_wait_fn);
}
+static void dpm_wait_for_suppliers(struct device *dev, bool async)
+{
+ struct device_link *link;
+ int idx;
+
+ idx = device_links_read_lock();
+
+ /*
+ * If the supplier goes away right after we've checked the link to it,
+ * we'll wait for its completion to change the state, but that's fine,
+ * because the only things that will block as a result are the SRCU
+ * callbacks freeing the link objects for the links in the list we're
+ * walking.
+ */
+ list_for_each_entry_rcu(link, &dev->links_to_suppliers, c_node)
+ if (link->status != DEVICE_LINK_DORMANT)
+ dpm_wait(link->supplier, async);
+
+ device_links_read_unlock(idx);
+}
+
+static void dpm_wait_for_superior(struct device *dev, bool async)
+{
+ dpm_wait(dev->parent, async);
+ dpm_wait_for_suppliers(dev, async);
+}
+
+static void dpm_wait_for_consumers(struct device *dev, bool async)
+{
+ struct device_link *link;
+ int idx;
+
+ idx = device_links_read_lock();
+
+ /*
+ * The status of a device link can only be changed from "dormant" by a
+ * probe, but that cannot happen during system suspend/resume. In
+ * theory it can change to "dormant" at that time, but then it is
+ * reasonable to wait for the target device anyway (eg. if it goes
+ * away, it's better to wait for it to go away completely and then
+ * continue instead of trying to continue in parallel with its
+ * unregistration).
+ */
+ list_for_each_entry_rcu(link, &dev->links_to_consumers, s_node)
+ if (link->status != DEVICE_LINK_DORMANT)
+ dpm_wait(link->consumer, async);
+
+ device_links_read_unlock(idx);
+}
+
+static void dpm_wait_for_subordinate(struct device *dev, bool async)
+{
+ dpm_wait_for_children(dev, async);
+ dpm_wait_for_consumers(dev, async);
+}
+
/**
* pm_op - Return the PM operation appropriate for given PM event.
* @ops: PM operations to choose from.
@@ -488,7 +544,7 @@ static int device_resume_noirq(struct de
if (!dev->power.is_noirq_suspended)
goto Out;
- dpm_wait(dev->parent, async);
+ dpm_wait_for_superior(dev, async);
if (dev->pm_domain) {
info = "noirq power domain ";
@@ -618,7 +674,7 @@ static int device_resume_early(struct de
if (!dev->power.is_late_suspended)
goto Out;
- dpm_wait(dev->parent, async);
+ dpm_wait_for_superior(dev, async);
if (dev->pm_domain) {
info = "early power domain ";
@@ -750,7 +806,7 @@ static int device_resume(struct device *
goto Complete;
}
- dpm_wait(dev->parent, async);
+ dpm_wait_for_superior(dev, async);
dpm_watchdog_set(&wd, dev);
device_lock(dev);
@@ -1038,7 +1094,7 @@ static int __device_suspend_noirq(struct
if (dev->power.syscore || dev->power.direct_complete)
goto Complete;
- dpm_wait_for_children(dev, async);
+ dpm_wait_for_subordinate(dev, async);
if (dev->pm_domain) {
info = "noirq power domain ";
@@ -1185,7 +1241,7 @@ static int __device_suspend_late(struct
if (dev->power.syscore || dev->power.direct_complete)
goto Complete;
- dpm_wait_for_children(dev, async);
+ dpm_wait_for_subordinate(dev, async);
if (dev->pm_domain) {
info = "late power domain ";
@@ -1358,7 +1414,7 @@ static int __device_suspend(struct devic
TRACE_DEVICE(dev);
TRACE_SUSPEND(0);
- dpm_wait_for_children(dev, async);
+ dpm_wait_for_subordinate(dev, async);
if (async_error)
goto Complete;
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC/RFT][PATCH v2 0/7] Functional dependencies between devices "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-08 23:30 +0200
[RFC/RFT][PATCH v2 7/7] PM / runtime: Optimize the use of device links "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-08 23:30 +0200
[RFC/RFT][PATCH v2 5/7] PM / runtime: Flag to indicate PM sleep transitions in progress "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-08 23:30 +0200
Re: [RFC/RFT][PATCH v2 5/7] PM / runtime: Flag to indicate PM sleep transitions in progress Lukas Wunner <lukas@wunner.de> - 2016-09-12 16:10 +0200
Re: [RFC/RFT][PATCH v2 5/7] PM / runtime: Flag to indicate PM sleep transitions in progress "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-12 23:20 +0200
Re: [RFC/RFT][PATCH v2 5/7] PM / runtime: Flag to indicate PM sleep transitions in progress Lukas Wunner <lukas@wunner.de> - 2016-09-13 01:00 +0200
Re: [RFC/RFT][PATCH v2 5/7] PM / runtime: Flag to indicate PM sleep transitions in progress Marek Szyprowski <m.szyprowski@samsung.com> - 2016-09-13 09:30 +0200
Re: [RFC/RFT][PATCH v2 5/7] PM / runtime: Flag to indicate PM sleep transitions in progress "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-14 02:00 +0200
[RFC/RFT][PATCH v2 4/7] PM / runtime: Pass flags argument to __pm_runtime_disable() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-08 23:30 +0200
Re: [RFC/RFT][PATCH v2 0/7] Functional dependencies between devices "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-08 23:30 +0200
[RFC/RFT][PATCH v2 1/7] driver core: Add a wrapper around __device_release_driver() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-08 23:30 +0200
[RFC/RFT][PATCH v2 3/7] PM / sleep: Make async suspend/resume of devices use device links "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-08 23:30 +0200
Re: [RFC/RFT][PATCH v2 3/7] PM / sleep: Make async suspend/resume of devices use device links Lukas Wunner <lukas@wunner.de> - 2016-09-10 15:40 +0200
Re: [RFC/RFT][PATCH v2 3/7] PM / sleep: Make async suspend/resume of devices use device links "Rafael J. Wysocki" <rafael@kernel.org> - 2016-09-11 00:20 +0200
[RFC/RFT][PATCH v2 2/7] driver core: Functional dependencies tracking support "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-08 23:30 +0200
Re: [RFC/RFT][PATCH v2 2/7] driver core: Functional dependencies tracking support Ulf Hansson <ulf.hansson@linaro.org> - 2016-09-09 10:30 +0200
Re: [RFC/RFT][PATCH v2 2/7] driver core: Functional dependencies tracking support Mark Brown <broonie@kernel.org> - 2016-09-09 14:10 +0200
Re: [RFC/RFT][PATCH v2 2/7] driver core: Functional dependencies tracking support Ulf Hansson <ulf.hansson@linaro.org> - 2016-09-09 16:20 +0200
Re: [RFC/RFT][PATCH v2 2/7] driver core: Functional dependencies tracking support "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-15 03:10 +0200
Re: [RFC/RFT][PATCH v2 2/7] driver core: Functional dependencies tracking support Lukas Wunner <lukas@wunner.de> - 2016-09-11 15:50 +0200
Re: [RFC/RFT][PATCH v2 2/7] driver core: Functional dependencies tracking support Lukas Wunner <lukas@wunner.de> - 2016-09-11 22:50 +0200
Re: [RFC/RFT][PATCH v2 2/7] driver core: Functional dependencies tracking support "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-14 03:20 +0200
Re: [RFC/RFT][PATCH v2 2/7] driver core: Functional dependencies tracking support Lukas Wunner <lukas@wunner.de> - 2016-09-14 10:30 +0200
Re: [RFC/RFT][PATCH v2 2/7] driver core: Functional dependencies tracking support "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-14 15:20 +0200
[RFC/RFT][PATCH v2 6/7] PM / runtime: Use device links "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-08 23:30 +0200
Re: [RFC/RFT][PATCH v2 6/7] PM / runtime: Use device links Lukas Wunner <lukas@wunner.de> - 2016-09-12 11:50 +0200
Re: [RFC/RFT][PATCH v2 6/7] PM / runtime: Use device links "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-12 16:00 +0200
Re: [RFC/RFT][PATCH v2 6/7] PM / runtime: Use device links "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-14 03:20 +0200
Re: [RFC/RFT][PATCH v2 0/7] Functional dependencies between devices Lukas Wunner <lukas@wunner.de> - 2016-09-10 13:40 +0200
Re: [RFC/RFT][PATCH v2 0/7] Functional dependencies between devices "Rafael J. Wysocki" <rafael@kernel.org> - 2016-09-11 00:10 +0200
Re: [RFC/RFT][PATCH v2 0/7] Functional dependencies between devices Lukas Wunner <lukas@wunner.de> - 2016-09-13 20:00 +0200
Re: [RFC/RFT][PATCH v2 0/7] Functional dependencies between devices "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-14 01:20 +0200
Re: [RFC/RFT][PATCH v2 0/7] Functional dependencies between devices Lukas Wunner <lukas@wunner.de> - 2016-09-18 14:40 +0200
Re: [RFC/RFT][PATCH v2 0/7] Functional dependencies between devices Marek Szyprowski <m.szyprowski@samsung.com> - 2016-09-13 12:00 +0200
Re: [RFC/RFT][PATCH v2 0/7] Functional dependencies between devices "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-14 00:40 +0200
Re: [RFC/RFT][PATCH v2 0/7] Functional dependencies between devices Lukas Wunner <lukas@wunner.de> - 2016-09-18 13:30 +0200
[RFC/RFT][PATCH v3 5/5] PM / runtime: Optimize the use of device links "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-16 00:10 +0200
[Resend][RFC/RFT][PATCH v3 1/5] driver core: Add a wrapper around __device_release_driver() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-16 00:10 +0200
[RFC/RFT][PATCH v3 2/5] driver core: Functional dependencies tracking support "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-16 00:10 +0200
Re: [RFC/RFT][PATCH v3 2/5] driver core: Functional dependencies tracking support Marek Szyprowski <m.szyprowski@samsung.com> - 2016-09-16 10:00 +0200
Re: [RFC/RFT][PATCH v3 2/5] driver core: Functional dependencies tracking support "Rafael J. Wysocki" <rafael@kernel.org> - 2016-09-16 14:10 +0200
[Update][RFC/RFT][PATCH v3 2/5] driver core: Functional dependencies tracking support "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-16 14:30 +0200
Re: [Update][RFC/RFT][PATCH v3 2/5] driver core: Functional dependencies tracking support Lukas Wunner <lukas@wunner.de> - 2016-09-20 00:50 +0200
[RFC/RFT][PATCH v3 3/5] PM / sleep: Make async suspend/resume of devices use device links "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-16 00:10 +0200
[RFC/RFT][PATCH v3 0/5] Functional dependencies between devices "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-16 00:10 +0200
[RFC/RFT][PATCH v3 4/5] PM / runtime: Use device links "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-09-16 00:10 +0200
Re: [RFC/RFT][PATCH v3 0/5] Functional dependencies between devices Marek Szyprowski <m.szyprowski@samsung.com> - 2016-09-16 09:30 +0200
Re: [RFC/RFT][PATCH v3 0/5] Functional dependencies between devices Marek Szyprowski <m.szyprowski@samsung.com> - 2016-09-16 10:00 +0200
Re: [RFC/RFT][PATCH v3 0/5] Functional dependencies between devices "Rafael J. Wysocki" <rafael@kernel.org> - 2016-09-16 14:10 +0200
csiph-web