From patchwork Thu Aug 18 22:26:54 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: 9288849 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 7590C600CB for ; Fri, 19 Aug 2016 01:10:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 657C32926D for ; Fri, 19 Aug 2016 01:10:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A0FA2929C; Fri, 19 Aug 2016 01:10:38 +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 EAD982926D for ; Fri, 19 Aug 2016 01:10:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754667AbcHSBKe (ORCPT ); Thu, 18 Aug 2016 21:10:34 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:1722 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754387AbcHSBKb (ORCPT ); Thu, 18 Aug 2016 21:10:31 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u7IMNmpl088130 for ; Thu, 18 Aug 2016 18:27:18 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0b-001b2d01.pphosted.com with ESMTP id 24vrm59k8s-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 18 Aug 2016 18:27:17 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 18 Aug 2016 16:27:16 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 18 Aug 2016 16:27:12 -0600 X-IBM-Helo: d03dlp01.boulder.ibm.com X-IBM-MailFrom: ego@linux.vnet.ibm.com Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 25EF51FF0045; Thu, 18 Aug 2016 16:26:54 -0600 (MDT) Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u7IMRBgV16187886; Thu, 18 Aug 2016 22:27:11 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 880F0AE043; Thu, 18 Aug 2016 18:27:11 -0400 (EDT) Received: from sofia.ibm.com (unknown [9.77.198.149]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 1325BAE052; Thu, 18 Aug 2016 18:27:11 -0400 (EDT) Received: by sofia.ibm.com (Postfix, from userid 1000) id 4C7202E2DE6; Fri, 19 Aug 2016 03:57:06 +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 1/2] cpuidle: Allow idle-states to be disabled at start Date: Fri, 19 Aug 2016 03:56:54 +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-0016-0000-0000-000004755F09 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:15 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16081822-0017-0000-0000-00003223BB75 Message-Id: <48afad7788300482c047fc35e70ca8e4bf31a5ac.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" Currently all the idle states registered by a cpu-idle driver are enabled by default. This patch adds a mechanism which allows the driver to hint if an idle-state should start in a disabled state. The cpu-idle core will use this hint to appropriately initialize the usage->disable knob of the CPU device idle state. The state can be enabled at run time by echo'ing a zero to the sysfs "disable" control file. Signed-off-by: Gautham R. Shenoy --- drivers/cpuidle/cpuidle.c | 7 +++++++ include/linux/cpuidle.h | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index c73207a..b4debc7 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -439,7 +439,14 @@ static void __cpuidle_unregister_device(struct cpuidle_device *dev) static void __cpuidle_device_init(struct cpuidle_device *dev) { + struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); + int i; + memset(dev->states_usage, 0, sizeof(dev->states_usage)); + for (i = 0; i < drv->state_count; i++) { + if (drv->states[i].disable_use_at_start) + dev->states_usage[i].disable = 1; + } dev->last_residency = 0; } diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index bb31373..f3fe855 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -44,7 +44,12 @@ struct cpuidle_state { int power_usage; /* in mW */ unsigned int target_residency; /* in US */ bool disabled; /* disabled on all CPUs */ - + /* + * disable_use_at_start: If true, then this idle state will be + * disabled by default. It can be enabled at runtime using the + * per-cpu cpuidle sysfs control file named "disable". + */ + bool disable_use_at_start; int (*enter) (struct cpuidle_device *dev, struct cpuidle_driver *drv, int index);