linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jean.pihet@newoldbits.com
To: "Rafael J. Wysocki" <rjw@sisk.pl>, Paul Walmsley <paul@pwsan.com>,
	Kevin Hilman <khilman@ti.com>,
	Magnus Damm <magnus.damm@gmail.com>,
	Linux PM mailing list <linux-pm@lists.linux-foun>
Cc: Jean Pihet <j-pihet@ti.com>
Subject: [PATCH 05/13] PM: QoS: support the dynamic insertion and removal of devices
Date: Thu, 28 Jul 2011 10:30:12 +0200	[thread overview]
Message-ID: <1311841821-10252-6-git-send-email-j-pihet@ti.com> (raw)
In-Reply-To: <1311841821-10252-1-git-send-email-j-pihet@ti.com>

From: Jean Pihet <j-pihet@ti.com>

The devices latency constraints class of PM QoS is storing the
constraints list in the device dev_pm_info struct.

This patch adds the init and de-init of the per-device constraints
list in order to support the dynamic insertion and removal
of the devices in the system.

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 drivers/base/power/main.c |   10 ++++------
 include/linux/pm.h        |    1 +
 include/linux/pm_qos.h    |    2 ++
 kernel/pm_qos.c           |   30 ++++++++++++++++++++++++++++++
 4 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 360c2c0..c86f97c 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -97,12 +97,8 @@ void device_pm_add(struct device *dev)
 			dev_name(dev->parent));
 	list_add_tail(&dev->power.entry, &dpm_list);
 	mutex_unlock(&dpm_list_mtx);
-	plist_head_init(&dev->power.latency_constraints.list, &dev->power.lock);
-	dev->power.latency_constraints.target_value =
-					PM_QOS_DEV_LAT_DEFAULT_VALUE;
-	dev->power.latency_constraints.default_value =
-					PM_QOS_DEV_LAT_DEFAULT_VALUE;
-	dev->power.latency_constraints.type = PM_QOS_MIN;
+	/* Call PM QoS to init the per-device latency constraints */
+	pm_qos_dev_constraints_init(dev);
 }
 
 /**
@@ -113,6 +109,8 @@ void device_pm_remove(struct device *dev)
 {
 	pr_debug("PM: Removing info for %s:%s\n",
 		 dev->bus ? dev->bus->name : "No Bus", dev_name(dev));
+	/* Call PM QoS to de-init the per-device latency constraints */
+	pm_qos_dev_constraints_deinit(dev);
 	complete_all(&dev->power.completion);
 	mutex_lock(&dpm_list_mtx);
 	list_del_init(&dev->power.entry);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 35e48a3..3ed53be 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -466,6 +466,7 @@ struct dev_pm_info {
 	void			*subsys_data;  /* Owned by the subsystem. */
 #endif
 	struct pm_qos_constraints	latency_constraints;
+	int			latency_constraints_init;
 };
 
 extern void update_pm_runtime_accounting(struct device *dev);
diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h
index d72b16b..4d36537 100644
--- a/include/linux/pm_qos.h
+++ b/include/linux/pm_qos.h
@@ -63,4 +63,6 @@ int pm_qos_add_notifier(int class, struct notifier_block *notifier);
 int pm_qos_remove_notifier(int class, struct notifier_block *notifier);
 int pm_qos_request_active(struct pm_qos_request *req);
 
+void pm_qos_dev_constraints_init(struct device *dev);
+void pm_qos_dev_constraints_deinit(struct device *dev);
 #endif
diff --git a/kernel/pm_qos.c b/kernel/pm_qos.c
index 7edc6d0..361fc3f 100644
--- a/kernel/pm_qos.c
+++ b/kernel/pm_qos.c
@@ -202,6 +202,9 @@ static void update_target(struct pm_qos_request *req,
 			WARN(1, KERN_ERR "PM QoS API called with NULL dev\n");
 			return;
 		}
+		/* Silently return if the device is being released */
+		if (!req->dev->power.latency_constraints_init)
+			return;
 		c = &req->dev->power.latency_constraints;
 		break;
 	case PM_QOS_CPU_DMA_LATENCY:
@@ -387,6 +390,33 @@ int pm_qos_remove_notifier(int class, struct notifier_block *notifier)
 }
 EXPORT_SYMBOL_GPL(pm_qos_remove_notifier);
 
