All of lore.kernel.org
 help / color / mirror / Atom feed
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: rjw@rjwysocki.net, lenb@kernel.org
Cc: linux-pm@vger.kernel.org,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: [PATCH] cpufreq: intel_pstate: Increase precision
Date: Mon,  5 Jun 2017 18:01:04 -0700	[thread overview]
Message-ID: <1496710864-117662-1-git-send-email-srinivas.pandruvada@linux.intel.com> (raw)

In some cases the scaling max/min limit set via cpufreq interface doesn't
result in correct max/min.

For example, with the data below:

cpuinfo_max_freq:3700000
scaling_max_freq:2500000
HWP max ratio = 37

With the current fixed point conversion to ratio using 14 bit shift:
max_perf = (2500000 << 14) / 3700000 = 11070
Rounding up with 14 = 11070
HWP max ratio corresponding to 2500000 will be
= (hwp max ratio * max_perf) >> 14
= 24

So this will result in 100Mhz less frequency than what is requested,
with scaling factor of 100000.

To fix this if we increase the shift to 15 bits.
max_perf = (2500000 << 15) / 3700000 = 22140
rounded up with 15 = 22144
The new max ratio corresponding to 2500000 will be
= (hwp max ratio * max_perf) >> 15
= 25
This will result in correct scaling max frequency.

This patch changes EXT_BITS to 7 from 6, so this will result in 15 bit
shift during fixed point math above.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/cpufreq/intel_pstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 640eb7e4..6386422 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -52,7 +52,7 @@
 #define int_tofp(X) ((int64_t)(X) << FRAC_BITS)
 #define fp_toint(X) ((X) >> FRAC_BITS)
 
-#define EXT_BITS 6
+#define EXT_BITS 7
 #define EXT_FRAC_BITS (EXT_BITS + FRAC_BITS)
 #define fp_ext_toint(X) ((X) >> EXT_FRAC_BITS)
 #define int_ext_tofp(X) ((int64_t)(X) << EXT_FRAC_BITS)
-- 
2.7.4

                 reply	other threads:[~2017-06-06  1:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1496710864-117662-1-git-send-email-srinivas.pandruvada@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.