From patchwork Sat Dec 13 16:51:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kachhap X-Patchwork-Id: 5486901 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 25697BEEA8 for ; Sat, 13 Dec 2014 17:02:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F261420220 for ; Sat, 13 Dec 2014 17:02:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C9BF12021B for ; Sat, 13 Dec 2014 17:02:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xzq2X-0002hV-GI; Sat, 13 Dec 2014 16:59:33 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xzq2K-0002ce-51 for linux-arm-kernel@lists.infradead.org; Sat, 13 Dec 2014 16:59:21 +0000 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NGJ0097V5U5G140@mailout2.samsung.com> for linux-arm-kernel@lists.infradead.org; Sun, 14 Dec 2014 01:58:53 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id DB.C6.17016.C407C845; Sun, 14 Dec 2014 01:58:53 +0900 (KST) X-AuditID: cbfee68d-f79296d000004278-06-548c704c38cc Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 20.8C.20081.C407C845; Sun, 14 Dec 2014 01:58:52 +0900 (KST) Received: from chromebld-server.sisodomain.com ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NGJ008QG5TRSP60@mmp2.samsung.com>; Sun, 14 Dec 2014 01:58:52 +0900 (KST) From: Amit Daniel Kachhap To: linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC v3 1/2] PM / Domains: Extend API pm_genpd_dev_need_restore to use restore types Date: Sat, 13 Dec 2014 22:21:57 +0530 Message-id: <1418489518-7252-1-git-send-email-amit.daniel@samsung.com> X-Mailer: git-send-email 2.2.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRmVeSWpSXmKPExsWyRsSkWte3oCfE4MRPZouGqyEWc2dPYrTo XXCVzeLr4RWMFrOm7GWy2PT4GqvF5V1z2Cw+9x5htJhxfh+Txdojd9ktFm39wm5x5vQlVovD b9pZLTqWMVqs2vWH0eL42nAHAY+JZ3U9ds66y+6xeM9LJo871/aweWxeUu+x5Wo7i0ffllWM Hp83yQVwRHHZpKTmZJalFunbJXBlfPk2j6Vgm2XF3BOvWBoY9+h3MXJySAiYSHzYuYwZwhaT uHBvPVsXIxeHkMBSRomLB08zwhSd2DCbCSIxnVHi2P6bLBDOBCaJe+fPsIJUsQkYS/zcuZ8d xBYR0JCY0vWYHaSIWWAKs0RH6yImkISwQKpE+5rLYA0sAqoSh2a3gK3gFXCTuDb9GNQdchJb bj1ih7AvsUv0TK2DqBeQ+Db5ENBmDqC4rMSmA1DlkhIHV9xgmcAouICRYRWjaGpBckFxUnqR oV5xYm5xaV66XnJ+7iZGYJyc/vesdwfj7QPWhxgFOBiVeHgtertDhFgTy4orcw8xmgJtmMgs JZq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76 nZeNi9k2sRyefD3km47cMgUJmcqfCjMLTxrrfHezOPr0TMBBt0MHnzq6S9Vf1TjH0auTxWpy 5YBcdV5o1T/HP6oXq8uCStxe7Fm5U4mlOCPRUIu5qDgRACU7I3DZAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141213_085920_358997_3E736BD5 X-CRM114-Status: GOOD ( 19.04 ) X-Spam-Score: -5.0 (-----) Cc: len.brown@intel.com, ulf.hansson@linaro.org, linux-samsung-soc@vger.kernel.org, geert+renesas@glider.be, linux-pm@vger.kernel.org, pankaj.dubey@samsung.com, rjw@rjwysocki.net, tomasz.figa@gmail.com, linux-kernel@vger.kernel.org, Amit Daniel Kachhap , khilman@linaro.org, thomas.ab@samsung.com, s.nawrocki@samsung.com, kgene.kim@samsung.com, m.szyprowski@samsung.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of using bool to restore suspended devices initially, use flags like GPD_DEV_SUSPEND_INIT, GPD_DEV_RESTORE_INIT and GPD_DEV_RESTORE_FORCE. The first two flags will be similar to the existing true/false functionality. The third flag may be used to force restore of suspended devices whenever their associated power domain is turned on. Currently, PD power off function powers off all the associated unused devices. The functionality added in this patch is similar to it. This feature may be used for those devices which are always in ON state if the PD associated with them is ON but may need local runtime resume and suspend during PD On/Off. These devices (like clock) may not implement complete pm_runtime calls such as pm_runtime_get/pm_runtime_put due to subsystems interaction behaviour or any other reason. The model works like, DEV1 (Attaches itself with PD but no calls to pm_runtime_get and / pm_runtime_put. Its local runtime_suspend/resume is invoked via / GPD_DEV_RESTORE_FORCE option) / PD -- DEV2 (Implements complete PM runtime and calls pm_runtime_get and \ pm_runtime_put. This in turn invokes PD On/Off) \ DEV3 (Similar to DEV1) Signed-off-by: Amit Daniel Kachhap --- This work is continuation of earlier work, In V2: Completely removed notfiers and add support for huge clock list to be suspended and restored. There was some issue in this as some clocks are not exposed and are just initialised by bootloaders. This approach required all of them to be exposed which is cumbersome. Also some clock API's set_parent are disabling the original parent clocks which is not required. Link (https://lkml.org/lkml/2014/11/24/290) In V1: Implemented PM Domain notfier such as PD_ON_PRE, PD_ON_POST PD_OFF_PRE and PD_OFF_POST. This was not supported and other options suggested. link (http://www.spinics.net/lists/linux-samsung-soc/msg38442.html) This work may also assist exynos iommu pm runtime posted earlier by Marek http://lists.linaro.org/pipermail/linaro-mm-sig/2014-August/004099.html drivers/base/power/domain.c | 40 ++++++++++++++++++++++++++++++++++++---- include/linux/pm_domain.h | 15 +++++++++++++-- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 6a103a3..d955a05 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -49,6 +49,7 @@ static LIST_HEAD(gpd_list); static DEFINE_MUTEX(gpd_list_lock); +static void __pm_genpd_restore_devices(struct generic_pm_domain *genpd); static struct generic_pm_domain *pm_genpd_lookup_name(const char *domain_name) { @@ -176,6 +177,8 @@ static int genpd_power_on(struct generic_pm_domain *genpd) pr_warn("%s: Power-%s latency exceeded, new value %lld ns\n", genpd->name, "on", elapsed_ns); + __pm_genpd_restore_devices(genpd); + return ret; } @@ -453,6 +456,24 @@ static void __pm_genpd_restore_device(struct pm_domain_data *pdd, } /** + * __pm_genpd_restore_devices- Restore the pre-suspend state of all device + * according to the restore flag. + * @genpd: PM domain the device belongs to. + */ +static void __pm_genpd_restore_devices(struct generic_pm_domain *genpd) +{ + struct pm_domain_data *pdd; + struct generic_pm_domain_data *gpd_data; + + /* Force restore the devices according to the restore flag */ + list_for_each_entry(pdd, &genpd->dev_list, list_node) { + gpd_data = to_gpd_data(pdd); + if (gpd_data->force_restore == true) + __pm_genpd_restore_device(pdd, genpd); + } +} + +/** * genpd_abort_poweroff - Check if a PM domain power off should be aborted. * @genpd: PM domain to check. * @@ -1469,6 +1490,7 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, gpd_data->base.dev = dev; list_add_tail(&gpd_data->base.list_node, &genpd->dev_list); gpd_data->need_restore = -1; + gpd_data->force_restore = false; gpd_data->td.constraint_changed = true; gpd_data->td.effective_constraint_ns = -1; mutex_unlock(&gpd_data->lock); @@ -1561,18 +1583,28 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd, /** * pm_genpd_dev_need_restore - Set/unset the device's "need restore" flag. * @dev: Device to set/unset the flag for. - * @val: The new value of the device's "need restore" flag. + * @val: This can have values GPD_DEV_SUSPEND_INIT or GPD_DEV_RESTORE_INIT + * together with GPD_DEV_RESTORE_FORCE. */ -void pm_genpd_dev_need_restore(struct device *dev, bool val) +void pm_genpd_dev_need_restore(struct device *dev, unsigned int val) { struct pm_subsys_data *psd; + struct generic_pm_domain_data *pdd; unsigned long flags; spin_lock_irqsave(&dev->power.lock, flags); psd = dev_to_psd(dev); - if (psd && psd->domain_data) - to_gpd_data(psd->domain_data)->need_restore = val ? 1 : 0; + if (psd && psd->domain_data) { + pdd = to_gpd_data(psd->domain_data); + if (val & GPD_DEV_SUSPEND_INIT) + pdd->need_restore = 0; + else if (val & GPD_DEV_RESTORE_INIT) + pdd->need_restore = 1; + + if (val & GPD_DEV_RESTORE_FORCE) + pdd->force_restore = true; + } spin_unlock_irqrestore(&dev->power.lock, flags); } diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 6cd20d5..8aa74ee 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -20,6 +20,15 @@ /* Defines used for the flags field in the struct generic_pm_domain */ #define GENPD_FLAG_PM_CLK (1U << 0) /* PM domain uses PM clk */ +/* Defines used for the types of restore */ +#define GPD_DEV_SUSPEND_INIT 0x1 /* Initiate the device runtime as + suspend/resume/suspend... */ +#define GPD_DEV_RESTORE_INIT 0x10 /* Initiate the device runtime as + resume/suspend/suspend... */ +#define GPD_DEV_RESTORE_FORCE 0x100 /* Force these devices to always do + resume in PD power on. Initial + behaviour can be one of the above */ + enum gpd_status { GPD_STATE_ACTIVE = 0, /* PM domain is active */ GPD_STATE_WAIT_MASTER, /* PM domain's master is being waited for */ @@ -116,6 +125,7 @@ struct generic_pm_domain_data { struct mutex lock; unsigned int refcount; int need_restore; + bool force_restore; }; #ifdef CONFIG_PM_GENERIC_DOMAINS @@ -140,7 +150,7 @@ extern int __pm_genpd_name_add_device(const char *domain_name, extern int pm_genpd_remove_device(struct generic_pm_domain *genpd, struct device *dev); -extern void pm_genpd_dev_need_restore(struct device *dev, bool val); +extern void pm_genpd_dev_need_restore(struct device *dev, unsigned int val); extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, struct generic_pm_domain *new_subdomain); extern int pm_genpd_add_subdomain_names(const char *master_name, @@ -187,7 +197,8 @@ static inline int pm_genpd_remove_device(struct generic_pm_domain *genpd, { return -ENOSYS; } -static inline void pm_genpd_dev_need_restore(struct device *dev, bool val) {} +static inline void pm_genpd_dev_need_restore(struct device *dev, + unsigned int val) {} static inline int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, struct generic_pm_domain *new_sd) {