intel_pstate: Add num_pstates to sysfs
authorKristen Carlson Accardi <kristen@linux.intel.com>
Wed, 28 Jan 2015 23:03:28 +0000 (15:03 -0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 30 Jan 2015 00:52:17 +0000 (01:52 +0100)
Add a sysfs interface to display the total number of supported
pstates.  This value is independent of whether turbo has been
enabled or disabled.

Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Documentation/cpu-freq/intel-pstate.txt
drivers/cpufreq/intel_pstate.c

index 7767ce6756beb1166ef805a66a5d5d431c500eb6..655750743fb09b3c78a8b5c47cc96ace7b311722 100644 (file)
@@ -41,6 +41,10 @@ controlling P state selection. These files have been added to
       is supported by hardware that is in the turbo range.  This number
       is independent of whether turbo has been disabled or not.
 
+      num_pstates: displays the number of pstates that are supported
+      by hardware.  This number is independent of whether turbo has
+      been disabled or not.
+
 For contemporary Intel processors, the frequency is controlled by the
 processor itself and the P-states exposed to software are related to
 performance levels.  The idea that frequency can be set to a single
index ed6dd7dac094fc91ca3c5fb3a2bb1085e93147b1..80ecc351d613a68788c57e6a3ee625d35d2ecefa 100644 (file)
@@ -354,6 +354,17 @@ static ssize_t show_turbo_pct(struct kobject *kobj,
        return sprintf(buf, "%u\n", turbo_pct);
 }
 
+static ssize_t show_num_pstates(struct kobject *kobj,
+                               struct attribute *attr, char *buf)
+{
+       struct cpudata *cpu;
+       int total;
+
+       cpu = all_cpu_data[0];
+       total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1;
+       return sprintf(buf, "%u\n", total);
+}
+
 static ssize_t show_no_turbo(struct kobject *kobj,
                             struct attribute *attr, char *buf)
 {
@@ -435,12 +446,14 @@ define_one_global_rw(no_turbo);
 define_one_global_rw(max_perf_pct);
 define_one_global_rw(min_perf_pct);
 define_one_global_ro(turbo_pct);
+define_one_global_ro(num_pstates);
 
 static struct attribute *intel_pstate_attributes[] = {
        &no_turbo.attr,
        &max_perf_pct.attr,
        &min_perf_pct.attr,
        &turbo_pct.attr,
+       &num_pstates.attr,
        NULL
 };