Skip to content

Commit 05131ec

Browse files
Venkatesh Pallipadilenb
authored andcommitted
[ACPI] Avoid BIOS inflicted crashes by evaluating _PDC only once
Linux invokes the AML _PDC method (Processor Driver Capabilities) to tell the BIOS what features it can handle. While the ACPI spec says nothing about the OS invoking _PDC multiple times, doing so with changing bits seems to hopelessly confuse the BIOS on multiple platforms up to and including crashing the system. Factor out the _PDC invocation so Linux invokes it only once. http://bugzilla.kernel.org/show_bug.cgi?id=5483 Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent d2149b5 commit 05131ec

16 files changed

Lines changed: 243 additions & 231 deletions

File tree

‎arch/i386/kernel/acpi/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ obj-$(CONFIG_X86_IO_APIC) += earlyquirk.o
33
obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o
44

55
ifneq ($(CONFIG_ACPI_PROCESSOR),)
6-
obj-y += cstate.o
6+
obj-y += cstate.o processor.o
77
endif
88

‎arch/i386/kernel/acpi/cstate.c‎

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -14,64 +14,6 @@
1414
#include <acpi/processor.h>
1515
#include <asm/acpi.h>
1616

17-
static void acpi_processor_power_init_intel_pdc(struct acpi_processor_power
18-
*pow)
19-
{
20-
struct acpi_object_list *obj_list;
21-
union acpi_object *obj;
22-
u32 *buf;
23-
24-
/* allocate and initialize pdc. It will be used later. */
25-
obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
26-
if (!obj_list) {
27-
printk(KERN_ERR "Memory allocation error\n");
28-
return;
29-
}
30-
31-
obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
32-
if (!obj) {
33-
printk(KERN_ERR "Memory allocation error\n");
34-
kfree(obj_list);
35-
return;
36-
}
37-
38-
buf = kmalloc(12, GFP_KERNEL);
39-
if (!buf) {
40-
printk(KERN_ERR "Memory allocation error\n");
41-
kfree(obj);
42-
kfree(obj_list);
43-
return;
44-
}
45-
46-
buf[0] = ACPI_PDC_REVISION_ID;
47-
buf[1] = 1;
48-
buf[2] = ACPI_PDC_C_CAPABILITY_SMP;
49-
50-
obj->type = ACPI_TYPE_BUFFER;
51-
obj->buffer.length = 12;
52-
obj->buffer.pointer = (u8 *) buf;
53-
obj_list->count = 1;
54-
obj_list->pointer = obj;
55-
pow->pdc = obj_list;
56-
57-
return;
58-
}
59-
60-
/* Initialize _PDC data based on the CPU vendor */
61-
void acpi_processor_power_init_pdc(struct acpi_processor_power *pow,
62-
unsigned int cpu)
63-
{
64-
struct cpuinfo_x86 *c = cpu_data + cpu;
65-
66-
pow->pdc = NULL;
67-
if (c->x86_vendor == X86_VENDOR_INTEL)
68-
acpi_processor_power_init_intel_pdc(pow);
69-
70-
return;
71-
}
72-
73-
EXPORT_SYMBOL(acpi_processor_power_init_pdc);
74-
7517
/*
7618
* Initialize bm_flags based on the CPU cache properties
7719
* On SMP it depends on cache configuration

‎arch/i386/kernel/acpi/processor.c‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* arch/i386/kernel/acpi/processor.c
3+
*
4+
* Copyright (C) 2005 Intel Corporation
5+
* Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
6+
* - Added _PDC for platforms with Intel CPUs
7+
*/
8+
9+
#include <linux/kernel.h>
10+
#include <linux/module.h>
11+
#include <linux/init.h>
12+
#include <linux/acpi.h>
13+
14+
#include <acpi/processor.h>
15+
#include <asm/acpi.h>
16+
17+
static void init_intel_pdc(struct acpi_processor *pr, struct cpuinfo_x86 *c)
18+
{
19+
struct acpi_object_list *obj_list;
20+
union acpi_object *obj;
21+
u32 *buf;
22+
23+
/* allocate and initialize pdc. It will be used later. */
24+
obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
25+
if (!obj_list) {
26+
printk(KERN_ERR "Memory allocation error\n");
27+
return;
28+
}
29+
30+
obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
31+
if (!obj) {
32+
printk(KERN_ERR "Memory allocation error\n");
33+
kfree(obj_list);
34+
return;
35+
}
36+
37+
buf = kmalloc(12, GFP_KERNEL);
38+
if (!buf) {
39+
printk(KERN_ERR "Memory allocation error\n");
40+
kfree(obj);
41+
kfree(obj_list);
42+
return;
43+
}
44+
45+
buf[0] = ACPI_PDC_REVISION_ID;
46+
buf[1] = 1;
47+
buf[2] = ACPI_PDC_C_CAPABILITY_SMP;
48+
49+
if (cpu_has(c, X86_FEATURE_EST))
50+
buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP;
51+
52+
obj->type = ACPI_TYPE_BUFFER;
53+
obj->buffer.length = 12;
54+
obj->buffer.pointer = (u8 *) buf;
55+
obj_list->count = 1;
56+
obj_list->pointer = obj;
57+
pr->pdc = obj_list;
58+
59+
return;
60+
}
61+
62+
/* Initialize _PDC data based on the CPU vendor */
63+
void arch_acpi_processor_init_pdc(struct acpi_processor *pr)
64+
{
65+
unsigned int cpu = pr->id;
66+
struct cpuinfo_x86 *c = cpu_data + cpu;
67+
68+
pr->pdc = NULL;
69+
if (c->x86_vendor == X86_VENDOR_INTEL)
70+
init_intel_pdc(pr, c);
71+
72+
return;
73+
}
74+
75+
EXPORT_SYMBOL(arch_acpi_processor_init_pdc);

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

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -297,68 +297,6 @@ acpi_cpufreq_guess_freq (
297297
}
298298

