mce_intel.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Common code for Intel machine checks
  3. */
  4. #include <linux/interrupt.h>
  5. #include <linux/kernel.h>
  6. #include <linux/types.h>
  7. #include <linux/init.h>
  8. #include <linux/smp.h>
  9. #include <asm/therm_throt.h>
  10. #include <asm/processor.h>
  11. #include <asm/system.h>
  12. #include <asm/apic.h>
  13. #include <asm/msr.h>
  14. #include "mce.h"
  15. void intel_init_thermal(struct cpuinfo_x86 *c)
  16. {
  17. unsigned int cpu = smp_processor_id();
  18. int tm2 = 0;
  19. u32 l, h;
  20. /*
  21. * Thermal monitoring depends on ACPI, clock modulation
  22. * and APIC as well
  23. */
  24. if (!cpu_has(c, X86_FEATURE_ACPI) || !cpu_has(c, X86_FEATURE_ACC) ||
  25. !cpu_has(c, X86_FEATURE_APIC)) {
  26. pr_debug("Thermal monitoring disabled\n");
  27. return;
  28. }
  29. /*
  30. * First check if its enabled already, in which case there might
  31. * be some SMM goo which handles it, so we can't even put a handler
  32. * since it might be delivered via SMI already:
  33. */
  34. rdmsr(MSR_IA32_MISC_ENABLE, l, h);
  35. h = apic_read(APIC_LVTTHMR);
  36. if ((l & MSR_IA32_MISC_ENABLE_TM1) && (h & APIC_DM_SMI)) {
  37. printk(KERN_DEBUG
  38. "CPU%d: Thermal monitoring handled by SMI\n", cpu);
  39. return;
  40. }
  41. if (cpu_has(c, X86_FEATURE_TM2) && (l & MSR_IA32_MISC_ENABLE_TM2))
  42. tm2 = 1;
  43. /* Check whether a vector already exists */
  44. if (h & APIC_VECTOR_MASK) {
  45. printk(KERN_DEBUG
  46. "CPU%d: Thermal LVT vector (%#x) already installed\n",
  47. cpu, (h & APIC_VECTOR_MASK));
  48. return;
  49. }
  50. /* We'll mask the thermal vector in the lapic till we're ready: */
  51. h = THERMAL_APIC_VECTOR | APIC_DM_FIXED | APIC_LVT_MASKED;
  52. apic_write(APIC_LVTTHMR, h);
  53. rdmsr(MSR_IA32_THERM_INTERRUPT, l, h);
  54. wrmsr(MSR_IA32_THERM_INTERRUPT,
  55. l | (THERM_INT_LOW_ENABLE | THERM_INT_HIGH_ENABLE), h);
  56. intel_set_thermal_handler();
  57. rdmsr(MSR_IA32_MISC_ENABLE, l, h);
  58. wrmsr(MSR_IA32_MISC_ENABLE, l | MSR_IA32_MISC_ENABLE_TM1, h);
  59. /* Unmask the thermal vector: */
  60. l = apic_read(APIC_LVTTHMR);
  61. apic_write(APIC_LVTTHMR, l & ~APIC_LVT_MASKED);
  62. printk(KERN_INFO "CPU%d: Thermal monitoring enabled (%s)\n",
  63. cpu, tm2 ? "TM2" : "TM1");
  64. /* enable thermal throttle processing */
  65. atomic_set(&therm_throt_en, 1);
  66. }