From patchwork Fri Jul 29 21:56:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 73054 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1601258qga; Fri, 29 Jul 2016 14:57:10 -0700 (PDT) X-Received: by 10.98.90.133 with SMTP id o127mr72215194pfb.61.1469829410752; Fri, 29 Jul 2016 14:56:50 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 195si20379500pfz.17.2016.07.29.14.56.50; Fri, 29 Jul 2016 14:56:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1754132AbcG2V4t (ORCPT + 8 others); Fri, 29 Jul 2016 17:56:49 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:33881 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753882AbcG2V4s (ORCPT ); Fri, 29 Jul 2016 17:56:48 -0400 Received: by mail-pa0-f54.google.com with SMTP id fi15so34629170pac.1 for ; Fri, 29 Jul 2016 14:56:48 -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=nP2WZEnkovd6MyeNkqtBYHiNrUsPjiWq+Ghgyn8hWr8=; b=R3SDrwGivbgAzRCAijZ3ifCqxYPlJve7PYj6mkywlcfGWGaTDWvp0n8NwVtX9/7heM DyTosk0mmx3SGKjDtpaCtT6T/orNUUAmPx3zql6CzpAF6pl0ZqklhW4DEuzbjWfbDdTt V9bcT6iDa2BD57MvJ0weDmr42L9wwUS4dxMYM= 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=nP2WZEnkovd6MyeNkqtBYHiNrUsPjiWq+Ghgyn8hWr8=; b=PAAyPL40WeOXSfzHf2FgUWI57FtcB/bo8aPh5LqhZ8Et3m0W9IztfnAcA/0Vfn7fzJ 0DpPJSVvTzqakb2SZO6TmdnW2jb81rU6sA5ixR0sG+LAphKKKOb3J0gll9sJp+0IT2cE 3lPdwspGTZuSzsl2vBNlc+ZdRPO29y4eChrJIY+C91ArBNymXovj0303a7/0h5uDy7Pb 9E98D9ULQbHipugagH+qZuPXHcEP7pyW0mHDbnupmlpdnt1JioZuwOFWNz6p1cTLs4Es nKoUp5xbFBKJEMXJ5wRVPxqmxr0avf4R9TCbx5GjHAnXni1rNqbOqkouKBBDXTCMMoyy rnQg== X-Gm-Message-State: AEkoousAaS4upYUQXHr7cULDt95rdTZKtF3LK5zbxzNnIPnr6N796Bd3deX7DGT1kB6V8OrK X-Received: by 10.66.181.139 with SMTP id dw11mr73264304pac.2.1469829408131; Fri, 29 Jul 2016 14:56:48 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id 81sm27196601pfm.90.2016.07.29.14.56.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jul 2016 14:56:47 -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, Lina Iyer , Daniel Lezcano , Lorenzo Pieralisi Subject: [PATCH v2 07/14] ARM: cpuidle: Add runtime PM support for CPUs Date: Fri, 29 Jul 2016 15:56:18 -0600 Message-Id: <1469829385-11511-8-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469829385-11511-1-git-send-email-lina.iyer@linaro.org> References: <1469829385-11511-1-git-send-email-lina.iyer@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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. 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(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" 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/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index e342565e..3abd145 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. */ ret = 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); }