From patchwork Sun Jul 10 20:46:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 962612 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6AKlqGE011006 for ; Sun, 10 Jul 2011 20:47:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756657Ab1GJUrd (ORCPT ); Sun, 10 Jul 2011 16:47:33 -0400 Received: from ogre.sisk.pl ([217.79.144.158]:43412 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756120Ab1GJUr2 (ORCPT ); Sun, 10 Jul 2011 16:47:28 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by ogre.sisk.pl (Postfix) with ESMTP id 38D431B501B; Sun, 10 Jul 2011 22:20:31 +0200 (CEST) Received: from ogre.sisk.pl ([127.0.0.1]) by localhost (ogre.sisk.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 09367-07; Sun, 10 Jul 2011 22:20:07 +0200 (CEST) Received: from ferrari.rjw.lan (220-bem-13.acn.waw.pl [82.210.184.220]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ogre.sisk.pl (Postfix) with ESMTP id 83FE31B4F96; Sun, 10 Jul 2011 22:20:06 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM mailing list Subject: [PATCH 1/2] PM / Domains: Introduce function to power off all unused PM domains Date: Sun, 10 Jul 2011 22:46:55 +0200 User-Agent: KMail/1.13.6 (Linux/3.0.0-rc6+; KDE/4.6.0; x86_64; ; ) Cc: Magnus Damm , LKML , "Linux-SH" References: <201107102246.05107.rjw@sisk.pl> In-Reply-To: <201107102246.05107.rjw@sisk.pl> MIME-Version: 1.0 Message-Id: <201107102246.56059.rjw@sisk.pl> X-Virus-Scanned: amavisd-new at ogre.sisk.pl using MkS_Vir for Linux Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sun, 10 Jul 2011 20:47:53 +0000 (UTC) From: Rafael J. Wysocki Add a new function pm_genpd_poweroff_unused() queuing up the execution of pm_genpd_poweroff() for every initialized generic PM domain. Calling it will cause every generic PM domain without devices in use to be powered off. Signed-off-by: Rafael J. Wysocki --- drivers/base/power/domain.c | 21 +++++++++++++++++++++ include/linux/pm_domain.h | 3 +++ 2 files changed, 24 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/include/linux/pm_domain.h =================================================================== --- linux-2.6.orig/include/linux/pm_domain.h +++ linux-2.6/include/linux/pm_domain.h @@ -24,6 +24,7 @@ struct dev_power_governor { struct generic_pm_domain { struct dev_pm_domain domain; /* PM domain operations */ + struct list_head gpd_list_node; /* Node in the global PM domains list */ struct list_head sd_node; /* Node in the parent's subdomain list */ struct generic_pm_domain *parent; /* Parent PM domain */ struct list_head sd_list; /* List of dubdomains */ @@ -71,6 +72,7 @@ extern int pm_genpd_remove_subdomain(str extern void pm_genpd_init(struct generic_pm_domain *genpd, struct dev_power_governor *gov, bool is_off); extern int pm_genpd_poweron(struct generic_pm_domain *genpd); +extern void pm_genpd_poweroff_unused(void); #else static inline int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev) @@ -98,6 +100,7 @@ static inline int pm_genpd_poweron(struc { return -ENOSYS; } +static inline void pm_genpd_poweroff_unused(void) {} #endif #endif /* _LINUX_PM_DOMAIN_H */ Index: linux-2.6/drivers/base/power/domain.c =================================================================== --- linux-2.6.orig/drivers/base/power/domain.c +++ linux-2.6/drivers/base/power/domain.c @@ -16,6 +16,9 @@ #include #include +static LIST_HEAD(gpd_list); +static DEFINE_MUTEX(gpd_list_lock); + #ifdef CONFIG_PM static struct generic_pm_domain *dev_to_genpd(struct device *dev) @@ -1241,4 +1244,22 @@ void pm_genpd_init(struct generic_pm_dom genpd->domain.ops.restore_noirq = pm_genpd_restore_noirq; genpd->domain.ops.restore = pm_genpd_restore; genpd->domain.ops.complete = pm_genpd_complete; + mutex_lock(&gpd_list_lock); + list_add(&genpd->gpd_list_node, &gpd_list); + mutex_unlock(&gpd_list_lock); +} + +/** + * pm_genpd_poweroff_unused - Power off all PM domains with no devices in use. + */ +void pm_genpd_poweroff_unused(void) +{ + struct generic_pm_domain *genpd; + + mutex_lock(&gpd_list_lock); + + list_for_each_entry(genpd, &gpd_list, gpd_list_node) + genpd_queue_power_off_work(genpd); + + mutex_unlock(&gpd_list_lock); }