Skip to content

Commit 66b00a7

Browse files
committed
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq
* 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq: [CPUFREQ] Fix stale cpufreq_cpu_governor pointer [CPUFREQ] Resolve time unit thinko in ondemand/conservative govs [CPUFREQ] speedstep-ich: fix error caused by 394122a [CPUFREQ] Fix use after free on governor restore [CPUFREQ] acpi-cpufreq: blacklist Intel 0f68: Fix HT detection and put in notification message [CPUFREQ] powernow-k8: Fix test in get_transition_latency() [CPUFREQ] longhaul: select Longhaul version 2 for capable CPUs
2 parents a414f01 + 90e41ba commit 66b00a7

7 files changed

Lines changed: 70 additions & 32 deletions

File tree

‎arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,15 +526,21 @@ static const struct dmi_system_id sw_any_bug_dmi_table[] = {
526526

527527
static int acpi_cpufreq_blacklist(struct cpuinfo_x86 *c)
528528
{
529-
/* http://www.intel.com/Assets/PDF/specupdate/314554.pdf
529+
/* Intel Xeon Processor 7100 Series Specification Update
530+
* http://www.intel.com/Assets/PDF/specupdate/314554.pdf
530531
* AL30: A Machine Check Exception (MCE) Occurring during an
531532
* Enhanced Intel SpeedStep Technology Ratio Change May Cause
532-
* Both Processor Cores to Lock Up when HT is enabled*/
533+
* Both Processor Cores to Lock Up. */
533534
if (c->x86_vendor == X86_VENDOR_INTEL) {
534535
if ((c->x86 == 15) &&
535536
(c->x86_model == 6) &&
536-
(c->x86_mask == 8) && smt_capable())
537+
(c->x86_mask == 8)) {
538+
printk(KERN_INFO "acpi-cpufreq: Intel(R) "
539+
"Xeon(R) 7100 Errata AL30, processors may "
540+
"lock up on frequency changes: disabling "
541+
"acpi-cpufreq.\n");
537542
return -ENODEV;
543+
}
538544
}
539545
return 0;
540546
}
@@ -549,13 +555,18 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
549555
unsigned int result = 0;
550556
struct cpuinfo_x86 *c = &cpu_data(policy->cpu);
551557
struct acpi_processor_performance *perf;
558+
#ifdef CONFIG_SMP
559+
static int blacklisted;
560+
#endif
552561

553562
dprintk("acpi_cpufreq_cpu_init\n");
554563

555564
#ifdef CONFIG_SMP
556-
result = acpi_cpufreq_blacklist(c);
557-
if (result)
558-
return result;
565+
if (blacklisted)
566+
return blacklisted;
567+
blacklisted = acpi_cpufreq_blacklist(c);
568+
if (blacklisted)
569+
return blacklisted;
559570
#endif
560571

561572
data = kzalloc(sizeof(struct acpi_cpufreq_data), GFP_KERNEL);

‎arch/x86/kernel/cpu/cpufreq/longhaul.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
813813
memcpy(eblcr, samuel2_eblcr, sizeof(samuel2_eblcr));
814814
break;
815815
case 1 ... 15:
816-
longhaul_version = TYPE_LONGHAUL_V1;
816+
longhaul_version = TYPE_LONGHAUL_V2;
817817
if (c->x86_mask < 8) {
818818
cpu_model = CPU_SAMUEL2;
819819
cpuname = "C3 'Samuel 2' [C5B]";

‎arch/x86/kernel/cpu/cpufreq/powernow-k8.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ static int get_transition_latency(struct powernow_k8_data *data)
10221022
* set it to 1 to avoid problems in the future.
10231023
* For all others it's a BIOS bug.
10241024
*/
1025-
if (!boot_cpu_data.x86 == 0x11)
1025+
if (boot_cpu_data.x86 != 0x11)
10261026
printk(KERN_ERR FW_WARN PFX "Invalid zero transition "
10271027
"latency\n");
10281028
max_latency = 1;

‎arch/x86/kernel/cpu/cpufreq/speedstep-ich.c‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -232,28 +232,23 @@ static unsigned int speedstep_detect_chipset(void)
232232
return 0;
233233
}
234234

235-
struct get_freq_data {
236-
unsigned int speed;
237-
unsigned int processor;
238-
};
239-
240-
static void get_freq_data(void *_data)
235+
static void get_freq_data(void *_speed)
241236
{
242-
struct get_freq_data *data = _data;
237+
unsigned int *speed = _speed;
243238

244-
data->speed = speedstep_get_frequency(data->processor);
239+
*speed = speedstep_get_frequency(speedstep_processor);
245240
}
246241

247242
static unsigned int speedstep_get(unsigned int cpu)
248243
{
249-
struct get_freq_data data = { .processor = cpu };
244+
unsigned int speed;
250245

251246
/* You're supposed to ensure CPU is online. */
252-
if (smp_call_function_single(cpu, get_freq_data, &data, 1) != 0)
247+
if (smp_call_function_single(cpu, get_freq_data, &speed, 1) != 0)
253248
BUG();
254249

255-
dprintk("detected %u kHz as current frequency\n", data.speed);
256-
return data.speed;
250+
dprintk("detected %u kHz as current frequency\n", speed);
251+
return speed;
257252
}
258253

259254
/**

‎drivers/cpufreq/cpufreq.c‎

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static struct cpufreq_driver *cpufreq_driver;
4141
static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data);
4242
#ifdef CONFIG_HOTPLUG_CPU
4343
/* This one keeps track of the previously set governor of a removed CPU */
44-
static DEFINE_PER_CPU(struct cpufreq_governor *, cpufreq_cpu_governor);
44+
static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor);
4545
#endif
4646
static DEFINE_SPINLOCK(cpufreq_driver_lock);
4747

