linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kristen Carlson Accardi <kristen@linux.intel.com>
To: rjw@rjwysocki.net
Cc: srinivas.pandruvada@linux.intel.com, linux-pm@vger.kernel.org
Subject: [PATCH 2/2] intel_pstate: Add num_pstates to sysfs
Date: Wed, 28 Jan 2015 15:03:28 -0800	[thread overview]
Message-ID: <1422486208-14367-3-git-send-email-kristen@linux.intel.com> (raw)
In-Reply-To: <1422486208-14367-1-git-send-email-kristen@linux.intel.com>

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>
---
 Documentation/cpu-freq/intel-pstate.txt |  4 ++++
 drivers/cpufreq/intel_pstate.c          | 13 +++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/Documentation/cpu-freq/intel-pstate.txt b/Documentation/cpu-freq/intel-pstate.txt
index 7767ce6..6557507 100644
--- a/Documentation/cpu-freq/intel-pstate.txt
+++ b/Documentation/cpu-freq/intel-pstate.txt
@@ -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
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index f558c2e..3ea9aff 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -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
 };
 
-- 
1.9.3


      parent reply	other threads:[~2015-01-29  1:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-28 23:03 [PATCH 0/2] sysfs additions for intel_pstate Kristen Carlson Accardi
2015-01-28 23:03 ` [PATCH 1/2] intel_pstate: expose turbo range to sysfs Kristen Carlson Accardi
2015-01-28 23:03 ` Kristen Carlson Accardi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1422486208-14367-3-git-send-email-kristen@linux.intel.com \
    --to=kristen@linux.intel.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=srinivas.pandruvada@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).