* [PATCH 0/4] Fixes for limits enforcement
@ 2017-01-18 18:48 Srinivas Pandruvada
2017-01-18 18:48 ` [PATCH 1/4] cpufreq: intel_pstate: Fix sysfs limits enforcement for performance policy Srinivas Pandruvada
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2017-01-18 18:48 UTC (permalink / raw)
To: rjw, len.brown; +Cc: linux-kernel, linux-pm, Srinivas Pandruvada
This series includes fixes for sysfs limits enforcement. Only the
patch 1/4 is new in 4.10.rc, others are not new issues.
Srinivas Pandruvada (4):
cpufreq: intel_pstate: Fix sysfs limits enforcement for performance
policy
cpufreq: intel_pstate: Lower frequency than expected under no_turbo
cpufreq: intel_pstate: Make HWP limits compatible with legacy
cpufreq: intel_pstate: Calculate guaranteed performance for HWP
drivers/cpufreq/intel_pstate.c | 113 +++++++++++++++++++++++++++++------------
1 file changed, 80 insertions(+), 33 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] cpufreq: intel_pstate: Fix sysfs limits enforcement for performance policy
2017-01-18 18:48 [PATCH 0/4] Fixes for limits enforcement Srinivas Pandruvada
@ 2017-01-18 18:48 ` Srinivas Pandruvada
2017-01-18 18:48 ` [PATCH 2/4] cpufreq: intel_pstate: Lower frequency than expected under no_turbo Srinivas Pandruvada
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2017-01-18 18:48 UTC (permalink / raw)
To: rjw, len.brown; +Cc: linux-kernel, linux-pm, Srinivas Pandruvada
The side effect of keeping intel_pstate sysfs limits in sync with cpufreq
is that the now sysfs limits can't enforced under performance policy.
For example if the max_perf_pct is changed from 100 to 80, this will call
intel_pstate_set_policy(), which will change the max_perf to 100 again for
performance policy. Same issue happens, when no_turbo is set.
This change calculates max and min frequency using sysfs performance
limits in intel_pstate_verify_policy() and adjusts policy limits by
calling cpufreq_verify_within_limits(). Also when no_turbo is set, don't
set performance limits.
Fixes: 111b8b3fe4fa (cpufreq: intel_pstate: Always keep all limits settings in sync)
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/cpufreq/intel_pstate.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index f91c257..a54d65a 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -2005,7 +2005,8 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
limits = &performance_limits;
perf_limits = limits;
}
- if (policy->max >= policy->cpuinfo.max_freq) {
+ if (policy->max >= policy->cpuinfo.max_freq &&
+ !limits->no_turbo) {
pr_debug("set performance\n");
intel_pstate_set_performance_limits(perf_limits);
goto out;
@@ -2047,6 +2048,17 @@ static int intel_pstate_verify_policy(struct cpufreq_policy *policy)
policy->policy != CPUFREQ_POLICY_PERFORMANCE)
return -EINVAL;
+ /* When per-CPU limits are used, sysfs limits are not used */
+ if (!per_cpu_limits) {
+ unsigned int max_freq, min_freq;
+
+ max_freq = policy->cpuinfo.max_freq *
+ limits->max_sysfs_pct / 100;
+ min_freq = policy->cpuinfo.max_freq *
+ limits->min_sysfs_pct / 100;
+ cpufreq_verify_within_limits(policy, min_freq, max_freq);
+ }
+
return 0;
}
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/4] cpufreq: intel_pstate: Lower frequency than expected under no_turbo
2017-01-18 18:48 [PATCH 0/4] Fixes for limits enforcement Srinivas Pandruvada
2017-01-18 18:48 ` [PATCH 1/4] cpufreq: intel_pstate: Fix sysfs limits enforcement for performance policy Srinivas Pandruvada
@ 2017-01-18 18:48 ` Srinivas Pandruvada
2017-01-18 18:48 ` [PATCH 3/4] cpufreq: intel_pstate: Make HWP limits compatible with legacy Srinivas Pandruvada
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2017-01-18 18:48 UTC (permalink / raw)
To: rjw, len.brown; +Cc: linux-kernel, linux-pm, Srinivas Pandruvada
When turbo is not disabled by BIOS, but user disabled from intel P-State
sysfs and changes max/min using cpufreq sysfs, the resultant frequency
is lower than what user requested.
The reason for this, when the perf limits are calculated in set_policy()
callback, they are with reference to max cpu frequency (turbo frequency
), but when enforced in the intel_pstate_get_min_max() they are with
reference to max available performance as documented in the intel_pstate
documentation (in this case max non turbo P-State).
This needs similar change as done in intel_cpufreq_verify_policy() for
passive mode. Set policy->cpuinfo.max_freq based on the turbo status.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/cpufreq/intel_pstate.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index a54d65a..a5f1a04 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -2042,6 +2042,20 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
static int intel_pstate_verify_policy(struct cpufreq_policy *policy)
{
+ struct cpudata *cpu = all_cpu_data[policy->cpu];
+ struct perf_limits *perf_limits;
+
+ if (policy->policy == CPUFREQ_POLICY_PERFORMANCE)
+ perf_limits = &performance_limits;
+ else
+ perf_limits = &powersave_limits;
+
+ update_turbo_state();
+ policy->cpuinfo.max_freq = perf_limits->turbo_disabled ||
+ perf_limits->no_turbo ?
+ cpu->pstate.max_freq :
+ cpu->pstate.turbo_freq;
+
cpufreq_verify_within_cpu_limits(policy);
if (policy->policy != CPUFREQ_POLICY_POWERSAVE &&
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/4] cpufreq: intel_pstate: Make HWP limits compatible with legacy
2017-01-18 18:48 [PATCH 0/4] Fixes for limits enforcement Srinivas Pandruvada
2017-01-18 18:48 ` [PATCH 1/4] cpufreq: intel_pstate: Fix sysfs limits enforcement for performance policy Srinivas Pandruvada
2017-01-18 18:48 ` [PATCH 2/4] cpufreq: intel_pstate: Lower frequency than expected under no_turbo Srinivas Pandruvada
@ 2017-01-18 18:48 ` Srinivas Pandruvada
2017-01-18 18:48 ` [PATCH 4/4] cpufreq: intel_pstate: Calculate guaranteed performance for HWP Srinivas Pandruvada
2017-01-20 2:13 ` [PATCH 0/4] Fixes for limits enforcement Rafael J. Wysocki
4 siblings, 0 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2017-01-18 18:48 UTC (permalink / raw)
To: rjw, len.brown; +Cc: linux-kernel, linux-pm, Srinivas Pandruvada
Under HWP the performance limits are calculated using max_perf_pct
and min_perf_pct using possible performance, not available performance.
The available performance can be reduced by no_turbo setting. To make
compatible with legacy mode, use max/min performance percentage with
respect to available performance.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/cpufreq/intel_pstate.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index a5f1a04..095bcaf 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -873,7 +873,10 @@ static void intel_pstate_hwp_set(struct cpufreq_policy *policy)
rdmsrl_on_cpu(cpu, MSR_HWP_CAPABILITIES, &cap);
hw_min = HWP_LOWEST_PERF(cap);
- hw_max = HWP_HIGHEST_PERF(cap);
+ if (limits->no_turbo)
+ hw_max = HWP_GUARANTEED_PERF(cap);
+ else
+ hw_max = HWP_HIGHEST_PERF(cap);
range = hw_max - hw_min;
max_perf_pct = perf_limits->max_perf_pct;
@@ -887,11 +890,6 @@ static void intel_pstate_hwp_set(struct cpufreq_policy *policy)
adj_range = max_perf_pct * range / 100;
max = hw_min + adj_range;
- if (limits->no_turbo) {
- hw_max = HWP_GUARANTEED_PERF(cap);
- if (hw_max < max)
- max = hw_max;
- }
value &= ~HWP_MAX_PERF(~0L);
value |= HWP_MAX_PERF(max);
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/4] cpufreq: intel_pstate: Calculate guaranteed performance for HWP
2017-01-18 18:48 [PATCH 0/4] Fixes for limits enforcement Srinivas Pandruvada
` (2 preceding siblings ...)
2017-01-18 18:48 ` [PATCH 3/4] cpufreq: intel_pstate: Make HWP limits compatible with legacy Srinivas Pandruvada
@ 2017-01-18 18:48 ` Srinivas Pandruvada
2017-01-20 2:13 ` [PATCH 0/4] Fixes for limits enforcement Rafael J. Wysocki
4 siblings, 0 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2017-01-18 18:48 UTC (permalink / raw)
To: rjw, len.brown; +Cc: linux-kernel, linux-pm, Srinivas Pandruvada
When HWP is active, turbo activation ratio is not used to calculate max
non turbo ratio. But on these systems the max non turbo ratio is decided
by config TDP settings.
This change removes usage of MSR_TURBO_ACTIVATION_RATIO for HWP systems,
instead directly use TDP ratios, when more than one TDPs are available.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/cpufreq/intel_pstate.c | 75 +++++++++++++++++++++++++++---------------
1 file changed, 49 insertions(+), 26 deletions(-)
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 095bcaf..694c1a3 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1343,48 +1343,71 @@ static int core_get_max_pstate_physical(void)
return (value >> 8) & 0xFF;
}
+static int core_get_tdp_ratio(u64 plat_info)
+{
+ /* Check how many TDP levels present */
+ if (plat_info & 0x600000000) {
+ u64 tdp_ctrl;
+ u64 tdp_ratio;
+ int tdp_msr;
+ int err;
+
+ /* Get the TDP level (0, 1, 2) to get ratios */
+ err = rdmsrl_safe(MSR_CONFIG_TDP_CONTROL, &tdp_ctrl);
+ if (err)
+ return err;
+
+ /* TDP MSR are continuous starting at 0x648 */
+ tdp_msr = MSR_CONFIG_TDP_NOMINAL + (tdp_ctrl & 0x3);
+ err = rdmsrl_safe(tdp_msr, &tdp_ratio);
+ if (err)
+ return err;
+
+ /* For level 1 and 2, bits[23:16] contain the ratio */
+ if (tdp_ctrl)
+ tdp_ratio >>= 16;
+
+ tdp_ratio &= 0xff; /* ratios are only 8 bits long */
+ pr_debug("tdp_ratio %x\n", (int)tdp_ratio);
+
+ return (int)tdp_ratio;
+ }
+
+ return -ENXIO;
+}
+
static int core_get_max_pstate(void)
{
u64 tar;
u64 plat_info;
int max_pstate;
+ int tdp_ratio;
int err;
rdmsrl(MSR_PLATFORM_INFO, plat_info);
max_pstate = (plat_info >> 8) & 0xFF;
+ tdp_ratio = core_get_tdp_ratio(plat_info);
+ if (tdp_ratio < 0)
+ return max_pstate;
+
+ if (hwp_active) {
+ /* Turbo activation ratio is not used on HWP platforms */
+ return tdp_ratio;
+ }
+
err = rdmsrl_safe(MSR_TURBO_ACTIVATION_RATIO, &tar);
if (!err) {
+ int tar_levels;
+
/* Do some sanity checking for safety */
- if (plat_info & 0x600000000) {
- u64 tdp_ctrl;
- u64 tdp_ratio;
- int tdp_msr;
-
- err = rdmsrl_safe(MSR_CONFIG_TDP_CONTROL, &tdp_ctrl);
- if (err)
- goto skip_tar;
-
- tdp_msr = MSR_CONFIG_TDP_NOMINAL + (tdp_ctrl & 0x3);
- err = rdmsrl_safe(tdp_msr, &tdp_ratio);
- if (err)
- goto skip_tar;
-
- /* For level 1 and 2, bits[23:16] contain the ratio */
- if (tdp_ctrl)
- tdp_ratio >>= 16;
-
- tdp_ratio &= 0xff; /* ratios are only 8 bits long */
- if (tdp_ratio - 1 == tar) {
- max_pstate = tar;
- pr_debug("max_pstate=TAC %x\n", max_pstate);
- } else {
- goto skip_tar;
- }
+ tar_levels = tar & 0xff;
+ if (tdp_ratio - 1 == tar_levels) {
+ max_pstate = tar_levels;
+ pr_debug("max_pstate=TAC %x\n", max_pstate);
}
}
-skip_tar:
return max_pstate;
}
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] Fixes for limits enforcement
2017-01-18 18:48 [PATCH 0/4] Fixes for limits enforcement Srinivas Pandruvada
` (3 preceding siblings ...)
2017-01-18 18:48 ` [PATCH 4/4] cpufreq: intel_pstate: Calculate guaranteed performance for HWP Srinivas Pandruvada
@ 2017-01-20 2:13 ` Rafael J. Wysocki
4 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2017-01-20 2:13 UTC (permalink / raw)
To: Srinivas Pandruvada
Cc: Rafael J. Wysocki, Len Brown, Linux Kernel Mailing List, Linux PM
On Wed, Jan 18, 2017 at 7:48 PM, Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
> This series includes fixes for sysfs limits enforcement. Only the
> patch 1/4 is new in 4.10.rc, others are not new issues.
OK
I'll queue up the [1/4] as a fix for 4.10 and the rest for 4.11, then.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-01-20 2:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-18 18:48 [PATCH 0/4] Fixes for limits enforcement Srinivas Pandruvada
2017-01-18 18:48 ` [PATCH 1/4] cpufreq: intel_pstate: Fix sysfs limits enforcement for performance policy Srinivas Pandruvada
2017-01-18 18:48 ` [PATCH 2/4] cpufreq: intel_pstate: Lower frequency than expected under no_turbo Srinivas Pandruvada
2017-01-18 18:48 ` [PATCH 3/4] cpufreq: intel_pstate: Make HWP limits compatible with legacy Srinivas Pandruvada
2017-01-18 18:48 ` [PATCH 4/4] cpufreq: intel_pstate: Calculate guaranteed performance for HWP Srinivas Pandruvada
2017-01-20 2:13 ` [PATCH 0/4] Fixes for limits enforcement Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®