Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5527111ybi; Tue, 30 Jul 2019 22:46:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9BPc2xNxjqeblBAOIjeNl6Sw2Qtt2dGt6vrt/dKbxVE5OZbyXCoMpqnnsJodn51u9Q5oT X-Received: by 2002:a62:1c93:: with SMTP id c141mr46929917pfc.9.1564551982537; Tue, 30 Jul 2019 22:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564551982; cv=none; d=google.com; s=arc-20160816; b=IqdzB70OeGf6W8tTLZVpptu0JTRoXoZ/FLXqODj/IMgZWdkjIhNGlA1sx5W2QrOHzW DxSiiCnXdt0fbmpfw0mYgHAJUos9GWItiWnbAYKAYWUbI3IcRBFNdde9lZJvKY1TQiun GJeCMf+OECahdv/u4+DgTwneuV9kr1hq5wlPJTFMQN+Kvl+uS3AehOPEtvcYpjBHPBMD 3V6/gezyRWmm3CU8lQwyt6yCWeT6xb81KVAZD7Auy1EXLnlRkx2le6YCpD1HCrAqj/Ey 3mjladfwDqZ3Nq1l8M11rjJzIGvWkC31vBxeld0oyxjb67GOZ7ic2bJX/fZlgoCxch20 KyXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=vwnjh06rcFFc6RKf/GCuVotlGFpphXihOhUxn4b1qqk=; b=aYlHro/6uOeD+ngrdUUgecPPh7rIjEZpvuRsKMU/1WMfSTFNK/aplHYADL9wNsYILb nojNaWbEcWglG8ZupxUExepyhhVaxtwZmZJoDaQkRMnomoW/2muru+OcjtGrifn3vFnI u/vo8xBmM00aVIGeew7KMwYM1v/gx+wdTb8uVhyiRVOsVCS7hN/97yWPntjsOikRqdqA 8uw9L0mCj4JW0bKLoC/VPQ/DQKU4th2R5sO2jpRVwGFRCtfNRL93eDzK0OXSoS9PAJ26 z2t/DlaHbcEjgOgP3rtiISQWQPguWbmGU2fXfHfGykE3yfd0921bHz1j0oUtAB8fEX8C OLtw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l36si5240517pgb.292.2019.07.30.22.46.07; Tue, 30 Jul 2019 22:46:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727853AbfGaEVV (ORCPT + 99 others); Wed, 31 Jul 2019 00:21:21 -0400 Received: from mga18.intel.com ([134.134.136.126]:41294 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726421AbfGaEVV (ORCPT ); Wed, 31 Jul 2019 00:21:21 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jul 2019 21:21:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,328,1559545200"; d="scan'208";a="347395045" Received: from chenyu-office.sh.intel.com ([10.239.158.163]) by orsmga005.jf.intel.com with ESMTP; 30 Jul 2019 21:21:18 -0700 From: Chen Yu To: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, yu.c.chen@intel.com, Len Brown , "Wysocki, Rafael J" , Rui Zhang , David Box , "Tan, Raymond" Subject: [PATCH] Introducing the mask_cstate to disable specific c-states during bootup Date: Wed, 31 Jul 2019 12:31:44 +0800 Message-Id: <20190731043144.30863-1-yu.c.chen@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is request to disable specific c-states during bootup for debug purpose. For example, deeper c-states except C1,C1E,C10 are disabled during bootup otherwise it might not boot up well due to incorrect setting in FW. For example, intel_idle.mask_cstate=0x3c, would disable cstate 2,3,4,5 in the table (1<<2) | (1<<3) | (1<<4) | (1<<5) which is C6,C7s,C8,C9 on Broxton. This could have it come up as present, but with c-states disabled, so user can enable those c-states later to test. Cc: Len Brown Cc: "Wysocki, Rafael J" Cc: Rui Zhang Cc: David Box Cc: "Tan, Raymond" Signed-off-by: Chen Yu --- .../admin-guide/kernel-parameters.txt | 7 ++++ drivers/idle/intel_idle.c | 36 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 7ccd158b3894..93a326c42877 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1733,6 +1733,13 @@ provided by tboot because it makes the system vulnerable to DMA attacks. + intel_idle.mask_cstate= [HW,X86] + Mask of C-states to be disabled during bootup. For + example, mask_cstate=0x3c, would disable cstate 2,3,4,5 + in the table + (1<<2) | (1<<3) | (1<<4) | (1<<5) + which is C6,C7s,C8,C9 on Broxton. + intel_idle.max_cstate= [KNL,HW,ACPI,X86] 0 disables intel_idle and fall back on acpi_idle. 1 to 9 specify maximum depth of C-state. diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index fa5ff77b8fe4..ed3233864b69 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -63,6 +63,8 @@ static struct cpuidle_driver intel_idle_driver = { /* intel_idle.max_cstate=0 disables driver */ static int max_cstate = CPUIDLE_STATE_MAX - 1; +static unsigned int mask_cstate; + static unsigned int mwait_substates; #define LAPIC_TIMER_ALWAYS_RELIABLE 0xFFFFFFFF @@ -1354,6 +1356,12 @@ static void __init intel_idle_cpuidle_driver_init(void) if (num_substates == 0) continue; + if ((1UL<= CPUIDLE_STATE_MAX) { + ret = -EINVAL; + goto exit_mask; + } + + mask_cstate = new_mask_cstate; + smp_mb(); + +exit_mask: + return ret; +} + +static const struct kernel_param_ops mask_cstate_ops = { + .set = mask_cstate_set, + .get = param_get_int, +}; +module_param_cb(mask_cstate, &mask_cstate_ops, &mask_cstate, 0644); -- 2.17.1