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