From patchwork Thu Sep 5 16:29:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 825784 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9CF41A08B8; Thu, 5 Sep 2024 16:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725553819; cv=none; b=IdndIHY89/cUzm0vKTHFjJ/jJsorS4vdauhwoG1vPu1UfDLvV3qdhrEXEK09Bo5VZMykrxGBQFP9s2n/VWl1M40XHK/XXFdplaXJsqhV3OY730RgbaWend2dDwun8jfPXPHVC1znRMbIJ3wM4SX69eUb4fJxTBfW9yG7PSNu2SU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725553819; c=relaxed/simple; bh=ZAeOThCVIA/Hdzu0NXAoIn+TTinxpUo0rpgK3LbmGIE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DOhctowY2sH6CS2MVExpC8zsxA4gn+VMDX1WZ9F1xShDoHNzuXlLOlyjw5cR9Vu7J9HYW+shmNIAjMNxabXHoEeRf8e4pf1HZF3529eP9ei2zt6MAaqv8I0fQJI7dFrnQPHPAYoA64Q/NiD/R2q6u8TXIwkmD0d5FDnAkGE/quw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fiKBvbsH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fiKBvbsH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5CCBC4CECA; Thu, 5 Sep 2024 16:30:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725553819; bh=ZAeOThCVIA/Hdzu0NXAoIn+TTinxpUo0rpgK3LbmGIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fiKBvbsHvPtuPoqorYewNsdu9tW97uv9mpiJBViIE+5LELearMNhjMRhGHLWF7ZNH vleUPwo2AeGNfiG/RImGl8ECC7w30pINS/dkcD9I/S3gICk6pU7ohrYnMqv4IihviH HiLOGD+XXhcmndeBRtzh7mhmdBKTJ9qL7sa8dOJiW9ZXoIlmQrdlPR/UFa55f8naxJ FmkHfAakiYN3ILZdr+7GFR9R+GHPlcYdhPX0GqX481MnmOXntqa7Db2yDfuyMMVxId M07O2GSEp5Kaw0EVIi4x2MO6YJP+8dngMmJQwSxgxslCQPTz+8YJpItZO0PFeQS7GI Hd1ozyupkLJZQ== From: Mario Limonciello To: "Gautham R . Shenoy" , Perry Yuan Cc: Borislav Petkov , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "Rafael J . Wysocki" , linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)), linux-acpi@vger.kernel.org (open list:ACPI), linux-pm@vger.kernel.org (open list:CPU FREQUENCY SCALING FRAMEWORK), Mario Limonciello Subject: [PATCH v3 02/11] ACPI: CPPC: Adjust return code for inline functions in !CONFIG_ACPI_CPPC_LIB Date: Thu, 5 Sep 2024 11:29:58 -0500 Message-ID: <20240905163007.1350840-3-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240905163007.1350840-1-superm1@kernel.org> References: <20240905163007.1350840-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello Checkpath emits the following warning: ``` WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP ``` Adjust the code accordingly. Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- v2->v3: * Pick up tag --- include/acpi/cppc_acpi.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h index 930b6afba6f4d..409a7190a4a86 100644 --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -162,31 +162,31 @@ extern int cppc_set_auto_sel(int cpu, bool enable); #else /* !CONFIG_ACPI_CPPC_LIB */ static inline int cppc_get_desired_perf(int cpunum, u64 *desired_perf) { - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf) { - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline int cppc_get_highest_perf(int cpunum, u64 *highest_perf) { - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs) { - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) { - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline int cppc_set_enable(int cpu, bool enable) { - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps) { - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline bool cppc_perf_ctrs_in_pcc(void) { @@ -210,27 +210,27 @@ static inline bool cpc_ffh_supported(void) } static inline int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val) { - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val) { - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable) { - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline int cppc_get_epp_perf(int cpunum, u64 *epp_perf) { - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline int cppc_set_auto_sel(int cpu, bool enable) { - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline int cppc_get_auto_sel_caps(int cpunum, struct cppc_perf_caps *perf_caps) { - return -ENOTSUPP; + return -EOPNOTSUPP; } #endif /* !CONFIG_ACPI_CPPC_LIB */ From patchwork Thu Sep 5 16:30:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 825783 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C7A51A2C14; Thu, 5 Sep 2024 16:30:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725553822; cv=none; b=t/n8WvELJhViCkOjdsmTBYKdpwoKBR90hsMQImff0BdUr5rPjFLs+KdTe4dJL955LHfBqk/ZHyCo4U7r0YAlv7rqXPDQXM2ruS00gG5e+JR8QeGaEB6OstdX8Zho1+uf5eJ9i+uhrnpZd45VymkbyKx4YJ3ga6UO+AhYhUAWmAI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725553822; c=relaxed/simple; bh=Zt3i+cvHegpXXitpCTq/1E918OQsdv+WUjbGkfVqzaY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XP7BtSOjwC3/OXE1lTRWEFTvjd2bqD7JWH4szUpwqeM3BI5HhHCIycJVT9NcChNecvxmQZp61E5bf/+7X3ExDLQyTaZnSLIvv4eK9xSlIii9LTdJNYZZGn6An6oDWDXlEaeBiJleBHUF4kmdBodbOFwu6WXJb8ItQS3UAQGdFqI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MOBw9jGW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MOBw9jGW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 290D7C4CEC3; Thu, 5 Sep 2024 16:30:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725553822; bh=Zt3i+cvHegpXXitpCTq/1E918OQsdv+WUjbGkfVqzaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MOBw9jGWBy6zH4mf7er170DBKItNU2UaaG4P/92GcBFXTjwYd70aDDdHQ+CcFgFUF k6SifQsr9Y/BmL+dV2e02RXQnCHzxkt0KHKJ8UmbhtrcIM23KWtANvbc6v4kunvuge RSy7uiJI+sfZ9dntVp5xjpncb1XvfQzJGQH2KaMf/y42Mdi+reQSF4G6wm2V0Mctwj H+VAsAHF+12/bQLQm++BylRbk8zdTiNG+rQeVzO2pxZrNG2eY2i9V/7RI2u1A5NXVe eqilM77OgaCD+XuUJKdT4tHdzuNVMc/JtsQwRG53YuS1q5lqi7CBr473l4kRDwH9al E6b3vcWhar2XQ== From: Mario Limonciello To: "Gautham R . Shenoy" , Perry Yuan Cc: Borislav Petkov , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "Rafael J . Wysocki" , linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)), linux-acpi@vger.kernel.org (open list:ACPI), linux-pm@vger.kernel.org (open list:CPU FREQUENCY SCALING FRAMEWORK), Mario Limonciello , "Gautham R . Shenoy" Subject: [PATCH v3 04/11] ACPI: CPPC: Drop check for non zero perf ratio Date: Thu, 5 Sep 2024 11:30:00 -0500 Message-ID: <20240905163007.1350840-5-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240905163007.1350840-1-superm1@kernel.org> References: <20240905163007.1350840-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello perf_ratio is a u64 and SCHED_CAPACITY_SCALE is a large number. Shifting by one will never have a zero value. Drop the check. Suggested-by: Gautham R. Shenoy Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- v2->v3: * Correct typo in commit message * Pick up tag --- arch/x86/kernel/acpi/cppc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/x86/kernel/acpi/cppc.c b/arch/x86/kernel/acpi/cppc.c index 660cfeb6384ba..e65c77afab318 100644 --- a/arch/x86/kernel/acpi/cppc.c +++ b/arch/x86/kernel/acpi/cppc.c @@ -91,13 +91,8 @@ static void amd_set_max_freq_ratio(void) return; } - perf_ratio = div_u64(numerator * SCHED_CAPACITY_SCALE, nominal_perf); /* midpoint between max_boost and max_P */ - perf_ratio = (perf_ratio + SCHED_CAPACITY_SCALE) >> 1; - if (!perf_ratio) { - pr_debug("Non-zero highest/nominal perf values led to a 0 ratio\n"); - return; - } + perf_ratio = (div_u64(numerator * SCHED_CAPACITY_SCALE, nominal_perf) + SCHED_CAPACITY_SCALE) >> 1; freq_invariance_set_perf_ratio(perf_ratio, false); } From patchwork Thu Sep 5 16:30:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 825782 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C94091A3A9D; Thu, 5 Sep 2024 16:30:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725553824; cv=none; b=KBDcHfcx9CmNb6fVgh9LPRHM2VkkMw5Lptg+3hmHGS5mCjE93FSOMFXnNCa09BnO4TKIxJd4J7hWPEATNEBkLdZ4+4PijmXcoSXLfaaCepDkrwn8lU+eZfi4TfJMQ3PkSAw/6WEPjBwIeQcpit2+H6Xzm+ExWmDLkCbk9dvbLIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725553824; c=relaxed/simple; bh=SN+VV989YznpmWRMUK1wgF+lwg7k+mPg1elKKPJ0iac=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OKCZ8+H58YEVwLzWw/1U8hSf7i6NWo4M6Vzqw+Y0Q3/9bl6XLn5YXlGQKh+2nKimX0oRJIMWf+GvOVnuPYhbrehTGs/wFP3Hw/nXfhnyZgxowenjizWxruMuK20xDmCCQR2aEz4g4eyGmFGYWqH8ej3MsXyqH5PSelFIfuPnqDQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=seQyZai6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="seQyZai6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A097C4CEC7; Thu, 5 Sep 2024 16:30:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725553823; bh=SN+VV989YznpmWRMUK1wgF+lwg7k+mPg1elKKPJ0iac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=seQyZai6qK17Jl2DWBqYRgCEG2VfAd8WrVIrexs3RGg4djkF70sVPEPM2UATuUBle PkOuT/q4J3MgRNOHNHjaXw4ilhegmFoR9haxV2BTx6vRJk7rqoZUPbZvnYtAwVR0Nw LVbPU4wKGIT9tq+QJGZ4XLvhwffQzxLFWTilqSp6TW5CIpO/oQQUYFEt++HZDSDqO1 Z8hg/0Fg6RWw5ucM5dO+8jU0qoIzm9hSGie2y8WfQeBxR7iTo7K828XQUTcDkzfdMy wIzsgYLYc+NeTWmSUU9R8NyVTymfZJ7wV0R5dgvKUOAnbLxkRaboasTpcLjmrAMbGs C2wtGdkD9FMCw== From: Mario Limonciello To: "Gautham R . Shenoy" , Perry Yuan Cc: Borislav Petkov , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "Rafael J . Wysocki" , linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)), linux-acpi@vger.kernel.org (open list:ACPI), linux-pm@vger.kernel.org (open list:CPU FREQUENCY SCALING FRAMEWORK), Mario Limonciello , Perry Yuan Subject: [PATCH v3 05/11] ACPI: CPPC: Adjust debug messages in amd_set_max_freq_ratio() to warn Date: Thu, 5 Sep 2024 11:30:01 -0500 Message-ID: <20240905163007.1350840-6-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240905163007.1350840-1-superm1@kernel.org> References: <20240905163007.1350840-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello If the boost ratio isn't calculated properly for the system for any reason this can cause other problems that are non-obvious. Raise all messages to warn instead. Suggested-by: Perry Yuan Reviewed-by: Perry Yuan Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- arch/x86/kernel/acpi/cppc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/acpi/cppc.c b/arch/x86/kernel/acpi/cppc.c index e65c77afab318..f0328ce98a8fe 100644 --- a/arch/x86/kernel/acpi/cppc.c +++ b/arch/x86/kernel/acpi/cppc.c @@ -75,19 +75,19 @@ static void amd_set_max_freq_ratio(void) rc = cppc_get_perf_caps(0, &perf_caps); if (rc) { - pr_debug("Could not retrieve perf counters (%d)\n", rc); + pr_warn("Could not retrieve perf counters (%d)\n", rc); return; } rc = amd_get_boost_ratio_numerator(0, &numerator); if (rc) { - pr_debug("Could not retrieve highest performance (%d)\n", rc); + pr_warn("Could not retrieve highest performance (%d)\n", rc); return; } nominal_perf = perf_caps.nominal_perf; if (!nominal_perf) { - pr_debug("Could not retrieve nominal performance\n"); + pr_warn("Could not retrieve nominal performance\n"); return; } From patchwork Thu Sep 5 16:30:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 825781 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E3A31A7267; Thu, 5 Sep 2024 16:30:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725553827; cv=none; b=SBW2PoQTI253MHvkYp23M2I5KLY2aToB7KobS+m4n73e8cMr6uYRHOP5r7bDqBPGIOTSiLzfgjOr6to6ze4jv06Hdl/3Qu6P0tfrZfodsyB/uz2OWcJ54bLe8DBLa9tVBsTVdotprjbVCrj55MKkWjHV7CI/PugN/PetjD+rfp0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725553827; c=relaxed/simple; bh=Y54jxoqOwq9hafYzm3zMRq3v1cZWWr87gVCbSOuKlsI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l+9s9UO7Vve+RYxPNkG7lTC9p+Mam39ANzJXyjHoXyLZjMhcBBHK0hr/L05k/lMWZz9rwnENnRIh6waomtL1pDhQcA+kqlEZptgJZyz8T73SDWn1T9EFmIGmM//8l5Z/vBroZrngOx0Kx0/8dmU1S5D+EoO1cKiNK5G1wKiuUIU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BDNcmz93; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BDNcmz93" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D7A1C4CEC7; Thu, 5 Sep 2024 16:30:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725553827; bh=Y54jxoqOwq9hafYzm3zMRq3v1cZWWr87gVCbSOuKlsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BDNcmz93dGLHlQYH5aM5GF5k/Tky8bDBKfLN9eO4ruqvluJRiScIQq6IArnImzqYV k4YkSmmms/RzdE2aUe6Or+ZddrmABbQIENRKQLKm9R8f5a/VQHh2ORAPA7F0fUsLgy U5veu6HuLJAnPhHUpp3/S0hifVUv129b3cL1ZxpmiPX4bsDO5TwMornrm+fJdlIZwG 78Lu1T62MztnYOW/4Ohw59jqo39XQKkgZ1WILIr43IHzEPPSh0N0sdofJ6qUtLhZmX 8jQZ23Di/UjMbCnFb2VA/RfTQ9WeyYMeQVp/RYdxuhh0vqWZGisAs1UQBZsnIPrYzX 9vqhCGkqdul6g== From: Mario Limonciello To: "Gautham R . Shenoy" , Perry Yuan Cc: Borislav Petkov , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "Rafael J . Wysocki" , linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)), linux-acpi@vger.kernel.org (open list:ACPI), linux-pm@vger.kernel.org (open list:CPU FREQUENCY SCALING FRAMEWORK), Mario Limonciello Subject: [PATCH v3 08/11] cpufreq: amd-pstate: Merge amd_pstate_highest_perf_set() into amd_get_boost_ratio_numerator() Date: Thu, 5 Sep 2024 11:30:04 -0500 Message-ID: <20240905163007.1350840-9-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240905163007.1350840-1-superm1@kernel.org> References: <20240905163007.1350840-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello The special case in amd_pstate_highest_perf_set() is the value used for calculating the boost numerator. Merge this into amd_get_boost_ratio_numerator() and then use that to calculate boost ratio. This allows dropping more special casing of the highest perf value. Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- v2->v3: * Add tag v1->v2: * Document that preferred cores will have different values for highest perf. * Fix an uninitialized variable caused by merge --- Documentation/admin-guide/pm/amd-pstate.rst | 3 +- arch/x86/kernel/acpi/cppc.c | 16 +++++++ drivers/cpufreq/amd-pstate.c | 52 ++++----------------- 3 files changed, 28 insertions(+), 43 deletions(-) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index d0324d44f5482..e13915c540648 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -251,7 +251,8 @@ performance supported in `AMD CPPC Performance Capability `_). In some ASICs, the highest CPPC performance is not the one in the ``_CPC`` table, so we need to expose it to sysfs. If boost is not active, but still supported, this maximum frequency will be larger than the one in -``cpuinfo``. +``cpuinfo``. On systems that support preferred core, the driver will have +different values for some cores than others. This attribute is read-only. ``amd_pstate_lowest_nonlinear_freq`` diff --git a/arch/x86/kernel/acpi/cppc.c b/arch/x86/kernel/acpi/cppc.c index df367bc359308..956984054bf30 100644 --- a/arch/x86/kernel/acpi/cppc.c +++ b/arch/x86/kernel/acpi/cppc.c @@ -9,6 +9,7 @@ #include #include +#define CPPC_HIGHEST_PERF_PERFORMANCE 196 #define CPPC_HIGHEST_PERF_PREFCORE 166 enum amd_pref_core { @@ -245,6 +246,21 @@ int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator) *numerator = boost_numerator; return 0; } + + /* + * For AMD CPUs with Family ID 19H and Model ID range 0x70 to 0x7f, + * the highest performance level is set to 196. + * https://bugzilla.kernel.org/show_bug.cgi?id=218759 + */ + if (cpu_feature_enabled(X86_FEATURE_ZEN4)) { + switch (boot_cpu_data.x86_model) { + case 0x70 ... 0x7f: + *numerator = CPPC_HIGHEST_PERF_PERFORMANCE; + return 0; + default: + break; + } + } *numerator = CPPC_HIGHEST_PERF_PREFCORE; return 0; diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index c29cdf2d3882c..3ae41af6f041e 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -52,8 +52,6 @@ #define AMD_PSTATE_TRANSITION_LATENCY 20000 #define AMD_PSTATE_TRANSITION_DELAY 1000 #define AMD_PSTATE_FAST_CPPC_TRANSITION_DELAY 600 -#define CPPC_HIGHEST_PERF_PERFORMANCE 196 -#define CPPC_HIGHEST_PERF_DEFAULT 166 #define AMD_CPPC_EPP_PERFORMANCE 0x00 #define AMD_CPPC_EPP_BALANCE_PERFORMANCE 0x80 @@ -372,43 +370,17 @@ static inline int amd_pstate_enable(bool enable) return static_call(amd_pstate_enable)(enable); } -static u32 amd_pstate_highest_perf_set(struct amd_cpudata *cpudata) -{ - struct cpuinfo_x86 *c = &cpu_data(0); - - /* - * For AMD CPUs with Family ID 19H and Model ID range 0x70 to 0x7f, - * the highest performance level is set to 196. - * https://bugzilla.kernel.org/show_bug.cgi?id=218759 - */ - if (c->x86 == 0x19 && (c->x86_model >= 0x70 && c->x86_model <= 0x7f)) - return CPPC_HIGHEST_PERF_PERFORMANCE; - - return CPPC_HIGHEST_PERF_DEFAULT; -} - static int pstate_init_perf(struct amd_cpudata *cpudata) { u64 cap1; - u32 highest_perf; int ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1, &cap1); if (ret) return ret; - /* For platforms that do not support the preferred core feature, the - * highest_pef may be configured with 166 or 255, to avoid max frequency - * calculated wrongly. we take the AMD_CPPC_HIGHEST_PERF(cap1) value as - * the default max perf. - */ - if (cpudata->hw_prefcore) - highest_perf = amd_pstate_highest_perf_set(cpudata); - else - highest_perf = AMD_CPPC_HIGHEST_PERF(cap1); - - WRITE_ONCE(cpudata->highest_perf, highest_perf); - WRITE_ONCE(cpudata->max_limit_perf, highest_perf); + WRITE_ONCE(cpudata->highest_perf, AMD_CPPC_HIGHEST_PERF(cap1)); + WRITE_ONCE(cpudata->max_limit_perf, AMD_CPPC_HIGHEST_PERF(cap1)); WRITE_ONCE(cpudata->nominal_perf, AMD_CPPC_NOMINAL_PERF(cap1)); WRITE_ONCE(cpudata->lowest_nonlinear_perf, AMD_CPPC_LOWNONLIN_PERF(cap1)); WRITE_ONCE(cpudata->lowest_perf, AMD_CPPC_LOWEST_PERF(cap1)); @@ -420,19 +392,13 @@ static int pstate_init_perf(struct amd_cpudata *cpudata) static int cppc_init_perf(struct amd_cpudata *cpudata) { struct cppc_perf_caps cppc_perf; - u32 highest_perf; int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); if (ret) return ret; - if (cpudata->hw_prefcore) - highest_perf = amd_pstate_highest_perf_set(cpudata); - else - highest_perf = cppc_perf.highest_perf; - - WRITE_ONCE(cpudata->highest_perf, highest_perf); - WRITE_ONCE(cpudata->max_limit_perf, highest_perf); + WRITE_ONCE(cpudata->highest_perf, cppc_perf.highest_perf); + WRITE_ONCE(cpudata->max_limit_perf, cppc_perf.highest_perf); WRITE_ONCE(cpudata->nominal_perf, cppc_perf.nominal_perf); WRITE_ONCE(cpudata->lowest_nonlinear_perf, cppc_perf.lowest_nonlinear_perf); @@ -905,8 +871,8 @@ static u32 amd_pstate_get_transition_latency(unsigned int cpu) static int amd_pstate_init_freq(struct amd_cpudata *cpudata) { int ret; - u32 min_freq; - u32 highest_perf, max_freq; + u32 min_freq, max_freq; + u64 numerator; u32 nominal_perf, nominal_freq; u32 lowest_nonlinear_perf, lowest_nonlinear_freq; u32 boost_ratio, lowest_nonlinear_ratio; @@ -928,8 +894,10 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata) nominal_perf = READ_ONCE(cpudata->nominal_perf); - highest_perf = READ_ONCE(cpudata->highest_perf); - boost_ratio = div_u64(highest_perf << SCHED_CAPACITY_SHIFT, nominal_perf); + ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator); + if (ret) + return ret; + boost_ratio = div_u64(numerator << SCHED_CAPACITY_SHIFT, nominal_perf); max_freq = (nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT) * 1000; lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf); From patchwork Thu Sep 5 16:30:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 825780 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C16811AE056; Thu, 5 Sep 2024 16:30:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725553829; cv=none; b=PEYwYYJJl+jqj+abF3fpHZw92w8KGikkXP4H9TYt4yrdTo46L/Q2MGLk3EwZ9eDInfomWy/UNM/OSfZXOgsCXmPbySBiIIHG2hec8bc5Q+978vNSDUwdiWWxbpXtuIjIbFK+vCZ5NYl0FvACwNlCwRwZFkYMWU/kJhiNajnRiC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725553829; c=relaxed/simple; bh=Hvu/JDym95sl9P2OaGdfnlcHvW9GhdS42LXTs42qNMk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ulutI5FSVs+uIQ7PtUIB6y7A6KsmASrO88aA6RKZyKfchWrRTJ6skB2nKs7323taALWwjpe7jzLv1Rk2XHnjaScfuOB44LMYHPiSvNUWIds9in7M40FHaTIElIb/4ovuDKwa8CZZRJt42ue+ud74REW+wmrQ2oiEzC73ivk75ps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UEeRcFP4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UEeRcFP4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E2AFC4CEC3; Thu, 5 Sep 2024 16:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725553829; bh=Hvu/JDym95sl9P2OaGdfnlcHvW9GhdS42LXTs42qNMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UEeRcFP4hQ/4B4S3/fx4scu5EFBZCQs5mdXWnQl6OZt/ZUKSlNEHTj5Dnw1uIHQlx QZKUtYn86Rj/bbcGnCJEYF6Qu9yPrsUUgOmVOXhhxrRU0RygabQhrtCIAwDuIyJOTH 5Dz1WiLw/LbS2PT/3Zl8IJzG8yw5BxJj+0hsWG0mXjQDdNtD7RX08cCV94WkhJ5gvu NcVNYL2VFj4dqhiUgZpOUdYzNPLvcjcP43vxNWNQ3IsAZfcVV4HoRzgTSpi5mIVRVH IuxKEEfIq3Gv4ll5F57H7fkjhpxX6zGjNEzhagZOZe26fTZZd5bjZXRZh9vux4ir81 6CM1FsaZAR42A== From: Mario Limonciello To: "Gautham R . Shenoy" , Perry Yuan Cc: Borislav Petkov , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "Rafael J . Wysocki" , linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)), linux-acpi@vger.kernel.org (open list:ACPI), linux-pm@vger.kernel.org (open list:CPU FREQUENCY SCALING FRAMEWORK), Mario Limonciello Subject: [PATCH v3 10/11] cpufreq: amd-pstate: Add documentation for `amd_pstate_hw_prefcore` Date: Thu, 5 Sep 2024 11:30:06 -0500 Message-ID: <20240905163007.1350840-11-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240905163007.1350840-1-superm1@kernel.org> References: <20240905163007.1350840-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello Explain that the sysfs file represents both preferred core being enabled by the user and supported by the hardware. Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- v2->v3: * Add tag --- Documentation/admin-guide/pm/amd-pstate.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index e13915c540648..d5c050ea390dc 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -263,6 +263,11 @@ lowest non-linear performance in `AMD CPPC Performance Capability `_.) This attribute is read-only. +``amd_pstate_hw_prefcore`` + +Whether the platform supports the preferred core feature and it has been +enabled. This attribute is read-only. + ``energy_performance_available_preferences`` A list of all the supported EPP preferences that could be used for