299299

300-
/*
301-
* acpi_processor_cpu_init_pdc_est - let BIOS know about the SMP capabilities
302-
* of this driver
303-
* @perf: processor-specific acpi_io_data struct
304-
* @cpu: CPU being initialized
305-
*
306-
* To avoid issues with legacy OSes, some BIOSes require to be informed of
307-
* the SMP capabilities of OS P-state driver. Here we set the bits in _PDC
308-
* accordingly, for Enhanced Speedstep. Actual call to _PDC is done in
309-
* driver/acpi/processor.c
310-
*/
311-
static void
312-
acpi_processor_cpu_init_pdc_est(
313-
struct acpi_processor_performance *perf,
314-
unsigned int cpu,
315-
struct acpi_object_list *obj_list
316-
)
317-
{
318-
union acpi_object *obj;
319-
u32 *buf;
320-
struct cpuinfo_x86 *c = cpu_data + cpu;
321-
dprintk("acpi_processor_cpu_init_pdc_est\n");
322-
323-
if (!cpu_has(c, X86_FEATURE_EST))
324-
return;
325-
326-
/* Initialize pdc. It will be used later. */
327-
if (!obj_list)
328-
return;
329-
330-
if (!(obj_list->count && obj_list->pointer))
331-
return;
332-
333-
obj = obj_list->pointer;
334-
if ((obj->buffer.length == 12) && obj->buffer.pointer) {
335-
buf = (u32 *)obj->buffer.pointer;
336-
buf[0] = ACPI_PDC_REVISION_ID;
337-
buf[1] = 1;
338-
buf[2] = ACPI_PDC_EST_CAPABILITY_SMP;
339-
perf->pdc = obj_list;
340-
}
341-
return;
342-
}
343-
344-
345-
/* CPU specific PDC initialization */
346-
static void
347-
acpi_processor_cpu_init_pdc(
348-
struct acpi_processor_performance *perf,
349-
unsigned int cpu,
350-
struct acpi_object_list *obj_list
351-
)
352-
{
353-
struct cpuinfo_x86 *c = cpu_data + cpu;
354-
dprintk("acpi_processor_cpu_init_pdc\n");
355-
perf->pdc = NULL;
356-
if (cpu_has(c, X86_FEATURE_EST))
357-
acpi_processor_cpu_init_pdc_est(perf, cpu, obj_list);
358-
return;
359-
}
360-
361-
362300
static int
363301
acpi_cpufreq_cpu_init (
364302
struct cpufreq_policy *policy)
@@ -373,19 +311,14 @@ acpi_cpufreq_cpu_init (
373311
struct acpi_object_list arg_list = {1, &arg0};
374312

375313
dprintk("acpi_cpufreq_cpu_init\n");
376-
/* setup arg_list for _PDC settings */
377-
arg0.buffer.length = 12;
378-
arg0.buffer.pointer = (u8 *) arg0_buf;
379314

380315
data = kzalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL);
381316
if (!data)
382317
return (-ENOMEM);
383318

384319
acpi_io_data[cpu] = data;
385320

