From patchwork Wed Aug 14 11:56:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: preeti X-Patchwork-Id: 2844428 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D8FF2BF546 for ; Wed, 14 Aug 2013 12:01:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F4302050D for ; Wed, 14 Aug 2013 12:01:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5354820508 for ; Wed, 14 Aug 2013 12:01:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759930Ab3HNL7I (ORCPT ); Wed, 14 Aug 2013 07:59:08 -0400 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:47684 "EHLO e23smtp05.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759675Ab3HNL7G (ORCPT ); Wed, 14 Aug 2013 07:59:06 -0400 Received: from /spool/local by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Aug 2013 21:52:02 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp05.au.ibm.com (202.81.31.211) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Aug 2013 21:52:00 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id D12942CE804C; Wed, 14 Aug 2013 21:59:01 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7EBhCXt4653354; Wed, 14 Aug 2013 21:43:12 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r7EBwxiw007771; Wed, 14 Aug 2013 21:59:01 +1000 Received: from preeti.in.ibm.com (preeti.in.ibm.com [9.124.35.218] (may be forged)) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r7EBwl6Z007610; Wed, 14 Aug 2013 21:58:55 +1000 Subject: [RFC V2 PATCH 4/6] cpuidle/ppc: Add longnap state to the idle states on powernv To: fweisbec@gmail.com, paul.gortmaker@windriver.com, paulus@samba.org, shangw@linux.vnet.ibm.com, galak@kernel.crashing.org, deepthi@linux.vnet.ibm.com, benh@kernel.crashing.org, paulmck@linux.vnet.ibm.com, arnd@arndb.de, linux-pm@vger.kernel.org, rostedt@goodmis.org, rjw@sisk.pl, john.stultz@linaro.org, tglx@linutronix.de, chenhui.zhao@freescale.com, michael@ellerman.id.au, r58472@freescale.com, geoff@infradead.org, linux-kernel@vger.kernel.org, srivatsa.bhat@linux.vnet.ibm.com, schwidefsky@de.ibm.com, svaidy@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org From: Preeti U Murthy Date: Wed, 14 Aug 2013 17:26:23 +0530 Message-ID: <20130814115623.5193.36974.stgit@preeti.in.ibm.com> In-Reply-To: <20130814115311.5193.32212.stgit@preeti.in.ibm.com> References: <20130814115311.5193.32212.stgit@preeti.in.ibm.com> User-Agent: StGit/0.16-38-g167d MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13081411-1396-0000-0000-000003679664 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 This patch hooks into the existing broadcast framework along with the support that this patchset introduces for ppc, and the cpuidle driver backend for powernv(posted out by Deepthi Dharwar:https://lkml.org/lkml/2013/7/23/128) to add sleep state as one of the deep idle states, in which the decrementer is switched off. However in this patch, we only emulate sleep by going into a state which does a nap with the decrementer interrupts disabled, termed as longnap. This enables focus on the timer broadcast framework for ppc in this series of patches , which is required as a first step to enable sleep on ppc. Signed-off-by: Preeti U Murthy --- arch/powerpc/platforms/powernv/processor_idle.c | 48 +++++++++++++++++++++++ 1 file changed, 47 insertions(+), 1 deletion(-) -- 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/arch/powerpc/platforms/powernv/processor_idle.c b/arch/powerpc/platforms/powernv/processor_idle.c index f43ad91a..9aca502 100644 --- a/arch/powerpc/platforms/powernv/processor_idle.c +++ b/arch/powerpc/platforms/powernv/processor_idle.c @@ -9,16 +9,18 @@ #include #include #include +#include #include #include +#include struct cpuidle_driver powernv_idle_driver = { .name = "powernv_idle", .owner = THIS_MODULE, }; -#define MAX_IDLE_STATE_COUNT 2 +#define MAX_IDLE_STATE_COUNT 3 static int max_idle_state = MAX_IDLE_STATE_COUNT - 1; static struct cpuidle_device __percpu *powernv_cpuidle_devices; @@ -54,6 +56,43 @@ static int nap_loop(struct cpuidle_device *dev, return index; } +/* Emulate sleep, with long nap. + * During sleep, the core does not receive decrementer interrupts. + * Emulate sleep using long nap with decrementers interrupts disabled. + * This is an initial prototype to test the timer offload framework for ppc. + * We will eventually introduce the sleep state once the timer offload framework + * for ppc is stable. + */ +static int longnap_loop(struct cpuidle_device *dev, + struct cpuidle_driver *drv, + int index) +{ + int cpu = dev->cpu; + + unsigned long lpcr = mfspr(SPRN_LPCR); + + lpcr &= ~(LPCR_MER | LPCR_PECE); /* lpcr[mer] must be 0 */ + + /* exit powersave upon external interrupt, but not decrementer + * interrupt, Emulate sleep. + */ + lpcr |= LPCR_PECE0; + + if (cpu != bc_cpu) { + mtspr(SPRN_LPCR, lpcr); + clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu); + power7_nap(); + clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu); + } else { + /* Wakeup on a decrementer interrupt, Do a nap */ + lpcr |= LPCR_PECE1; + mtspr(SPRN_LPCR, lpcr); + power7_nap(); + } + + return index; +} + /* * States for dedicated partition case. */ @@ -72,6 +111,13 @@ static struct cpuidle_state powernv_states[MAX_IDLE_STATE_COUNT] = { .exit_latency = 10, .target_residency = 100, .enter = &nap_loop }, + { /* LongNap */ + .name = "LongNap", + .desc = "LongNap", + .flags = CPUIDLE_FLAG_TIME_VALID, + .exit_latency = 10, + .target_residency = 100, + .enter = &longnap_loop }, }; static int powernv_cpuidle_add_cpu_notifier(struct notifier_block *n,