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=1796381966; b=SSU6mD3quBA5VrPTKZzy7mLfDoNYhcLhmkRlriV+/X4akZ0ocGtZSE6Q6sHWxyn79SAl 4WcmvKw7JifYnx7f7mD4Hoi75+eLxcIAQ+p3uomSjH+zNLubQPu6kRgyZmpiM48WyeCCi N6KYcZG/uz2RTeeYe4M4OZ3968LzCIjEo1vjIW+GpV0y44f/Tiy8htmRivrPGp8wMs1sC uUPW8wGx4fht5z5bZyMccm0RodObZ0cP8Ps+OhjQROa1aSgOvl3Wj54xsxjdpUFdsQhYU DSUlkKLMtr28nyXT61JwoffEw+je4uQ1wf2dMtOAhKvZf+vJ1fNOGn2wbpvnav8C1yA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381966; 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=n5CWxDEhFAIYlzIoSw0GMfghebTltHO5s5g6Tv0bxdw=; b=sxJPsQsO3azQ6PJXcZpGa+75xD1lIaJcLV/hMTsAnchrHFxsbPZvU9VRYwwux9L6fOLJ HdUg6sK4TVG+F8hPGpZAi49r5PjMYAl8/J6SfFE7ySBlGPfaeIodBySfO3+JBImKbWhLo SsoNLRQEU7wD6nzT5MXsXbB1kv7XH2bzU+cq4sk8uR7vb5IO7wzRoDsfD0/0K22L2OwxS 4qUM37gFgVdPX0cQJ6spAguyjiT+/3+SrRnZ3W94Sjto/hOaIymZmcnhK9rdkCU8+mNWW vQmiozCxPklpWh2VGVmZbu8I4VfuGifJP8g/d4Z7M0mwyfUMiSjdB9ErIBqnmP//pjA== 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=ZSbtBd3H; 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 4BD12606A322; Fri, 4 Dec 2026 10:59:26 +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=ZSbtBd3H Received: by smtp.kernel.org (Postfix) with ESMTPSA id B75101F000C2; Fri, 4 Dec 2026 10:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381966; bh=n5CWxDEhFAIYlzIoSw0GMfghebTltHO5s5g6Tv0bxdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZSbtBd3HgxYUK5Pmbpd9P0MD2p+VvuvcLGPQrloVMN+j+EXpibQXP7gYJGCdod49k FIBRrUbT2vzgtKmxBbfK8tH6HuOahtZ/ISu7+xq8BMx5lM1onID/ZuE44EXKP8jWbj tZrp2S8JWBjOdd3nRzPhel9POAu9qdwl9Dr12eeU= 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 6.18 250/703] cpufreq: intel_pstate: Refresh cpuinfo.max_freq when a CPU goes online Date: Fri, 4 Dec 2026 19:02:29 +0900 Message-ID: <20261204100634.449116072@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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 6.18-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 00ac6e509a9bf..23262ce56c246 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1460,16 +1460,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); } @@ -1603,6 +1611,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; @@ -3014,6 +3028,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