processor_pdc.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. */
  10. #include <linux/dmi.h>
  11. #include <acpi/acpi_drivers.h>
  12. #include <acpi/processor.h>
  13. #include "internal.h"
  14. #define PREFIX "ACPI: "
  15. #define _COMPONENT ACPI_PROCESSOR_COMPONENT
  16. ACPI_MODULE_NAME("processor_pdc");
  17. static int set_no_mwait(const struct dmi_system_id *id)
  18. {
  19. printk(KERN_NOTICE PREFIX "%s detected - "
  20. "disabling mwait for CPU C-states\n", id->ident);
  21. idle_nomwait = 1;
  22. return 0;
  23. }
  24. static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = {
  25. {
  26. set_no_mwait, "IFL91 board", {
  27. DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
  28. DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"),
  29. DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"),
  30. DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL},
  31. {
  32. set_no_mwait, "Extensa 5220", {
  33. DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
  34. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  35. DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
  36. DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
  37. {},
  38. };
  39. static void acpi_set_pdc_bits(u32 *buf)
  40. {
  41. buf[0] = ACPI_PDC_REVISION_ID;
  42. buf[1] = 1;
  43. /* Enable coordination with firmware's _TSD info */
  44. buf[2] = ACPI_PDC_SMP_T_SWCOORD;
  45. /* Twiddle arch-specific bits needed for _PDC */
  46. arch_acpi_set_pdc_bits(buf);
  47. }
  48. static struct acpi_object_list *acpi_processor_alloc_pdc(void)
  49. {
  50. struct acpi_object_list *obj_list;
  51. union acpi_object *obj;
  52. u32 *buf;
  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 NULL;
  58. }
  59. obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
  60. if (!obj) {
  61. printk(KERN_ERR "Memory allocation error\n");
  62. kfree(obj_list);
  63. return NULL;
  64. }
  65. buf = kmalloc(12, GFP_KERNEL);
  66. if (!buf) {
  67. printk(KERN_ERR "Memory allocation error\n");
  68. kfree(obj);
  69. kfree(obj_list);
  70. return NULL;
  71. }
  72. acpi_set_pdc_bits(buf);
  73. obj->type = ACPI_TYPE_BUFFER;
  74. obj->buffer.length = 12;
  75. obj->buffer.pointer = (u8 *) buf;
  76. obj_list->count = 1;
  77. obj_list->pointer = obj;
  78. return obj_list;
  79. }
  80. /*
  81. * _PDC is required for a BIOS-OS handshake for most of the newer
  82. * ACPI processor features.
  83. */
  84. static int
  85. acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
  86. {
  87. acpi_status status = AE_OK;
  88. if (idle_nomwait) {
  89. /*
  90. * If mwait is disabled for CPU C-states, the C2C3_FFH access
  91. * mode will be disabled in the parameter of _PDC object.
  92. * Of course C1_FFH access mode will also be disabled.
  93. */
  94. union acpi_object *obj;
  95. u32 *buffer = NULL;
  96. obj = pdc_in->pointer;
  97. buffer = (u32 *)(obj->buffer.pointer);
  98. buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
  99. }
  100. status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL);
  101. if (ACPI_FAILURE(status))
  102. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  103. "Could not evaluate _PDC, using legacy perf. control.\n"));
  104. return status;
  105. }
  106. void acpi_processor_set_pdc(acpi_handle handle)
  107. {
  108. struct acpi_object_list *obj_list;
  109. if (arch_has_acpi_pdc() == false)
  110. return;
  111. obj_list = acpi_processor_alloc_pdc();
  112. if (!obj_list)
  113. return;
  114. acpi_processor_eval_pdc(handle, obj_list);
  115. kfree(obj_list->pointer->buffer.pointer);
  116. kfree(obj_list->pointer);
  117. kfree(obj_list);
  118. }
  119. EXPORT_SYMBOL_GPL(acpi_processor_set_pdc);
  120. static acpi_status
  121. early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
  122. {
  123. acpi_processor_set_pdc(handle);
  124. return AE_OK;
  125. }
  126. void acpi_early_processor_set_pdc(void)
  127. {
  128. /*
  129. * Check whether the system is DMI table. If yes, OSPM
  130. * should not use mwait for CPU-states.
  131. */
  132. dmi_check_system(processor_idle_dmi_table);
  133. acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
  134. ACPI_UINT32_MAX,
  135. early_init_pdc, NULL, NULL, NULL);
  136. }