diff mbox series

[v2,07/11] x86/cpufreq: add "cpufreq=amd-cppc,active" para

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

Commit Message

Penny, Zheng Feb. 6, 2025, 8:32 a.m. UTC
From: Penny Zheng <penny.zheng@amd.com>

The amd-cppc driver may support multiple working modes, passive and active.

Introduce `active` tag for users to explicitly select active mode and a new
variable `opt_cpufreq_active` to keep track of which mode is currently enabled.
Specific implementation will be introduced in the following commits.

Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
---
v1 -> v2:
- Remove pointless initializer
- Move driver registration change to the next commit
---
 docs/misc/xen-command-line.pandoc    | 8 +++++++-
 xen/arch/x86/acpi/cpufreq/amd-cppc.c | 9 +++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

Comments

Jan Beulich Feb. 12, 2025, 3:52 p.m. UTC | #1
On 06.02.2025 09:32, Penny Zheng wrote:
> --- a/docs/misc/xen-command-line.pandoc
> +++ b/docs/misc/xen-command-line.pandoc
> @@ -515,7 +515,7 @@ If set, force use of the performance counters for oprofile, rather than detectin
>  available support.
>  
>  ### cpufreq
> -> `= none | {{ <boolean> | xen } { [:[powersave|performance|ondemand|userspace][,[<maxfreq>]][,[<minfreq>]]] } [,verbose]} | dom0-kernel | hwp[:[<hdc>][,verbose]] | amd-cppc[:[verbose]]`
> +> `= none | {{ <boolean> | xen } { [:[powersave|performance|ondemand|userspace][,[<maxfreq>]][,[<minfreq>]]] } [,verbose]} | dom0-kernel | hwp[:[<hdc>][,verbose]] | amd-cppc[:[active][,verbose]]`
>  
>  > Default: `xen`
>  
> @@ -538,6 +538,12 @@ choice of `dom0-kernel` is deprecated and not supported by all Dom0 kernels.
>    on supported AMD hardware to provide finer grained frequency control mechanism.
>    The default is disabled. If `amd-cppc` is selected, but hardware support
>    is not available, Xen will fallback to cpufreq=xen.
> +* `active` is a boolean to enable amd-cppc driver in active(autonomous) mode.
> +  In this mode, users could provide a hint with energy performance preference
> +  register to the hardware if they want to bias toward performance(0x0) or
> +  energy efficiency(0xff), then CPPC power algorithm will calculate the runtime
> +  workload and adjust the realtime cores frequency according to the power supply
> +  and thermal, core voltage and some other hardware conditions.

All the option offers to the user is a boolean. The description wants to be
written based on that; to be honest, with what is there and with the new
variable not actually consumed anywhere, I have no real idea what this is
about. Hex numbers in particular don't belong here at all, imo. And "users
could provide a hint" needs to be more practical: Users don't directly write
to the "energy performance preference register" (or any other one).

> --- a/xen/arch/x86/acpi/cpufreq/amd-cppc.c
> +++ b/xen/arch/x86/acpi/cpufreq/amd-cppc.c
> @@ -33,6 +33,8 @@
>  #define amd_cppc_warn(fmt, args...)                         \
>      printk(XENLOG_WARNING "AMD_CPPC: CPU%u warning: " fmt, cpu, ## args)
>  
> +static bool __ro_after_init opt_cpufreq_active;

The name is ambiguous. It reads as if this was a global enable/disable for
the cpufreq subsystem. opt_active_mode perhaps, seeing this is local to
the CPPC driver?

Jan
diff mbox series

Patch

diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index 78cfb8a02e..13f650270d 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -515,7 +515,7 @@  If set, force use of the performance counters for oprofile, rather than detectin
 available support.
 
 ### cpufreq
-> `= none | {{ <boolean> | xen } { [:[powersave|performance|ondemand|userspace][,[<maxfreq>]][,[<minfreq>]]] } [,verbose]} | dom0-kernel | hwp[:[<hdc>][,verbose]] | amd-cppc[:[verbose]]`
+> `= none | {{ <boolean> | xen } { [:[powersave|performance|ondemand|userspace][,[<maxfreq>]][,[<minfreq>]]] } [,verbose]} | dom0-kernel | hwp[:[<hdc>][,verbose]] | amd-cppc[:[active][,verbose]]`
 
 > Default: `xen`
 
@@ -538,6 +538,12 @@  choice of `dom0-kernel` is deprecated and not supported by all Dom0 kernels.
   on supported AMD hardware to provide finer grained frequency control mechanism.
   The default is disabled. If `amd-cppc` is selected, but hardware support
   is not available, Xen will fallback to cpufreq=xen.
+* `active` is a boolean to enable amd-cppc driver in active(autonomous) mode.
+  In this mode, users could provide a hint with energy performance preference
+  register to the hardware if they want to bias toward performance(0x0) or
+  energy efficiency(0xff), then CPPC power algorithm will calculate the runtime
+  workload and adjust the realtime cores frequency according to the power supply
+  and thermal, core voltage and some other hardware conditions.
 
 There is also support for `;`-separated fallback options:
 `cpufreq=hwp;xen,verbose`.  This first tries `hwp` and falls back to `xen` if
diff --git a/xen/arch/x86/acpi/cpufreq/amd-cppc.c b/xen/arch/x86/acpi/cpufreq/amd-cppc.c
index f14e7a6638..1742c57170 100644
--- a/xen/arch/x86/acpi/cpufreq/amd-cppc.c
+++ b/xen/arch/x86/acpi/cpufreq/amd-cppc.c
@@ -33,6 +33,8 @@ 
 #define amd_cppc_warn(fmt, args...)                         \
     printk(XENLOG_WARNING "AMD_CPPC: CPU%u warning: " fmt, cpu, ## args)
 
+static bool __ro_after_init opt_cpufreq_active;
+
 struct amd_cppc_drv_data
 {
     struct xen_processor_cppc *cppc_data;
@@ -80,6 +82,13 @@  static bool __init amd_cppc_handle_option(const char *s, const char *end)
         return true;
     }
 
+    ret = parse_boolean("active", s, end);
+    if ( ret >= 0 )
+    {
+        opt_cpufreq_active = ret;
+        return true;
+    }
+
     return false;
 }