Skip to content

Commit 78f1699

Browse files
Alex Chianglenb
authored andcommitted
ACPI: processor: call _PDC early
We discovered that at least one machine (HP Envy), methods in the DSDT attempt to call external methods defined in a dynamically loaded SSDT. Unfortunately, the DSDT methods we are trying to call are part of the EC initialization, which happens very early, and the the dynamic SSDT is only loaded when a processor _PDC method runs much later. This results in namespace lookup errors for the (as of yet) undefined methods. Since Windows doesn't have any issues with this machine, we take it as a hint that they must be evaluating _PDC much earlier than we are. Thus, the proper thing for Linux to do should be to match the Windows implementation more closely. Provide a mechanism to call _PDC before we enable the EC. Doing so loads the dynamic tables, and allows the EC to be enabled correctly. The ACPI processor driver will still evaluate _PDC in its .add() method to cover the hotplug case. Resolves: http://bugzilla.kernel.org/show_bug.cgi?id=14824 Cc: ming.m.lin@intel.com Signed-off-by: Alex Chiang <achiang@hp.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 5563935 commit 78f1699

6 files changed

Lines changed: 115 additions & 69 deletions

File tree

‎drivers/acpi/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ acpi-$(CONFIG_ACPI_SLEEP) += proc.o
3232
#
3333
acpi-y += bus.o glue.o
3434
acpi-y += scan.o
35+
acpi-y += processor_pdc.o
3536
acpi-y += ec.o
3637
acpi-$(CONFIG_ACPI_DOCK) += dock.o
3738
acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o

‎drivers/acpi/bus.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,8 @@ static int __init acpi_bus_init(void)
888888
goto error1;
889889
}
890890

891+
acpi_early_processor_set_pdc();
892+
891893
/*
892894
* Maybe EC region is required at bus_scan/acpi_get_devices. So it
893895
* is necessary to enable it as early as possible.

‎drivers/acpi/internal.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ int acpi_power_transition(struct acpi_device *device, int state);
4343
extern int acpi_power_nocheck;
4444

4545
int acpi_wakeup_device_init(void);
46+
void acpi_early_processor_set_pdc(void);
4647

4748
/* --------------------------------------------------------------------------
4849
Embedded Controller

‎drivers/acpi/processor_core.c‎

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -124,29 +124,6 @@ static const struct file_operations acpi_processor_info_fops = {
124124

125125
DEFINE_PER_CPU(struct acpi_processor *, processors);
126126
struct acpi_processor_errata errata __read_mostly;
127-
static int set_no_mwait(const struct dmi_system_id *id)
128-
{
129-
printk(KERN_NOTICE PREFIX "%s detected - "
130-
"disabling mwait for CPU C-states\n", id->ident);
131-
idle_nomwait = 1;
132-
return 0;
133-
}
134-
135-
static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = {
136-
{
137-
set_no_mwait, "IFL91 board", {
138-
DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
139-
DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"),
140-
DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"),
141-
DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL},
142-
{
143-
set_no_mwait, "Extensa 5220", {
144-
DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
145-
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
146-
DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
147-
DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
148-
{},
149-
};
150127

151128
/* --------------------------------------------------------------------------
152129
Errata Handling
@@ -276,45 +253,6 @@ static int acpi_processor_errata(struct acpi_processor *pr)
276253
return result;
277254
}
278255

279-
/* --------------------------------------------------------------------------
280-
Common ACPI processor functions
281-
-------------------------------------------------------------------------- */
282-
283-
/*
284-
* _PDC is required for a BIOS-OS handshake for most of the newer
285-
* ACPI processor features.
286-
*/
287-
static int acpi_processor_set_pdc(struct acpi_processor *pr)
288-
{
289-
struct acpi_object_list *pdc_in = pr->pdc;
290-
acpi_status status = AE_OK;
291-
292-
293-
if (!pdc_in)
294-
return status;
295-
if (idle_nomwait) {
296-
/*
297-
* If mwait is disabled for CPU C-states, the C2C3_FFH access
298-
* mode will be disabled in the parameter of _PDC object.
299-
* Of course C1_FFH access mode will also be disabled.
300-
*/
301-
union acpi_object *obj;
302-
u32 *buffer = NULL;
303-
304-
obj = pdc_in->pointer;
305-
buffer = (u32 *)(obj->buffer.pointer);
306-
buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
307-
308-
}
309-
status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL);
310-
311-
if (ACPI_FAILURE(status))
312-
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
313-
"Could not evaluate _PDC, using legacy perf. control...\n"));
314-
315-
return status;
316-
}
317-
318256
/* --------------------------------------------------------------------------
319257
FS Interface (/proc)
320258
-------------------------------------------------------------------------- */
@@ -825,9 +763,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
825763
}
826764

