processor_pdc.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #include <linux/dmi.h>
  2. #include <acpi/acpi_drivers.h>
  3. #include <acpi/processor.h>
  4. #include "internal.h"
  5. #define PREFIX "ACPI: "
  6. #define _COMPONENT ACPI_PROCESSOR_COMPONENT
  7. ACPI_MODULE_NAME("processor_pdc");
  8. static int set_no_mwait(const struct dmi_system_id *id)
  9. {
  10. printk(KERN_NOTICE PREFIX "%s detected - "
  11. "disabling mwait for CPU C-states\n", id->ident);
  12. idle_nomwait = 1;
  13. return 0;
  14. }
  15. static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = {
  16. {
  17. set_no_mwait, "IFL91 board", {
  18. DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
  19. DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"),
  20. DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"),
  21. DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL},
  22. {
  23. set_no_mwait, "Extensa 5220", {
  24. DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
  25. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  26. DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
  27. DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
  28. {},
  29. };
  30. static void acpi_processor_init_pdc(struct acpi_processor *pr)
  31. {
  32. struct acpi_object_list *obj_list;
  33. union acpi_object *obj;
  34. u32 *buf;
  35. pr->pdc = NULL;
  36. /* allocate and initialize pdc. It will be used later. */
  37. obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
  38. if (!obj_list) {
  39. printk(KERN_ERR "Memory allocation error\n");
  40. return;
  41. }
  42. obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
  43. if (!obj) {
  44. printk(KERN_ERR "Memory allocation error\n");
  45. kfree(obj_list);
  46. return;
  47. }
  48. buf = kmalloc(12, GFP_KERNEL);
  49. if (!buf) {
  50. printk(KERN_ERR "Memory allocation error\n");
  51. kfree(obj);
  52. kfree(obj_list);
  53. return;
  54. }
  55. obj->type = ACPI_TYPE_BUFFER;
  56. obj->buffer.length = 12;
  57. obj->buffer.pointer = (u8 *) buf;
  58. obj_list->count = 1;
  59. obj_list->pointer = obj;
  60. pr->pdc = obj_list;
  61. /* Now let the arch do the bit-twiddling to buf[] */
  62. arch_acpi_processor_init_pdc(pr);
  63. return;
  64. }
  65. /*
  66. * _PDC is required for a BIOS-OS handshake for most of the newer
  67. * ACPI processor features.
  68. */
  69. static int acpi_processor_eval_pdc(struct acpi_processor *pr)
  70. {
  71. struct acpi_object_list *pdc_in = pr->pdc;
  72. acpi_status status = AE_OK;
  73. if (!pdc_in)
  74. return status;
  75. if (idle_nomwait) {
  76. /*
  77. * If mwait is disabled for CPU C-states, the C2C3_FFH access
  78. * mode will be disabled in the parameter of _PDC object.
  79. * Of course C1_FFH access mode will also be disabled.
  80. */
  81. union acpi_object *obj;
  82. u32 *buffer = NULL;
  83. obj = pdc_in->pointer;
  84. buffer = (u32 *)(obj->buffer.pointer);
  85. buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
  86. }
  87. status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL);
  88. if (ACPI_FAILURE(status))
  89. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  90. "Could not evaluate _PDC, using legacy perf. control.\n"));
  91. return status;
  92. }
  93. void acpi_processor_set_pdc(struct acpi_processor *pr)
  94. {
  95. if (arch_has_acpi_pdc() == false)
  96. return;
  97. acpi_processor_init_pdc(pr);
  98. acpi_processor_eval_pdc(pr);
  99. arch_acpi_processor_cleanup_pdc(pr);
  100. }
  101. EXPORT_SYMBOL_GPL(acpi_processor_set_pdc);
  102. static acpi_status
  103. early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
  104. {
  105. struct acpi_processor pr;
  106. pr.handle = handle;
  107. /* x86 implementation looks at pr.id to determine some
  108. * CPU capabilites. We can just hard code to 0 since we're
  109. * assuming the CPUs in the system are homogenous and all
  110. * have the same capabilities.
  111. */
  112. pr.id = 0;
  113. acpi_processor_set_pdc(&pr);
  114. return AE_OK;
  115. }
  116. void acpi_early_processor_set_pdc(void)
  117. {
  118. /*
  119. * Check whether the system is DMI table. If yes, OSPM
  120. * should not use mwait for CPU-states.
  121. */
  122. dmi_check_system(processor_idle_dmi_table);
  123. acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
  124. ACPI_UINT32_MAX,
  125. early_init_pdc, NULL, NULL, NULL);
  126. }