Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1479524
| From | "Rafael J. Wysocki" <rjw@rjwysocki.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC/RFT][PATCH v2 7/7] PM / runtime: Optimize the use of device links |
| Date | 2016-09-08 23:30 +0200 |
| Message-ID | <sff3r-2Cw-5@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>
If the device has no links to suppliers that should be used for
runtime PM (links with DEVICE_LINK_PM_RUNTIME set), there is no
reason to walk the list of suppliers for that device during
runtime suspend and resume.
Add a simple mechanism to detect that case and possibly avoid the
extra unnecessary overhead.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/base/core.c | 6 ++++++
drivers/base/power/runtime.c | 23 ++++++++++++++++++++---
include/linux/pm.h | 1 +
include/linux/pm_runtime.h | 4 ++++
4 files changed, 31 insertions(+), 3 deletions(-)
Index: linux-pm/drivers/base/core.c
===================================================================
--- linux-pm.orig/drivers/base/core.c
+++ linux-pm/drivers/base/core.c
@@ -151,6 +151,9 @@ struct device_link *device_link_add(stru
link->consumer = consumer;
INIT_LIST_HEAD(&link->c_node);
spin_lock_init(&link->lock);
+ if (flags & DEVICE_LINK_PM_RUNTIME)
+ pm_runtime_new_link(consumer);
+
link->flags = flags;
link->status = status;
@@ -191,6 +194,9 @@ static void __device_link_del(struct dev
dev_info(link->consumer, "Dropping the link to %s\n",
dev_name(link->supplier));
+ if (link->flags & DEVICE_LINK_PM_RUNTIME)
+ pm_runtime_drop_link(link->consumer);
+
list_del_rcu(&link->s_node);
list_del_rcu(&link->c_node);
call_srcu(&device_links_srcu, &link->rcu_head, __device_link_free_srcu);
Index: linux-pm/drivers/base/power/runtime.c
===================================================================
--- linux-pm.orig/drivers/base/power/runtime.c
+++ linux-pm/drivers/base/power/runtime.c
@@ -270,6 +270,7 @@ static int __rpm_callback(int (*cb)(stru
{
struct device_link *link;
int retval, idx;
+ bool use_links = dev->power.links_count > 0;
if (dev->power.irq_safe) {
spin_unlock(&dev->power.lock);
@@ -283,7 +284,7 @@ static int __rpm_callback(int (*cb)(stru
* routine returns, so it is safe to read the status outside of
* the lock.
*/
- if (dev->power.runtime_status == RPM_RESUMING) {
+ if (use_links && dev->power.runtime_status == RPM_RESUMING) {
idx = device_links_read_lock();
list_for_each_entry_rcu(link, &dev->links_to_suppliers, c_node)
@@ -314,8 +315,9 @@ static int __rpm_callback(int (*cb)(stru
*
* Do that if resume fails too.
*/
- if ((dev->power.runtime_status == RPM_SUSPENDING && !retval)
- || (dev->power.runtime_status == RPM_RESUMING && retval)) {
+ if (use_links
+ && ((dev->power.runtime_status == RPM_SUSPENDING && !retval)
+ || (dev->power.runtime_status == RPM_RESUMING && retval))) {
idx = device_links_read_lock();
fail:
@@ -1546,6 +1548,21 @@ void pm_runtime_clean_up_links(struct de
device_links_read_unlock(idx);
}
+void pm_runtime_new_link(struct device *dev)
+{
+ spin_lock_irq(&dev->power.lock);
+ dev->power.links_count++;
+ spin_unlock_irq(&dev->power.lock);
+}
+
+void pm_runtime_drop_link(struct device *dev)
+{
+ spin_lock_irq(&dev->power.lock);
+ WARN_ON(dev->power.links_count == 0);
+ dev->power.links_count--;
+ spin_unlock_irq(&dev->power.lock);
+}
+
/**
* pm_runtime_force_suspend - Force a device into suspend state if needed.
* @dev: Device to suspend.
Index: linux-pm/include/linux/pm.h
===================================================================
--- linux-pm.orig/include/linux/pm.h
+++ linux-pm/include/linux/pm.h
@@ -597,6 +597,7 @@ struct dev_pm_info {
unsigned int use_autosuspend:1;
unsigned int timer_autosuspends:1;
unsigned int memalloc_noio:1;
+ unsigned int links_count;
enum rpm_request request;
enum rpm_status runtime_status;
int runtime_error;
Index: linux-pm/include/linux/pm_runtime.h
===================================================================
--- linux-pm.orig/include/linux/pm_runtime.h
+++ linux-pm/include/linux/pm_runtime.h
@@ -62,6 +62,8 @@ extern void pm_runtime_update_max_time_s
s64 delta_ns);
extern void pm_runtime_set_memalloc_noio(struct device *dev, bool enable);
extern void pm_runtime_clean_up_links(struct device *dev);
+extern void pm_runtime_new_link(struct device *dev);
+extern void pm_runtime_drop_link(struct device *dev);
static inline void pm_suspend_ignore_children(struct device *dev, bool enable)
{
@@ -194,6 +196,8 @@ static inline unsigned long pm_runtime_a
static inline void pm_runtime_set_memalloc_noio(struct device *dev,
bool enable){}
static inline void pm_runtime_clean_up_links(struct device *dev) {}
+static inline void pm_runtime_new_link(struct device *dev) {}
+static inline void pm_runtime_drop_link(struct device *dev) {}
#endif /* !CONFIG_PM */
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