827765
/* _PDC call should be done before doing anything else (if reqd.). */
828-
arch_acpi_processor_init_pdc(pr);
829766
acpi_processor_set_pdc(pr);
830-
arch_acpi_processor_cleanup_pdc(pr);
831767

832768
#ifdef CONFIG_CPU_FREQ
833769
acpi_processor_ppc_has_changed(pr, 0);
@@ -1145,11 +1081,6 @@ static int __init acpi_processor_init(void)
11451081
if (!acpi_processor_dir)
11461082
return -ENOMEM;
11471083
#endif
1148-
/*
1149-
* Check whether the system is DMI table. If yes, OSPM
1150-
* should not use mwait for CPU-states.
1151-
*/
1152-
dmi_check_system(processor_idle_dmi_table);
11531084
result = cpuidle_register_driver(&acpi_idle_driver);
11541085
if (result < 0)
11551086
goto out_proc;

‎drivers/acpi/processor_pdc.c‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#include <linux/dmi.h>
2+
3+
#include <acpi/acpi_drivers.h>
4+
#include <acpi/processor.h>
5+
6+
#include "internal.h"
7+
8+
#define PREFIX "ACPI: "
9+
#define _COMPONENT ACPI_PROCESSOR_COMPONENT
10+
ACPI_MODULE_NAME("processor_pdc");
11+
12+
static int set_no_mwait(const struct dmi_system_id *id)
13+
{
14+
printk(KERN_NOTICE PREFIX "%s detected - "
15+
"disabling mwait for CPU C-states\n", id->ident);
16+
idle_nomwait = 1;
17+
return 0;
18+
}
19+
20+
static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = {
21+
{
22+
set_no_mwait, "IFL91 board", {
23+
DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
24+
DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"),
25+
DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"),
26+
DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL},
27+
{
28+
set_no_mwait, "Extensa 5220", {
29+
DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
30+
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
31+
DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
32+
DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
33+
{},
34+
};
35+
36+
/*
37+
* _PDC is required for a BIOS-OS handshake for most of the newer
38+
* ACPI processor features.
39+
*/
40+
static int acpi_processor_eval_pdc(struct acpi_processor *pr)
41+
{
42+
struct acpi_object_list *pdc_in = pr->pdc;
43+
acpi_status status = AE_OK;
44+
45+
if (!pdc_in)
46+
return status;
47+
if (idle_nomwait) {
48+
/*
49+
* If mwait is disabled for CPU C-states, the C2C3_FFH access
50+
* mode will be disabled in the parameter of _PDC object.
51+
* Of course C1_FFH access mode will also be disabled.
52+
*/
53+
union acpi_object *obj;
54+
u32 *buffer = NULL;
55+
56+
obj = pdc_in->pointer;
57+
buffer = (u32 *)(obj->buffer.pointer);
58+
buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
59+
60+
}
61+
status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL);
62+
63+
if (ACPI_FAILURE(status))
64+
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
65+
"Could not evaluate _PDC, using legacy perf. control.\n"));
66+
67+
return status;
68+
}
69+
70+
void acpi_processor_set_pdc(struct acpi_processor *pr)
71+
{
72+
arch_acpi_processor_init_pdc(pr);
73+
acpi_processor_eval_pdc(pr);
74+
arch_acpi_processor_cleanup_pdc(pr);
75+
}
76+
EXPORT_SYMBOL_GPL(acpi_processor_set_pdc);
77+
78+
static acpi_status
79+
early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
80+
{
81+
struct acpi_processor pr;
82+
83+
pr.handle = handle;
84+
85+
/* x86 implementation looks at pr.id to determine some
86+
* CPU capabilites. We can just hard code to 0 since we're
87+
* assuming the CPUs in the system are homogenous and all
88+
* have the same capabilities.
89+
*/
90+
pr.id = 0;
91+
92+
acpi_processor_set_pdc(&pr);
93+
94+
return AE_OK;
95+
}
96+
97+
void acpi_early_processor_set_pdc(void)
98+
{
99+
/*
100+
* Check whether the system is DMI table. If yes, OSPM
101+
* should not use mwait for CPU-states.
102+
*/
103+
dmi_check_system(processor_idle_dmi_table);
104+
105+
acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
106+
ACPI_UINT32_MAX,
107+
early_init_pdc, NULL, NULL, NULL);
108+
}

‎include/acpi/processor.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
325325

326326
#endif /* CONFIG_CPU_FREQ */
327327

328+
/* in processor_pdc.c */
329+
void acpi_processor_set_pdc(struct acpi_processor *pr);
330+
328331
/* in processor_throttling.c */
329332
int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
330333
int acpi_processor_get_throttling_info(struct acpi_processor *pr);

0 commit comments

Comments
 (0)