From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380301; b=Q8IHzvwdGKP0zenxUslj42ttfZovf8WetFa6+8ZHAtF+JDdsUkETZeLtAoY9o/1PSO54 4+jU5sgVXIlIn/tnD1gxpOssWQe4K4GvS31dPusSsnDE/QvJc2rKq0mzRJ9+g+4TiXGzQ erbyNyiub0CnuBIh9w+U6Or/VjpoenePwWOu8MrdS3YuX/PNd4q8iMX+dACtR7rnOoS3o QhjexdY5b21060stzl0ax6m6IOKA1Xsic/GiRfzNQ9+59xwixQrvgaGlVC+TvKFhfRJrP 25oUHAd3r+L4ixzAjpF6l0L0NMmCMAgwJPJTNY4PIwx8mMy62e7skEXqOzUE3CHZmkQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380301; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=8AvERsRJ86EIXMxqlky+2+sXFJC32KxZx0srNCiirYA=; b=kl22/CtmOHXl4GpM4lRTWzEI+43JeGylius4A6joyVIN+ryH8mCrLyMGUq4INtaUvUef CAAW3Nq0U3jkgfuTJcMrONsxlThqiUX+nSJmgI7SjPon5rP4bNg1glJa9cPd7sp8JrVSF bTNFZEBE/lUojApzI40D9APLTRFWi1Km3BpmM0zf2f9ovTXkSxQbJEo4eAl4i3g57aZaj 6WIG4peitLXp945N+eo3lSE++WNmM857jFsfS8L7UtKTDHX9o3uj4PF/C448z9ZagpLJp F1NmF5VbiO5xWW/rGEA5iPurSG3jHsWnrwwX/rd4u2A22o3wK3kyNQVxhaDeK6FKgww== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=BpmalPGO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CCD5606A32C; Fri, 4 Dec 2026 10:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=BpmalPGO Received: by smtp.kernel.org (Postfix) with ESMTPSA id C49BA1F00897; Fri, 4 Dec 2026 10:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380301; bh=8AvERsRJ86EIXMxqlky+2+sXFJC32KxZx0srNCiirYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BpmalPGOpNWOIYz+5gujf7M/BoGziWC58qUMNjo6YofNhBAuQmov1eSutWnDrB8UK ep4xRG2qEBpg7mhfZo+sZOQXMDkrUSYqqTQdOr2maaMJPBw4g8/CvjLRbwOS1tvpl0 F2khYExMdrA8tXKn/+boOxc0MoaF+deeJ0mpb2rE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ximing Zhang , Hugo Sales , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 7.3 213/742] cpufreq: intel_pstate: Refresh cpuinfo.max_freq when a CPU goes online Date: Fri, 4 Dec 2026 19:01:17 +0900 Message-ID: <20261204100640.737652805@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hugo Sales [ Upstream commit a636989f93b4f70df0e44dd3025ba13c05266053 ] A write to no_turbo or a change in the HWP capabilities updates policy->cpuinfo.max_freq through intel_pstate_update_max_freq(), which gets the policy with cpufreq_cpu_get(). That returns NULL for an offline CPU, so its policy keeps the old value. When the CPU comes back, the core reuses the policy and calls ->online(), and intel_pstate_cpu_online() doesn't recompute cpuinfo.max_freq either. Before commit 4adcf2e5829f ("cpufreq: intel_pstate: Add ->offline and ->online callbacks"), ->init() ran on every online and set it Turning turbo on while a CPU is offline leaves that CPU at the non-turbo maximum once it's back, while the other CPUs report the turbo frequency. In the reverse order the CPU keeps the turbo maximum with turbo off Set cpuinfo.max_freq at the end of intel_pstate_cpu_online(), after HWP is enabled again, the same way __intel_pstate_update_max_freq() does. cpufreq_online() applies the policy limits after that. Hold the CPU hotplug lock in store_no_turbo(), so a CPU can't come online between the no_turbo store and the update of the online CPUs Fixes: 4adcf2e5829f ("cpufreq: intel_pstate: Add ->offline and ->online callbacks") Reported-by: Ximing Zhang Closes: https://lore.kernel.org/all/20261108071225.54656-1-xzhangjr@gmail.com/ Signed-off-by: Hugo Sales Tested-by: Ximing Zhang [ rjw: Renamed the new function ] Link: https://patch.msgid.link/20261114-intel-pstate-online-max-freq-v1-1-1bbdae2b4986@hsal.es Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/cpufreq/intel_pstate.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index c78dcd681511c..d3650a6e37b54 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1426,16 +1426,24 @@ static void intel_pstate_update_policies(void) cpufreq_update_policy(cpu); } -static void __intel_pstate_update_max_freq(struct cpufreq_policy *policy, - struct cpudata *cpudata) +static void __intel_pstate_update_cpuinfo_max_freq(struct cpufreq_policy *policy, + struct cpudata *cpudata) { - guard(cpufreq_policy_write)(policy); + lockdep_assert_held_write(&policy->rwsem); if (hwp_active) intel_pstate_get_hwp_cap(cpudata); policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ? cpudata->pstate.max_freq : cpudata->pstate.turbo_freq; +} + +static void __intel_pstate_update_max_freq(struct cpufreq_policy *policy, + struct cpudata *cpudata) +{ + guard(cpufreq_policy_write)(policy); + + __intel_pstate_update_cpuinfo_max_freq(policy, cpudata); refresh_frequency_limits(policy); } @@ -1569,6 +1577,12 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b, return -EINVAL; guard(mutex)(&intel_pstate_driver_lock); + /* + * intel_pstate_update_max_freq() skips offline CPUs, and a CPU coming + * online reads global.no_turbo in intel_pstate_cpu_online(). Keep CPUs + * from coming online until every online CPU has the new limit + */ + guard(cpus_read_lock)(); if (!intel_pstate_driver) return -EAGAIN; @@ -3019,6 +3033,14 @@ static int intel_pstate_cpu_online(struct cpufreq_policy *policy) hybrid_update_capacity(cpu); } + /* + * intel_pstate_update_max_freq() skips offline CPUs, so the turbo + * setting or the HWP capabilities may have changed since this CPU + * went offline. Read the HWP capabilities only once HWP is enabled + * again + */ + __intel_pstate_update_cpuinfo_max_freq(policy, cpu); + return 0; } -- 2.53.0