Skip to contentSkip to conversation

x86/intel_pstate: add new policy fields and a new driver interface

PATCH Superseded Wei Wang 1 participant 1 message Apr 23, 2015

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Wei Wang

author
#0 lore raw

PATCH 4/9 x86/intel_pstate: add new policy fields and a new driver interface

In order to better support future Intel processors, intel_pstate changes to use percentage values to tune P-states. The intel_pstate driver uses its own internal governor, and it is recorded in the "policy->policy" field. The setpolicy driver interface is used to configure the intel_pstate internal policy. The __cpufreq_set_policy needs to be intercepted to use the setpolicy driver if it exists.

---
 xen/drivers/cpufreq/utility.c      |  5 +++++
 xen/include/acpi/cpufreq/cpufreq.h | 10 ++++++++++
 2 files changed, 15 insertions(+)
xen/drivers/cpufreq/utility.c +5 -0
index 519f862..04f88c2 100644
@@ -456,6 +456,11 @@ int __cpufreq_set_policy(struct cpufreq_policy *data,
 
     data->min = policy->min;
     data->max = policy->max;
+    data->min_perf_pct = policy->min_perf_pct;
+    data->max_perf_pct = policy->max_perf_pct;
+
+    if (cpufreq_driver->setpolicy)
+        return cpufreq_driver->setpolicy(data);
 
     if (policy->governor != data->governor) {
         /* save old, working values */
xen/include/acpi/cpufreq/cpufreq.h +10 -0
index f96c3e4..29d184c 100644
@@ -52,6 +52,11 @@ struct cpufreq_policy {
     unsigned int        max;    /* in kHz */
     unsigned int        cur;    /* in kHz, only needed if cpufreq
                                  * governors are used */
+    int                 min_perf_pct; /* min performance in percentage */
+    int                 max_perf_pct; /* max performance in percentage */
+    int                 turbo_pct;
+    unsigned int        pstates_num;
+    unsigned int        policy;
     struct cpufreq_governor     *governor;
 
     bool_t              resume; /* flag for cpufreq 1st run
@@ -87,6 +92,10 @@ struct cpufreq_freqs {
  *                          CPUFREQ GOVERNORS                        *
  *********************************************************************/
 
+/* the two internal governors used in intel_pstate */
+#define CPUFREQ_POLICY_POWERSAVE        (1)
+#define CPUFREQ_POLICY_PERFORMANCE      (2)
+
 #define CPUFREQ_GOV_START  1
 #define CPUFREQ_GOV_STOP   2
 #define CPUFREQ_GOV_LIMITS 3
@@ -145,6 +154,7 @@ struct cpufreq_driver {
     char   name[CPUFREQ_NAME_LEN];
     int    (*init)(struct cpufreq_policy *policy);
     int    (*verify)(struct cpufreq_policy *policy);
+    int    (*setpolicy)(struct cpufreq_policy *policy);
     int    (*update)(int cpuid, struct cpufreq_policy *policy);
     int    (*target)(struct cpufreq_policy *policy,
                      unsigned int target_freq,
Signature · 1 line
1.9.1