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 0ED6523ABA7 for ; Sat, 18 Oct 2025 16:13:43 +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=1760804024; cv=none; b=sO9Sd6RGcAfNGWF8W0bXlAghFwSSlNpyFsHa9xb+oQWmiTUSrV3bK2vqTpNuaWuhipaNjyunNZ5mtSP/k4Y6f63IThFN/CeslR/YQpjS1S2KmLRC+DmsRMJ90ii51mXxNEp7LGGTVLfhksIzoSbPPx5qqSY87RLCX0SG55ULcSQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760804024; c=relaxed/simple; bh=dtfyoyNPzGe8YqsOPazYfyUDuCoyigMhbNekU74ZN44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bn0aGMxJlp15a/IH5+hQQnAgQMrfazfWEXbmPvz4bWFBA3DRdAVjeeUOBojIAUezixX78Q/bbgFgzRgYtbd3+BqTWVy91eqQW3aoLn3Dnf033YypR48FQiflsyfDQ/w0DKFWZdHQbSgOnRKdXmHNvqTgf0TrtIgmcXW2HdpA1RY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wv4Z0doD; 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="Wv4Z0doD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C14AFC4CEF8; Sat, 18 Oct 2025 16:13:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760804023; bh=dtfyoyNPzGe8YqsOPazYfyUDuCoyigMhbNekU74ZN44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wv4Z0doDAf7fHvHAagnbRq8+Ak7395DoGcnc7mlTe+Drw2A/Z8Ec4ZwU5fMWGFLCn lLXS7n4X7W65IlGr/1hqN0ti5EJsEH2tOVkQuM2xdbleijhttEmCD8N01R/9/xKO7L 8qZpqcsPmSKU5NY/uiNbkayr4/3zJzxdM9BKG62vQoEC89muLAJ1d2kggZz3QGW3FV 5CwQK8uz7a/pxwXzd4VE108D2GjZ7ah0ELakHYvL60W4Xly8FuDgtkjNEFe4I21Ko9 bWoTIkQFXK8LbYPtXxoXRCGtV6hRQH8GBoicaSXx7KCpC6zCZFFCTRjf4yvpuDkLaY 3Y3YOIgP5jQ3A== 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.12.y] cpufreq: CPPC: Avoid using CPUFREQ_ETERNAL as transition delay Date: Sat, 18 Oct 2025 12:13:41 -0400 Message-ID: <20251018161341.836384-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2025101610-twistable-shaping-5da2@gregkh> References: <2025101610-twistable-shaping-5da2@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 8d5279c21e6cf..1abedcae50b26 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -339,6 +339,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 @@ -361,12 +371,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 a604c54ae44da..794e38320f568 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