386-
acpi_processor_cpu_init_pdc(&data->acpi_data, cpu, &arg_list);
387321
result = acpi_processor_register_performance(&data->acpi_data, cpu);
388-
data->acpi_data.pdc = NULL;
389322

390323
if (result)
391324
goto err_free;

‎arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -364,22 +364,10 @@ static struct acpi_processor_performance p;
364364
*/
365365
static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
366366
{
367-
union acpi_object arg0 = {ACPI_TYPE_BUFFER};
368-
u32 arg0_buf[3];
369-
struct acpi_object_list arg_list = {1, &arg0};
370367
unsigned long cur_freq;
371368
int result = 0, i;
372369
unsigned int cpu = policy->cpu;
373370

374-
/* _PDC settings */
375-
arg0.buffer.length = 12;
376-
arg0.buffer.pointer = (u8 *) arg0_buf;
377-
arg0_buf[0] = ACPI_PDC_REVISION_ID;
378-
arg0_buf[1] = 1;
379-
arg0_buf[2] = ACPI_PDC_EST_CAPABILITY_SMP_MSR;
380-
381-
p.pdc = &arg_list;
382-
383371
/* register with ACPI core */
384372
if (acpi_processor_register_performance(&p, cpu)) {
385373
dprintk(KERN_INFO PFX "obtaining ACPI data failed\n");

‎arch/ia64/kernel/cpufreq/Makefile‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
obj-$(CONFIG_IA64_ACPI_CPUFREQ) += acpi-cpufreq.o
2+
3+
ifneq ($(CONFIG_ACPI_PROCESSOR),)
4+
obj-y += acpi-processor.o
5+
endif
6+

‎arch/ia64/kernel/cpufreq/acpi-cpufreq.c‎

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -269,48 +269,6 @@ acpi_cpufreq_verify (
269269
}
270270

271271

272-
/*
273-
* processor_init_pdc - let BIOS know about the SMP capabilities
274-
* of this driver
275-
* @perf: processor-specific acpi_io_data struct
276-
* @cpu: CPU being initialized
277-
*
278-
* To avoid issues with legacy OSes, some BIOSes require to be informed of
279-
* the SMP capabilities of OS P-state driver. Here we set the bits in _PDC
280-
* accordingly. Actual call to _PDC is done in driver/acpi/processor.c
281-
*/
282-
static void
283-
processor_init_pdc (
284-
struct acpi_processor_performance *perf,
285-
unsigned int cpu,
286-
struct acpi_object_list *obj_list
287-
)
288-
{
289-
union acpi_object *obj;
290-
u32 *buf;
291-
292-
dprintk("processor_init_pdc\n");
293-
294-
perf->pdc = NULL;
295-
/* Initialize pdc. It will be used later. */
296-
if (!obj_list)
297-
return;
298-
299-
if (!(obj_list->count && obj_list->pointer))
300-
return;
301-
302-
obj = obj_list->pointer;
303-
if ((obj->buffer.length == 12) && obj->buffer.pointer) {
304-
buf = (u32 *)obj->buffer.pointer;
305-
buf[0] = ACPI_PDC_REVISION_ID;
306-
buf[1] = 1;
307-
buf[2] = ACPI_PDC_EST_CAPABILITY_SMP;
308-
perf->pdc = obj_list;
309-
}
310-
return;
311-
}
312-
313-
314272
static int
315273
acpi_cpufreq_cpu_init (
316274
struct cpufreq_policy *policy)
@@ -320,14 +278,7 @@ acpi_cpufreq_cpu_init (
320278
struct cpufreq_acpi_io *data;
321279
unsigned int result = 0;
322280

323-
union acpi_object arg0 = {ACPI_TYPE_BUFFER};
324-
u32 arg0_buf[3];
325-
struct acpi_object_list arg_list = {1, &arg0};
326-
327281
dprintk("acpi_cpufreq_cpu_init\n");
328-
/* setup arg_list for _PDC settings */
329-
arg0.buffer.length = 12;
330-
arg0.buffer.pointer = (u8 *) arg0_buf;
331282

332283
data = kmalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL);
333284
if (!data)
@@ -337,9 +288,7 @@ acpi_cpufreq_cpu_init (
337288

338289
acpi_io_data[cpu] = data;
339290

340-
processor_init_pdc(&data->acpi_data, cpu, &arg_list);
341291
result = acpi_processor_register_performance(&data->acpi_data, cpu);
342-
data->acpi_data.pdc = NULL;
343292

344293
if (result)
345294
goto err_free;

0 commit comments

Comments
 (0)