+++ /dev/null
-From 4629e907d1ba9d61016ecf1db2f068f697337979 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 25 Mar 2024 18:02:42 +0100
-Subject: cpufreq: intel_pstate: Do not update global.turbo_disabled after
- initialization
-
-From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-
-[ Upstream commit 0940f1a8011fd69be5082015068e0dc31c800c20 ]
-
-The global.turbo_disabled is updated quite often, especially in the
-passive mode in which case it is updated every time the scheduler calls
-into the driver. However, this is generally not necessary and it adds
-MSR read overhead to scheduler code paths (and that particular MSR is
-slow to read).
-
-For this reason, make the driver read MSR_IA32_MISC_ENABLE_TURBO_DISABLE
-just once at the cpufreq driver registration time and remove all of the
-in-flight updates of global.turbo_disabled.
-
-Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Stable-dep-of: ac4e04d9e378 ("cpufreq: intel_pstate: Unchecked MSR aceess in legacy mode")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/cpufreq/intel_pstate.c | 51 ++++++----------------------------
- 1 file changed, 8 insertions(+), 43 deletions(-)
-
-diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
-index b69bff009e780..255746c053b4c 100644
---- a/drivers/cpufreq/intel_pstate.c
-+++ b/drivers/cpufreq/intel_pstate.c
-@@ -172,7 +172,6 @@ struct vid_data {
- * based on the MSR_IA32_MISC_ENABLE value and whether or
- * not the maximum reported turbo P-state is different from
- * the maximum reported non-turbo one.
-- * @turbo_disabled_mf: The @turbo_disabled value reflected by cpuinfo.max_freq.
- * @min_perf_pct: Minimum capacity limit in percent of the maximum turbo
- * P-state capacity.
- * @max_perf_pct: Maximum capacity limit in percent of the maximum turbo
-@@ -181,7 +180,6 @@ struct vid_data {
- struct global_params {
- bool no_turbo;
- bool turbo_disabled;
-- bool turbo_disabled_mf;
- int max_perf_pct;
- int min_perf_pct;
- };
-@@ -592,12 +590,13 @@ static void intel_pstate_hybrid_hwp_adjust(struct cpudata *cpu)
- cpu->pstate.min_pstate = intel_pstate_freq_to_hwp(cpu, freq);
- }
-
--static inline void update_turbo_state(void)
-+static bool turbo_is_disabled(void)
- {
- u64 misc_en;
-
- rdmsrl(MSR_IA32_MISC_ENABLE, misc_en);
-- global.turbo_disabled = misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE;
-+
-+ return !!(misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE);
- }
-
- static int min_perf_pct_min(void)
-@@ -1152,40 +1151,16 @@ static void intel_pstate_update_policies(void)
- static void __intel_pstate_update_max_freq(struct cpudata *cpudata,
- struct cpufreq_policy *policy)
- {
-- policy->cpuinfo.max_freq = global.turbo_disabled_mf ?
-+ policy->cpuinfo.max_freq = global.turbo_disabled ?
- cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
- refresh_frequency_limits(policy);
- }
-
--static void intel_pstate_update_max_freq(unsigned int cpu)
--{
-- struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu);
--
-- if (!policy)
-- return;
--
-- __intel_pstate_update_max_freq(all_cpu_data[cpu], policy);
--
-- cpufreq_cpu_release(policy);
--}
--
- static void intel_pstate_update_limits(unsigned int cpu)
- {
- mutex_lock(&intel_pstate_driver_lock);
-
-- update_turbo_state();
-- /*
-- * If turbo has been turned on or off globally, policy limits for
-- * all CPUs need to be updated to reflect that.
-- */
-- if (global.turbo_disabled_mf != global.turbo_disabled) {
-- global.turbo_disabled_mf = global.turbo_disabled;
-- arch_set_max_freq_ratio(global.turbo_disabled);
-- for_each_possible_cpu(cpu)
-- intel_pstate_update_max_freq(cpu);
-- } else {
-- cpufreq_update_policy(cpu);
-- }
-+ cpufreq_update_policy(cpu);
-
- mutex_unlock(&intel_pstate_driver_lock);
- }
-@@ -1285,7 +1260,6 @@ static ssize_t show_no_turbo(struct kobject *kobj,
- return -EAGAIN;
- }
-
-- update_turbo_state();
- if (global.turbo_disabled)
- ret = sprintf(buf, "%u\n", global.turbo_disabled);
- else
-@@ -1315,7 +1289,6 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b,
-
- mutex_lock(&intel_pstate_limits_lock);
-
-- update_turbo_state();
- if (global.turbo_disabled) {
- pr_notice_once("Turbo disabled by BIOS or unavailable on processor\n");
- mutex_unlock(&intel_pstate_limits_lock);
-@@ -2296,8 +2269,6 @@ static void intel_pstate_adjust_pstate(struct cpudata *cpu)
- struct sample *sample;
- int target_pstate;
-
-- update_turbo_state();
--
- target_pstate = get_target_pstate(cpu);
- target_pstate = intel_pstate_prepare_request(cpu, target_pstate);
- trace_cpu_frequency(target_pstate * cpu->pstate.scaling, cpu->cpu);
-@@ -2607,7 +2578,6 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
- * be invoked on them.
- */
- intel_pstate_clear_update_util_hook(policy->cpu);
-- update_turbo_state();
- intel_pstate_set_pstate(cpu, pstate);
- } else {
- intel_pstate_set_update_util_hook(policy->cpu);
-@@ -2651,7 +2621,6 @@ static void intel_pstate_verify_cpu_policy(struct cpudata *cpu,
- {
- int max_freq;
-
-- update_turbo_state();
- if (hwp_active) {
- intel_pstate_get_hwp_cap(cpu);
- max_freq = global.no_turbo || global.turbo_disabled ?
-@@ -2748,8 +2717,6 @@ static int __intel_pstate_cpu_init(struct cpufreq_policy *policy)
-
- /* cpuinfo and default policy values */
- policy->cpuinfo.min_freq = cpu->pstate.min_freq;
-- update_turbo_state();
-- global.turbo_disabled_mf = global.turbo_disabled;
- policy->cpuinfo.max_freq = global.turbo_disabled ?
- cpu->pstate.max_freq : cpu->pstate.turbo_freq;
-
-@@ -2915,8 +2882,6 @@ static int intel_cpufreq_target(struct cpufreq_policy *policy,
- struct cpufreq_freqs freqs;
- int target_pstate;
-
-- update_turbo_state();
--
- freqs.old = policy->cur;
- freqs.new = target_freq;
-
-@@ -2938,8 +2903,6 @@ static unsigned int intel_cpufreq_fast_switch(struct cpufreq_policy *policy,
- struct cpudata *cpu = all_cpu_data[policy->cpu];
- int target_pstate;
-
-- update_turbo_state();
--
- target_pstate = intel_pstate_freq_to_hwp(cpu, target_freq);
-
- target_pstate = intel_cpufreq_update_pstate(policy, target_pstate, true);
-@@ -2957,7 +2920,6 @@ static void intel_cpufreq_adjust_perf(unsigned int cpunum,
- int old_pstate = cpu->pstate.current_pstate;
- int cap_pstate, min_pstate, max_pstate, target_pstate;
-
-- update_turbo_state();
- cap_pstate = global.turbo_disabled ? HWP_GUARANTEED_PERF(hwp_cap) :
- HWP_HIGHEST_PERF(hwp_cap);
-
-@@ -3147,6 +3109,9 @@ static int intel_pstate_register_driver(struct cpufreq_driver *driver)
-
- memset(&global, 0, sizeof(global));
- global.max_perf_pct = 100;
-+ global.turbo_disabled = turbo_is_disabled();
-+
-+ arch_set_max_freq_ratio(global.turbo_disabled);
-
- intel_pstate_driver = driver;
- ret = cpufreq_register_driver(intel_pstate_driver);
---
-2.39.5
-
+++ /dev/null
-From dc370f49bc51fd5519a1e4805969faf0fc904cdf Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 25 Mar 2024 18:01:58 +0100
-Subject: cpufreq: intel_pstate: Fold intel_pstate_max_within_limits() into
- caller
-
-From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-
-[ Upstream commit 032c5565eb80edb6f2faeb31939540c897987119 ]
-
-Fold intel_pstate_max_within_limits() into its only caller.
-
-No functional impact.
-
-Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Stable-dep-of: ac4e04d9e378 ("cpufreq: intel_pstate: Unchecked MSR aceess in legacy mode")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/cpufreq/intel_pstate.c | 13 ++++---------
- 1 file changed, 4 insertions(+), 9 deletions(-)
-
-diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
-index 7cb35842f68a1..b69bff009e780 100644
---- a/drivers/cpufreq/intel_pstate.c
-+++ b/drivers/cpufreq/intel_pstate.c
-@@ -2027,14 +2027,6 @@ static void intel_pstate_set_min_pstate(struct cpudata *cpu)
- intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate);
- }
-
--static void intel_pstate_max_within_limits(struct cpudata *cpu)
--{
-- int pstate = max(cpu->pstate.min_pstate, cpu->max_perf_ratio);
--
-- update_turbo_state();
-- intel_pstate_set_pstate(cpu, pstate);
--}
--
- static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
- {
- int perf_ctl_max_phys = pstate_funcs.get_max_physical(cpu->cpu);
-@@ -2608,12 +2600,15 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
- intel_pstate_update_perf_limits(cpu, policy->min, policy->max);
-
- if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE) {
-+ int pstate = max(cpu->pstate.min_pstate, cpu->max_perf_ratio);
-+
- /*
- * NOHZ_FULL CPUs need this as the governor callback may not
- * be invoked on them.
- */
- intel_pstate_clear_update_util_hook(policy->cpu);
-- intel_pstate_max_within_limits(cpu);
-+ update_turbo_state();
-+ intel_pstate_set_pstate(cpu, pstate);
- } else {
- intel_pstate_set_update_util_hook(policy->cpu);
- }
---
-2.39.5
-
+++ /dev/null
-From 0613992e81ad391f9dc4473a79b0ce9781d39249 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 7 Sep 2023 11:02:07 -0700
-Subject: cpufreq: intel_pstate: Revise global turbo disable check
-
-From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-
-[ Upstream commit 37b6ddba967c601479bea418a7ac6ff16b6232b7 ]
-
-Setting global turbo flag based on CPU 0 P-state limits is problematic
-as it limits max P-state request on every CPU on the system just based
-on its P-state limits.
-
-There are two cases in which global.turbo_disabled flag is set:
-- When the MSR_IA32_MISC_ENABLE_TURBO_DISABLE bit is set to 1
-in the MSR MSR_IA32_MISC_ENABLE. This bit can be only changed by
-the system BIOS before power up.
-- When the max non turbo P-state is same as max turbo P-state for CPU 0.
-
-The second check is not a valid to decide global turbo state based on
-the CPU 0. CPU 0 max turbo P-state can be same as max non turbo P-state,
-but for other CPUs this may not be true.
-
-There is no guarantee that max P-state limits are same for every CPU. This
-is possible that during fusing max P-state for a CPU is constrained. Also
-with the Intel Speed Select performance profile, CPU 0 may not be present
-in all profiles. In this case the max non turbo and turbo P-state can be
-set to the lowest possible P-state by the hardware when switched to
-such profile. Since max non turbo and turbo P-state is same,
-global.turbo_disabled flag will be set.
-
-Once global.turbo_disabled is set, any scaling max and min frequency
-update for any CPU will result in its max P-state constrained to the max
-non turbo P-state.
-
-Hence remove the check of max non turbo P-state equal to max turbo P-state
-of CPU 0 to set global turbo disabled flag.
-
-Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-[ rjw: Subject edit ]
-Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Stable-dep-of: ac4e04d9e378 ("cpufreq: intel_pstate: Unchecked MSR aceess in legacy mode")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/cpufreq/intel_pstate.c | 6 +-----
- 1 file changed, 1 insertion(+), 5 deletions(-)
-
-diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
-index 8a4fdf212ce0d..7cb35842f68a1 100644
---- a/drivers/cpufreq/intel_pstate.c
-+++ b/drivers/cpufreq/intel_pstate.c
-@@ -595,13 +595,9 @@ static void intel_pstate_hybrid_hwp_adjust(struct cpudata *cpu)
- static inline void update_turbo_state(void)
- {
- u64 misc_en;
-- struct cpudata *cpu;
-
-- cpu = all_cpu_data[0];
- rdmsrl(MSR_IA32_MISC_ENABLE, misc_en);
-- global.turbo_disabled =
-- (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ||
-- cpu->pstate.max_pstate == cpu->pstate.turbo_pstate);
-+ global.turbo_disabled = misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE;
- }
-
- static int min_perf_pct_min(void)
---
-2.39.5
-
+++ /dev/null
-From bef81dac54cd5941e5e251289beb60e386ac0c46 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 29 Apr 2025 14:07:11 -0700
-Subject: cpufreq: intel_pstate: Unchecked MSR aceess in legacy mode
-
-From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-
-[ Upstream commit ac4e04d9e378f5aa826c2406ad7871ae1b6a6fb9 ]
-
-When turbo mode is unavailable on a Skylake-X system, executing the
-command:
-
- # echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
-
-results in an unchecked MSR access error:
-
- WRMSR to 0x199 (attempted to write 0x0000000100001300).
-
-This issue was reproduced on an OEM (Original Equipment Manufacturer)
-system and is not a common problem across all Skylake-X systems.
-
-This error occurs because the MSR 0x199 Turbo Engage Bit (bit 32) is set
-when turbo mode is disabled. The issue arises when intel_pstate fails to
-detect that turbo mode is disabled. Here intel_pstate relies on
-MSR_IA32_MISC_ENABLE bit 38 to determine the status of turbo mode.
-However, on this system, bit 38 is not set even when turbo mode is
-disabled.
-
-According to the Intel Software Developer's Manual (SDM), the BIOS sets
-this bit during platform initialization to enable or disable
-opportunistic processor performance operations. Logically, this bit
-should be set in such cases. However, the SDM also specifies that "OS
-and applications must use CPUID leaf 06H to detect processors with
-opportunistic processor performance operations enabled."
-
-Therefore, in addition to checking MSR_IA32_MISC_ENABLE bit 38, verify
-that CPUID.06H:EAX[1] is 0 to accurately determine if turbo mode is
-disabled.
-
-Fixes: 4521e1a0ce17 ("cpufreq: intel_pstate: Reflect current no_turbo state correctly")
-Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: All applicable <stable@vger.kernel.org>
-Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/cpufreq/intel_pstate.c | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
-index 255746c053b4c..a6582fb846078 100644
---- a/drivers/cpufreq/intel_pstate.c
-+++ b/drivers/cpufreq/intel_pstate.c
-@@ -594,6 +594,9 @@ static bool turbo_is_disabled(void)
- {
- u64 misc_en;
-
-+ if (!cpu_feature_enabled(X86_FEATURE_IDA))
-+ return true;
-+
- rdmsrl(MSR_IA32_MISC_ENABLE, misc_en);
-
- return !!(misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE);
---
-2.39.5
-
xhci-limit-time-spent-with-xhc-interrupts-disabled-d.patch
memcg-drain-obj-stock-on-cpu-hotplug-teardown.patch
riscv-uprobes-add-missing-fence.i-after-building-the.patch
-cpufreq-intel_pstate-revise-global-turbo-disable-che.patch
-cpufreq-intel_pstate-fold-intel_pstate_max_within_li.patch
-cpufreq-intel_pstate-do-not-update-global.turbo_disa.patch
-cpufreq-intel_pstate-unchecked-msr-aceess-in-legacy-.patch
kernel-param-rename-locate_module_kobject.patch
kernel-globalize-lookup_or_create_module_kobject.patch
drivers-base-handle-module_kobject-creation.patch