From patchwork Thu Mar 26 18:41:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shilpasri G Bhat X-Patchwork-Id: 6101631 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BF1579F2A9 for ; Thu, 26 Mar 2015 18:42:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2B3B203F7 for ; Thu, 26 Mar 2015 18:42:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B72322038E for ; Thu, 26 Mar 2015 18:42:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751888AbbCZSmV (ORCPT ); Thu, 26 Mar 2015 14:42:21 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:55191 "EHLO e23smtp01.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751900AbbCZSmV (ORCPT ); Thu, 26 Mar 2015 14:42:21 -0400 Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 27 Mar 2015 04:42:19 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 27 Mar 2015 04:42:18 +1000 Received: from d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 3806F2CE8040; Fri, 27 Mar 2015 05:42:17 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t2QIg8PB39256318; Fri, 27 Mar 2015 05:42:17 +1100 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t2QIfhX3030300; Fri, 27 Mar 2015 05:41:43 +1100 Received: from localhost.in.ibm.com ([9.79.211.188]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t2QIffwh030081; Fri, 27 Mar 2015 05:41:41 +1100 From: Shilpasri G Bhat To: "Rafael J. Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Shilpasri G Bhat Subject: [PATCH v2] cpufreq: powernv: Add checks to report cpu frequency throttling conditions Date: Fri, 27 Mar 2015 00:11:22 +0530 Message-Id: <1427395282-31875-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.3 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15032618-1618-0000-0000-000001D10DF9 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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; /*