blob: 6f376bf42904f457bea5fccf198f90959ca5fc0a [file] [log] [blame]
Alex Chiang47817252009-12-20 12:19:34 -07001/*
2 * Copyright (C) 2005 Intel Corporation
3 * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
4 *
5 * Alex Chiang <achiang@hp.com>
6 * - Unified x86/ia64 implementations
7 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
8 * - Added _PDC for platforms with Intel CPUs
9 */
Alex Chiang78f16992009-12-20 12:19:09 -070010#include <linux/dmi.h>
11
12#include <acpi/acpi_drivers.h>
13#include <acpi/processor.h>
14
15#include "internal.h"
16
17#define PREFIX "ACPI: "
18#define _COMPONENT ACPI_PROCESSOR_COMPONENT
Alex Chiang4d5d4cd2010-02-22 12:11:14 -070019ACPI_MODULE_NAME("processor_core");
Alex Chiang78f16992009-12-20 12:19:09 -070020
21static int set_no_mwait(const struct dmi_system_id *id)
22{
23 printk(KERN_NOTICE PREFIX "%s detected - "
24 "disabling mwait for CPU C-states\n", id->ident);
25 idle_nomwait = 1;
26 return 0;
27}
28
29static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = {
30 {
31 set_no_mwait, "IFL91 board", {
32 DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
33 DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"),
34 DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"),
35 DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL},
36 {
37 set_no_mwait, "Extensa 5220", {
38 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
39 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
40 DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
41 DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
42 {},
43};
44
Alex Chiang08ea48a2009-12-20 12:19:24 -070045static void acpi_set_pdc_bits(u32 *buf)
46{
47 buf[0] = ACPI_PDC_REVISION_ID;
48 buf[1] = 1;
49
50 /* Enable coordination with firmware's _TSD info */
51 buf[2] = ACPI_PDC_SMP_T_SWCOORD;
Alex Chiang6c5807d2009-12-20 12:19:29 -070052
53 /* Twiddle arch-specific bits needed for _PDC */
54 arch_acpi_set_pdc_bits(buf);
Alex Chiang08ea48a2009-12-20 12:19:24 -070055}
56
Alex Chiang3b407ae2009-12-20 12:19:39 -070057static struct acpi_object_list *acpi_processor_alloc_pdc(void)
Alex Chiang407cd872009-12-20 12:19:19 -070058{
59 struct acpi_object_list *obj_list;
60 union acpi_object *obj;
61 u32 *buf;
62
Alex Chiang407cd872009-12-20 12:19:19 -070063 /* allocate and initialize pdc. It will be used later. */
64 obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
65 if (!obj_list) {
66 printk(KERN_ERR "Memory allocation error\n");
Alex Chiang3b407ae2009-12-20 12:19:39 -070067 return NULL;
Alex Chiang407cd872009-12-20 12:19:19 -070068 }
69
70 obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
71 if (!obj) {
72 printk(KERN_ERR "Memory allocation error\n");
73 kfree(obj_list);
Alex Chiang3b407ae2009-12-20 12:19:39 -070074 return NULL;
Alex Chiang407cd872009-12-20 12:19:19 -070075 }
76
77 buf = kmalloc(12, GFP_KERNEL);
78 if (!buf) {
79 printk(KERN_ERR "Memory allocation error\n");
80 kfree(obj);
81 kfree(obj_list);
Alex Chiang3b407ae2009-12-20 12:19:39 -070082 return NULL;
Alex Chiang407cd872009-12-20 12:19:19 -070083 }
84
Alex Chiang08ea48a2009-12-20 12:19:24 -070085 acpi_set_pdc_bits(buf);
86
Alex Chiang407cd872009-12-20 12:19:19 -070087 obj->type = ACPI_TYPE_BUFFER;
88 obj->buffer.length = 12;
89 obj->buffer.pointer = (u8 *) buf;
90 obj_list->count = 1;
91 obj_list->pointer = obj;
Alex Chiang407cd872009-12-20 12:19:19 -070092
Alex Chiang3b407ae2009-12-20 12:19:39 -070093 return obj_list;
Alex Chiang407cd872009-12-20 12:19:19 -070094}
95
Alex Chiang78f16992009-12-20 12:19:09 -070096/*
97 * _PDC is required for a BIOS-OS handshake for most of the newer
98 * ACPI processor features.
99 */
Alex Chiangfa118562009-12-20 12:19:45 -0700100static int
101acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
Alex Chiang78f16992009-12-20 12:19:09 -0700102{
Alex Chiang78f16992009-12-20 12:19:09 -0700103 acpi_status status = AE_OK;
104
Alex Chiang78f16992009-12-20 12:19:09 -0700105 if (idle_nomwait) {
106 /*
107 * If mwait is disabled for CPU C-states, the C2C3_FFH access
108 * mode will be disabled in the parameter of _PDC object.
109 * Of course C1_FFH access mode will also be disabled.
110 */
111 union acpi_object *obj;
112 u32 *buffer = NULL;
113
114 obj = pdc_in->pointer;
115 buffer = (u32 *)(obj->buffer.pointer);
116 buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
117
118 }
Alex Chiangfa118562009-12-20 12:19:45 -0700119 status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL);
Alex Chiang78f16992009-12-20 12:19:09 -0700120
121 if (ACPI_FAILURE(status))
122 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
123 "Could not evaluate _PDC, using legacy perf. control.\n"));
124
125 return status;
126}
127
Alex Chianga4932292010-01-20 00:06:35 -0700128static int early_pdc_done;
129
Alex Chiang43bab252009-12-20 12:23:16 -0700130void acpi_processor_set_pdc(acpi_handle handle)
Alex Chiang78f16992009-12-20 12:19:09 -0700131{
Alex Chiang3b407ae2009-12-20 12:19:39 -0700132 struct acpi_object_list *obj_list;
133
Alex Chiang1d9cb472009-12-20 12:19:14 -0700134 if (arch_has_acpi_pdc() == false)
135 return;
136
Alex Chianga4932292010-01-20 00:06:35 -0700137 if (early_pdc_done)
138 return;
139
Alex Chiang3b407ae2009-12-20 12:19:39 -0700140 obj_list = acpi_processor_alloc_pdc();
141 if (!obj_list)
142 return;
143
Alex Chiang43bab252009-12-20 12:23:16 -0700144 acpi_processor_eval_pdc(handle, obj_list);
Alex Chiangb9c2db72009-12-20 12:23:11 -0700145
146 kfree(obj_list->pointer->buffer.pointer);
147 kfree(obj_list->pointer);
148 kfree(obj_list);
Alex Chiang78f16992009-12-20 12:19:09 -0700149}
150EXPORT_SYMBOL_GPL(acpi_processor_set_pdc);
151
Alex Chiang2205cbe2010-01-19 16:55:41 -0700152static int early_pdc_optin;
153static int set_early_pdc_optin(const struct dmi_system_id *id)
154{
155 early_pdc_optin = 1;
156 return 0;
157}
158
Alex Chiang0406ad32010-01-20 00:06:30 -0700159static int param_early_pdc_optin(char *s)
160{
161 early_pdc_optin = 1;
162 return 1;
163}
164__setup("acpi_early_pdc_eval", param_early_pdc_optin);
165
Alex Chiang2205cbe2010-01-19 16:55:41 -0700166static struct dmi_system_id __cpuinitdata early_pdc_optin_table[] = {
167 {
168 set_early_pdc_optin, "HP Envy", {
169 DMI_MATCH(DMI_BIOS_VENDOR, "Hewlett-Packard"),
170 DMI_MATCH(DMI_PRODUCT_NAME, "HP Envy") }, NULL},
171 {
172 set_early_pdc_optin, "HP Pavilion dv6", {
173 DMI_MATCH(DMI_BIOS_VENDOR, "Hewlett-Packard"),
174 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv6") }, NULL},
175 {
176 set_early_pdc_optin, "HP Pavilion dv7", {
177 DMI_MATCH(DMI_BIOS_VENDOR, "Hewlett-Packard"),
178 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv7") }, NULL},
179 {},
180};
181
Alex Chiang78f16992009-12-20 12:19:09 -0700182static acpi_status
183early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
184{
Alex Chiang43bab252009-12-20 12:23:16 -0700185 acpi_processor_set_pdc(handle);
Alex Chiang78f16992009-12-20 12:19:09 -0700186 return AE_OK;
187}
188
Luck, Tony7a0b73a2009-12-28 10:39:23 -0800189void __init acpi_early_processor_set_pdc(void)
Alex Chiang78f16992009-12-20 12:19:09 -0700190{
191 /*
192 * Check whether the system is DMI table. If yes, OSPM
193 * should not use mwait for CPU-states.
194 */
195 dmi_check_system(processor_idle_dmi_table);
196
Alex Chiang2205cbe2010-01-19 16:55:41 -0700197 /*
198 * Allow systems to opt-in to early _PDC evaluation.
199 */
200 dmi_check_system(early_pdc_optin_table);
201 if (!early_pdc_optin)
202 return;
203
Alex Chiang78f16992009-12-20 12:19:09 -0700204 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
205 ACPI_UINT32_MAX,
206 early_init_pdc, NULL, NULL, NULL);
Alex Chianga4932292010-01-20 00:06:35 -0700207
208 early_pdc_done = 1;
Alex Chiang78f16992009-12-20 12:19:09 -0700209}