Commit 20910442 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branch 'pm-cpufreq'

* pm-cpufreq:
  cpufreq: Makefile: fix compilation for davinci platform
  intel_pstate: Set CPU number before accessing MSRs
  intel_pstate: Update documentation of {max,min}_perf_pct sysfs files
  intel_pstate: don't touch turbo bit if turbo disabled or unavailable.
  intel_pstate: Fix setting VID
parents ff253d3d 5a90af67
...@@ -15,10 +15,13 @@ New sysfs files for controlling P state selection have been added to ...@@ -15,10 +15,13 @@ New sysfs files for controlling P state selection have been added to
/sys/devices/system/cpu/intel_pstate/ /sys/devices/system/cpu/intel_pstate/
max_perf_pct: limits the maximum P state that will be requested by max_perf_pct: limits the maximum P state that will be requested by
the driver stated as a percentage of the available performance. the driver stated as a percentage of the available performance. The
available (P states) performance may be reduced by the no_turbo
setting described below.
min_perf_pct: limits the minimum P state that will be requested by min_perf_pct: limits the minimum P state that will be requested by
the driver stated as a percentage of the available performance. the driver stated as a percentage of the max (non-turbo)
performance level.
no_turbo: limits the driver to selecting P states below the turbo no_turbo: limits the driver to selecting P states below the turbo
frequency range. frequency range.
......
...@@ -49,7 +49,7 @@ obj-$(CONFIG_ARM_BIG_LITTLE_CPUFREQ) += arm_big_little.o ...@@ -49,7 +49,7 @@ obj-$(CONFIG_ARM_BIG_LITTLE_CPUFREQ) += arm_big_little.o
# LITTLE drivers, so that it is probed last. # LITTLE drivers, so that it is probed last.
obj-$(CONFIG_ARM_DT_BL_CPUFREQ) += arm_big_little_dt.o obj-$(CONFIG_ARM_DT_BL_CPUFREQ) += arm_big_little_dt.o
obj-$(CONFIG_ARCH_DAVINCI_DA850) += davinci-cpufreq.o obj-$(CONFIG_ARCH_DAVINCI) += davinci-cpufreq.o
obj-$(CONFIG_UX500_SOC_DB8500) += dbx500-cpufreq.o obj-$(CONFIG_UX500_SOC_DB8500) += dbx500-cpufreq.o
obj-$(CONFIG_ARM_EXYNOS_CPUFREQ) += exynos-cpufreq.o obj-$(CONFIG_ARM_EXYNOS_CPUFREQ) += exynos-cpufreq.o
obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ) += exynos4210-cpufreq.o obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ) += exynos4210-cpufreq.o
......
...@@ -128,6 +128,7 @@ static struct pstate_funcs pstate_funcs; ...@@ -128,6 +128,7 @@ static struct pstate_funcs pstate_funcs;
struct perf_limits { struct perf_limits {
int no_turbo; int no_turbo;
int turbo_disabled;
int max_perf_pct; int max_perf_pct;
int min_perf_pct; int min_perf_pct;
int32_t max_perf; int32_t max_perf;
...@@ -287,7 +288,10 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b, ...@@ -287,7 +288,10 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
if (ret != 1) if (ret != 1)
return -EINVAL; return -EINVAL;
limits.no_turbo = clamp_t(int, input, 0 , 1); limits.no_turbo = clamp_t(int, input, 0 , 1);
if (limits.turbo_disabled) {
pr_warn("Turbo disabled by BIOS or unavailable on processor\n");
limits.no_turbo = limits.turbo_disabled;
}
return count; return count;
} }
...@@ -357,21 +361,21 @@ static int byt_get_min_pstate(void) ...@@ -357,21 +361,21 @@ static int byt_get_min_pstate(void)
{ {
u64 value; u64 value;
rdmsrl(BYT_RATIOS, value); rdmsrl(BYT_RATIOS, value);
return (value >> 8) & 0x3F; return (value >> 8) & 0x7F;
} }
static int byt_get_max_pstate(void) static int byt_get_max_pstate(void)
{ {
u64 value; u64 value;
rdmsrl(BYT_RATIOS, value); rdmsrl(BYT_RATIOS, value);
return (value >> 16) & 0x3F; return (value >> 16) & 0x7F;
} }
static int byt_get_turbo_pstate(void) static int byt_get_turbo_pstate(void)
{ {
u64 value; u64 value;
rdmsrl(BYT_TURBO_RATIOS, value); rdmsrl(BYT_TURBO_RATIOS, value);
return value & 0x3F; return value & 0x7F;
} }
static void byt_set_pstate(struct cpudata *cpudata, int pstate) static void byt_set_pstate(struct cpudata *cpudata, int pstate)
...@@ -381,7 +385,7 @@ static void byt_set_pstate(struct cpudata *cpudata, int pstate) ...@@ -381,7 +385,7 @@ static void byt_set_pstate(struct cpudata *cpudata, int pstate)
u32 vid; u32 vid;
val = pstate << 8; val = pstate << 8;
if (limits.no_turbo) if (limits.no_turbo && !limits.turbo_disabled)
val |= (u64)1 << 32; val |= (u64)1 << 32;
vid_fp = cpudata->vid.min + mul_fp( vid_fp = cpudata->vid.min + mul_fp(
...@@ -405,8 +409,8 @@ static void byt_get_vid(struct cpudata *cpudata) ...@@ -405,8 +409,8 @@ static void byt_get_vid(struct cpudata *cpudata)
rdmsrl(BYT_VIDS, value); rdmsrl(BYT_VIDS, value);
cpudata->vid.min = int_tofp((value >> 8) & 0x3f); cpudata->vid.min = int_tofp((value >> 8) & 0x7f);
cpudata->vid.max = int_tofp((value >> 16) & 0x3f); cpudata->vid.max = int_tofp((value >> 16) & 0x7f);
cpudata->vid.ratio = div_fp( cpudata->vid.ratio = div_fp(
cpudata->vid.max - cpudata->vid.min, cpudata->vid.max - cpudata->vid.min,
int_tofp(cpudata->pstate.max_pstate - int_tofp(cpudata->pstate.max_pstate -
...@@ -448,7 +452,7 @@ static void core_set_pstate(struct cpudata *cpudata, int pstate) ...@@ -448,7 +452,7 @@ static void core_set_pstate(struct cpudata *cpudata, int pstate)
u64 val; u64 val;
val = pstate << 8; val = pstate << 8;
if (limits.no_turbo) if (limits.no_turbo && !limits.turbo_disabled)
val |= (u64)1 << 32; val |= (u64)1 << 32;
wrmsrl_on_cpu(cpudata->cpu, MSR_IA32_PERF_CTL, val); wrmsrl_on_cpu(cpudata->cpu, MSR_IA32_PERF_CTL, val);
...@@ -696,9 +700,8 @@ static int intel_pstate_init_cpu(unsigned int cpunum) ...@@ -696,9 +700,8 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
cpu = all_cpu_data[cpunum]; cpu = all_cpu_data[cpunum];
intel_pstate_get_cpu_pstates(cpu);
cpu->cpu = cpunum; cpu->cpu = cpunum;
intel_pstate_get_cpu_pstates(cpu);
init_timer_deferrable(&cpu->timer); init_timer_deferrable(&cpu->timer);
cpu->timer.function = intel_pstate_timer_func; cpu->timer.function = intel_pstate_timer_func;
...@@ -741,7 +744,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) ...@@ -741,7 +744,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
limits.min_perf = int_tofp(1); limits.min_perf = int_tofp(1);
limits.max_perf_pct = 100; limits.max_perf_pct = 100;
limits.max_perf = int_tofp(1); limits.max_perf = int_tofp(1);
limits.no_turbo = 0; limits.no_turbo = limits.turbo_disabled;
return 0; return 0;
} }
limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq; limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq;
...@@ -784,6 +787,7 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy) ...@@ -784,6 +787,7 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
{ {
struct cpudata *cpu; struct cpudata *cpu;
int rc; int rc;
u64 misc_en;
rc = intel_pstate_init_cpu(policy->cpu); rc = intel_pstate_init_cpu(policy->cpu);
if (rc) if (rc)
...@@ -791,8 +795,13 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy) ...@@ -791,8 +795,13 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
cpu = all_cpu_data[policy->cpu]; cpu = all_cpu_data[policy->cpu];
if (!limits.no_turbo && rdmsrl(MSR_IA32_MISC_ENABLE, misc_en);
limits.min_perf_pct == 100 && limits.max_perf_pct == 100) if (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ||
cpu->pstate.max_pstate == cpu->pstate.turbo_pstate) {
limits.turbo_disabled = 1;
limits.no_turbo = 1;
}
if (limits.min_perf_pct == 100 && limits.max_perf_pct == 100)
policy->policy = CPUFREQ_POLICY_PERFORMANCE; policy->policy = CPUFREQ_POLICY_PERFORMANCE;
else else
policy->policy = CPUFREQ_POLICY_POWERSAVE; policy->policy = CPUFREQ_POLICY_POWERSAVE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment