From patchwork Mon Oct 13 15:37:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dirk.brandewie@gmail.com X-Patchwork-Id: 5076941 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2955D9F65C for ; Mon, 13 Oct 2014 15:38:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58303201F7 for ; Mon, 13 Oct 2014 15:38:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 71417201C7 for ; Mon, 13 Oct 2014 15:38:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755282AbaJMPiB (ORCPT ); Mon, 13 Oct 2014 11:38:01 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:60595 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754490AbaJMPiA (ORCPT ); Mon, 13 Oct 2014 11:38:00 -0400 Received: by mail-pd0-f179.google.com with SMTP id r10so5789693pdi.38 for ; Mon, 13 Oct 2014 08:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TGV8PiHqNwfAkvA4Sds7CX5I8Sdr42R3OhJeCYj57fE=; b=E/NOnPfW2F47A+/G13KaqbTQ9lv45E3U2FwUsyNHWr6DCMS8uLtP52b/j55eeuvlgv sXL4X4KrYk0MjqipT6W56ZTZJpM51o/9N+SCmss2ZuOjkJBJQ6dQ6XVUzcwci1QVCuUQ il/O3bxChNIT3jBuNxavHo3x5VjtZ/OzxeC5dFUwiM7zWDXXtumSJ1W4xI3auGqcA6Ko rVvbw68N8Z+zyU6O+RnKKXnrG2QPmQ+ZOQLDuwmf+aDdSH45qLMoz+jfR4p7qB0sFach 3LedYy2NWcRwGCF1cAz3WDsbNV/Sr635GUxj5xybnqoRO4hNK3ZBAG74iNYy9yNRaz3a Q/Sw== X-Received: by 10.70.42.47 with SMTP id k15mr24607481pdl.79.1413214680221; Mon, 13 Oct 2014 08:38:00 -0700 (PDT) Received: from echolake.localdomain (static-50-43-32-60.bvtn.or.frontiernet.net. [50.43.32.60]) by mx.google.com with ESMTPSA id dg5sm10340216pdb.54.2014.10.13.08.37.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Oct 2014 08:37:59 -0700 (PDT) From: dirk.brandewie@gmail.com X-Google-Original-From: dirk.j.brandewie@intel.com To: linux-pm@vger.kernel.org Cc: rjw@rjwysocki.net, dirk.brandewie@gmail.com, Dirk Brandewie , stable@vger.kernel.org Subject: [PATCH 5/5] intel_pstate: Correct BYT VID values. Date: Mon, 13 Oct 2014 08:37:44 -0700 Message-Id: <1413214664-17687-5-git-send-email-dirk.j.brandewie@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1413214664-17687-1-git-send-email-dirk.j.brandewie@intel.com> References: <1413214664-17687-1-git-send-email-dirk.j.brandewie@intel.com> 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Dirk Brandewie Using a VID value that is not high enough for the requested P state can cause machine checks. Add a ceiling function to ensure calulated VIDs with fractional values are set to the next highest integer VID value. The algorythm for calculating the non-trubo VID from the BIOS writers guide is: vid_ratio = (vid_max - vid_min) / (max_pstate - min_pstate) vid = ceiling(vid_min + (req_pstate - min_pstate) * vid_ratio) Cc: stable@vger.kernel.org Signed-off-by: Dirk Brandewie --- drivers/cpufreq/intel_pstate.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 77a87fa..6f6d588 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -52,6 +52,17 @@ static inline int32_t div_fp(int32_t x, int32_t y) return div_s64((int64_t)x << FRAC_BITS, y); } +static inline int ceiling_fp(int32_t x) +{ + int mask, ret; + + ret = fp_toint(x); + mask = (1 << FRAC_BITS) - 1; + if (x & mask) + ret += 1; + return ret; +} + struct sample { int32_t core_pct_busy; u64 aperf; @@ -425,7 +436,7 @@ static void byt_set_pstate(struct cpudata *cpudata, int pstate) cpudata->vid.ratio); vid_fp = clamp_t(int32_t, vid_fp, cpudata->vid.min, cpudata->vid.max); - vid = fp_toint(vid_fp); + vid = ceiling_fp(vid_fp); if (pstate > cpudata->pstate.max_pstate) vid = cpudata->vid.turbo;