mce_intel_64.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Intel specific MCE features.
  3. * Copyright 2004 Zwane Mwaikambo <zwane@linuxpower.ca>
  4. */
  5. #include <linux/init.h>
  6. #include <linux/interrupt.h>
  7. #include <linux/percpu.h>
  8. #include <asm/processor.h>
  9. #include <asm/msr.h>
  10. #include <asm/mce.h>
  11. #include <asm/hw_irq.h>
  12. #include <asm/idle.h>
  13. #include <asm/therm_throt.h>
  14. asmlinkage void smp_thermal_interrupt(void)
  15. {
  16. __u64 msr_val;
  17. ack_APIC_irq();
  18. exit_idle();
  19. irq_enter();
  20. rdmsrl(MSR_IA32_THERM_STATUS, msr_val);
  21. if (therm_throt_process(msr_val & 1))
  22. mce_log_therm_throt_event(smp_processor_id(), msr_val);
  23. irq_exit();
  24. }
  25. static void __cpuinit intel_init_thermal(struct cpuinfo_x86 *c)
  26. {
  27. u32 l, h;
  28. int tm2 = 0;
  29. unsigned int cpu = smp_processor_id();
  30. if (!cpu_has(c, X86_FEATURE_ACPI))
  31. return;
  32. if (!cpu_has(c, X86_FEATURE_ACC))
  33. return;
  34. /* first check if TM1 is already enabled by the BIOS, in which
  35. * case there might be some SMM goo which handles it, so we can't even
  36. * put a handler since it might be delivered via SMI already.
  37. */
  38. rdmsr(MSR_IA32_MISC_ENABLE, l, h);
  39. h = apic_read(APIC_LVTTHMR);
  40. if ((l & (1 << 3)) && (h & APIC_DM_SMI)) {
  41. printk(KERN_DEBUG
  42. "CPU%d: Thermal monitoring handled by SMI\n", cpu);
  43. return;
  44. }
  45. if (cpu_has(c, X86_FEATURE_TM2) && (l & (1 << 13)))
  46. tm2 = 1;
  47. if (h & APIC_VECTOR_MASK) {
  48. printk(KERN_DEBUG
  49. "CPU%d: Thermal LVT vector (%#x) already "
  50. "installed\n", cpu, (h & APIC_VECTOR_MASK));
  51. return;
  52. }
  53. h = THERMAL_APIC_VECTOR;
  54. h |= (APIC_DM_FIXED | APIC_LVT_MASKED);
  55. apic_write(APIC_LVTTHMR, h);
  56. rdmsr(MSR_IA32_THERM_INTERRUPT, l, h);
  57. wrmsr(MSR_IA32_THERM_INTERRUPT, l | 0x03, h);
  58. rdmsr(MSR_IA32_MISC_ENABLE, l, h);
  59. wrmsr(MSR_IA32_MISC_ENABLE, l | (1 << 3), h);
  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. return;
  67. }
  68. void __cpuinit mce_intel_feature_init(struct cpuinfo_x86 *c)
  69. {
  70. intel_init_thermal(c);
  71. }