diff mbox series

[v4,10/15] xen/cpufreq: only set gov NULL when cpufreq_driver.setpolicy is NULL

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

Commit Message

Penny, Zheng April 14, 2025, 7:40 a.m. UTC
amd-cppc on active mode bypasses the scaling governor layer, and
provides its own P-state selection algorithms in hardware. 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.setpolicy is NULL, we need to deliberately
set old gov as NULL to trigger the according gov starting.

Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
v3 -> v4:
- fix indentation and this commit is independent of all earlier patches
---
 xen/drivers/cpufreq/cpufreq.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Jan Beulich April 14, 2025, 11:18 a.m. UTC | #1
On 14.04.2025 09:40, Penny Zheng wrote:
> amd-cppc on active mode bypasses the scaling governor layer, and
> provides its own P-state selection algorithms in hardware. 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.setpolicy is NULL, we need to deliberately
> set old gov as NULL to trigger the according gov starting.
> 
> Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> ---
> v3 -> v4:
> - fix indentation and this commit is independent of all earlier patches

I've committed this, but had to adjust for fuzz first. Would be nice if such
entirely ready (i.e. also independent) patches could be moved to the front of
the containing series.

Jan
diff mbox series

Patch

diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c
index 818668c99c..2e392110d8 100644
--- a/xen/drivers/cpufreq/cpufreq.c
+++ b/xen/drivers/cpufreq/cpufreq.c
@@ -396,7 +396,13 @@  int cpufreq_add_cpu(unsigned int cpu)
                     domain_info.num_processors) )
     {
         memcpy(&new_policy, policy, sizeof(struct cpufreq_policy));
-        policy->governor = NULL;
+
+        /*
+         * Only when cpufreq_driver.setpolicy == NULL, we need to deliberately
+         * set old gov as NULL to trigger the according gov starting.
+         */
+        if ( cpufreq_driver.setpolicy == NULL )
+            policy->governor = NULL;
 
         cpufreq_cmdline_common_para(&new_policy);