From patchwork Tue Mar 1 21:15:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 8470301 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 15D769F9A0 for ; Tue, 1 Mar 2016 21:16:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2086920304 for ; Tue, 1 Mar 2016 21:16:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D63F32035B for ; Tue, 1 Mar 2016 21:16:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753634AbcCAVQN (ORCPT ); Tue, 1 Mar 2016 16:16:13 -0500 Received: from mail-pf0-f179.google.com ([209.85.192.179]:33041 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753592AbcCAVQM (ORCPT ); Tue, 1 Mar 2016 16:16:12 -0500 Received: by mail-pf0-f179.google.com with SMTP id 124so58011759pfg.0 for ; Tue, 01 Mar 2016 13:16:11 -0800 (PST) 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=Be+zyQK43bPd52eVxNDIvZxJZHGl6HrgpHCkNrrldwo=; b=Huiogb/BtBiNDbg1cHhqS//2JPicfZFVWCdiR5uTESDpiDeygHj4GfsfRHtZZvO14A 6WRVhj/paPHybI7PGWB1lx+L58Np2zWEIOwpX/hbb/OC/3VRTwLUSjX3sIrJCUU8itZw Sh5Z/z6sk+b+LrZqck4lZkJA9CgSW3r29jdyQ= 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=Be+zyQK43bPd52eVxNDIvZxJZHGl6HrgpHCkNrrldwo=; b=JY2ckWpMmzreq6bE9aZBS4eCyeVuWg704i3O/ALe+R8NQNX0lCHuEweGSnA6fMRb78 x2eoQodaOrtP0XpoqZ4rU1ziy1FD4S0DX9T/V6BUGpgAkdZeYT+xhBuC+ii4txfOt8Q6 yyr/y1UxaxWFLjFSFgO9+yjOFH7bnow3ByTJXz+I2Yuk8f9ep/lBcyVOLvfDCmhjJFfW r6UXx/I6LeFk3/FWEnS8cO9PWTRE8YElfGBo6Gi73GNvfkdtjfJ96Gjk3SOChdSJ46oF eRYVMP+WGVVMNuvA/M5ily07Fag2+jxS889OJKLG3fyu0iHEFDfs4eqnFdakleMKmDNS SQcw== X-Gm-Message-State: AD7BkJIaWjaVqpOlSCi1PAWuMPw07e+zS09PzSgkb5HsbW5NBiHu2diOO+qNjf3AD7LPPime X-Received: by 10.98.9.92 with SMTP id e89mr33402783pfd.34.1456866971307; Tue, 01 Mar 2016 13:16:11 -0800 (PST) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id kw10sm47749328pab.0.2016.03.01.13.16.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Mar 2016 13:16:10 -0800 (PST) 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: geert@linux-m68k.org, k.kozlowski@samsung.com, msivasub@codeaurora.org, agross@codeaurora.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, lorenzo.pieralisi@arm.com, ahaslam@baylibre.com, mtitinger@baylibre.com, Lina Iyer , Daniel Lezcano Subject: [RFC v3 04/12] ARM: cpuidle: Add runtime PM support for CPUs Date: Tue, 1 Mar 2016 14:15:23 -0700 Message-Id: <1456866931-37851-6-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456866931-37851-1-git-send-email-lina.iyer@linaro.org> References: <1456866931-37851-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 X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 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. We do not call into runtime PM for ARM WFI to keep the default state simple and faster. Cc: Daniel Lezcano Cc: Lorenzo Pieralisi Signed-off-by: Lina Iyer --- drivers/cpuidle/cpuidle-arm.c | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index 545069d..4d6f197 100644 --- a/drivers/cpuidle/cpuidle-arm.c +++ b/drivers/cpuidle/cpuidle-arm.c @@ -11,12 +11,14 @@ #define pr_fmt(fmt) "CPUidle arm: " fmt +#include #include #include #include #include #include #include +#include #include #include @@ -37,6 +39,7 @@ static int arm_enter_idle_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, int idx) { int ret; + struct device *cpu_dev = get_cpu_device(dev->cpu); if (!idx) { cpu_do_idle(); @@ -46,12 +49,20 @@ static int arm_enter_idle_state(struct cpuidle_device *dev, ret = cpu_pm_enter(); if (!ret) { /* + * Call runtime PM suspend on our device + * Notify RCU to pay attention to critical sections + * called from within runtime PM. + */ + RCU_NONIDLE(pm_runtime_put_sync_suspend(cpu_dev)); + + /* * Pass idle state index to cpu_suspend which in turn will * call the CPU ops suspend protocol with idle index as a * parameter. */ arm_cpuidle_suspend(idx); + RCU_NONIDLE(pm_runtime_get_sync(cpu_dev)); cpu_pm_exit(); } @@ -84,6 +95,34 @@ static const struct of_device_id arm_idle_state_match[] __initconst = { { }, }; +#ifdef CONFIG_HOTPLUG_CPU +static int arm_idle_cpu_hotplug(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct device *cpu_dev = get_cpu_device(smp_processor_id()); + + /* Execute CPU runtime PM on that CPU */ + switch (action & ~CPU_TASKS_FROZEN) { + case CPU_DYING: + pm_runtime_put_sync_suspend(cpu_dev); + break; + case CPU_STARTING: + pm_runtime_get_sync(cpu_dev); + break; + default: + break; + } + + return NOTIFY_OK; +} +#else +static int arm_idle_cpu_hotplug(struct notifier_block *nb, + unsigned long action, void *data) +{ + return NOTIFY_OK; +} +#endif + /* * arm_idle_init * @@ -96,6 +135,7 @@ static int __init arm_idle_init(void) int cpu, ret; struct cpuidle_driver *drv = &arm_idle_driver; struct cpuidle_device *dev; + struct device *cpu_dev; /* * Initialize idle states data, starting at index 1. @@ -118,6 +158,16 @@ static int __init arm_idle_init(void) * idle states suspend back-end specific data */ for_each_possible_cpu(cpu) { + + /* Initialize Runtime PM for the CPU */ + cpu_dev = get_cpu_device(cpu); + pm_runtime_irq_safe(cpu_dev); + pm_runtime_enable(cpu_dev); + if (cpu_online(cpu)) { + pm_runtime_get_noresume(cpu_dev); + pm_runtime_set_active(cpu_dev); + } + ret = arm_cpuidle_init(cpu); /* @@ -148,10 +198,15 @@ static int __init arm_idle_init(void) } } + /* Register for hotplug notifications for runtime PM */ + hotcpu_notifier(arm_idle_cpu_hotplug, 0); + return 0; out_fail: while (--cpu >= 0) { dev = per_cpu(cpuidle_devices, cpu); + cpu_dev = get_cpu_device(cpu); + __pm_runtime_disable(cpu_dev, false); cpuidle_unregister_device(dev); kfree(dev); }