aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2016-11-28 04:52:03 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-11-28 08:31:06 -0500
commita3605c46e0c05b117e5710d72128f74b779c2e76 (patch)
tree8602fa47f02a004935f39ac4bfa692c6adc1094c
parent4d66ddf28dd6e0582eeca0266651d1f5f5db431e (diff)
cpufreq: acpi-cpufreq: drop rdmsr_on_cpus() usage
The online / pre_down callback is invoked on the target CPU since commit 1cf4f629d9d2 ("cpu/hotplug: Move online calls to hotplugged cpu") which means for the hotplug callback we can use rmdsrl() instead of rdmsr_on_cpus(). This leaves us with set_boost() as the only user which still needs to read/write the MSR on different CPUs. There is no point in doing that update on all cpus with the read modify write magic via per cpu data. We simply can issue a function call on all online CPUs which also means that we need half that many IPIs. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/cpufreq/acpi-cpufreq.c59
1 files changed, 20 insertions, 39 deletions
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 52b25f2356f2..3a98702b7445 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -84,7 +84,6 @@ static inline struct acpi_processor_performance *to_perf_data(struct acpi_cpufre
84static struct cpufreq_driver acpi_cpufreq_driver; 84static struct cpufreq_driver acpi_cpufreq_driver;
85 85
86static unsigned int acpi_pstate_strict; 86static unsigned int acpi_pstate_strict;
87static struct msr __percpu *msrs;
88 87
89static bool boost_state(unsigned int cpu) 88static bool boost_state(unsigned int cpu)
90{ 89{
@@ -104,11 +103,10 @@ static bool boost_state(unsigned int cpu)
104 return false; 103 return false;
105} 104}
106 105
107static void boost_set_msrs(bool enable, const struct cpumask *cpumask) 106static int boost_set_msr(bool enable)
108{ 107{
109 u32 cpu;
110 u32 msr_addr; 108 u32 msr_addr;
111 u64 msr_mask; 109 u64 msr_mask, val;
112 110
113 switch (boot_cpu_data.x86_vendor) { 111 switch (boot_cpu_data.x86_vendor) {
114 case X86_VENDOR_INTEL: 112 case X86_VENDOR_INTEL:
@@ -120,26 +118,31 @@ static void boost_set_msrs(bool enable, const struct cpumask *cpumask)
120 msr_mask = MSR_K7_HWCR_CPB_DIS; 118 msr_mask = MSR_K7_HWCR_CPB_DIS;
121 break; 119 break;
122 default: 120 default:
123 return; 121 return -EINVAL;
124 } 122 }
125 123
126 rdmsr_on_cpus(cpumask, msr_addr, msrs); 124 rdmsrl(msr_addr, val);
127 125
128 for_each_cpu(cpu, cpumask) { 126 if (enable)
129 struct msr *reg = per_cpu_ptr(msrs, cpu); 127 val &= ~msr_mask;
130 if (enable) 128 else
131 reg->q &= ~msr_mask; 129 val |= msr_mask;
132 else
133 reg->q |= msr_mask;
134 }
135 130
136 wrmsr_on_cpus(cpumask, msr_addr, msrs); 131 wrmsrl(msr_addr, val);
132 return 0;
133}
134
135static void boost_set_msr_each(void *p_en)
136{
137 bool enable = (bool) p_en;
138
139 boost_set_msr(enable);
137} 140}
138 141
139static int set_boost(int val) 142static int set_boost(int val)
140{ 143{
141 get_online_cpus(); 144 get_online_cpus();
142 boost_set_msrs(val, cpu_online_mask); 145 on_each_cpu(boost_set_msr_each, (void *)(long)val, 1);
143 put_online_cpus(); 146 put_online_cpus();
144 pr_debug("Core Boosting %sabled.\n", val ? "en" : "dis"); 147 pr_debug("Core Boosting %sabled.\n", val ? "en" : "dis");
145 148
@@ -538,29 +541,20 @@ static void free_acpi_perf_data(void)
538 541
539static int cpufreq_boost_online(unsigned int cpu) 542static int cpufreq_boost_online(unsigned int cpu)
540{ 543{
541 const struct cpumask *cpumask;
542
543 cpumask = get_cpu_mask(cpu);
544 /* 544 /*
545 * On the CPU_UP path we simply keep the boost-disable flag 545 * On the CPU_UP path we simply keep the boost-disable flag
546 * in sync with the current global state. 546 * in sync with the current global state.
547 */ 547 */
548 boost_set_msrs(acpi_cpufreq_driver.boost_enabled, cpumask); 548 return boost_set_msr(acpi_cpufreq_driver.boost_enabled);
549 return 0;
550} 549}
551 550
552static int cpufreq_boost_down_prep(unsigned int cpu) 551static int cpufreq_boost_down_prep(unsigned int cpu)
553{ 552{
554 const struct cpumask *cpumask;
555
556 cpumask = get_cpu_mask(cpu);
557
558 /* 553 /*
559 * Clear the boost-disable bit on the CPU_DOWN path so that 554 * Clear the boost-disable bit on the CPU_DOWN path so that
560 * this cpu cannot block the remaining ones from boosting. 555 * this cpu cannot block the remaining ones from boosting.
561 */ 556 */
562 boost_set_msrs(1, cpumask); 557 return boost_set_msr(1);
563 return 0;
564} 558}
565 559
566/* 560/*
@@ -918,11 +912,6 @@ static void __init acpi_cpufreq_boost_init(void)
918 if (!(boot_cpu_has(X86_FEATURE_CPB) || boot_cpu_has(X86_FEATURE_IDA))) 912 if (!(boot_cpu_has(X86_FEATURE_CPB) || boot_cpu_has(X86_FEATURE_IDA)))
919 return; 913 return;
920 914
921 msrs = msrs_alloc();
922
923 if (!msrs)
924 return;
925
926 acpi_cpufreq_driver.set_boost = set_boost; 915 acpi_cpufreq_driver.set_boost = set_boost;
927 acpi_cpufreq_driver.boost_enabled = boost_state(0); 916 acpi_cpufreq_driver.boost_enabled = boost_state(0);
928 917
@@ -934,8 +923,6 @@ static void __init acpi_cpufreq_boost_init(void)
934 cpufreq_boost_online, cpufreq_boost_down_prep); 923 cpufreq_boost_online, cpufreq_boost_down_prep);
935 if (ret < 0) { 924 if (ret < 0) {
936 pr_err("acpi_cpufreq: failed to register hotplug callbacks\n"); 925 pr_err("acpi_cpufreq: failed to register hotplug callbacks\n");
937 msrs_free(msrs);
938 msrs = NULL;
939 return; 926 return;
940 } 927 }
941 acpi_cpufreq_online = ret; 928 acpi_cpufreq_online = ret;
@@ -943,14 +930,8 @@ static void __init acpi_cpufreq_boost_init(void)
943 930
944static void acpi_cpufreq_boost_exit(void) 931static void acpi_cpufreq_boost_exit(void)
945{ 932{
946 if (!msrs)
947 return;
948
949 if (acpi_cpufreq_online >= 0) 933 if (acpi_cpufreq_online >= 0)
950 cpuhp_remove_state_nocalls(acpi_cpufreq_online); 934 cpuhp_remove_state_nocalls(acpi_cpufreq_online);
951
952 msrs_free(msrs);
953 msrs = NULL;
954} 935}
955 936
956static int __init acpi_cpufreq_init(void) 937static int __init acpi_cpufreq_init(void)