diff options
| -rw-r--r-- | Documentation/cpu-freq/governors.txt | 21 | ||||
| -rw-r--r-- | arch/x86/include/asm/cpufeature.h | 1 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/scattered.c | 3 | ||||
| -rw-r--r-- | drivers/cpufreq/Kconfig.x86 | 17 | ||||
| -rw-r--r-- | drivers/cpufreq/Makefile | 1 | ||||
| -rw-r--r-- | drivers/cpufreq/amd_freq_sensitivity.c | 148 |
6 files changed, 190 insertions, 1 deletions
diff --git a/Documentation/cpu-freq/governors.txt b/Documentation/cpu-freq/governors.txt index 4dfed30b7fda..66f9cc310686 100644 --- a/Documentation/cpu-freq/governors.txt +++ b/Documentation/cpu-freq/governors.txt | |||
| @@ -167,6 +167,27 @@ of load evaluation and helping the CPU stay at its top speed when truly | |||
| 167 | busy, rather than shifting back and forth in speed. This tunable has no | 167 | busy, rather than shifting back and forth in speed. This tunable has no |
| 168 | effect on behavior at lower speeds/lower CPU loads. | 168 | effect on behavior at lower speeds/lower CPU loads. |
| 169 | 169 | ||
| 170 | powersave_bias: this parameter takes a value between 0 to 1000. It | ||
| 171 | defines the percentage (times 10) value of the target frequency that | ||
| 172 | will be shaved off of the target. For example, when set to 100 -- 10%, | ||
| 173 | when ondemand governor would have targeted 1000 MHz, it will target | ||
| 174 | 1000 MHz - (10% of 1000 MHz) = 900 MHz instead. This is set to 0 | ||
| 175 | (disabled) by default. | ||
| 176 | When AMD frequency sensitivity powersave bias driver -- | ||
| 177 | drivers/cpufreq/amd_freq_sensitivity.c is loaded, this parameter | ||
| 178 | defines the workload frequency sensitivity threshold in which a lower | ||
| 179 | frequency is chosen instead of ondemand governor's original target. | ||
| 180 | The frequency sensitivity is a hardware reported (on AMD Family 16h | ||
| 181 | Processors and above) value between 0 to 100% that tells software how | ||
| 182 | the performance of the workload running on a CPU will change when | ||
| 183 | frequency changes. A workload with sensitivity of 0% (memory/IO-bound) | ||
| 184 | will not perform any better on higher core frequency, whereas a | ||
| 185 | workload with sensitivity of 100% (CPU-bound) will perform better | ||
| 186 | higher the frequency. When the driver is loaded, this is set to 400 | ||
| 187 | by default -- for CPUs running workloads with sensitivity value below | ||
| 188 | 40%, a lower frequency is chosen. Unloading the driver or writing 0 | ||
| 189 | will disable this feature. | ||
| 190 | |||
| 170 | 191 | ||
| 171 | 2.5 Conservative | 192 | 2.5 Conservative |
| 172 | ---------------- | 193 | ---------------- |
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 93fe929d1cee..9e22520a97ee 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h | |||
| @@ -182,6 +182,7 @@ | |||
| 182 | #define X86_FEATURE_PTS (7*32+ 6) /* Intel Package Thermal Status */ | 182 | #define X86_FEATURE_PTS (7*32+ 6) /* Intel Package Thermal Status */ |
| 183 | #define X86_FEATURE_DTHERM (7*32+ 7) /* Digital Thermal Sensor */ | 183 | #define X86_FEATURE_DTHERM (7*32+ 7) /* Digital Thermal Sensor */ |
| 184 | #define X86_FEATURE_HW_PSTATE (7*32+ 8) /* AMD HW-PState */ | 184 | #define X86_FEATURE_HW_PSTATE (7*32+ 8) /* AMD HW-PState */ |
| 185 | #define X86_FEATURE_PROC_FEEDBACK (7*32+ 9) /* AMD ProcFeedbackInterface */ | ||
| 185 | 186 | ||
| 186 | /* Virtualization flags: Linux defined, word 8 */ | 187 | /* Virtualization flags: Linux defined, word 8 */ |
| 187 | #define X86_FEATURE_TPR_SHADOW (8*32+ 0) /* Intel TPR Shadow */ | 188 | #define X86_FEATURE_TPR_SHADOW (8*32+ 0) /* Intel TPR Shadow */ |
diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index ee8e9abc859f..d92b5dad15dd 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c | |||
| @@ -39,8 +39,9 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c) | |||
| 39 | { X86_FEATURE_APERFMPERF, CR_ECX, 0, 0x00000006, 0 }, | 39 | { X86_FEATURE_APERFMPERF, CR_ECX, 0, 0x00000006, 0 }, |
| 40 | { X86_FEATURE_EPB, CR_ECX, 3, 0x00000006, 0 }, | 40 | { X86_FEATURE_EPB, CR_ECX, 3, 0x00000006, 0 }, |
| 41 | { X86_FEATURE_XSAVEOPT, CR_EAX, 0, 0x0000000d, 1 }, | 41 | { X86_FEATURE_XSAVEOPT, CR_EAX, 0, 0x0000000d, 1 }, |
| 42 | { X86_FEATURE_CPB, CR_EDX, 9, 0x80000007, 0 }, | ||
| 43 | { X86_FEATURE_HW_PSTATE, CR_EDX, 7, 0x80000007, 0 }, | 42 | { X86_FEATURE_HW_PSTATE, CR_EDX, 7, 0x80000007, 0 }, |
| 43 | { X86_FEATURE_CPB, CR_EDX, 9, 0x80000007, 0 }, | ||
| 44 | { X86_FEATURE_PROC_FEEDBACK, CR_EDX,11, 0x80000007, 0 }, | ||
| 44 | { X86_FEATURE_NPT, CR_EDX, 0, 0x8000000a, 0 }, | 45 | { X86_FEATURE_NPT, CR_EDX, 0, 0x8000000a, 0 }, |
| 45 | { X86_FEATURE_LBRV, CR_EDX, 1, 0x8000000a, 0 }, | 46 | { X86_FEATURE_LBRV, CR_EDX, 1, 0x8000000a, 0 }, |
| 46 | { X86_FEATURE_SVML, CR_EDX, 2, 0x8000000a, 0 }, | 47 | { X86_FEATURE_SVML, CR_EDX, 2, 0x8000000a, 0 }, |
diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86 index d7dc0ed6adb0..2b8a8c374548 100644 --- a/drivers/cpufreq/Kconfig.x86 +++ b/drivers/cpufreq/Kconfig.x86 | |||
| @@ -129,6 +129,23 @@ config X86_POWERNOW_K8 | |||
| 129 | 129 | ||
| 130 | For details, take a look at <file:Documentation/cpu-freq/>. | 130 | For details, take a look at <file:Documentation/cpu-freq/>. |
| 131 | 131 | ||
| 132 | config X86_AMD_FREQ_SENSITIVITY | ||
| 133 | tristate "AMD frequency sensitivity feedback powersave bias" | ||
| 134 | depends on CPU_FREQ_GOV_ONDEMAND && X86_ACPI_CPUFREQ && CPU_SUP_AMD | ||
| 135 | help | ||
| 136 | This adds AMD-specific powersave bias function to the ondemand | ||
| 137 | governor, which allows it to make more power-conscious frequency | ||
| 138 | change decisions based on feedback from hardware (availble on AMD | ||
| 139 | Family 16h and above). | ||
| 140 | |||
| 141 | Hardware feedback tells software how "sensitive" to frequency changes | ||
| 142 | the CPUs' workloads are. CPU-bound workloads will be more sensitive | ||
| 143 | -- they will perform better as frequency increases. Memory/IO-bound | ||
| 144 | workloads will be less sensitive -- they will not necessarily perform | ||
| 145 | better as frequency increases. | ||
| 146 | |||
| 147 | If in doubt, say N. | ||
| 148 | |||
| 132 | config X86_GX_SUSPMOD | 149 | config X86_GX_SUSPMOD |
| 133 | tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation" | 150 | tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation" |
| 134 | depends on X86_32 && PCI | 151 | depends on X86_32 && PCI |
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index 17417c7ee135..a264dd302c34 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile | |||
| @@ -41,6 +41,7 @@ obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o | |||
| 41 | obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o | 41 | obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o |
| 42 | obj-$(CONFIG_X86_CPUFREQ_NFORCE2) += cpufreq-nforce2.o | 42 | obj-$(CONFIG_X86_CPUFREQ_NFORCE2) += cpufreq-nforce2.o |
| 43 | obj-$(CONFIG_X86_INTEL_PSTATE) += intel_pstate.o | 43 | obj-$(CONFIG_X86_INTEL_PSTATE) += intel_pstate.o |
| 44 | obj-$(CONFIG_X86_AMD_FREQ_SENSITIVITY) += amd_freq_sensitivity.o | ||
| 44 | 45 | ||
| 45 | ################################################################################## | 46 | ################################################################################## |
| 46 | # ARM SoC drivers | 47 | # ARM SoC drivers |
diff --git a/drivers/cpufreq/amd_freq_sensitivity.c b/drivers/cpufreq/amd_freq_sensitivity.c new file mode 100644 index 000000000000..f6b79ab0070b --- /dev/null +++ b/drivers/cpufreq/amd_freq_sensitivity.c | |||
| @@ -0,0 +1,148 @@ | |||
| 1 | /* | ||
| 2 | * amd_freq_sensitivity.c: AMD frequency sensitivity feedback powersave bias | ||
| 3 | * for the ondemand governor. | ||
| 4 | * | ||
| 5 | * Copyright (C) 2013 Advanced Micro Devices, Inc. | ||
| 6 | * | ||
| 7 | * Author: Jacob Shin <jacob.shin@amd.com> | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License version 2 as | ||
| 11 | * published by the Free Software Foundation. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/kernel.h> | ||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/types.h> | ||
| 17 | #include <linux/percpu-defs.h> | ||
| 18 | #include <linux/init.h> | ||
| 19 | #include <linux/mod_devicetable.h> | ||
| 20 | |||
| 21 | #include <asm/msr.h> | ||
| 22 | #include <asm/cpufeature.h> | ||
| 23 | |||
| 24 | #include "cpufreq_governor.h" | ||
| 25 | |||
| 26 | #define MSR_AMD64_FREQ_SENSITIVITY_ACTUAL 0xc0010080 | ||
| 27 | #define MSR_AMD64_FREQ_SENSITIVITY_REFERENCE 0xc0010081 | ||
| 28 | #define CLASS_CODE_SHIFT 56 | ||
| 29 | #define POWERSAVE_BIAS_MAX 1000 | ||
| 30 | #define POWERSAVE_BIAS_DEF 400 | ||
| 31 | |||
| 32 | struct cpu_data_t { | ||
| 33 | u64 actual; | ||
| 34 | u64 reference; | ||
| 35 | unsigned int freq_prev; | ||
| 36 | }; | ||
| 37 | |||
| 38 | static DEFINE_PER_CPU(struct cpu_data_t, cpu_data); | ||
| 39 | |||
| 40 | static unsigned int amd_powersave_bias_target(struct cpufreq_policy *policy, | ||
| 41 | unsigned int freq_next, | ||
| 42 | unsigned int relation) | ||
| 43 | { | ||
| 44 | int sensitivity; | ||
| 45 | long d_actual, d_reference; | ||
| 46 | struct msr actual, reference; | ||
| 47 | struct cpu_data_t *data = &per_cpu(cpu_data, policy->cpu); | ||
| 48 | struct dbs_data *od_data = policy->governor_data; | ||
| 49 | struct od_dbs_tuners *od_tuners = od_data->tuners; | ||
| 50 | struct od_cpu_dbs_info_s *od_info = | ||
| 51 | od_data->cdata->get_cpu_dbs_info_s(policy->cpu); | ||
| 52 | |||
| 53 | if (!od_info->freq_table) | ||
| 54 | return freq_next; | ||
| 55 | |||
| 56 | rdmsr_on_cpu(policy->cpu, MSR_AMD64_FREQ_SENSITIVITY_ACTUAL, | ||
| 57 | &actual.l, &actual.h); | ||
| 58 | rdmsr_on_cpu(policy->cpu, MSR_AMD64_FREQ_SENSITIVITY_REFERENCE, | ||
| 59 | &reference.l, &reference.h); | ||
| 60 | actual.h &= 0x00ffffff; | ||
| 61 | reference.h &= 0x00ffffff; | ||
| 62 | |||
| 63 | /* counter wrapped around, so stay on current frequency */ | ||
| 64 | if (actual.q < data->actual || reference.q < data->reference) { | ||
| 65 | freq_next = policy->cur; | ||
| 66 | goto out; | ||
| 67 | } | ||
| 68 | |||
| 69 | d_actual = actual.q - data->actual; | ||
| 70 | d_reference = reference.q - data->reference; | ||
| 71 | |||
| 72 | /* divide by 0, so stay on current frequency as well */ | ||
| 73 | if (d_reference == 0) { | ||
| 74 | freq_next = policy->cur; | ||
| 75 | goto out; | ||
| 76 | } | ||
| 77 | |||
