From patchwork Fri Feb 12 20:50:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 8297491 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F3EC9C02AA for ; Fri, 12 Feb 2016 20:54:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0969520454 for ; Fri, 12 Feb 2016 20:54:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2178720444 for ; Fri, 12 Feb 2016 20:54:00 +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 1aUKhf-0007AV-Nr; Fri, 12 Feb 2016 20:52:35 +0000 Received: from mail-pf0-x230.google.com ([2607:f8b0:400e:c00::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aUKgr-0006U3-7S for linux-arm-kernel@lists.infradead.org; Fri, 12 Feb 2016 20:51:47 +0000 Received: by mail-pf0-x230.google.com with SMTP id c10so53772819pfc.2 for ; Fri, 12 Feb 2016 12:51:24 -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=La6HBYjSBR0x9x3YIfOf+cSI16IANy+l6Sn73o0yKNc=; b=jeLRn/2KYneCiXCE2h0qMLcceanLexR1B1rfTEMPkd+osRwSOkceyiyhu9xw0c1qNo 09ohXqE9bNKNmrAgwd4Vj7RepnKVcOyR+FG4LrD/9JHXxEyAAVCHtt8nq9+HBjP61Hig jSnCaB7TvTyaYx6hDiW2wMKpxo8s+3wSYlNk8= 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=La6HBYjSBR0x9x3YIfOf+cSI16IANy+l6Sn73o0yKNc=; b=ahIk3brLScnkKftWe7UDnAwKPKUn0TFih52COsIf13caloVKr0d6mEozOVIeeXkYNO we+7yYv5c7INVZuZ3yFAAM58ofU+dF/3RmoCzwvO5qrXnTqKSm6w1ShDDgDLniqmalKJ qKdGNvCr9fxrceUjrzhVDYraSQT7xDghs0WyQ1efL9b1cE879bbhHGinXyF7JQLnFPsc vFtd+SDGWTh6OvXZ4oilCZxbcosWuhi1wgdKz8PJCdSakjfxdSHb1OywVON1M4WmTCDZ ULTdRN/hNCO+AcUXjv3baOrmaySTtGBUbOGUwHMG1ctP6PWTOxxT7ONaFnMKHN3e82V3 eGXg== X-Gm-Message-State: AG10YOTxLwPEKe/VLCJL2QC2BZuzIg7a6kWNQ7hVQqT03gf6AM3vB4U4UOBgRvwfI2Acj3kF X-Received: by 10.98.68.86 with SMTP id r83mr5161611pfa.12.1455310284483; Fri, 12 Feb 2016 12:51:24 -0800 (PST) Received: from ubuntu.localdomain ([172.56.8.98]) by smtp.gmail.com with ESMTPSA id x12sm21401070pfi.88.2016.02.12.12.51.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Feb 2016 12:51:23 -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 Subject: [RFC v2 04/12] ARM: cpuidle: Add runtime PM support for CPUs Date: Fri, 12 Feb 2016 13:50:30 -0700 Message-Id: <1455310238-8963-5-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455310238-8963-1-git-send-email-lina.iyer@linaro.org> References: <1455310238-8963-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160212_125145_607239_2B368D82 X-CRM114-Status: GOOD ( 17.39 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: k.kozlowski@samsung.com, lorenzo.pieralisi@arm.com, ahaslam@baylibre.com, linux-arm-msm@vger.kernel.org, Daniel Lezcano , sboyd@codeaurora.org, msivasub@codeaurora.org, geert@linux-m68k.org, Lina Iyer , agross@codeaurora.org, mtitinger@baylibre.com 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,DKIM_SIGNED, RCVD_IN_DNSWL_MED,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 --- Changes since RFC v1 - - runtime PM initialization is now done as part of this file - hotplug and its runtime PM invocation is done here drivers/cpuidle/cpuidle-arm.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index 545069d..bf7a80c 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(); @@ -45,6 +48,8 @@ static int arm_enter_idle_state(struct cpuidle_device *dev, ret = cpu_pm_enter(); if (!ret) { + 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 @@ -52,6 +57,7 @@ static int arm_enter_idle_state(struct cpuidle_device *dev, */ arm_cpuidle_suspend(idx); + RCU_NONIDLE(pm_runtime_get_sync(cpu_dev)); cpu_pm_exit(); } @@ -84,6 +90,30 @@ static const struct of_device_id arm_idle_state_match[] __initconst = { { }, }; +#ifdef CONFIG_HOTPLUG_CPU +static int 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) { + case CPU_DYING: + case CPU_DYING_FROZEN: + RCU_NONIDLE(pm_runtime_put_sync_suspend(cpu_dev)); + break; + case CPU_STARTING: + case CPU_STARTING_FROZEN: + RCU_NONIDLE(pm_runtime_get_sync(cpu_dev)); + break; + default: + break; + } + + return NOTIFY_OK; +} +#endif + /* * arm_idle_init * @@ -96,6 +126,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 +149,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 +189,17 @@ static int __init arm_idle_init(void) } } +#ifdef CONFIG_HOTPLUG_CPU + /* Register for hotplug notifications for runtime PM */ + hotcpu_notifier(cpu_hotplug, 0); +#endif + 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); }