Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2226426pxb; Thu, 4 Nov 2021 16:31:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxssK6rVVKZkJWWeByo7hJcyxsZAhGAQhSSoxXo4y+dhrplDGuZy8qhiFW7Lz7IpUAib2Gs X-Received: by 2002:a17:906:3157:: with SMTP id e23mr14150539eje.359.1636068681215; Thu, 04 Nov 2021 16:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636068681; cv=none; d=google.com; s=arc-20160816; b=xU024RtZFVNzs51bVlf8eaU55bPMNwJq8kcqFfShDLeX3lCtGqdFk6Ou/dRlkv3Nro JZNddp4W9HErAEy3pJ7/7OHt0DMirmIYq7c8vRmY5E+5bf60gLQ+Uzg1sMogLJik6fqm HORBcfP1MKFgLJBypsOjxvZ+dEjt0t3tqjTJLePH+0fDnlovEdGoNO7Z2ehu5KPdhwm1 H8EigJUvNJYzGWMHC0q8cEQT2BROSirhcH8A0beqf4WIYHr8a4gXTi7a0XwH7/GXiDbi MPRblOKXnafYXzzzmmKP3Uw1vx3ykecalQgePbVFi3SNPfesoNXMBSAmA16f1UzczmNW rdnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=zRuInVHxLD5DPPcqvDBnCckdcxFby1xNm+mFH9i3dPY=; b=FuqdtrUgibvS5LZxVKOwkEPZspD7A5T3D1wbhuMQ2DwNcbMQCAyO9Ulo8gIqJjxvff 8BXSOnMMQLyyquroXNN92570iQNDe4nzqAoyqgC4jNl4/rcT/2Gw9HlosRVDtLsRBRRn P3i1PF5bY/ih5kz0+BzI7smHg0Uj77TE+AzLA82FH+DvjTIstPbf6c/xnyL5k6uC0SvS UObf7LRahLxRXMKAMSWSf2Q3CHcjyYc5ZUj16zPRuYApHbnBUQmLBkM7V2FR1CZry9mO cWjjE94e5fYxkIK/jEJfL+nZj9AapzqT1KtrtPnJ0PEoeEobisyNDfDuGviO3NkdsfC+ /SHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id 28si8126693ejb.18.2021.11.04.16.30.57; Thu, 04 Nov 2021 16:31:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232424AbhKDXCo (ORCPT + 99 others); Thu, 4 Nov 2021 19:02:44 -0400 Received: from mga17.intel.com ([192.55.52.151]:49621 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232360AbhKDXCf (ORCPT ); Thu, 4 Nov 2021 19:02:35 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="212554549" X-IronPort-AV: E=Sophos;i="5.87,209,1631602800"; d="scan'208";a="212554549" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2021 15:59:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,209,1631602800"; d="scan'208";a="490138598" Received: from chang-linux-3.sc.intel.com ([172.25.66.175]) by orsmga007.jf.intel.com with ESMTP; 04 Nov 2021 15:59:56 -0700 From: "Chang S. Bae" To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, tglx@linutronix.de, dave.hansen@linux.intel.com, peterz@infradead.org, bp@alien8.de, mingo@redhat.com, chang.seok.bae@intel.com, linux-pm@vger.kernel.org Subject: [PATCH 4/4] intel_idle: Add SPR support with AMX INIT-state Date: Thu, 4 Nov 2021 15:52:26 -0700 Message-Id: <20211104225226.5031-5-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211104225226.5031-1-chang.seok.bae@intel.com> References: <20211104225226.5031-1-chang.seok.bae@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a custom Sapphire Rapids C-state table to intel_idle driver. The parameters in the table are preferred over those supplied by ACPI. SPR supports AMX, and so this custom table uses idle entry points that know how to initialize AMX state if necessary. This guarantees that AMX state will never be the cause of hardware C-state demotion from C6 to C1E. Under some conditions, this may result in improved power savings and thus a higher available turbo frequency budget. [ Based on patch by Artem Bityutskiy . ] Suggested-by: Peter Zijlstra (Intel) Signed-off-by: Chang S. Bae Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org --- drivers/idle/intel_idle.c | 62 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index e6c543b5ee1d..0ac7dc9e6d51 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -54,6 +54,7 @@ #include #include #include +#include #define INTEL_IDLE_VERSION "0.5.1" @@ -155,6 +156,39 @@ static __cpuidle int intel_idle_s2idle(struct cpuidle_device *dev, return 0; } +/** + * intel_idle_tile - Ask the processor to enter the given idle state. + * @dev: cpuidle device of the target CPU. + * @drv: cpuidle driver (assumed to point to intel_idle_driver). + * + * Ensure TILE registers in INIT-state before using intel_idle() to + * enter the idle state. + */ +static __cpuidle int intel_idle_tile(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int index) +{ + fpu_idle_fpregs(); + + return intel_idle(dev, drv, index); +} + +/** + * intel_idle_s2idle_tile - Ask the processor to enter the given idle state. + * @dev: cpuidle device of the target CPU. + * @drv: cpuidle driver (assumed to point to intel_idle_driver). + * @index: Target idle state index. + * + * Ensure TILE registers in INIT-state before using intel_idle_s2idle() to + * enter the idle state. + */ +static __cpuidle int intel_idle_s2idle_tile(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int index) +{ + fpu_idle_fpregs(); + + return intel_idle_s2idle(dev, drv, index); +} + /* * States are indexed by the cstate number, * which is also the index into the MWAIT hint array. @@ -752,6 +786,27 @@ static struct cpuidle_state icx_cstates[] __initdata = { .enter = NULL } }; +static struct cpuidle_state spr_cstates[] __initdata = { + { + .name = "C1", + .desc = "MWAIT 0x00", + .flags = MWAIT2flg(0x00), + .exit_latency = 1, + .target_residency = 1, + .enter = &intel_idle, + .enter_s2idle = intel_idle_s2idle, }, + { + .name = "C6", + .desc = "MWAIT 0x20", + .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, + .exit_latency = 128, + .target_residency = 384, + .enter = &intel_idle_tile, + .enter_s2idle = intel_idle_s2idle_tile, }, + { + .enter = NULL } +}; + static struct cpuidle_state atom_cstates[] __initdata = { { .name = "C1E", @@ -1095,6 +1150,12 @@ static const struct idle_cpu idle_cpu_icx __initconst = { .use_acpi = true, }; +static const struct idle_cpu idle_cpu_spr __initconst = { + .state_table = spr_cstates, + .disable_promotion_to_c1e = true, + .use_acpi = true, +}; + static const struct idle_cpu idle_cpu_avn __initconst = { .state_table = avn_cstates, .disable_promotion_to_c1e = true, @@ -1157,6 +1218,7 @@ static const struct x86_cpu_id intel_idle_ids[] __initconst = { X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_X, &idle_cpu_skx), X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, &idle_cpu_icx), X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_D, &idle_cpu_icx), + X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, &idle_cpu_spr), X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNL, &idle_cpu_knl), X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNM, &idle_cpu_knl), X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT, &idle_cpu_bxt), -- 2.17.1