Alex Chiang | 4781725 | 2009-12-20 12:19:34 -0700 | [diff] [blame] | 1 | /* |
| 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 Chiang | 78f1699 | 2009-12-20 12:19:09 -0700 | [diff] [blame] | 10 | #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 |
| 19 | ACPI_MODULE_NAME("processor_pdc"); |
| 20 | |
| 21 | static 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 | |
| 29 | static 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 Chiang | 08ea48a | 2009-12-20 12:19:24 -0700 | [diff] [blame] | 45 | static 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 Chiang | 6c5807d | 2009-12-20 12:19:29 -0700 | [diff] [blame] | 52 | |
| 53 | /* Twiddle arch-specific bits needed for _PDC */ |
| 54 | arch_acpi_set_pdc_bits(buf); |
Alex Chiang | 08ea48a | 2009-12-20 12:19:24 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Alex Chiang | 3b407ae | 2009-12-20 12:19:39 -0700 | [diff] [blame] | 57 | static struct acpi_object_list *acpi_processor_alloc_pdc(void) |
Alex Chiang | 407cd87 | 2009-12-20 12:19:19 -0700 | [diff] [blame] | 58 | { |
| 59 | struct acpi_object_list *obj_list; |
| 60 | union acpi_object *obj; |
| 61 | u32 *buf; |
| 62 | |
Alex Chiang | 407cd87 | 2009-12-20 12:19:19 -0700 | [diff] [blame] | 63 | /* 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 Chiang | 3b407ae | 2009-12-20 12:19:39 -0700 | [diff] [blame] | 67 | return NULL; |
Alex Chiang | 407cd87 | 2009-12-20 12:19:19 -0700 | [diff] [blame] | 68 | } |
| 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 Chiang | 3b407ae | 2009-12-20 12:19:39 -0700 | [diff] [blame] | 74 | return NULL; |
Alex Chiang | 407cd87 | 2009-12-20 12:19:19 -0700 | [diff] [blame] | 75 | } |
| 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 Chiang | 3b407ae | 2009-12-20 12:19:39 -0700 | [diff] [blame] | 82 | return NULL; |
Alex Chiang | 407cd87 | 2009-12-20 12:19:19 -0700 | [diff] [blame] | 83 | } |
| 84 | |
Alex Chiang | 08ea48a | 2009-12-20 12:19:24 -0700 | [diff] [blame] | 85 | acpi_set_pdc_bits(buf); |
| 86 | |
Alex Chiang | 407cd87 | 2009-12-20 12:19:19 -0700 | [diff] [blame] | 87 | 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 Chiang | 407cd87 | 2009-12-20 12:19:19 -0700 | [diff] [blame] | 92 | |
Alex Chiang | 3b407ae | 2009-12-20 12:19:39 -0700 | [diff] [blame] | 93 | return obj_list; |
Alex Chiang | 407cd87 | 2009-12-20 12:19:19 -0700 | [diff] [blame] | 94 | } |
| 95 | |
Alex Chiang | 78f1699 | 2009-12-20 12:19:09 -0700 | [diff] [blame] | 96 | /* |
| 97 | * _PDC is required for a BIOS-OS handshake for most of the newer |
| 98 | * ACPI processor features. |
| 99 | */ |
Alex Chiang | fa11856 | 2009-12-20 12:19:45 -0700 | [diff] [blame] | 100 | static int |
| 101 | acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) |
Alex Chiang | 78f1699 | 2009-12-20 12:19:09 -0700 | [diff] [blame] | 102 | { |
Alex Chiang | 78f1699 | 2009-12-20 12:19:09 -0700 | [diff] [blame] | 103 | acpi_status status = AE_OK; |
| 104 | |
Alex Chiang | 78f1699 | 2009-12-20 12:19:09 -0700 | [diff] [blame] | 105 | 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 Chiang | fa11856 | 2009-12-20 12:19:45 -0700 | [diff] [blame] | 119 | status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL); |
Alex Chiang | 78f1699 | 2009-12-20 12:19:09 -0700 | [diff] [blame] | 120 | |
| 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 | |
| 128 | void acpi_processor_set_pdc(struct acpi_processor *pr) |
| 129 | { |
Alex Chiang | 3b407ae | 2009-12-20 12:19:39 -0700 | [diff] [blame] | 130 | struct acpi_object_list *obj_list; |
| 131 | |
Alex Chiang | 1d9cb47 | 2009-12-20 12:19:14 -0700 | [diff] [blame] | 132 | if (arch_has_acpi_pdc() == false) |
| 133 | return; |
| 134 | |
Alex Chiang | 3b407ae | 2009-12-20 12:19:39 -0700 | [diff] [blame] | 135 | obj_list = acpi_processor_alloc_pdc(); |
| 136 | if (!obj_list) |
| 137 | return; |
| 138 | |
Alex Chiang | fa11856 | 2009-12-20 12:19:45 -0700 | [diff] [blame] | 139 | acpi_processor_eval_pdc(pr->handle, obj_list); |
Alex Chiang | b9c2db7 | 2009-12-20 12:23:11 -0700 | [diff] [blame^] | 140 | |
| 141 | kfree(obj_list->pointer->buffer.pointer); |
| 142 | kfree(obj_list->pointer); |
| 143 | kfree(obj_list); |
Alex Chiang | 78f1699 | 2009-12-20 12:19:09 -0700 | [diff] [blame] | 144 | } |
| 145 | EXPORT_SYMBOL_GPL(acpi_processor_set_pdc); |
| 146 | |
| 147 | static acpi_status |
| 148 | early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv) |
| 149 | { |
| 150 | struct acpi_processor pr; |
| 151 | |
| 152 | pr.handle = handle; |
| 153 | |
| 154 | /* x86 implementation looks at pr.id to determine some |
| 155 | * CPU capabilites. We can just hard code to 0 since we're |
| 156 | * assuming the CPUs in the system are homogenous and all |
| 157 | * have the same capabilities. |
| 158 | */ |
| 159 | pr.id = 0; |
| 160 | |
| 161 | acpi_processor_set_pdc(&pr); |
| 162 | |
| 163 | return AE_OK; |
| 164 | } |
| 165 | |
| 166 | void acpi_early_processor_set_pdc(void) |
| 167 | { |
| 168 | /* |
| 169 | * Check whether the system is DMI table. If yes, OSPM |
| 170 | * should not use mwait for CPU-states. |
| 171 | */ |
| 172 | dmi_check_system(processor_idle_dmi_table); |
| 173 | |
| 174 | acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, |
| 175 | ACPI_UINT32_MAX, |
| 176 | early_init_pdc, NULL, NULL, NULL); |
| 177 | } |