@@ -774,10 +774,12 @@ int cpufreq_add_dev_policy(unsigned int cpu, struct cpufreq_policy *policy,
774774
#ifdef CONFIG_SMP
775775
unsigned long flags;
776776
unsigned int j;
777-
778777
#ifdef CONFIG_HOTPLUG_CPU
779-
if (per_cpu(cpufreq_cpu_governor, cpu)) {
780-
policy->governor = per_cpu(cpufreq_cpu_governor, cpu);
778+
struct cpufreq_governor *gov;
779+
780+
gov = __find_governor(per_cpu(cpufreq_cpu_governor, cpu));
781+
if (gov) {
782+
policy->governor = gov;
781783
dprintk("Restoring governor %s for cpu %d\n",
782784
policy->governor->name, cpu);
783785
}
@@ -949,10 +951,13 @@ int cpufreq_add_dev_interface(unsigned int cpu, struct cpufreq_policy *policy,
949951
static int cpufreq_add_dev(struct sys_device *sys_dev)
950952
{
951953
unsigned int cpu = sys_dev->id;
952-
int ret = 0;
954+
int ret = 0, found = 0;
953955
struct cpufreq_policy *policy;
954956
unsigned long flags;
955957
unsigned int j;
958+
#ifdef CONFIG_HOTPLUG_CPU
959+
int sibling;
960+
#endif
956961

957962
if (cpu_is_offline(cpu))
958963
return 0;
@@ -999,7 +1004,19 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
9991004
INIT_WORK(&policy->update, handle_update);
10001005

10011006
/* Set governor before ->init, so that driver could check it */
1002-
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
1007+
#ifdef CONFIG_HOTPLUG_CPU
1008+
for_each_online_cpu(sibling) {
1009+
struct cpufreq_policy *cp = per_cpu(cpufreq_cpu_data, sibling);
1010+
if (cp && cp->governor &&
1011+
(cpumask_test_cpu(cpu, cp->related_cpus))) {
1012+
policy->governor = cp->governor;
1013+
found = 1;
1014+
break;
1015+
}
1016+
}
1017+
#endif
1018+
if (!found)
1019+
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
10031020
/* call driver. From then on the cpufreq must be able
10041021
* to accept all calls to ->verify and ->setpolicy for this CPU
10051022
*/
@@ -1111,7 +1128,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
11111128
#ifdef CONFIG_SMP
11121129

11131130
#ifdef CONFIG_HOTPLUG_CPU
1114-
per_cpu(cpufreq_cpu_governor, cpu) = data->governor;
1131+
strncpy(per_cpu(cpufreq_cpu_governor, cpu), data->governor->name,
1132+
CPUFREQ_NAME_LEN);
11151133
#endif
11161134

11171135
/* if we have other CPUs still registered, we need to unlink them,
@@ -1135,7 +1153,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
11351153
continue;
11361154
dprintk("removing link for cpu %u\n", j);
11371155
#ifdef CONFIG_HOTPLUG_CPU
1138-
per_cpu(cpufreq_cpu_governor, j) = data->governor;
1156+
strncpy(per_cpu(cpufreq_cpu_governor, j),
1157+
data->governor->name, CPUFREQ_NAME_LEN);
11391158
#endif
11401159
cpu_sys_dev = get_cpu_sysdev(j);
11411160
sysfs_remove_link(&cpu_sys_dev->kobj, "cpufreq");
@@ -1606,9 +1625,22 @@ EXPORT_SYMBOL_GPL(cpufreq_register_governor);
16061625

16071626
void cpufreq_unregister_governor(struct cpufreq_governor *governor)
16081627
{
1628+
#ifdef CONFIG_HOTPLUG_CPU
1629+
int cpu;
1630+
#endif
1631+
16091632
if (!governor)
16101633
return;
16111634

1635+
#ifdef CONFIG_HOTPLUG_CPU
1636+
for_each_present_cpu(cpu) {
1637+
if (cpu_online(cpu))
1638+
continue;
1639+
if (!strcmp(per_cpu(cpufreq_cpu_governor, cpu), governor->name))
1640+
strcpy(per_cpu(cpufreq_cpu_governor, cpu), "\0");
1641+
}
1642+
#endif
1643+
16121644
mutex_lock(&cpufreq_governor_mutex);
16131645
list_del(&governor->governor_list);
16141646
mutex_unlock(&cpufreq_governor_mutex);

‎drivers/cpufreq/cpufreq_conservative.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu,
116116

117117
idle_time = cputime64_sub(cur_wall_time, busy_time);
118118
if (wall)
119-
*wall = cur_wall_time;
119+
*wall = (cputime64_t)jiffies_to_usecs(cur_wall_time);
120120

121-
return idle_time;
121+
return (cputime64_t)jiffies_to_usecs(idle_time);;
122122
}
123123

124124
static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall)

‎drivers/cpufreq/cpufreq_ondemand.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu,
133133

134134
idle_time = cputime64_sub(cur_wall_time, busy_time);
135135
if (wall)
136-
*wall = cur_wall_time;
136+
*wall = (cputime64_t)jiffies_to_usecs(cur_wall_time);
137137

138-
return idle_time;
138+
return (cputime64_t)jiffies_to_usecs(idle_time);
139139
}
140140

141141
static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall)

0 commit comments

Comments
 (0)