From patchwork Thu Aug 18 22:26:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautham R Shenoy X-Patchwork-Id: 9288911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 722E1600CB for ; Fri, 19 Aug 2016 01:17:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60FF2292D4 for ; Fri, 19 Aug 2016 01:17:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50A1C292D8; Fri, 19 Aug 2016 01:17:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D096E29271 for ; Fri, 19 Aug 2016 01:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755032AbcHSBRf (ORCPT ); Thu, 18 Aug 2016 21:17:35 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33940 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755038AbcHSBRa (ORCPT ); Thu, 18 Aug 2016 21:17:30 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u7IMNmdX092167 for ; Thu, 18 Aug 2016 18:27:27 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 24v7622v5r-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 18 Aug 2016 18:27:27 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 18 Aug 2016 16:27:26 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 18 Aug 2016 16:27:21 -0600 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: ego@linux.vnet.ibm.com Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 0295919D8041; Thu, 18 Aug 2016 16:26:54 -0600 (MDT) Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u7IMRLlJ5964274; Thu, 18 Aug 2016 15:27:21 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F7646A03B; Thu, 18 Aug 2016 16:27:21 -0600 (MDT) Received: from sofia.ibm.com (unknown [9.77.198.149]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 812566A03C; Thu, 18 Aug 2016 16:27:20 -0600 (MDT) Received: by sofia.ibm.com (Postfix, from userid 1000) id 0C0732E2DE7; Fri, 19 Aug 2016 03:57:08 +0530 (IST) From: "Gautham R. Shenoy" To: "Rafael J. Wysocki" , Daniel Lezcano , Michael Ellerman , Benjamin Herrenschmidt , Michael Neuling , Paul Mackerras , Vaidyanathan Srinivasan Cc: Anton Blanchard , linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, "Gautham R. Shenoy" Subject: [RFC/PATCH 2/2] powernv:cpuidle: Enable winkle idle state in CPU-Idle. Date: Fri, 19 Aug 2016 03:56:55 +0530 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16081822-0020-0000-0000-00000996286E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005614; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000181; SDB=6.00746583; UDB=6.00352005; IPR=6.00519116; BA=6.00004668; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012381; XFM=3.00000011; UTC=2016-08-18 22:27:24 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16081822-0021-0000-0000-000054B1BC83 Message-Id: <82851f91268d8c3aae38079b57f4e46c3a1b1f5e.1471557381.git.ego@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-08-18_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1608180299 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Gautham R. Shenoy" cpu-idle on powernv currently has support for only snooze, nap and fastsleep states. Winkle idle state was excluded due to its large exit-latency. This patch adds winkle as a cpu-idle state for experimental purposes. This state is disabled at start by default. However, should an adventurous user want to enable it on a particular CPU(s), they can do so by echo'ing a zero into the per-cpu sysfs cpuidle control file named "disable" corresponding to this state. Signed-off-by: Gautham R. Shenoy --- drivers/cpuidle/cpuidle-powernv.c | 44 ++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c index f7ca891..0437d8a 100644 --- a/drivers/cpuidle/cpuidle-powernv.c +++ b/drivers/cpuidle/cpuidle-powernv.c @@ -20,7 +20,6 @@ #include #include -#define POWERNV_THRESHOLD_LATENCY_NS 200000 struct cpuidle_driver powernv_idle_driver = { .name = "powernv_idle", @@ -95,6 +94,30 @@ static int fastsleep_loop(struct cpuidle_device *dev, return index; } + +static int winkle_loop(struct cpuidle_device *dev, + struct cpuidle_driver *drv, + int index) +{ + unsigned long old_lpcr = mfspr(SPRN_LPCR); + unsigned long new_lpcr; + + if (unlikely(system_state < SYSTEM_RUNNING)) + return index; + + new_lpcr = old_lpcr; + /* Do not exit powersave upon decrementer as we've setup the timer + * offload. + */ + new_lpcr &= ~LPCR_PECE1; + + mtspr(SPRN_LPCR, new_lpcr); + power7_winkle(); + + mtspr(SPRN_LPCR, old_lpcr); + + return index; +} #endif static int stop_loop(struct cpuidle_device *dev, @@ -246,13 +269,6 @@ static int powernv_add_idle_states(void) "ibm,cpu-idle-state-residency-ns", residency_ns, dt_idle_states); for (i = 0; i < dt_idle_states; i++) { - /* - * If an idle state has exit latency beyond - * POWERNV_THRESHOLD_LATENCY_NS then don't use it - * in cpu-idle. - */ - if (latency_ns[i] > POWERNV_THRESHOLD_LATENCY_NS) - continue; /* * Cpuidle accepts exit_latency and target_residency in us. @@ -301,6 +317,18 @@ static int powernv_add_idle_states(void) powernv_states[nr_idle_states].enter = stop_loop; stop_psscr_table[nr_idle_states] = psscr_val[i]; } + + if (flags[i] & OPAL_PM_WINKLE_ENABLED) { + int state_idx = nr_idle_states; + + strcpy(powernv_states[state_idx].name, "Winkle"); + strcpy(powernv_states[state_idx].desc, "Winkle"); + powernv_states[state_idx].flags = + CPUIDLE_FLAG_TIMER_STOP; + powernv_states[state_idx].target_residency = 500000; + powernv_states[state_idx].enter = winkle_loop; + powernv_states[state_idx].disable_use_at_start = true; + } #endif powernv_states[nr_idle_states].exit_latency = ((unsigned int)latency_ns[i]) / 1000;