From: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Viresh Kumar <viresh.kumar@linaro.org>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Subject: [PATCH v2] cpufreq: powernv: Add checks to report cpu frequency throttling conditions
Date: Fri, 27 Mar 2015 00:11:22 +0530 [thread overview]
Message-ID: <1427395282-31875-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> (raw)
Cpu frequency can be throttled due to failures of components like OCC,
power supply and fan. It can also be throttled due to temperature and
power limit. We can detect the throttling by checking 1)if max frequency
is reduced, 2)if the core is put to safe frequency 3)if the SPR based
frequency management is disabled.
The current status of the core is read from Power Management Status
Register(PMSR) to check if any of the throttling condition is
occurred and the appropriate throttling message is reported.
Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
---
Changes from V1: Removed unused value of PMCR register
drivers/cpufreq/powernv-cpufreq.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 2dfd4fd..4837eed 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -36,7 +36,7 @@
#define POWERNV_MAX_PSTATES 256
static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1];
-static bool rebooting;
+static bool rebooting, throttled;
/*
* Note: The set of pstates consists of contiguous integers, the
@@ -294,6 +294,40 @@ static inline unsigned int get_nominal_index(void)
return powernv_pstate_info.max - powernv_pstate_info.nominal;
}
+static void powernv_cpufreq_throttle_check(unsigned int cpu)
+{
+ unsigned long pmsr;
+ int pmsr_pmax, pmsr_lp;
+
+ pmsr = get_pmspr(SPRN_PMSR);
+
+ /* Check for Pmax Capping */
+ pmsr_pmax = (s8)((pmsr >> 32) & 0xFF);
+ if (pmsr_pmax != powernv_pstate_info.max) {
+ throttled = true;
+ pr_warn("Cpu %d Pmax is reduced to %d\n", cpu, pmsr_pmax);
+ }
+
+ /* Check for Psafe by reading LocalPstate
+ * or check if Psafe_mode_active- 34th bit is set in PMSR.
+ */
+ pmsr_lp = (s8)((pmsr >> 48) & 0xFF);
+ if ((pmsr_lp < powernv_pstate_info.min) || ((pmsr >> 30) & 1)) {
+ throttled = true;
+ pr_warn("Cpu %d in Psafe %d PMSR[34]=%lx\n", cpu,
+ pmsr_lp, ((pmsr >> 30) & 1));
+ }
+
+ /* Check if SPR_EM_DISABLED- 33rd bit is set in PMSR */
+ if ((pmsr >> 31) & 1) {
+ throttled = true;
+ pr_warn("Frequency management disabled cpu %d PMSR[33]=%lx\n",
+ cpu, ((pmsr >> 31) & 1));
+ }
+ if (throttled)
+ pr_warn("Cpu Frequency is throttled\n");
+}
+
/*
* powernv_cpufreq_target_index: Sets the frequency corresponding to
* the cpufreq table entry indexed by new_index on the cpus in the
@@ -307,6 +341,9 @@ static int powernv_cpufreq_target_index(struct cpufreq_policy *policy,
if (unlikely(rebooting) && new_index != get_nominal_index())
return 0;
+ if (!throttled)
+ powernv_cpufreq_throttle_check(smp_processor_id());
+
freq_data.pstate_id = powernv_freqs[new_index].driver_data;
/*
--
1.9.3
next reply other threads:[~2015-03-26 18:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 18:41 Shilpasri G Bhat [this message]
2015-03-27 4:35 ` Viresh Kumar
2015-03-27 6:32 ` Shilpasri G Bhat
2015-03-27 6:44 ` Viresh Kumar
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=1427395282-31875-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com \
--to=shilpa.bhat@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=viresh.kumar@linaro.org \
/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
all inboxes | Powered by JetHome®