]>
Commit | Line | Data |
---|---|---|
78f16996 AC |
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 | ||
08ea48a3 AC |
36 | static void acpi_set_pdc_bits(u32 *buf) |
37 | { | |
38 | buf[0] = ACPI_PDC_REVISION_ID; | |
39 | buf[1] = 1; | |
40 | ||
41 | /* Enable coordination with firmware's _TSD info */ | |
42 | buf[2] = ACPI_PDC_SMP_T_SWCOORD; | |
43 | } | |
44 | ||
407cd87c AC |
45 | static void acpi_processor_init_pdc(struct acpi_processor *pr) |
46 | { | |
47 | struct acpi_object_list *obj_list; | |
48 | union acpi_object *obj; | |
49 | u32 *buf; | |
50 | ||
51 | pr->pdc = NULL; | |
52 | ||
53 | /* allocate and initialize pdc. It will be used later. */ | |
54 | obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL); | |
55 | if (!obj_list) { | |
56 | printk(KERN_ERR "Memory allocation error\n"); | |
57 | return; | |
58 | } | |
59 | ||
60 | obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL); | |
61 | if (!obj) { | |
62 | printk(KERN_ERR "Memory allocation error\n"); | |
63 | kfree(obj_list); | |
64 | return; | |
65 | } | |
66 | ||
67 | buf = kmalloc(12, GFP_KERNEL); | |
68 | if (!buf) { | |
69 | printk(KERN_ERR "Memory allocation error\n"); | |
70 | kfree(obj); | |
71 | kfree(obj_list); | |
72 | return; | |
73 | } | |
74 | ||
08ea48a3 AC |
75 | acpi_set_pdc_bits(buf); |
76 | ||
407cd87c AC |
77 | obj->type = ACPI_TYPE_BUFFER; |
78 | obj->buffer.length = 12; | |
79 | obj->buffer.pointer = (u8 *) buf; | |
80 | obj_list->count = 1; | |
81 | obj_list->pointer = obj; | |
82 | pr->pdc = obj_list; | |
83 | ||
84 | /* Now let the arch do the bit-twiddling to buf[] */ | |
85 | arch_acpi_processor_init_pdc(pr); | |
86 | ||
87 | return; | |
88 | } | |
89 | ||
78f16996 AC |
90 | /* |
91 | * _PDC is required for a BIOS-OS handshake for most of the newer | |
92 | * ACPI processor features. | |
93 | */ | |
94 | static int acpi_processor_eval_pdc(struct acpi_processor *pr) | |
95 | { | |
96 | struct acpi_object_list *pdc_in = pr->pdc; | |
97 | acpi_status status = AE_OK; | |
98 | ||
99 | if (!pdc_in) | |
100 | return status; | |
101 | if (idle_nomwait) { | |
102 | /* | |
103 | * If mwait is disabled for CPU C-states, the C2C3_FFH access | |
104 | * mode will be disabled in the parameter of _PDC object. | |
105 | * Of course C1_FFH access mode will also be disabled. | |
106 | */ | |
107 | union acpi_object *obj; | |
108 | u32 *buffer = NULL; | |
109 | ||
110 | obj = pdc_in->pointer; | |
111 | buffer = (u32 *)(obj->buffer.pointer); | |
112 | buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH); | |
113 | ||
114 | } | |
115 | status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL); | |
116 | ||
117 | if (ACPI_FAILURE(status)) | |
118 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | |
119 | "Could not evaluate _PDC, using legacy perf. control.\n")); | |
120 | ||
121 | return status; | |
122 | } | |
123 | ||
124 | void acpi_processor_set_pdc(struct acpi_processor *pr) | |
125 | { | |
1d9cb470 AC |
126 | if (arch_has_acpi_pdc() == false) |
127 | return; | |
128 | ||
407cd87c | 129 | acpi_processor_init_pdc(pr); |
78f16996 AC |
130 | acpi_processor_eval_pdc(pr); |
131 | arch_acpi_processor_cleanup_pdc(pr); | |
132 | } | |
133 | EXPORT_SYMBOL_GPL(acpi_processor_set_pdc); | |
134 | ||
135 | static acpi_status | |
136 | early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv) | |
137 | { | |
138 | struct acpi_processor pr; | |
139 | ||
140 | pr.handle = handle; | |
141 | ||
142 | /* x86 implementation looks at pr.id to determine some | |
143 | * CPU capabilites. We can just hard code to 0 since we're | |
144 | * assuming the CPUs in the system are homogenous and all | |
145 | * have the same capabilities. | |
146 | */ | |
147 | pr.id = 0; | |
148 | ||
149 | acpi_processor_set_pdc(&pr); | |
150 | ||
151 | return AE_OK; | |
152 | } | |
153 | ||
154 | void acpi_early_processor_set_pdc(void) | |
155 | { | |
156 | /* | |
157 | * Check whether the system is DMI table. If yes, OSPM | |
158 | * should not use mwait for CPU-states. | |
159 | */ | |
160 | dmi_check_system(processor_idle_dmi_table); | |
161 | ||
162 | acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, | |
163 | ACPI_UINT32_MAX, | |
164 | early_init_pdc, NULL, NULL, NULL); | |
165 | } |