From patchwork Mon Mar 21 12:27:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prarit Bhargava X-Patchwork-Id: 8632261 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3463FC0553 for ; Mon, 21 Mar 2016 12:27:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C7FC20149 for ; Mon, 21 Mar 2016 12:27:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 316C920120 for ; Mon, 21 Mar 2016 12:27:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755297AbcCUM1m (ORCPT ); Mon, 21 Mar 2016 08:27:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53344 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755811AbcCUM1Y (ORCPT ); Mon, 21 Mar 2016 08:27:24 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id E4511144186; Mon, 21 Mar 2016 12:27:23 +0000 (UTC) Received: from prarit.bos.redhat.com (prarit-guest.khw.lab.eng.bos.redhat.com [10.16.186.145]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2LCRJlc023265; Mon, 21 Mar 2016 08:27:23 -0400 From: Prarit Bhargava To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Prarit Bhargava , "Rafael J. Wysocki" , Radivoje Jovanovic , Seiichi Ikarashi , Mathias Krause , Ajay Thomas Subject: [PATCH 3/3 v3] powercap, intel_rapl, Add ignore_max_time_window_check module parameter for broken BIOSes Date: Mon, 21 Mar 2016 08:27:16 -0400 Message-Id: <1458563236-19269-4-git-send-email-prarit@redhat.com> In-Reply-To: <1458563236-19269-1-git-send-email-prarit@redhat.com> References: <1458563236-19269-1-git-send-email-prarit@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 21 Mar 2016 12:27:23 +0000 (UTC) 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, 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 Some systems erroneously set the maximum time window field of MSR_PKG_POWER_INFO register to 0. This results in a user not being able to set the time windows for the package. In some cases, however, RAPL will still continue to work with a small window (albeit through some trial and error). This patch adds a ignore_max_time_window_check module parameter to avoid the maximum time window check in set_time_window(). [v2]: change name to max_time_window_check, fix (val == 0) check [v3]: fix typo in debug message Cc: "Rafael J. Wysocki" Cc: Prarit Bhargava Cc: Radivoje Jovanovic Cc: Seiichi Ikarashi Cc: Mathias Krause Cc: Ajay Thomas Signed-off-by: Prarit Bhargava --- drivers/powercap/intel_rapl.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c index cf89b3d..87dac13 100644 --- a/drivers/powercap/intel_rapl.c +++ b/drivers/powercap/intel_rapl.c @@ -505,13 +505,24 @@ static int get_max_time_window(struct powercap_zone *power_zone, int id, if (rapl_read_data_raw(rd, MAX_TIME_WINDOW, true, &val)) ret = -EIO; - else + else { *data = val; - + if (val == 0) + pr_warn_once(FW_BUG "intel_rapl: Maximum Time Window is zero. This is a BIOS bug that should be reported to your hardware or BIOS vendor. The value of zero may prevent Intel RAPL from functioning properly. Most bugs can be avoided by setting the ignore_max_time_window_check module parameter.\n"); + } put_online_cpus(); return ret; } +/* Some BIOSes incorrectly program the maximum time window in the + * MSR_PKG_POWER_INFO register. Some of these systems still have functional + * RAPL registers, etc., so give the user the option of disabling the maximum + * time window check. + */ +static int ignore_max_time_window_check; +module_param(ignore_max_time_window_check, int, 0444); +MODULE_PARM_DESC(ignore_max_time_window_check, "Ignore maximum time window check. A bug should be reported to your hardware or BIOS vendor if this parameter is used."); + static int set_time_window(struct powercap_zone *power_zone, int id, u64 window) { @@ -532,7 +543,8 @@ static int set_time_window(struct powercap_zone *power_zone, int id, * The MSR_RAPL_POWER_UNIT register, read during initialization, * does contain the smallest unit of time that can be measured. */ - if ((window > max_window) || (window < rp->time_unit)) { + if ((!ignore_max_time_window_check && (window > max_window)) || + (window < rp->time_unit)) { ret = -EINVAL; goto out; }