From patchwork Fri Mar 3 20:41:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 94863 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp418620qgd; Fri, 3 Mar 2017 12:48:49 -0800 (PST) X-Received: by 10.98.6.133 with SMTP id 127mr5802236pfg.110.1488574129547; Fri, 03 Mar 2017 12:48:49 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si2934772pli.166.2017.03.03.12.48.49; Fri, 03 Mar 2017 12:48:49 -0800 (PST) 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 sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751970AbdCCUsa (ORCPT + 9 others); Fri, 3 Mar 2017 15:48:30 -0500 Received: from mail-pf0-f180.google.com ([209.85.192.180]:36374 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751989AbdCCUs2 (ORCPT ); Fri, 3 Mar 2017 15:48:28 -0500 Received: by mail-pf0-f180.google.com with SMTP id x66so36674545pfb.3 for ; Fri, 03 Mar 2017 12:47:56 -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=b64DY7c06fi7gb468KaUgcMCr/VhwxWFnyq1ssIafEQ=; b=PEMyGLx2ZuA4czOy1fnc7KPJH/exoNKvRkkQDndv9WY8NAl359q27sx4zpYZIhvLLU FgsnovECPJPrgqW+oh4H6slQsOinXo1eVr5Wc0oSUymcjhhGfLpQGWd1zLXga5/0QS7R QURclsYEwlpqfR3NUOvvHhFYl3JVyTMak1VzY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=b64DY7c06fi7gb468KaUgcMCr/VhwxWFnyq1ssIafEQ=; b=AOu9wUH7rW3LEFMMkdrBb+1wcRxNE9m5cy+Uim6RzSxr1UuWjrlqLzl5MmxD3cAUIj Yn0Q36PvhPUpixCPVUnK5C6BPvwhOfz+QfwAadTgjceDClJq4uFe9b4NacqqXkf/9D6k jCfso9lXStihg+XHLEaM9/WsiBcMFJIxdb8MuhOb/YSI5d+NOKPDYWQS4RH9n403lQdi 1eISA/ljFUJFO+fncHlLntU2WzTcwdoBD5J/ZOe806tLMPP7G6ACZ2kqN+94AC3ZEBlA 3Wix7hBAJvIl8l+LlpmtnFup2IAasasMCmyWbks0QxcdTYVzKlDMZSZXLQzqKTLPx/VW fxbg== X-Gm-Message-State: AMke39lr0616q1rBXvUm5WzXBzYwyu2mpDgIuY10q6EUuHCOeDNu9RV0RjZ/MeEJzzSrHPh2 X-Received: by 10.84.232.9 with SMTP id h9mr7007668plk.102.1488573705181; Fri, 03 Mar 2017 12:41:45 -0800 (PST) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id o189sm25207003pga.12.2017.03.03.12.41.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Mar 2017 12:41:44 -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: 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 2/9] drivers: cpu: Setup CPU devices to do runtime PM Date: Fri, 3 Mar 2017 12:41:28 -0800 Message-Id: <1488573695-106680-3-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488573695-106680-1-git-send-email-lina.iyer@linaro.org> References: <1488573695-106680-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 CPU devices just like any other device, can do runtime PM. However, CPU devices may only do runtime only when IRQs are disabled. The devices must be set as IRQ safe. Cc: Kevin Hilman Cc: Rafael J. Wysocki Signed-off-by: Lina Iyer --- drivers/base/cpu.c | 15 +++++++++++++++ 1 file changed, 15 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/base/cpu.c b/drivers/base/cpu.c index 2c3b359..77451ad 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "base.h" @@ -345,6 +346,19 @@ static int cpu_uevent(struct device *dev, struct kobj_uevent_env *env) } #endif +#ifdef CONFIG_PM +static void cpu_runtime_pm_init(struct device *dev) +{ + pm_runtime_irq_safe(dev); + pm_runtime_enable(dev); + if (cpu_online(dev->id)) + pm_runtime_set_active(dev); +} +#else +static void cpu_runtime_pm_init(struct device *dev) +{ } +#endif + /* * register_cpu - Setup a sysfs device for a CPU. * @cpu - cpu->hotpluggable field set to 1 will generate a control file in @@ -379,6 +393,7 @@ int register_cpu(struct cpu *cpu, int num) register_cpu_under_node(num, cpu_to_node(num)); dev_pm_qos_expose_latency_limit(&cpu->dev, 0); + cpu_runtime_pm_init(&cpu->dev); return 0; } From patchwork Fri Mar 3 20:41:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 94867 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp419109qgd; Fri, 3 Mar 2017 12:50:17 -0800 (PST) X-Received: by 10.98.101.71 with SMTP id z68mr5847909pfb.25.1488574216976; Fri, 03 Mar 2017 12:50:16 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si11539201pga.366.2017.03.03.12.50.16; Fri, 03 Mar 2017 12:50:16 -0800 (PST) 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 sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752114AbdCCUuQ (ORCPT + 9 others); Fri, 3 Mar 2017 15:50:16 -0500 Received: from mail-pf0-f176.google.com ([209.85.192.176]:33304 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752093AbdCCUuP (ORCPT ); Fri, 3 Mar 2017 15:50:15 -0500 Received: by mail-pf0-f176.google.com with SMTP id w189so36536607pfb.0 for ; Fri, 03 Mar 2017 12:50:14 -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=U+qE9zaF3BN7TiNKr3Pfn4NyoGuMva//UYp+wbkMXd8=; b=d1V19wvAvZ6mDyg86n8TvsHoTIfveOw3ib2Nu6H7p3wn7sd/Lobt//454Y4Ak2xr39 1G+5rMrtL6YO7lJyFBp4kJEF0zSqrnJnHobT118FhQMEm2l++ay5fbbhw+DJ893ovEi+ F76qxePgleM1VRDoWADfJnJMZ6JtNwz07ae7s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U+qE9zaF3BN7TiNKr3Pfn4NyoGuMva//UYp+wbkMXd8=; b=YelD+s+WSwHJcxCRrg6PsnUt8BdTM2SfpDxqtJWqmOLoK9sL6Sql5+NqvPfv/n1Uib n0dDYPX50C4KAZhHYN50qUIj70vitOMzhTG5l96SmZJXXJfWDJ46YgpejTi0LeLi+cvT hp26vyXyyn4XjgNaax3sHO8tYsTfYvkbftv60Q9ZMUM2jOwr2X2lxZdlJpiyVT1UiSB0 FbnrFY/U6tZTgZfqnn3nP5T8vcOAgYBxVfXc+OTcJnDQBdRrrUTG4Ddh1HB76ug9TGY9 m/sVg/OpLD+YDyOeLld0/ZciVf0mbpX5Q4mOxLk7LwaNYM9ZlVJrrANSnV7R//MSJjFS tCsg== X-Gm-Message-State: AMke39mLq1/+f0mhYKAVD+TQBq+tGKfRrf1lUL5Bky8dAhOOtB2y2foi4XpmxnSleau5cWn4 X-Received: by 10.98.57.23 with SMTP id g23mr5814339pfa.32.1488573712296; Fri, 03 Mar 2017 12:41:52 -0800 (PST) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id o189sm25207003pga.12.2017.03.03.12.41.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Mar 2017 12:41:51 -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: 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 , Thomas Gleixner Subject: [PATCH V5 5/9] timer: Export next wake up of a CPU Date: Fri, 3 Mar 2017 12:41:31 -0800 Message-Id: <1488573695-106680-6-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488573695-106680-1-git-send-email-lina.iyer@linaro.org> References: <1488573695-106680-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 Knowing the sleep length of the CPU is useful for the power state determination on idle. The value is relative to the time when the call was invoked by the CPU. This doesn't work well when there is a need to know when the actual wakeup is. By reading the next wake up event of a CPU, governors can determine the first CPU to wake up (due to timer) amongst a cluster of CPUs and the sleep time available between the last CPU to idle and the first CPU to resume. This information is useful to determine if the caches and other common hardware blocks can also be put in idle during this common period of inactivity. Cc: Thomas Gleixner Cc: Stephen Boyd Signed-off-by: Lina Iyer --- include/linux/tick.h | 10 ++++++++++ kernel/time/tick-sched.c | 11 +++++++++++ 2 files changed, 21 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/include/linux/tick.h b/include/linux/tick.h index a04fea1..2416021 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -117,6 +117,7 @@ extern void tick_nohz_idle_enter(void); extern void tick_nohz_idle_exit(void); extern void tick_nohz_irq_exit(void); extern ktime_t tick_nohz_get_sleep_length(void); +extern ktime_t tick_nohz_get_next_wakeup(int cpu); extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time); extern u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time); #else /* !CONFIG_NO_HZ_COMMON */ @@ -129,6 +130,15 @@ static inline ktime_t tick_nohz_get_sleep_length(void) { return NSEC_PER_SEC / HZ; } + +static inline ktime_t tick_nohz_get_next_wakeup(int cpu) +{ + ktime_t len = NSEC_PER_SEC/HZ; + + /* Next wake up is the tick period, assume it starts now */ + return ktime_add(len, ktime_get()); +} + static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; } static inline u64 get_cpu_iowait_time_us(int cpu, u64 *unused) { return -1; } #endif /* !CONFIG_NO_HZ_COMMON */ diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 2c115fd..03e7c17 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -989,6 +989,17 @@ ktime_t tick_nohz_get_sleep_length(void) return ts->sleep_length; } +/** + * tick_nohz_get_next_wakeup - return the next wake up of the CPU + */ +ktime_t tick_nohz_get_next_wakeup(int cpu) +{ + struct clock_event_device *dev = + per_cpu(tick_cpu_device.evtdev, cpu); + + return dev->next_event; +} + static void tick_nohz_account_idle_ticks(struct tick_sched *ts) { #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE