From mboxrd@z Thu Jan 1 00:00:00 1970 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 B6C6E339A8 for ; Sat, 18 Oct 2025 16:25: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=1760804722; cv=none; b=iZsbQ208O8m1XRSpAEmaj287vqdt/XrvBk0uSB5FE23fATiuQuvyVGoHCzR+WkcD56rHC87Lu5yV8Khs5uJ3bh4JzfatpQfGVZyPk+pAbfHiCcY536fehPVIW9TPK2RxUQHCN0R/lgb3su1jVFGrYVCrqM3snMZrIy5LsRyNa9o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760804722; c=relaxed/simple; bh=aPEDiBjl7+7HrZFOdqqEJ571DSssQfO2fjtlh615/xM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kzqc3/rIUX+BQW5i9sB6WFjX3qTuf+pFp0tFT2sj4DBFZ2vckwgzoNeybGpHo/YxOwIaC7qIz/yOCmCWw9hmgCWPQuiG3H2ox8KfRwUg1tXEuXTiWp7eT/51/Pq7RORTVDTOf7rX1e18BOxu/YDjPSEBLSGzYRyKM67rL4nT3iI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HxIWXPAh; 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="HxIWXPAh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48491C4CEF8; Sat, 18 Oct 2025 16:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760804722; bh=aPEDiBjl7+7HrZFOdqqEJ571DSssQfO2fjtlh615/xM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HxIWXPAhkQ25hhjlUFh1Y9SmfrX9frTPE335FMuhn4m5r2wseJrzTB18hSDliBR8U 4zs9yyHj27Q724ggoFoEAObEK6VZ6nZ+Mw0E9AshlBHbkibHv2xRRLMPgzEK9zbIaJ W/5O7e2J80vK7RbRZA5/GN4Vpjb+zHUCKzE27ETrR+75AacAUCVGEcSVNketkP5ABj vuETmdcYXfTQUunsf1YLuSSL5z6Uc9DcNBQzPNJwz6oh5zhyh2H5rgTMb8fgSHicpr yhyA4uiqkBHeGnimTAyXVf8fAbV/08Ubyko9pVWHxMip4KN8TPpu4RpLRmGIrBh1hR zbeK0jpFtD+0w== From: Sasha Levin To: stable@vger.kernel.org Cc: "Rafael J. Wysocki" , "Mario Limonciello (AMD)" , Jie Zhan , Viresh Kumar , Qais Yousef , Sasha Levin Subject: [PATCH 6.6.y] cpufreq: CPPC: Avoid using CPUFREQ_ETERNAL as transition delay Date: Sat, 18 Oct 2025 12:25:19 -0400 Message-ID: <20251018162519.839592-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2025101609-unmoved-thud-9d3a@gregkh> References: <2025101609-unmoved-thud-9d3a@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Rafael J. Wysocki" [ Upstream commit f965d111e68f4a993cc44d487d416e3d954eea11 ] If cppc_get_transition_latency() returns CPUFREQ_ETERNAL to indicate a failure to retrieve the transition latency value from the platform firmware, the CPPC cpufreq driver will use that value (converted to microseconds) as the policy transition delay, but it is way too large for any practical use. Address this by making the driver use the cpufreq's default transition latency value (in microseconds) as the transition delay if CPUFREQ_ETERNAL is returned by cppc_get_transition_latency(). Fixes: d4f3388afd48 ("cpufreq / CPPC: Set platform specific transition_delay_us") Cc: 5.19+ # 5.19 Signed-off-by: Rafael J. Wysocki Reviewed-by: Mario Limonciello (AMD) Reviewed-by: Jie Zhan Acked-by: Viresh Kumar Reviewed-by: Qais Yousef [ added CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS definition to include/linux/cpufreq.h ] Signed-off-by: Sasha Levin --- drivers/cpufreq/cppc_cpufreq.c | 14 ++++++++++++-- include/linux/cpufreq.h | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index ea32bdf7cc24e..4d96eed64fe0c 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -344,6 +344,16 @@ static int cppc_verify_policy(struct cpufreq_policy_data *policy) return 0; } +static unsigned int __cppc_cpufreq_get_transition_delay_us(unsigned int cpu) +{ + unsigned int transition_latency_ns = cppc_get_transition_latency(cpu); + + if (transition_latency_ns == CPUFREQ_ETERNAL) + return CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS / NSEC_PER_USEC; + + return transition_latency_ns / NSEC_PER_USEC; +} + /* * The PCC subspace describes the rate at which platform can accept commands * on the shared PCC channel (including READs which do not count towards freq @@ -366,12 +376,12 @@ static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu) return 10000; } } - return cppc_get_transition_latency(cpu) / NSEC_PER_USEC; + return __cppc_cpufreq_get_transition_delay_us(cpu); } #else static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu) { - return cppc_get_transition_latency(cpu) / NSEC_PER_USEC; + return __cppc_cpufreq_get_transition_delay_us(cpu); } #endif diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index bfecd9dcb5529..1f94fe8559a9a 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -32,6 +32,9 @@ */ #define CPUFREQ_ETERNAL (-1) + +#define CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS NSEC_PER_MSEC + #define CPUFREQ_NAME_LEN 16 /* Print length for names. Extra 1 space for accommodating '\n' in prints */ #define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1) -- 2.51.0