Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit d845cd9

Browse files
spandruvadarafaeljw
authored andcommitted
cpufreq: intel_pstate: Support highest performance change interrupt
On some systems, the HWP (Hardware P-states) highest performance level can change from the value set at boot-up. This behavior can lead to two issues: - The 'cpuinfo_max_freq' within the 'cpufreq' sysfs will not reflect the CPU's highest achievable performance. - Even if the CPU's highest performance level is increased after booting, the CPU may not reach the full expected performance. The availability of this feature is indicated by the CPUID instruction: if CPUID[6].EAX[15] is set to 1, the feature is supported. When supported, setting bit 2 of the MSR_HWP_INTERRUPT register enables notifications of the highest performance level changes. Therefore, as part of enabling the HWP interrupt, bit 2 of the MSR_HWP_INTERRUPT should also be set when this feature is supported. Upon a change in the highest performance level, a new HWP interrupt is generated, with bit 3 of the MSR_HWP_STATUS register set, and the MSR_HWP_CAPABILITIES register is updated with the new highest performance limit. The processing of the interrupt is the same as the guaranteed performance change. Notify change to cpufreq core and update MSR_HWP_REQUEST with new performance limits. The current driver implementation already takes care of the highest performance change as part of: commit dfeeedc ("cpufreq: intel_pstate: Update cpuinfo.max_freq on HWP_CAP changes") For example: Before highest performance change interrupt: cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 3700000 cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq 3700000 After highest performance changes interrupt: cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq 3900000 cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 3900000 Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://patch.msgid.link/20240624161109.1427640-3-srinivas.pandruvada@linux.intel.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 7ea8193 commit d845cd9

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,17 +1626,24 @@ static void intel_pstate_notify_work(struct work_struct *work)
16261626
static DEFINE_SPINLOCK(hwp_notify_lock);
16271627
static cpumask_t hwp_intr_enable_mask;
16281628

1629+
#define HWP_GUARANTEED_PERF_CHANGE_STATUS BIT(0)
1630+
#define HWP_HIGHEST_PERF_CHANGE_STATUS BIT(3)
1631+
16291632
void notify_hwp_interrupt(void)
16301633
{
16311634
unsigned int this_cpu = smp_processor_id();
1635+
u64 value, status_mask;
16321636
unsigned long flags;
1633-
u64 value;
16341637

16351638
if (!hwp_active || !cpu_feature_enabled(X86_FEATURE_HWP_NOTIFY))
16361639
return;
16371640

1641+
status_mask = HWP_GUARANTEED_PERF_CHANGE_STATUS;
1642+
if (cpu_feature_enabled(X86_FEATURE_HWP_HIGHEST_PERF_CHANGE))
1643+
status_mask |= HWP_HIGHEST_PERF_CHANGE_STATUS;
1644+
16381645
rdmsrl_safe(MSR_HWP_STATUS, &value);
1639-
if (!(value & 0x01))
1646+
if (!(value & status_mask))
16401647
return;
16411648

16421649
spin_lock_irqsave(&hwp_notify_lock, flags);
@@ -1674,17 +1681,25 @@ static void intel_pstate_disable_hwp_interrupt(struct cpudata *cpudata)
16741681
cancel_delayed_work_sync(&cpudata->hwp_notify_work);
16751682
}
16761683

1684+
#define HWP_GUARANTEED_PERF_CHANGE_REQ BIT(0)
1685+
#define HWP_HIGHEST_PERF_CHANGE_REQ BIT(2)
1686+
16771687
static void intel_pstate_enable_hwp_interrupt(struct cpudata *cpudata)
16781688
{
1679-
/* Enable HWP notification interrupt for guaranteed performance change */
1689+
/* Enable HWP notification interrupt for performance change */
16801690
if (boot_cpu_has(X86_FEATURE_HWP_NOTIFY)) {
1691+
u64 interrupt_mask = HWP_GUARANTEED_PERF_CHANGE_REQ;
1692+
16811693
spin_lock_irq(&hwp_notify_lock);
16821694
INIT_DELAYED_WORK(&cpudata->hwp_notify_work, intel_pstate_notify_work);
16831695
cpumask_set_cpu(cpudata->cpu, &hwp_intr_enable_mask);
16841696
spin_unlock_irq(&hwp_notify_lock);
16851697

1698+
if (cpu_feature_enabled(X86_FEATURE_HWP_HIGHEST_PERF_CHANGE))
1699+
interrupt_mask |= HWP_HIGHEST_PERF_CHANGE_REQ;
1700+
16861701
/* wrmsrl_on_cpu has to be outside spinlock as this can result in IPC */
1687-
wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x01);
1702+
wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, interrupt_mask);
16881703
wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_STATUS, 0);
16891704
}
16901705
}

0 commit comments

Comments
 (0)