diff mbox series

[v1,07/11] xen/cpufreq: only set gov NULL when cpufreq_driver.target() exists

Message ID 20241203081111.463400-8-Penny.Zheng@amd.com (mailing list archive)
State New
Headers show
Series amd-pstate CPU Performance Scaling Driver | expand

Commit Message

Penny Zheng Dec. 3, 2024, 8:11 a.m. UTC
From: Penny Zheng <penny.zheng@amd.com>

amd-pstate on active mode bypasses the scaling governor layer, and
provides its own P-state selection algorithms. Consequently, when
it is used, the driver's -> setpolicy() callback is invoked
to register per-CPU utilization update callbacks, not the ->target()
callback.

So, only when cpufreq_driver.target() exists, we need to deliberately
set old gov as NULL to trigger the according gov starting.

Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
---
 xen/drivers/cpufreq/cpufreq.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c
index 54d554aa4f..c170a2cb2b 100644
--- a/xen/drivers/cpufreq/cpufreq.c
+++ b/xen/drivers/cpufreq/cpufreq.c
@@ -316,7 +316,13 @@  int cpufreq_add_cpu(unsigned int cpu)
     if (hw_all || (cpumask_weight(cpufreq_dom->map) ==
                    perf->domain_info.num_processors)) {
         memcpy(&new_policy, policy, sizeof(struct cpufreq_policy));
-        policy->governor = NULL;
+
+       /*
+        * Only when cpufreq_driver.target exists, we need to deliberately set old gov as NULL
+        * to trigger the according gov starting.
+        */
+       if ( cpufreq_driver.target )
+            policy->governor = NULL;
 
         cpufreq_cmdline_common_para(&new_policy);