processor.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2005 Intel Corporation
  3. * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
  4. * - Added _PDC for platforms with Intel CPUs
  5. */
  6. #include <linux/kernel.h>
  7. #include <linux/module.h>
  8. #include <linux/init.h>
  9. #include <linux/acpi.h>
  10. #include <acpi/processor.h>
  11. #include <asm/acpi.h>
  12. static void init_intel_pdc(struct acpi_processor *pr, struct cpuinfo_x86 *c)
  13. {
  14. struct acpi_object_list *obj_list;
  15. union acpi_object *obj;
  16. u32 *buf;
  17. /* allocate and initialize pdc. It will be used later. */
  18. obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
  19. if (!obj_list) {
  20. printk(KERN_ERR "Memory allocation error\n");
  21. return;
  22. }
  23. obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
  24. if (!obj) {
  25. printk(KERN_ERR "Memory allocation error\n");
  26. kfree(obj_list);
  27. return;
  28. }
  29. buf = kmalloc(12, GFP_KERNEL);
  30. if (!buf) {
  31. printk(KERN_ERR "Memory allocation error\n");
  32. kfree(obj);
  33. kfree(obj_list);
  34. return;
  35. }
  36. buf[0] = ACPI_PDC_REVISION_ID;
  37. buf[1] = 1;
  38. buf[2] = ACPI_PDC_C_CAPABILITY_SMP;
  39. /*
  40. * The default of PDC_SMP_T_SWCOORD bit is set for intel x86 cpu so
  41. * that OSPM is capable of native ACPI throttling software
  42. * coordination using BIOS supplied _TSD info.
  43. */
  44. buf[2] |= ACPI_PDC_SMP_T_SWCOORD;
  45. if (cpu_has(c, X86_FEATURE_EST))
  46. buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
  47. if (cpu_has(c, X86_FEATURE_ACPI))
  48. buf[2] |= ACPI_PDC_T_FFH;
  49. /*
  50. * If mwait/monitor is unsupported, C2/C3_FFH will be disabled
  51. */
  52. if (!cpu_has(c, X86_FEATURE_MWAIT))
  53. buf[2] &= ~(ACPI_PDC_C_C2C3_FFH);
  54. obj->type = ACPI_TYPE_BUFFER;
  55. obj->buffer.length = 12;
  56. obj->buffer.pointer = (u8 *) buf;
  57. obj_list->count = 1;
  58. obj_list->pointer = obj;
  59. pr->pdc = obj_list;
  60. return;
  61. }
  62. /* Initialize _PDC data based on the CPU vendor */
  63. void arch_acpi_processor_init_pdc(struct acpi_processor *pr)
  64. {
  65. struct cpuinfo_x86 *c = &cpu_data(pr->id);
  66. pr->pdc = NULL;
  67. if (c->x86_vendor == X86_VENDOR_INTEL)
  68. init_intel_pdc(pr, c);
  69. return;
  70. }
  71. EXPORT_SYMBOL(arch_acpi_processor_init_pdc);