From patchwork Thu Jul 28 08:30:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Pihet X-Patchwork-Id: 1014882 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6S8Y1SD010872 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 28 Jul 2011 08:34:21 GMT Received: from daredevil.linux-foundation.org (localhost [127.0.0.1]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p6S8WcEP007569; Thu, 28 Jul 2011 01:32:40 -0700 Received: from mail-ww0-f43.google.com (mail-ww0-f43.google.com [74.125.82.43]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p6S8V34R006978 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Thu, 28 Jul 2011 01:31:05 -0700 Received: by wwi18 with SMTP id 18so1876183wwi.24 for ; Thu, 28 Jul 2011 01:31:03 -0700 (PDT) Received: by 10.227.207.206 with SMTP id fz14mr1034794wbb.76.1311841863128; Thu, 28 Jul 2011 01:31:03 -0700 (PDT) Received: from localhost.localdomain (60.73-66-87.adsl-dyn.isp.belgacom.be [87.66.73.60]) by mx.google.com with ESMTPS id eo18sm622335wbb.29.2011.07.28.01.31.01 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Jul 2011 01:31:02 -0700 (PDT) From: jean.pihet@newoldbits.com To: "Rafael J. Wysocki" , Paul Walmsley , Kevin Hilman , Magnus Damm , Linux PM mailing list , linux-omap@vger.kernel.org, markgross@thegnar.org, broonie@opensource.wolfsonmicro.com Date: Thu, 28 Jul 2011 10:30:12 +0200 Message-Id: <1311841821-10252-6-git-send-email-j-pihet@ti.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1311841821-10252-1-git-send-email-j-pihet@ti.com> References: <1311841821-10252-1-git-send-email-j-pihet@ti.com> Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-3.583 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.21 Cc: Jean Pihet Subject: [linux-pm] [PATCH 05/13] PM: QoS: support the dynamic insertion and removal of devices X-BeenThere: linux-pm@lists.linux-foundation.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux power management List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 28 Jul 2011 08:34:21 +0000 (UTC) From: Jean Pihet 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 --- 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;