From patchwork Mon Nov 18 07:06:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuxuan Shui X-Patchwork-Id: 3195481 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DD2C9C045B for ; Mon, 18 Nov 2013 07:06:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F85D20278 for ; Mon, 18 Nov 2013 07:06:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E2BC2013A for ; Mon, 18 Nov 2013 07:06:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751237Ab3KRHGu (ORCPT ); Mon, 18 Nov 2013 02:06:50 -0500 Received: from mail-pb0-f51.google.com ([209.85.160.51]:50704 "EHLO mail-pb0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750752Ab3KRHGu (ORCPT ); Mon, 18 Nov 2013 02:06:50 -0500 Received: by mail-pb0-f51.google.com with SMTP id up15so1592387pbc.38 for ; Sun, 17 Nov 2013 23:06:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=BRx73juU5/1ADxdsVkhgZBf0P1ZFWZrgxArm4ok7M4k=; b=qaGMFyzyfc9dncCWJwdRvNRwzu7PO0wWQz+TUjsRMo690anmtrs7B6JjxF5y3Dd9zU MoIGJiW9isdL+p8oSIPcDlAvcxiRRFpcEb/lxUJTu0kPFwjA5xMESrb/W/p61SlHzkB0 I5VAvnhsHg6LsMstu15jjAklJyj1cHLmFuYi/3iPMKqtD9YjU+pt7fqaDOD1fgBrAdLa fQDTKhhNRDpCJRZaTVSAaCl5qTy4g8wqB5fs621p8sLpgc63ZdDs2Hhf4b4kCO1f+Y+S K9lEztJJtG65krNmnksWoXOSNo1m8auBRjXHNNcx7JiVjDQO5VCHwdzg1KzmEXqWUxSx EpHQ== X-Received: by 10.66.154.1 with SMTP id vk1mr19994606pab.85.1384758409595; Sun, 17 Nov 2013 23:06:49 -0800 (PST) Received: from localhost.localdomain (nialv7.xen.prgmr.com. [71.19.156.202]) by mx.google.com with ESMTPSA id go4sm21202507pbb.15.2013.11.17.23.06.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Nov 2013 23:06:49 -0800 (PST) From: Yuxuan Shui To: linux-pm@vger.kernel.org Cc: arjan@linux.intel.com, jacob.jun.pan@linux.intel.com, Yuxuan Shui Subject: [PATCH] intel_powerclamp: Fix cstate counter detection. Date: Mon, 18 Nov 2013 15:06:35 +0800 Message-Id: <1384758395-5074-1-git-send-email-yshuiv7@gmail.com> X-Mailer: git-send-email 1.8.4.2 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Having all zero cstate count doesn't necesserily mean the cstate counter is no functional. Signed-off-by: Yuxuan Shui --- drivers/thermal/intel_powerclamp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c index b40b37c..e302769 100644 --- a/drivers/thermal/intel_powerclamp.c +++ b/drivers/thermal/intel_powerclamp.c @@ -206,6 +206,15 @@ static void find_target_mwait(void) } +static bool has_pkg_state_counter(void) +{ + u64 tmp; + return !rdmsrl_safe(MSR_PKG_C2_RESIDENCY, &tmp) || + !rdmsrl_safe(MSR_PKG_C3_RESIDENCY, &tmp) || + !rdmsrl_safe(MSR_PKG_C6_RESIDENCY, &tmp) || + !rdmsrl_safe(MSR_PKG_C7_RESIDENCY, &tmp); +} + static u64 pkg_state_counter(void) { u64 val; @@ -500,7 +509,7 @@ static int start_power_clamp(void) struct task_struct *thread; /* check if pkg cstate counter is completely 0, abort in this case */ - if (!pkg_state_counter()) { + if (!has_pkg_state_counter()) { pr_err("pkg cstate counter not functional, abort\n"); return -EINVAL; }