+++ /dev/null
-From f8932eb7f77838e33fa7d95510c125f26c98a4dd 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 bcfde997f445d..a26d28c437699 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;
- };
-@@ -560,12 +558,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)
-@@ -1110,40 +1109,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);
- }
-@@ -1243,7 +1218,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
-@@ -1273,7 +1247,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);
-@@ -2205,8 +2178,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);
-@@ -2523,7 +2494,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);
-@@ -2562,7 +2532,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 ?
-@@ -2659,8 +2628,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;
-
-@@ -2826,8 +2793,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;
-
-@@ -2849,8 +2814,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);
-@@ -2868,7 +2831,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);
-
-@@ -3058,6 +3020,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 84097c4bb28e934fd60bcf17878f9d97822c7a17 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 6f69e396ce8c8..bcfde997f445d 100644
---- a/drivers/cpufreq/intel_pstate.c
-+++ b/drivers/cpufreq/intel_pstate.c
-@@ -1936,14 +1936,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);
-@@ -2524,12 +2516,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 aa88dc777754b1557313c1cbf447c1720dcfbc7e Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 28 Sep 2021 09:42:17 -0700
-Subject: cpufreq: intel_pstate: Process HWP Guaranteed change notification
-
-From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-
-[ Upstream commit 57577c996d731ce1e5a4a488e64e6e201b360847 ]
-
-It is possible that HWP guaranteed ratio is changed in response to
-change in power and thermal limits. For example when Intel Speed Select
-performance profile is changed or there is change in TDP, hardware can
-send notifications. It is possible that the guaranteed ratio is
-increased. This creates an issue when turbo is disabled, as the old
-limits set in MSR_HWP_REQUEST are still lower and hardware will clip
-to older limits.
-
-This change enables HWP interrupt and process HWP interrupts. When
-guaranteed is changed, calls cpufreq_update_policy() so that driver
-callbacks are called to update to new HWP limits. This callback
-is called from a delayed workqueue of 10ms to avoid frequent updates.
-
-Although the scope of IA32_HWP_INTERRUPT is per logical cpu, on some
-plaforms interrupt is generated on all CPUs. This is particularly a
-problem during initialization, when the driver didn't allocated
-data for other CPUs. So this change uses a cpumask of enabled CPUs and
-process interrupts on those CPUs only.
-
-When the cpufreq offline() or suspend() callback is called, HWP interrupt
-is disabled on those CPUs and also cancels any pending work item.
-
-Spin lock is used to protect data and processing shared with interrupt
-handler. Here READ_ONCE(), WRITE_ONCE() macros are used to designate
-shared data, even though spin lock act as an optimization barrier here.
-
-Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Tested-by: pablomh@gmail.com
-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 | 117 +++++++++++++++++++++++++++++++--
- 1 file changed, 111 insertions(+), 6 deletions(-)
-
-diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
-index 4de71e772f514..2a1d21438a468 100644
---- a/drivers/cpufreq/intel_pstate.c
-+++ b/drivers/cpufreq/intel_pstate.c
-@@ -33,6 +33,7 @@
- #include <asm/cpu_device_id.h>
- #include <asm/cpufeature.h>
- #include <asm/intel-family.h>
-+#include "../drivers/thermal/intel/thermal_interrupt.h"
-
- #define INTEL_PSTATE_SAMPLING_INTERVAL (10 * NSEC_PER_MSEC)
-
-@@ -220,6 +221,7 @@ struct global_params {
- * @sched_flags: Store scheduler flags for possible cross CPU update
- * @hwp_boost_min: Last HWP boosted min performance
- * @suspended: Whether or not the driver has been suspended.
-+ * @hwp_notify_work: workqueue for HWP notifications.
- *
- * This structure stores per CPU instance data for all CPUs.
- */
-@@ -258,6 +260,7 @@ struct cpudata {
- unsigned int sched_flags;
- u32 hwp_boost_min;
- bool suspended;
-+ struct delayed_work hwp_notify_work;
- };
-
- static struct cpudata **all_cpu_data;
-@@ -983,11 +986,15 @@ static void intel_pstate_hwp_set(unsigned int cpu)
- wrmsrl_on_cpu(cpu, MSR_HWP_REQUEST, value);
- }
-
-+static void intel_pstate_disable_hwp_interrupt(struct cpudata *cpudata);
-+
- static void intel_pstate_hwp_offline(struct cpudata *cpu)
- {
- u64 value = READ_ONCE(cpu->hwp_req_cached);
- int min_perf;
-
-+ intel_pstate_disable_hwp_interrupt(cpu);
-+
- if (boot_cpu_has(X86_FEATURE_HWP_EPP)) {
- /*
- * In case the EPP has been set to "performance" by the
-@@ -1064,6 +1071,9 @@ static int intel_pstate_suspend(struct cpufreq_policy *policy)
-
- cpu->suspended = true;
-
-+ /* disable HWP interrupt and cancel any pending work */
-+ intel_pstate_disable_hwp_interrupt(cpu);
-+
- return 0;
- }
-
-@@ -1557,15 +1567,105 @@ static void intel_pstate_sysfs_hide_hwp_dynamic_boost(void)
-
- /************************** sysfs end ************************/
-
-+static void intel_pstate_notify_work(struct work_struct *work)
-+{
-+ struct cpudata *cpudata =
-+ container_of(to_delayed_work(work), struct cpudata, hwp_notify_work);
-+
-+ cpufreq_update_policy(cpudata->cpu);
-+ wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_STATUS, 0);
-+}
-+
-+static DEFINE_SPINLOCK(hwp_notify_lock);
-+static cpumask_t hwp_intr_enable_mask;
-+
-+void notify_hwp_interrupt(void)
-+{
-+ unsigned int this_cpu = smp_processor_id();
-+ struct cpudata *cpudata;
-+ unsigned long flags;
-+ u64 value;
-+
-+ if (!READ_ONCE(hwp_active) || !boot_cpu_has(X86_FEATURE_HWP_NOTIFY))
-+ return;
-+
-+ rdmsrl_safe(MSR_HWP_STATUS, &value);
-+ if (!(value & 0x01))
-+ return;
-+
-+ spin_lock_irqsave(&hwp_notify_lock, flags);
-+
-+ if (!cpumask_test_cpu(this_cpu, &hwp_intr_enable_mask))
-+ goto ack_intr;
-+
-+ /*
-+ * Currently we never free all_cpu_data. And we can't reach here
-+ * without this allocated. But for safety for future changes, added
-+ * check.
-+ */
-+ if (unlikely(!READ_ONCE(all_cpu_data)))
-+ goto ack_intr;
-+
-+ /*
-+ * The free is done during cleanup, when cpufreq registry is failed.
-+ * We wouldn't be here if it fails on init or switch status. But for
-+ * future changes, added check.
-+ */
-+ cpudata = READ_ONCE(all_cpu_data[this_cpu]);
-+ if (unlikely(!cpudata))
-+ goto ack_intr;
-+
-+ schedule_delayed_work(&cpudata->hwp_notify_work, msecs_to_jiffies(10));
-+
-+ spin_unlock_irqrestore(&hwp_notify_lock, flags);
-+
-+ return;
-+
-+ack_intr:
-+ wrmsrl_safe(MSR_HWP_STATUS, 0);
-+ spin_unlock_irqrestore(&hwp_notify_lock, flags);
-+}
-+
-+static void intel_pstate_disable_hwp_interrupt(struct cpudata *cpudata)
-+{
-+ unsigned long flags;
-+
-+ /* wrmsrl_on_cpu has to be outside spinlock as this can result in IPC */
-+ wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00);
-+
-+ spin_lock_irqsave(&hwp_notify_lock, flags);
-+ if (cpumask_test_and_clear_cpu(cpudata->cpu, &hwp_intr_enable_mask))
-+ cancel_delayed_work(&cpudata->hwp_notify_work);
-+ spin_unlock_irqrestore(&hwp_notify_lock, flags);
-+}
-+
-+static void intel_pstate_enable_hwp_interrupt(struct cpudata *cpudata)
-+{
-+ /* Enable HWP notification interrupt for guaranteed performance change */
-+ if (boot_cpu_has(X86_FEATURE_HWP_NOTIFY)) {
-+ unsigned long flags;
-+
-+ spin_lock_irqsave(&hwp_notify_lock, flags);
-+ INIT_DELAYED_WORK(&cpudata->hwp_notify_work, intel_pstate_notify_work);
-+ cpumask_set_cpu(cpudata->cpu, &hwp_intr_enable_mask);
-+ spin_unlock_irqrestore(&hwp_notify_lock, flags);
-+
-+ /* wrmsrl_on_cpu has to be outside spinlock as this can result in IPC */
-+ wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x01);
-+ }
-+}
-+
- static void intel_pstate_hwp_enable(struct cpudata *cpudata)
- {
-- /* First disable HWP notification interrupt as we don't process them */
-+ /* First disable HWP notification interrupt till we activate again */
- if (boot_cpu_has(X86_FEATURE_HWP_NOTIFY))
- wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00);
-
- wrmsrl_on_cpu(cpudata->cpu, MSR_PM_ENABLE, 0x1);
- if (cpudata->epp_default == -EINVAL)
- cpudata->epp_default = intel_pstate_get_epp(cpudata, 0);
-+
-+ intel_pstate_enable_hwp_interrupt(cpudata);
- }
-
- static int atom_get_min_pstate(int not_used)
-@@ -2266,7 +2366,7 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
- if (!cpu)
- return -ENOMEM;
-
-- all_cpu_data[cpunum] = cpu;
-+ WRITE_ONCE(all_cpu_data[cpunum], cpu);
-
- cpu->cpu = cpunum;
-
-@@ -2937,8 +3037,10 @@ static void intel_pstate_driver_cleanup(void)
- if (intel_pstate_driver == &intel_pstate)
- intel_pstate_clear_update_util_hook(cpu);
-
-+ spin_lock(&hwp_notify_lock);
- kfree(all_cpu_data[cpu]);
-- all_cpu_data[cpu] = NULL;
-+ WRITE_ONCE(all_cpu_data[cpu], NULL);
-+ spin_unlock(&hwp_notify_lock);
- }
- }
- cpus_read_unlock();
-@@ -3207,6 +3309,7 @@ static bool intel_pstate_hwp_is_enabled(void)
-
- static int __init intel_pstate_init(void)
- {
-+ static struct cpudata **_all_cpu_data;
- const struct x86_cpu_id *id;
- int rc;
-
-@@ -3232,7 +3335,7 @@ static int __init intel_pstate_init(void)
- * deal with it.
- */
- if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) || hwp_forced) {
-- hwp_active++;
-+ WRITE_ONCE(hwp_active, 1);
- hwp_mode_bdw = id->driver_data;
- intel_pstate.attr = hwp_cpufreq_attrs;
- intel_cpufreq.attr = hwp_cpufreq_attrs;
-@@ -3283,10 +3386,12 @@ static int __init intel_pstate_init(void)
-
- pr_info("Intel P-state driver initializing\n");
-
-- all_cpu_data = vzalloc(array_size(sizeof(void *), num_possible_cpus()));
-- if (!all_cpu_data)
-+ _all_cpu_data = vzalloc(array_size(sizeof(void *), num_possible_cpus()));
-+ if (!_all_cpu_data)
- return -ENOMEM;
-
-+ WRITE_ONCE(all_cpu_data, _all_cpu_data);
-+
- intel_pstate_request_control_from_smm();
-
- intel_pstate_sysfs_expose_params();
---
-2.39.5
-
+++ /dev/null
-From c954aeeeadc7694c41fb563942cbabf72fe2e1e3 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 cb6fb9cdba0b8..6f69e396ce8c8 100644
---- a/drivers/cpufreq/intel_pstate.c
-+++ b/drivers/cpufreq/intel_pstate.c
-@@ -563,13 +563,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 440d08e6e32a6192de35b667bd2b69f71d972009 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 a26d28c437699..875c8cdaddda1 100644
---- a/drivers/cpufreq/intel_pstate.c
-+++ b/drivers/cpufreq/intel_pstate.c
-@@ -562,6 +562,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
-
+++ /dev/null
-From f9f9bd456c7f1a49b58ecb484e5d2509c0e340b2 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 17 Dec 2021 20:06:08 +0100
-Subject: cpufreq: intel_pstate: Update cpuinfo.max_freq on HWP_CAP changes
-
-From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-
-[ Upstream commit dfeeedc1bf5772226bddf51ed3f853e5a6707bf1 ]
-
-With HWP enabled, when the turbo range of performance levels is
-disabled by the platform firmware, the CPU capacity is given by
-the "guaranteed performance" field in MSR_HWP_CAPABILITIES which
-is generally dynamic. When it changes, the kernel receives an HWP
-notification interrupt handled by notify_hwp_interrupt().
-
-When the "guaranteed performance" value changes in the above
-configuration, the CPU performance scaling needs to be adjusted so
-as to use the new CPU capacity in computations, which means that
-the cpuinfo.max_freq value needs to be updated for that CPU.
-
-Accordingly, modify intel_pstate_notify_work() to read
-MSR_HWP_CAPABILITIES and update cpuinfo.max_freq to reflect the
-new configuration (this update can be carried out even if the
-configuration doesn't actually change, because it simply doesn't
-matter then and it takes less time to update it than to do extra
-checks to decide whether or not a change has really occurred).
-
-Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-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 | 24 +++++++++++++++++-------
- 1 file changed, 17 insertions(+), 7 deletions(-)
-
-diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
-index 2a1d21438a468..cb6fb9cdba0b8 100644
---- a/drivers/cpufreq/intel_pstate.c
-+++ b/drivers/cpufreq/intel_pstate.c
-@@ -1111,19 +1111,22 @@ static void intel_pstate_update_policies(void)
- cpufreq_update_policy(cpu);
- }
-
-+static void __intel_pstate_update_max_freq(struct cpudata *cpudata,
-+ struct cpufreq_policy *policy)
-+{
-+ policy->cpuinfo.max_freq = global.turbo_disabled_mf ?
-+ 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);
-- struct cpudata *cpudata;
-
- if (!policy)
- return;
-
-- cpudata = all_cpu_data[cpu];
-- policy->cpuinfo.max_freq = global.turbo_disabled_mf ?
-- cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
--
-- refresh_frequency_limits(policy);
-+ __intel_pstate_update_max_freq(all_cpu_data[cpu], policy);
-
- cpufreq_cpu_release(policy);
- }
-@@ -1571,8 +1574,15 @@ static void intel_pstate_notify_work(struct work_struct *work)
- {
- struct cpudata *cpudata =
- container_of(to_delayed_work(work), struct cpudata, hwp_notify_work);
-+ struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpudata->cpu);
-+
-+ if (policy) {
-+ intel_pstate_get_hwp_cap(cpudata);
-+ __intel_pstate_update_max_freq(cpudata, policy);
-+
-+ cpufreq_cpu_release(policy);
-+ }
-
-- cpufreq_update_policy(cpudata->cpu);
- wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_STATUS, 0);
- }
-
---
-2.39.5
-
irqchip-gic-v2m-prevent-use-after-free-of-gicv2m_get.patch
serial-msm-configure-correct-working-mode-before-sta.patch
riscv-uprobes-add-missing-fence.i-after-building-the.patch
-cpufreq-intel_pstate-process-hwp-guaranteed-change-n.patch
-cpufreq-intel_pstate-update-cpuinfo.max_freq-on-hwp_.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
spi-tegra114-remove-unnecessary-null-pointer-checks.patch
spi-tegra114-don-t-fail-set_cs_timing-when-delays-ar.patch
iommu-arm-smmu-v3-use-the-new-rb-tree-helpers.patch
+++ /dev/null
-From 05f4584ff713d6064d7a12ded2952a58cc5c7678 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 e26c0b0096080..18d6d2a357ce1 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;
- };
-@@ -559,12 +557,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)
-@@ -1119,40 +1118,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);
- }
-@@ -1252,7 +1227,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
-@@ -1282,7 +1256,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);
-@@ -2253,8 +2226,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);
-@@ -2572,7 +2543,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);
-@@ -2616,7 +2586,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 ?
-@@ -2713,8 +2682,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;
-
-@@ -2880,8 +2847,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;
-
-@@ -2903,8 +2868,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);
-@@ -2922,7 +2885,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);
-
-@@ -3112,6 +3074,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 5920bf68fdd391d9ca9c68a0da71b7b0e616aa22 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 faeeef4acdf70..e26c0b0096080 100644
---- a/drivers/cpufreq/intel_pstate.c
-+++ b/drivers/cpufreq/intel_pstate.c
-@@ -1984,14 +1984,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);
-@@ -2573,12 +2565,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 a7b500eb867264fb33adcfc8ba370ccd893b0cd2 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 d471d74df3bbb..faeeef4acdf70 100644
---- a/drivers/cpufreq/intel_pstate.c
-+++ b/drivers/cpufreq/intel_pstate.c
-@@ -562,13 +562,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 eda97920501cd72b95367e79b7345efb45705636 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 18d6d2a357ce1..bc0dec57bc8e2 100644
---- a/drivers/cpufreq/intel_pstate.c
-+++ b/drivers/cpufreq/intel_pstate.c
-@@ -561,6 +561,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
-
irqchip-gic-v2m-prevent-use-after-free-of-gicv2m_get.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
spi-tegra114-remove-unnecessary-null-pointer-checks.patch
spi-tegra114-don-t-fail-set_cs_timing-when-delays-ar.patch
iommu-arm-smmu-v3-use-the-new-rb-tree-helpers.patch