+/* Called from the device PM subsystem at device init */
+void pm_qos_dev_constraints_init(struct device *dev)
+{
+	plist_head_init(&dev->power.latency_constraints.list, &dev->power.lock);
+	dev->power.latency_constraints.target_value =
+					PM_QOS_DEV_LAT_DEFAULT_VALUE;
+	dev->power.latency_constraints.default_value =
+					PM_QOS_DEV_LAT_DEFAULT_VALUE;
+	dev->power.latency_constraints.type = PM_QOS_MIN;
+	dev->power.latency_constraints_init = 1;
+}
+
+/* Called from the device PM subsystem at device release */
+void pm_qos_dev_constraints_deinit(struct device *dev)
+{
+	struct pm_qos_request *req, *tmp;
+
+	dev->power.latency_constraints_init = 0;
+
+	/* Flush the constraints list for the device */
+	plist_for_each_entry_safe(req, tmp,
+				  &dev->power.latency_constraints.list,
+				  node)
+		update_target(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE);
+	plist_head_init(&dev->power.latency_constraints.list, &dev->power.lock);
+}
+
 static int register_pm_qos_misc(struct pm_qos_object *qos)
 {
 	qos->pm_qos_power_miscdev.minor = MISC_DYNAMIC_MINOR;
-- 
1.7.2.5


  parent reply	other threads:[~2011-07-28  8:31 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-28  8:30 [RFC/PATCH v3 00/13] PM QoS: add a per-device latency constraints class jean.pihet
2011-07-28  8:30 ` [PATCH 01/13] PM: QoS: rename pm_qos_params files to pm_qos jean.pihet
2011-07-29 21:57   ` Rafael J. Wysocki
2011-08-02  9:31     ` Jean Pihet
2011-08-02  9:47       ` Rafael J. Wysocki
2011-07-28  8:30 ` [PATCH 02/13] PM: add a per-device wake-up latency constraints plist jean.pihet
2011-07-29 21:58   ` Rafael J. Wysocki
2011-07-28  8:30 ` [PATCH 03/13] PM: QoS: extend the in-kernel API with per-device latency constraints jean.pihet
2011-07-29 22:55   ` Rafael J. Wysocki
2011-08-02  9:41     ` Jean Pihet
2011-08-02 21:02       ` Rafael J. Wysocki
2011-08-02 18:01   ` Kevin Hilman
2011-07-28  8:30 ` [PATCH 04/13] PM: QoS: implement the " jean.pihet
2011-07-30 22:30   ` Rafael J. Wysocki
2011-08-02 10:05     ` Jean Pihet
2011-08-02 21:13       ` Rafael J. Wysocki
2011-07-28  8:30 ` jean.pihet [this message]
2011-07-30 22:38   ` [PATCH 05/13] PM: QoS: support the dynamic insertion and removal of devices Rafael J. Wysocki
2011-08-02 10:07     ` Jean Pihet
2011-07-28  8:30 ` [PATCH 06/13] OMAP PM: create a PM layer plugin for per-device constraints jean.pihet
2011-07-28  8:30 ` [PATCH 07/13] OMAP PM: early init of the pwrdms states jean.pihet
2011-07-29  8:08   ` Todd Poynor
2011-07-29  8:50     ` Jean Pihet
2011-08-02  8:57       ` Jean Pihet
2011-08-11 15:12         ` Jean Pihet
2011-07-28  8:30 ` [PATCH 08/13] OMAP2+: powerdomain: control power domains next state jean.pihet
2011-07-29  7:59   ` Todd Poynor
2011-07-29  8:47     ` Jean Pihet
2011-07-29 18:00       ` Todd Poynor
2011-08-11 15:09         ` Jean Pihet
2011-07-28  8:30 ` [PATCH 09/13] OMAP3: powerdomain data: add wake-up latency figures jean.pihet
2011-07-28  8:30 ` [PATCH 10/13] OMAP4: " jean.pihet
2011-07-28  8:30 ` [PATCH 11/13] OMAP2+: omap_hwmod: manage the wake-up latency constraints jean.pihet
2011-07-28  8:30 ` [PATCH 12/13] OMAP: PM CONSTRAINTS: implement the devices " jean.pihet
2011-07-28  8:30 ` [PATCH 13/13] OMAP2+: cpuidle only influences the MPU state jean.pihet
2011-07-28 13:14 ` [RFC/PATCH v3 00/13] PM QoS: add a per-device latency constraints class mark gross
2011-07-29  8:37   ` Jean Pihet
2011-07-29 14:24     ` mark gross
2011-07-29 21:46       ` Rafael J. Wysocki
2011-07-31 17:38         ` [linux-pm] " mark gross
2011-07-29 21:25 ` Rafael J. Wysocki

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=1311841821-10252-6-git-send-email-j-pihet@ti.com \
    --to=jean.pihet@newoldbits.com \
    --cc=j-pihet@ti.com \
    --cc=khilman@ti.com \
    --cc=linux-pm@lists.linux-foun \
    --cc=magnus.damm@gmail.com \
    --cc=paul@pwsan.com \
    --cc=rjw@sisk.pl \
    /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).