From: dirk.brandewie@gmail.com
To: linux-pm@vger.kernel.org
Cc: rjw@rjwysocki.net, dirk.brandewie@gmail.com,
Dirk Brandewie <dirk.j.brandewie@intel.com>,
stable@vger.kernel.org
Subject: [PATCH 5/5] intel_pstate: Correct BYT VID values.
Date: Mon, 13 Oct 2014 08:37:44 -0700 [thread overview]
Message-ID: <1413214664-17687-5-git-send-email-dirk.j.brandewie@intel.com> (raw)
In-Reply-To: <1413214664-17687-1-git-send-email-dirk.j.brandewie@intel.com>
From: Dirk Brandewie <dirk.j.brandewie@intel.com>
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 <dirk.j.brandewie@intel.com>
---
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;
--
1.9.3
next prev parent reply other threads:[~2014-10-13 15:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-13 15:37 [PATCH 1/5] cpufreq: expose scaling_cur_freq sysfs file for set_policy() drivers dirk.brandewie
2014-10-13 15:37 ` [PATCH 2/5] cpufreq: intel_pstate: Reflect current no_turbo state correctly dirk.brandewie
2014-10-13 15:37 ` [PATCH 3/5] intel_pstate: Don't lose sysfs settings during cpu offline dirk.brandewie
2014-10-13 15:37 ` [PATCH 4/5] intel_pstate: Fix BYT frequency reporting dirk.brandewie
2014-10-13 15:37 ` dirk.brandewie [this message]
2014-10-21 13:31 ` [PATCH 1/5] cpufreq: expose scaling_cur_freq sysfs file for set_policy() drivers Rafael J. Wysocki
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=1413214664-17687-5-git-send-email-dirk.j.brandewie@intel.com \
--to=dirk.brandewie@gmail.com \
--cc=dirk.j.brandewie@intel.com \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=stable@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).