From patchwork Fri Aug 26 20:17:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 74837 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp544186qga; Fri, 26 Aug 2016 13:18:53 -0700 (PDT) X-Received: by 10.66.199.5 with SMTP id jg5mr9143788pac.137.1472242716046; Fri, 26 Aug 2016 13:18:36 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i29si22890162pfa.172.2016.08.26.13.18.35; Fri, 26 Aug 2016 13:18:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754113AbcHZUSe (ORCPT + 14 others); Fri, 26 Aug 2016 16:18:34 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:34764 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753741AbcHZUSc (ORCPT ); Fri, 26 Aug 2016 16:18:32 -0400 Received: by mail-pf0-f175.google.com with SMTP id p64so31715331pfb.1 for ; Fri, 26 Aug 2016 13:18:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IAppFQxW9BSRqPyQa/Rc/948FI7NE50hCpo278YvvNs=; b=aAQW4EaxFRVCLq3TCOFcApKJrbZqcebG6FtqBQNOwseuGopP+S2bRIxczIbUMf7Vgr wt5m2YZdd0t98zW/yYKyZWZo1rZo2E5hGAsNu60oyEtQ4iERmBTnPSgDeLvqm7x0Z1xb kgJOeNu8wy7Pv8BoiIUpAuRFzkIy9XeixeZh4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IAppFQxW9BSRqPyQa/Rc/948FI7NE50hCpo278YvvNs=; b=M2Chyt2DNi41e5ysYQuZ1iO4Qe/armYE+HpseUgng9lJr8W4lHLtG58xLG7L1ee3ww iMITkHJ4KJL6oWI90og49GMY/7fkDatg11qR2xPiYZXzuTg9mMpTCB7z4KGozrPxyVmz vpgcME2Jz1XWPLYPqnv9582SWFSBGAAyVCN191XC4MGFAn6ESQfk1SO2OeLNyjaVmHZx 6qUWojZie2AwLSq7KoFdh+wKGX3f6IFt+Z00qCvaNsaR7wIr03/+TvNWr4bMVK/ZtKbm PBRLcdLILFGFjV3W0VGZ/DstKYDYNq5e9vJ2N8HDAhB4DDb8+R5dALXUhVjMzjipQw6N yToA== X-Gm-Message-State: AE9vXwMOtm65H7a8uj0bvQHvwqyFPM4DfTEa2PgP1T9Kx6CV4btHctnk7piddwZVuLPPeJYf X-Received: by 10.98.14.72 with SMTP id w69mr9080520pfi.119.1472242711540; Fri, 26 Aug 2016 13:18:31 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id m128sm30761463pfm.42.2016.08.26.13.18.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Aug 2016 13:18:30 -0700 (PDT) From: Lina Iyer To: ulf.hansson@linaro.org, khilman@kernel.org, rjw@rjwysocki.net, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: andy.gross@linaro.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, brendan.jackman@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, Juri.Lelli@arm.com, Lina Iyer Subject: [PATCH v5 07/16] kernel/cpu_pm: Add runtime PM support for CPUs Date: Fri, 26 Aug 2016 14:17:49 -0600 Message-Id: <1472242678-33700-8-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472242678-33700-1-git-send-email-lina.iyer@linaro.org> References: <1472242678-33700-1-git-send-email-lina.iyer@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Notify runtime PM when the CPU is going to be powered off in the idle state. This allows for runtime PM suspend/resume of the CPU as well as its PM domain. Cc: Kevin Hilman Cc: Rafael J. Wysocki Signed-off-by: Lina Iyer --- kernel/cpu_pm.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/kernel/cpu_pm.c b/kernel/cpu_pm.c index 009cc9a..657ce06 100644 --- a/kernel/cpu_pm.c +++ b/kernel/cpu_pm.c @@ -16,9 +16,11 @@ */ #include +#include #include #include #include +#include #include #include @@ -99,6 +101,7 @@ int cpu_pm_enter(void) { int nr_calls; int ret = 0; + struct device *dev = get_cpu_device(smp_processor_id()); read_lock(&cpu_pm_notifier_lock); ret = cpu_pm_notify(CPU_PM_ENTER, -1, &nr_calls); @@ -110,6 +113,10 @@ int cpu_pm_enter(void) cpu_pm_notify(CPU_PM_ENTER_FAILED, nr_calls - 1, NULL); read_unlock(&cpu_pm_notifier_lock); + /* Notify Runtime PM that we are suspending the CPU */ + if (!ret && dev) + RCU_NONIDLE(pm_runtime_put_sync_suspend(dev)); + return ret; } EXPORT_SYMBOL_GPL(cpu_pm_enter); @@ -129,6 +136,11 @@ EXPORT_SYMBOL_GPL(cpu_pm_enter); int cpu_pm_exit(void) { int ret; + struct device *dev = get_cpu_device(smp_processor_id()); + + /* Notify Runtime PM that we are resuming the CPU */ + if (dev) + RCU_NONIDLE(pm_runtime_get_sync(dev)); read_lock(&cpu_pm_notifier_lock); ret = cpu_pm_notify(CPU_PM_EXIT, -1, NULL); @@ -200,6 +212,39 @@ int cpu_cluster_pm_exit(void) } EXPORT_SYMBOL_GPL(cpu_cluster_pm_exit); +#ifdef CONFIG_HOTPLUG_CPU +static int cpu_pm_cpu_hotplug(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct device *dev = get_cpu_device(smp_processor_id()); + + if (!dev) + return NOTIFY_OK; + + /* Execute CPU runtime PM on that CPU */ + switch (action & ~CPU_TASKS_FROZEN) { + case CPU_DYING: + pm_runtime_put_sync_suspend(dev); + break; + case CPU_STARTING: + pm_runtime_get_sync(dev); + break; + default: + break; + } + + return NOTIFY_OK; +} + +static int __init cpu_pm_hotplug_init(void) +{ + /* Register for hotplug notifications for runtime PM */ + hotcpu_notifier(cpu_pm_cpu_hotplug, 0); + return 0; +} +device_initcall(cpu_pm_hotplug_init); +#endif + #ifdef CONFIG_PM static int cpu_pm_suspend(void) {