apic_64.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  1. /*
  2. * Local APIC handling, local APIC timers
  3. *
  4. * (c) 1999, 2000 Ingo Molnar <mingo@redhat.com>
  5. *
  6. * Fixes
  7. * Maciej W. Rozycki : Bits for genuine 82489DX APICs;
  8. * thanks to Eric Gilmore
  9. * and Rolf G. Tews
  10. * for testing these extensively.
  11. * Maciej W. Rozycki : Various updates and fixes.
  12. * Mikael Pettersson : Power Management for UP-APIC.
  13. * Pavel Machek and
  14. * Mikael Pettersson : PM converted to driver model.
  15. */
  16. #include <linux/init.h>
  17. #include <linux/mm.h>
  18. #include <linux/delay.h>
  19. #include <linux/bootmem.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/mc146818rtc.h>
  22. #include <linux/kernel_stat.h>
  23. #include <linux/sysdev.h>
  24. #include <linux/ioport.h>
  25. #include <linux/clockchips.h>
  26. #include <linux/acpi_pmtmr.h>
  27. #include <linux/module.h>
  28. #include <asm/atomic.h>
  29. #include <asm/smp.h>
  30. #include <asm/mtrr.h>
  31. #include <asm/mpspec.h>
  32. #include <asm/hpet.h>
  33. #include <asm/pgalloc.h>
  34. #include <asm/mach_apic.h>
  35. #include <asm/nmi.h>
  36. #include <asm/idle.h>
  37. #include <asm/proto.h>
  38. #include <asm/timex.h>
  39. #include <asm/apic.h>
  40. int disable_apic_timer __cpuinitdata;
  41. static int apic_calibrate_pmtmr __initdata;
  42. int disable_apic;
  43. /* Local APIC timer works in C2 */
  44. int local_apic_timer_c2_ok;
  45. EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok);
  46. /*
  47. * Debug level, exported for io_apic.c
  48. */
  49. int apic_verbosity;
  50. static struct resource lapic_resource = {
  51. .name = "Local APIC",
  52. .flags = IORESOURCE_MEM | IORESOURCE_BUSY,
  53. };
  54. static unsigned int calibration_result;
  55. static int lapic_next_event(unsigned long delta,
  56. struct clock_event_device *evt);
  57. static void lapic_timer_setup(enum clock_event_mode mode,
  58. struct clock_event_device *evt);
  59. static void lapic_timer_broadcast(cpumask_t mask);
  60. static void apic_pm_activate(void);
  61. static struct clock_event_device lapic_clockevent = {
  62. .name = "lapic",
  63. .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT
  64. | CLOCK_EVT_FEAT_C3STOP | CLOCK_EVT_FEAT_DUMMY,
  65. .shift = 32,
  66. .set_mode = lapic_timer_setup,
  67. .set_next_event = lapic_next_event,
  68. .broadcast = lapic_timer_broadcast,
  69. .rating = 100,
  70. .irq = -1,
  71. };
  72. static DEFINE_PER_CPU(struct clock_event_device, lapic_events);
  73. static unsigned long apic_phys;
  74. /*
  75. * Get the LAPIC version
  76. */
  77. static inline int lapic_get_version(void)
  78. {
  79. return GET_APIC_VERSION(apic_read(APIC_LVR));
  80. }
  81. /*
  82. * Check, if the APIC is integrated or a seperate chip
  83. */
  84. static inline int lapic_is_integrated(void)
  85. {
  86. return 1;
  87. }
  88. /*
  89. * Check, whether this is a modern or a first generation APIC
  90. */
  91. static int modern_apic(void)
  92. {
  93. /* AMD systems use old APIC versions, so check the CPU */
  94. if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
  95. boot_cpu_data.x86 >= 0xf)
  96. return 1;
  97. return lapic_get_version() >= 0x14;
  98. }
  99. void apic_wait_icr_idle(void)
  100. {
  101. while (apic_read(APIC_ICR) & APIC_ICR_BUSY)
  102. cpu_relax();
  103. }
  104. u32 safe_apic_wait_icr_idle(void)
  105. {
  106. u32 send_status;
  107. int timeout;
  108. timeout = 0;
  109. do {
  110. send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
  111. if (!send_status)
  112. break;
  113. udelay(100);
  114. } while (timeout++ < 1000);
  115. return send_status;
  116. }
  117. /**
  118. * enable_NMI_through_LVT0 - enable NMI through local vector table 0
  119. */
  120. void __cpuinit enable_NMI_through_LVT0(void)
  121. {
  122. unsigned int v;
  123. /* unmask and set to NMI */
  124. v = APIC_DM_NMI;
  125. apic_write(APIC_LVT0, v);
  126. }
  127. /**
  128. * lapic_get_maxlvt - get the maximum number of local vector table entries
  129. */
  130. int lapic_get_maxlvt(void)
  131. {
  132. unsigned int v, maxlvt;
  133. v = apic_read(APIC_LVR);
  134. maxlvt = GET_APIC_MAXLVT(v);
  135. return maxlvt;
  136. }
  137. /*
  138. * This function sets up the local APIC timer, with a timeout of
  139. * 'clocks' APIC bus clock. During calibration we actually call
  140. * this function twice on the boot CPU, once with a bogus timeout
  141. * value, second time for real. The other (noncalibrating) CPUs
  142. * call this function only once, with the real, calibrated value.
  143. *
  144. * We do reads before writes even if unnecessary, to get around the
  145. * P5 APIC double write bug.
  146. */
  147. static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
  148. {
  149. unsigned int lvtt_value, tmp_value;
  150. lvtt_value = LOCAL_TIMER_VECTOR;
  151. if (!oneshot)
  152. lvtt_value |= APIC_LVT_TIMER_PERIODIC;
  153. if (!irqen)
  154. lvtt_value |= APIC_LVT_MASKED;
  155. apic_write(APIC_LVTT, lvtt_value);
  156. /*
  157. * Divide PICLK by 16
  158. */
  159. tmp_value = apic_read(APIC_TDCR);
  160. apic_write(APIC_TDCR, (tmp_value
  161. & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE))
  162. | APIC_TDR_DIV_16);
  163. if (!oneshot)
  164. apic_write(APIC_TMICT, clocks);
  165. }
  166. /*
  167. * Setup extended LVT, AMD specific (K8, family 10h)
  168. *
  169. * Vector mappings are hard coded. On K8 only offset 0 (APIC500) and
  170. * MCE interrupts are supported. Thus MCE offset must be set to 0.
  171. */
  172. #define APIC_EILVT_LVTOFF_MCE 0
  173. #define APIC_EILVT_LVTOFF_IBS 1
  174. static void setup_APIC_eilvt(u8 lvt_off, u8 vector, u8 msg_type, u8 mask)
  175. {
  176. unsigned long reg = (lvt_off << 4) + APIC_EILVT0;
  177. unsigned int v = (mask << 16) | (msg_type << 8) | vector;
  178. apic_write(reg, v);
  179. }
  180. u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask)
  181. {
  182. setup_APIC_eilvt(APIC_EILVT_LVTOFF_MCE, vector, msg_type, mask);
  183. return APIC_EILVT_LVTOFF_MCE;
  184. }
  185. u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask)
  186. {
  187. setup_APIC_eilvt(APIC_EILVT_LVTOFF_IBS, vector, msg_type, mask);
  188. return APIC_EILVT_LVTOFF_IBS;
  189. }
  190. /*
  191. * Program the next event, relative to now
  192. */
  193. static int lapic_next_event(unsigned long delta,
  194. struct clock_event_device *evt)
  195. {
  196. apic_write(APIC_TMICT, delta);
  197. return 0;
  198. }
  199. /*
  200. * Setup the lapic timer in periodic or oneshot mode
  201. */
  202. static void lapic_timer_setup(enum clock_event_mode mode,
  203. struct clock_event_device *evt)
  204. {
  205. unsigned long flags;
  206. unsigned int v;
  207. /* Lapic used as dummy for broadcast ? */
  208. if (evt->features & CLOCK_EVT_FEAT_DUMMY)
  209. return;
  210. local_irq_save(flags);
  211. switch (mode) {
  212. case CLOCK_EVT_MODE_PERIODIC:
  213. case CLOCK_EVT_MODE_ONESHOT:
  214. __setup_APIC_LVTT(calibration_result,
  215. mode != CLOCK_EVT_MODE_PERIODIC, 1);
  216. break;
  217. case CLOCK_EVT_MODE_UNUSED:
  218. case CLOCK_EVT_MODE_SHUTDOWN:
  219. v = apic_read(APIC_LVTT);
  220. v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
  221. apic_write(APIC_LVTT, v);
  222. break;
  223. case CLOCK_EVT_MODE_RESUME:
  224. /* Nothing to do here */
  225. break;
  226. }
  227. local_irq_restore(flags);
  228. }
  229. /*
  230. * Local APIC timer broadcast function
  231. */
  232. static void lapic_timer_broadcast(cpumask_t mask)
  233. {
  234. #ifdef CONFIG_SMP
  235. send_IPI_mask(mask, LOCAL_TIMER_VECTOR);
  236. #endif
  237. }
  238. /*
  239. * Setup the local APIC timer for this CPU. Copy the initilized values
  240. * of the boot CPU and register the clock event in the framework.
  241. */
  242. static void setup_APIC_timer(void)
  243. {
  244. struct clock_event_device *levt = &__get_cpu_var(lapic_events);
  245. memcpy(levt, &lapic_clockevent, sizeof(*levt));
  246. levt->cpumask = cpumask_of_cpu(smp_processor_id());
  247. clockevents_register_device(levt);
  248. }
  249. /*
  250. * In this function we calibrate APIC bus clocks to the external
  251. * timer. Unfortunately we cannot use jiffies and the timer irq
  252. * to calibrate, since some later bootup code depends on getting
  253. * the first irq? Ugh.
  254. *
  255. * We want to do the calibration only once since we
  256. * want to have local timer irqs syncron. CPUs connected
  257. * by the same APIC bus have the very same bus frequency.
  258. * And we want to have irqs off anyways, no accidental
  259. * APIC irq that way.
  260. */
  261. #define TICK_COUNT 100000000
  262. static void __init calibrate_APIC_clock(void)
  263. {
  264. unsigned apic, apic_start;
  265. unsigned long tsc, tsc_start;
  266. int result;
  267. local_irq_disable();
  268. /*
  269. * Put whatever arbitrary (but long enough) timeout
  270. * value into the APIC clock, we just want to get the
  271. * counter running for calibration.
  272. *
  273. * No interrupt enable !
  274. */
  275. __setup_APIC_LVTT(250000000, 0, 0);
  276. apic_start = apic_read(APIC_TMCCT);
  277. #ifdef CONFIG_X86_PM_TIMER
  278. if (apic_calibrate_pmtmr && pmtmr_ioport) {
  279. pmtimer_wait(5000); /* 5ms wait */
  280. apic = apic_read(APIC_TMCCT);
  281. result = (apic_start - apic) * 1000L / 5;
  282. } else
  283. #endif
  284. {
  285. rdtscll(tsc_start);
  286. do {
  287. apic = apic_read(APIC_TMCCT);
  288. rdtscll(tsc);
  289. } while ((tsc - tsc_start) < TICK_COUNT &&
  290. (apic_start - apic) < TICK_COUNT);
  291. result = (apic_start - apic) * 1000L * tsc_khz /
  292. (tsc - tsc_start);
  293. }
  294. local_irq_enable();
  295. printk(KERN_DEBUG "APIC timer calibration result %d\n", result);
  296. printk(KERN_INFO "Detected %d.%03d MHz APIC timer.\n",
  297. result / 1000 / 1000, result / 1000 % 1000);
  298. /* Calculate the scaled math multiplication factor */
  299. lapic_clockevent.mult = div_sc(result, NSEC_PER_SEC, 32);
  300. lapic_clockevent.max_delta_ns =
  301. clockevent_delta2ns(0x7FFFFF, &lapic_clockevent);
  302. lapic_clockevent.min_delta_ns =
  303. clockevent_delta2ns(0xF, &lapic_clockevent);
  304. calibration_result = result / HZ;
  305. }
  306. /*
  307. * Setup the boot APIC
  308. *
  309. * Calibrate and verify the result.
  310. */
  311. void __init setup_boot_APIC_clock(void)
  312. {
  313. /*
  314. * The local apic timer can be disabled via the kernel commandline.
  315. * Register the lapic timer as a dummy clock event source on SMP
  316. * systems, so the broadcast mechanism is used. On UP systems simply
  317. * ignore it.
  318. */
  319. if (disable_apic_timer) {
  320. printk(KERN_INFO "Disabling APIC timer\n");
  321. /* No broadcast on UP ! */
  322. if (num_possible_cpus() > 1) {
  323. lapic_clockevent.mult = 1;
  324. setup_APIC_timer();
  325. }
  326. return;
  327. }
  328. printk(KERN_INFO "Using local APIC timer interrupts.\n");
  329. calibrate_APIC_clock();
  330. /*
  331. * Do a sanity check on the APIC calibration result
  332. */
  333. if (calibration_result < (1000000 / HZ)) {
  334. printk(KERN_WARNING
  335. "APIC frequency too slow, disabling apic timer\n");
  336. /* No broadcast on UP ! */
  337. if (num_possible_cpus() > 1)
  338. setup_APIC_timer();
  339. return;
  340. }
  341. /*
  342. * If nmi_watchdog is set to IO_APIC, we need the
  343. * PIT/HPET going. Otherwise register lapic as a dummy
  344. * device.
  345. */
  346. if (nmi_watchdog != NMI_IO_APIC)
  347. lapic_clockevent.features &= ~CLOCK_EVT_FEAT_DUMMY;
  348. else
  349. printk(KERN_WARNING "APIC timer registered as dummy,"
  350. " due to nmi_watchdog=1!\n");
  351. setup_APIC_timer();
  352. }
  353. /*
  354. * AMD C1E enabled CPUs have a real nasty problem: Some BIOSes set the
  355. * C1E flag only in the secondary CPU, so when we detect the wreckage
  356. * we already have enabled the boot CPU local apic timer. Check, if
  357. * disable_apic_timer is set and the DUMMY flag is cleared. If yes,
  358. * set the DUMMY flag again and force the broadcast mode in the
  359. * clockevents layer.
  360. */
  361. void __cpuinit check_boot_apic_timer_broadcast(void)
  362. {
  363. if (!disable_apic_timer ||
  364. (lapic_clockevent.features & CLOCK_EVT_FEAT_DUMMY))
  365. return;
  366. printk(KERN_INFO "AMD C1E detected late. Force timer broadcast.\n");
  367. lapic_clockevent.features |= CLOCK_EVT_FEAT_DUMMY;
  368. local_irq_enable();
  369. clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_FORCE, &boot_cpu_id);
  370. local_irq_disable();
  371. }
  372. void __cpuinit setup_secondary_APIC_clock(void)
  373. {
  374. check_boot_apic_timer_broadcast();
  375. setup_APIC_timer();
  376. }
  377. /*
  378. * The guts of the apic timer interrupt
  379. */
  380. static void local_apic_timer_interrupt(void)
  381. {
  382. int cpu = smp_processor_id();
  383. struct clock_event_device *evt = &per_cpu(lapic_events, cpu);
  384. /*
  385. * Normally we should not be here till LAPIC has been initialized but
  386. * in some cases like kdump, its possible that there is a pending LAPIC
  387. * timer interrupt from previous kernel's context and is delivered in
  388. * new kernel the moment interrupts are enabled.
  389. *
  390. * Interrupts are enabled early and LAPIC is setup much later, hence
  391. * its possible that when we get here evt->event_handler is NULL.
  392. * Check for event_handler being NULL and discard the interrupt as
  393. * spurious.
  394. */
  395. if (!evt->event_handler) {
  396. printk(KERN_WARNING
  397. "Spurious LAPIC timer interrupt on cpu %d\n", cpu);
  398. /* Switch it off */
  399. lapic_timer_setup(CLOCK_EVT_MODE_SHUTDOWN, evt);
  400. return;
  401. }
  402. /*
  403. * the NMI deadlock-detector uses this.
  404. */
  405. add_pda(apic_timer_irqs, 1);
  406. evt->event_handler(evt);
  407. }
  408. /*
  409. * Local APIC timer interrupt. This is the most natural way for doing
  410. * local interrupts, but local timer interrupts can be emulated by
  411. * broadcast interrupts too. [in case the hw doesn't support APIC timers]
  412. *
  413. * [ if a single-CPU system runs an SMP kernel then we call the local
  414. * interrupt as well. Thus we cannot inline the local irq ... ]
  415. */
  416. void smp_apic_timer_interrupt(struct pt_regs *regs)
  417. {
  418. struct pt_regs *old_regs = set_irq_regs(regs);
  419. /*
  420. * NOTE! We'd better ACK the irq immediately,
  421. * because timer handling can be slow.
  422. */
  423. ack_APIC_irq();
  424. /*
  425. * update_process_times() expects us to have done irq_enter().
  426. * Besides, if we don't timer interrupts ignore the global
  427. * interrupt lock, which is the WrongThing (tm) to do.
  428. */
  429. exit_idle();
  430. irq_enter();
  431. local_apic_timer_interrupt();
  432. irq_exit();
  433. set_irq_regs(old_regs);
  434. }
  435. int setup_profiling_timer(unsigned int multiplier)
  436. {
  437. return -EINVAL;
  438. }
  439. /*
  440. * Local APIC start and shutdown
  441. */
  442. /**
  443. * clear_local_APIC - shutdown the local APIC
  444. *
  445. * This is called, when a CPU is disabled and before rebooting, so the state of
  446. * the local APIC has no dangling leftovers. Also used to cleanout any BIOS
  447. * leftovers during boot.
  448. */
  449. void clear_local_APIC(void)
  450. {
  451. int maxlvt = lapic_get_maxlvt();
  452. u32 v;
  453. /* APIC hasn't been mapped yet */
  454. if (!apic_phys)
  455. return;
  456. maxlvt = lapic_get_maxlvt();
  457. /*
  458. * Masking an LVT entry can trigger a local APIC error
  459. * if the vector is zero. Mask LVTERR first to prevent this.
  460. */
  461. if (maxlvt >= 3) {
  462. v = ERROR_APIC_VECTOR; /* any non-zero vector will do */
  463. apic_write(APIC_LVTERR, v | APIC_LVT_MASKED);
  464. }
  465. /*
  466. * Careful: we have to set masks only first to deassert
  467. * any level-triggered sources.
  468. */
  469. v = apic_read(APIC_LVTT);
  470. apic_write(APIC_LVTT, v | APIC_LVT_MASKED);
  471. v = apic_read(APIC_LVT0);
  472. apic_write(APIC_LVT0, v | APIC_LVT_MASKED);
  473. v = apic_read(APIC_LVT1);
  474. apic_write(APIC_LVT1, v | APIC_LVT_MASKED);
  475. if (maxlvt >= 4) {
  476. v = apic_read(APIC_LVTPC);
  477. apic_write(APIC_LVTPC, v | APIC_LVT_MASKED);
  478. }
  479. /*
  480. * Clean APIC state for other OSs:
  481. */
  482. apic_write(APIC_LVTT, APIC_LVT_MASKED);
  483. apic_write(APIC_LVT0, APIC_LVT_MASKED);
  484. apic_write(APIC_LVT1, APIC_LVT_MASKED);
  485. if (maxlvt >= 3)
  486. apic_write(APIC_LVTERR, APIC_LVT_MASKED);
  487. if (maxlvt >= 4)
  488. apic_write(APIC_LVTPC, APIC_LVT_MASKED);
  489. apic_write(APIC_ESR, 0);
  490. apic_read(APIC_ESR);
  491. }
  492. /**
  493. * disable_local_APIC - clear and disable the local APIC
  494. */
  495. void disable_local_APIC(void)
  496. {
  497. unsigned int value;
  498. clear_local_APIC();
  499. /*
  500. * Disable APIC (implies clearing of registers
  501. * for 82489DX!).
  502. */
  503. value = apic_read(APIC_SPIV);
  504. value &= ~APIC_SPIV_APIC_ENABLED;
  505. apic_write(APIC_SPIV, value);
  506. }
  507. void lapic_shutdown(void)
  508. {
  509. unsigned long flags;
  510. if (!cpu_has_apic)
  511. return;
  512. local_irq_save(flags);
  513. disable_local_APIC();
  514. local_irq_restore(flags);
  515. }
  516. /*
  517. * This is to verify that we're looking at a real local APIC.
  518. * Check these against your board if the CPUs aren't getting
  519. * started for no apparent reason.
  520. */
  521. int __init verify_local_APIC(void)
  522. {
  523. unsigned int reg0, reg1;
  524. /*
  525. * The version register is read-only in a real APIC.
  526. */
  527. reg0 = apic_read(APIC_LVR);
  528. apic_printk(APIC_DEBUG, "Getting VERSION: %x\n", reg0);
  529. apic_write(APIC_LVR, reg0 ^ APIC_LVR_MASK);
  530. reg1 = apic_read(APIC_LVR);
  531. apic_printk(APIC_DEBUG, "Getting VERSION: %x\n", reg1);
  532. /*
  533. * The two version reads above should print the same
  534. * numbers. If the second one is different, then we
  535. * poke at a non-APIC.
  536. */
  537. if (reg1 != reg0)
  538. return 0;
  539. /*
  540. * Check if the version looks reasonably.
  541. */
  542. reg1 = GET_APIC_VERSION(reg0);
  543. if (reg1 == 0x00 || reg1 == 0xff)
  544. return 0;
  545. reg1 = lapic_get_maxlvt();
  546. if (reg1 < 0x02 || reg1 == 0xff)
  547. return 0;
  548. /*
  549. * The ID register is read/write in a real APIC.
  550. */
  551. reg0 = apic_read(APIC_ID);
  552. apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg0);
  553. apic_write(APIC_ID, reg0 ^ APIC_ID_MASK);
  554. reg1 = apic_read(APIC_ID);
  555. apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg1);
  556. apic_write(APIC_ID, reg0);
  557. if (reg1 != (reg0 ^ APIC_ID_MASK))
  558. return 0;
  559. /*
  560. * The next two are just to see if we have sane values.
  561. * They're only really relevant if we're in Virtual Wire
  562. * compatibility mode, but most boxes are anymore.
  563. */
  564. reg0 = apic_read(APIC_LVT0);
  565. apic_printk(APIC_DEBUG, "Getting LVT0: %x\n", reg0);
  566. reg1 = apic_read(APIC_LVT1);
  567. apic_printk(APIC_DEBUG, "Getting LVT1: %x\n", reg1);
  568. return 1;
  569. }
  570. /**
  571. * sync_Arb_IDs - synchronize APIC bus arbitration IDs
  572. */
  573. void __init sync_Arb_IDs(void)
  574. {
  575. /* Unsupported on P4 - see Intel Dev. Manual Vol. 3, Ch. 8.6.1 */
  576. if (modern_apic())
  577. return;
  578. /*
  579. * Wait for idle.
  580. */
  581. apic_wait_icr_idle();
  582. apic_printk(APIC_DEBUG, "Synchronizing Arb IDs.\n");
  583. apic_write(APIC_ICR, APIC_DEST_ALLINC | APIC_INT_LEVELTRIG
  584. | APIC_DM_INIT);
  585. }
  586. /*
  587. * An initial setup of the virtual wire mode.
  588. */
  589. void __init init_bsp_APIC(void)
  590. {
  591. unsigned int value;
  592. /*
  593. * Don't do the setup now if we have a SMP BIOS as the
  594. * through-I/O-APIC virtual wire mode might be active.
  595. */
  596. if (smp_found_config || !cpu_has_apic)
  597. return;
  598. value = apic_read(APIC_LVR);
  599. /*
  600. * Do not trust the local APIC being empty at bootup.
  601. */
  602. clear_local_APIC();
  603. /*
  604. * Enable APIC.
  605. */
  606. value = apic_read(APIC_SPIV);
  607. value &= ~APIC_VECTOR_MASK;
  608. value |= APIC_SPIV_APIC_ENABLED;
  609. value |= APIC_SPIV_FOCUS_DISABLED;
  610. value |= SPURIOUS_APIC_VECTOR;
  611. apic_write(APIC_SPIV, value);
  612. /*
  613. * Set up the virtual wire mode.
  614. */
  615. apic_write(APIC_LVT0, APIC_DM_EXTINT);
  616. value = APIC_DM_NMI;
  617. apic_write(APIC_LVT1, value);
  618. }
  619. /**
  620. * setup_local_APIC - setup the local APIC
  621. */
  622. void __cpuinit setup_local_APIC(void)
  623. {
  624. unsigned int value;
  625. int i, j;
  626. value = apic_read(APIC_LVR);
  627. BUILD_BUG_ON((SPURIOUS_APIC_VECTOR & 0x0f) != 0x0f);
  628. /*
  629. * Double-check whether this APIC is really registered.
  630. * This is meaningless in clustered apic mode, so we skip it.
  631. */
  632. if (!apic_id_registered())
  633. BUG();
  634. /*
  635. * Intel recommends to set DFR, LDR and TPR before enabling
  636. * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
  637. * document number 292116). So here it goes...
  638. */
  639. init_apic_ldr();
  640. /*
  641. * Set Task Priority to 'accept all'. We never change this
  642. * later on.
  643. */
  644. value = apic_read(APIC_TASKPRI);
  645. value &= ~APIC_TPRI_MASK;
  646. apic_write(APIC_TASKPRI, value);
  647. /*
  648. * After a crash, we no longer service the interrupts and a pending
  649. * interrupt from previous kernel might still have ISR bit set.
  650. *
  651. * Most probably by now CPU has serviced that pending interrupt and
  652. * it might not have done the ack_APIC_irq() because it thought,
  653. * interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
  654. * does not clear the ISR bit and cpu thinks it has already serivced
  655. * the interrupt. Hence a vector might get locked. It was noticed
  656. * for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
  657. */
  658. for (i = APIC_ISR_NR - 1; i >= 0; i--) {
  659. value = apic_read(APIC_ISR + i*0x10);
  660. for (j = 31; j >= 0; j--) {
  661. if (value & (1<<j))
  662. ack_APIC_irq();
  663. }
  664. }
  665. /*
  666. * Now that we are all set up, enable the APIC
  667. */
  668. value = apic_read(APIC_SPIV);
  669. value &= ~APIC_VECTOR_MASK;
  670. /*
  671. * Enable APIC
  672. */
  673. value |= APIC_SPIV_APIC_ENABLED;
  674. /* We always use processor focus */
  675. /*
  676. * Set spurious IRQ vector
  677. */
  678. value |= SPURIOUS_APIC_VECTOR;
  679. apic_write(APIC_SPIV, value);
  680. /*
  681. * Set up LVT0, LVT1:
  682. *
  683. * set up through-local-APIC on the BP's LINT0. This is not
  684. * strictly necessary in pure symmetric-IO mode, but sometimes
  685. * we delegate interrupts to the 8259A.
  686. */
  687. /*
  688. * TODO: set up through-local-APIC from through-I/O-APIC? --macro
  689. */
  690. value = apic_read(APIC_LVT0) & APIC_LVT_MASKED;
  691. if (!smp_processor_id() && !value) {
  692. value = APIC_DM_EXTINT;
  693. apic_printk(APIC_VERBOSE, "enabled ExtINT on CPU#%d\n",
  694. smp_processor_id());
  695. } else {
  696. value = APIC_DM_EXTINT | APIC_LVT_MASKED;
  697. apic_printk(APIC_VERBOSE, "masked ExtINT on CPU#%d\n",
  698. smp_processor_id());
  699. }
  700. apic_write(APIC_LVT0, value);
  701. /*
  702. * only the BP should see the LINT1 NMI signal, obviously.
  703. */
  704. if (!smp_processor_id())
  705. value = APIC_DM_NMI;
  706. else
  707. value = APIC_DM_NMI | APIC_LVT_MASKED;
  708. apic_write(APIC_LVT1, value);
  709. }
  710. void __cpuinit lapic_setup_esr(void)
  711. {
  712. unsigned maxlvt = lapic_get_maxlvt();
  713. apic_write(APIC_LVTERR, ERROR_APIC_VECTOR);
  714. /*
  715. * spec says clear errors after enabling vector.
  716. */
  717. if (maxlvt > 3)
  718. apic_write(APIC_ESR, 0);
  719. }
  720. void __cpuinit end_local_APIC_setup(void)
  721. {
  722. lapic_setup_esr();
  723. nmi_watchdog_default();
  724. setup_apic_nmi_watchdog(NULL);
  725. apic_pm_activate();
  726. }
  727. /*
  728. * Detect and enable local APICs on non-SMP boards.
  729. * Original code written by Keir Fraser.
  730. * On AMD64 we trust the BIOS - if it says no APIC it is likely
  731. * not correctly set up (usually the APIC timer won't work etc.)
  732. */
  733. static int __init detect_init_APIC(void)
  734. {
  735. if (!cpu_has_apic) {
  736. printk(KERN_INFO "No local APIC present\n");
  737. return -1;
  738. }
  739. mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
  740. boot_cpu_id = 0;
  741. return 0;
  742. }
  743. /**
  744. * init_apic_mappings - initialize APIC mappings
  745. */
  746. void __init init_apic_mappings(void)
  747. {
  748. /*
  749. * If no local APIC can be found then set up a fake all
  750. * zeroes page to simulate the local APIC and another
  751. * one for the IO-APIC.
  752. */
  753. if (!smp_found_config && detect_init_APIC()) {
  754. apic_phys = (unsigned long) alloc_bootmem_pages(PAGE_SIZE);
  755. apic_phys = __pa(apic_phys);
  756. } else
  757. apic_phys = mp_lapic_addr;
  758. set_fixmap_nocache(FIX_APIC_BASE, apic_phys);
  759. apic_printk(APIC_VERBOSE, "mapped APIC to %16lx (%16lx)\n",
  760. APIC_BASE, apic_phys);
  761. /* Put local APIC into the resource map. */
  762. lapic_resource.start = apic_phys;
  763. lapic_resource.end = lapic_resource.start + PAGE_SIZE - 1;
  764. insert_resource(&iomem_resource, &lapic_resource);
  765. /*
  766. * Fetch the APIC ID of the BSP in case we have a
  767. * default configuration (or the MP table is broken).
  768. */
  769. boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID));
  770. }
  771. /*
  772. * This initializes the IO-APIC and APIC hardware if this is
  773. * a UP kernel.
  774. */
  775. int __init APIC_init_uniprocessor(void)
  776. {
  777. if (disable_apic) {
  778. printk(KERN_INFO "Apic disabled\n");
  779. return -1;
  780. }
  781. if (!cpu_has_apic) {
  782. disable_apic = 1;
  783. printk(KERN_INFO "Apic disabled by BIOS\n");
  784. return -1;
  785. }
  786. verify_local_APIC();
  787. phys_cpu_present_map = physid_mask_of_physid(boot_cpu_id);
  788. apic_write(APIC_ID, SET_APIC_ID(boot_cpu_id));
  789. setup_local_APIC();
  790. /*
  791. * Now enable IO-APICs, actually call clear_IO_APIC
  792. * We need clear_IO_APIC before enabling vector on BP
  793. */
  794. if (!skip_ioapic_setup && nr_ioapics)
  795. enable_IO_APIC();
  796. end_local_APIC_setup();
  797. if (smp_found_config && !skip_ioapic_setup && nr_ioapics)
  798. setup_IO_APIC();
  799. else
  800. nr_ioapics = 0;
  801. setup_boot_APIC_clock();
  802. check_nmi_watchdog();
  803. return 0;
  804. }
  805. /*
  806. * Local APIC interrupts
  807. */
  808. /*
  809. * This interrupt should _never_ happen with our APIC/SMP architecture
  810. */
  811. asmlinkage void smp_spurious_interrupt(void)
  812. {
  813. unsigned int v;
  814. exit_idle();
  815. irq_enter();
  816. /*
  817. * Check if this really is a spurious interrupt and ACK it
  818. * if it is a vectored one. Just in case...
  819. * Spurious interrupts should not be ACKed.
  820. */
  821. v = apic_read(APIC_ISR + ((SPURIOUS_APIC_VECTOR & ~0x1f) >> 1));
  822. if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f)))
  823. ack_APIC_irq();
  824. add_pda(irq_spurious_count, 1);
  825. irq_exit();
  826. }
  827. /*
  828. * This interrupt should never happen with our APIC/SMP architecture
  829. */
  830. asmlinkage void smp_error_interrupt(void)
  831. {
  832. unsigned int v, v1;
  833. exit_idle();
  834. irq_enter();
  835. /* First tickle the hardware, only then report what went on. -- REW */
  836. v = apic_read(APIC_ESR);
  837. apic_write(APIC_ESR, 0);
  838. v1 = apic_read(APIC_ESR);
  839. ack_APIC_irq();
  840. atomic_inc(&irq_err_count);
  841. /* Here is what the APIC error bits mean:
  842. 0: Send CS error
  843. 1: Receive CS error
  844. 2: Send accept error
  845. 3: Receive accept error
  846. 4: Reserved
  847. 5: Send illegal vector
  848. 6: Received illegal vector
  849. 7: Illegal register address
  850. */
  851. printk(KERN_DEBUG "APIC error on CPU%d: %02x(%02x)\n",
  852. smp_processor_id(), v , v1);
  853. irq_exit();
  854. }
  855. void disconnect_bsp_APIC(int virt_wire_setup)
  856. {
  857. /* Go back to Virtual Wire compatibility mode */
  858. unsigned long value;
  859. /* For the spurious interrupt use vector F, and enable it */
  860. value = apic_read(APIC_SPIV);
  861. value &= ~APIC_VECTOR_MASK;
  862. value |= APIC_SPIV_APIC_ENABLED;
  863. value |= 0xf;
  864. apic_write(APIC_SPIV, value);
  865. if (!virt_wire_setup) {
  866. /*
  867. * For LVT0 make it edge triggered, active high,
  868. * external and enabled
  869. */
  870. value = apic_read(APIC_LVT0);
  871. value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
  872. APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
  873. APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED);
  874. value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
  875. value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXTINT);
  876. apic_write(APIC_LVT0, value);
  877. } else {
  878. /* Disable LVT0 */
  879. apic_write(APIC_LVT0, APIC_LVT_MASKED);
  880. }
  881. /* For LVT1 make it edge triggered, active high, nmi and enabled */
  882. value = apic_read(APIC_LVT1);
  883. value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
  884. APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
  885. APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED);
  886. value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
  887. value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI);
  888. apic_write(APIC_LVT1, value);
  889. }
  890. /*
  891. * Power management
  892. */
  893. #ifdef CONFIG_PM
  894. static struct {
  895. /* 'active' is true if the local APIC was enabled by us and
  896. not the BIOS; this signifies that we are also responsible
  897. for disabling it before entering apm/acpi suspend */
  898. int active;
  899. /* r/w apic fields */
  900. unsigned int apic_id;
  901. unsigned int apic_taskpri;
  902. unsigned int apic_ldr;
  903. unsigned int apic_dfr;
  904. unsigned int apic_spiv;
  905. unsigned int apic_lvtt;
  906. unsigned int apic_lvtpc;
  907. unsigned int apic_lvt0;
  908. unsigned int apic_lvt1;
  909. unsigned int apic_lvterr;
  910. unsigned int apic_tmict;
  911. unsigned int apic_tdcr;
  912. unsigned int apic_thmr;
  913. } apic_pm_state;
  914. static int lapic_suspend(struct sys_device *dev, pm_message_t state)
  915. {
  916. unsigned long flags;
  917. int maxlvt;
  918. if (!apic_pm_state.active)
  919. return 0;
  920. maxlvt = lapic_get_maxlvt();
  921. apic_pm_state.apic_id = apic_read(APIC_ID);
  922. apic_pm_state.apic_taskpri = apic_read(APIC_TASKPRI);
  923. apic_pm_state.apic_ldr = apic_read(APIC_LDR);
  924. apic_pm_state.apic_dfr = apic_read(APIC_DFR);
  925. apic_pm_state.apic_spiv = apic_read(APIC_SPIV);
  926. apic_pm_state.apic_lvtt = apic_read(APIC_LVTT);
  927. if (maxlvt >= 4)
  928. apic_pm_state.apic_lvtpc = apic_read(APIC_LVTPC);
  929. apic_pm_state.apic_lvt0 = apic_read(APIC_LVT0);
  930. apic_pm_state.apic_lvt1 = apic_read(APIC_LVT1);
  931. apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR);
  932. apic_pm_state.apic_tmict = apic_read(APIC_TMICT);
  933. apic_pm_state.apic_tdcr = apic_read(APIC_TDCR);
  934. #ifdef CONFIG_X86_MCE_INTEL
  935. if (maxlvt >= 5)
  936. apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
  937. #endif
  938. local_irq_save(flags);
  939. disable_local_APIC();
  940. local_irq_restore(flags);
  941. return 0;
  942. }
  943. static int lapic_resume(struct sys_device *dev)
  944. {
  945. unsigned int l, h;
  946. unsigned long flags;
  947. int maxlvt;
  948. if (!apic_pm_state.active)
  949. return 0;
  950. maxlvt = lapic_get_maxlvt();
  951. local_irq_save(flags);
  952. rdmsr(MSR_IA32_APICBASE, l, h);
  953. l &= ~MSR_IA32_APICBASE_BASE;
  954. l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr;
  955. wrmsr(MSR_IA32_APICBASE, l, h);
  956. apic_write(APIC_LVTERR, ERROR_APIC_VECTOR | APIC_LVT_MASKED);
  957. apic_write(APIC_ID, apic_pm_state.apic_id);
  958. apic_write(APIC_DFR, apic_pm_state.apic_dfr);
  959. apic_write(APIC_LDR, apic_pm_state.apic_ldr);
  960. apic_write(APIC_TASKPRI, apic_pm_state.apic_taskpri);
  961. apic_write(APIC_SPIV, apic_pm_state.apic_spiv);
  962. apic_write(APIC_LVT0, apic_pm_state.apic_lvt0);
  963. apic_write(APIC_LVT1, apic_pm_state.apic_lvt1);
  964. #ifdef CONFIG_X86_MCE_INTEL
  965. if (maxlvt >= 5)
  966. apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr);
  967. #endif
  968. if (maxlvt >= 4)
  969. apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc);
  970. apic_write(APIC_LVTT, apic_pm_state.apic_lvtt);
  971. apic_write(APIC_TDCR, apic_pm_state.apic_tdcr);
  972. apic_write(APIC_TMICT, apic_pm_state.apic_tmict);
  973. apic_write(APIC_ESR, 0);
  974. apic_read(APIC_ESR);
  975. apic_write(APIC_LVTERR, apic_pm_state.apic_lvterr);
  976. apic_write(APIC_ESR, 0);
  977. apic_read(APIC_ESR);
  978. local_irq_restore(flags);
  979. return 0;
  980. }
  981. static struct sysdev_class lapic_sysclass = {
  982. .name = "lapic",
  983. .resume = lapic_resume,
  984. .suspend = lapic_suspend,
  985. };
  986. static struct sys_device device_lapic = {
  987. .id = 0,
  988. .cls = &lapic_sysclass,
  989. };
  990. static void __cpuinit apic_pm_activate(void)
  991. {
  992. apic_pm_state.active = 1;
  993. }
  994. static int __init init_lapic_sysfs(void)
  995. {
  996. int error;
  997. if (!cpu_has_apic)
  998. return 0;
  999. /* XXX: remove suspend/resume procs if !apic_pm_state.active? */
  1000. error = sysdev_class_register(&lapic_sysclass);
  1001. if (!error)
  1002. error = sysdev_register(&device_lapic);
  1003. return error;
  1004. }
  1005. device_initcall(init_lapic_sysfs);
  1006. #else /* CONFIG_PM */
  1007. static void apic_pm_activate(void) { }
  1008. #endif /* CONFIG_PM */
  1009. /*
  1010. * apic_is_clustered_box() -- Check if we can expect good TSC
  1011. *
  1012. * Thus far, the major user of this is IBM's Summit2 series:
  1013. *
  1014. * Clustered boxes may have unsynced TSC problems if they are
  1015. * multi-chassis. Use available data to take a good guess.
  1016. * If in doubt, go HPET.
  1017. */
  1018. __cpuinit int apic_is_clustered_box(void)
  1019. {
  1020. int i, clusters, zeros;
  1021. unsigned id;
  1022. u16 *bios_cpu_apicid = x86_bios_cpu_apicid_early_ptr;
  1023. DECLARE_BITMAP(clustermap, NUM_APIC_CLUSTERS);
  1024. bitmap_zero(clustermap, NUM_APIC_CLUSTERS);
  1025. for (i = 0; i < NR_CPUS; i++) {
  1026. /* are we being called early in kernel startup? */
  1027. if (bios_cpu_apicid) {
  1028. id = bios_cpu_apicid[i];
  1029. }
  1030. else if (i < nr_cpu_ids) {
  1031. if (cpu_present(i))
  1032. id = per_cpu(x86_bios_cpu_apicid, i);
  1033. else
  1034. continue;
  1035. }
  1036. else
  1037. break;
  1038. if (id != BAD_APICID)
  1039. __set_bit(APIC_CLUSTERID(id), clustermap);
  1040. }
  1041. /* Problem: Partially populated chassis may not have CPUs in some of
  1042. * the APIC clusters they have been allocated. Only present CPUs have
  1043. * x86_bios_cpu_apicid entries, thus causing zeroes in the bitmap.
  1044. * Since clusters are allocated sequentially, count zeros only if
  1045. * they are bounded by ones.
  1046. */
  1047. clusters = 0;
  1048. zeros = 0;
  1049. for (i = 0; i < NUM_APIC_CLUSTERS; i++) {
  1050. if (test_bit(i, clustermap)) {
  1051. clusters += 1 + zeros;
  1052. zeros = 0;
  1053. } else
  1054. ++zeros;
  1055. }
  1056. /*
  1057. * If clusters > 2, then should be multi-chassis.
  1058. * May have to revisit this when multi-core + hyperthreaded CPUs come
  1059. * out, but AFAIK this will work even for them.
  1060. */
  1061. return (clusters > 2);
  1062. }
  1063. /*
  1064. * APIC command line parameters
  1065. */
  1066. static int __init apic_set_verbosity(char *str)
  1067. {
  1068. if (str == NULL) {
  1069. skip_ioapic_setup = 0;
  1070. ioapic_force = 1;
  1071. return 0;
  1072. }
  1073. if (strcmp("debug", str) == 0)
  1074. apic_verbosity = APIC_DEBUG;
  1075. else if (strcmp("verbose", str) == 0)
  1076. apic_verbosity = APIC_VERBOSE;
  1077. else {
  1078. printk(KERN_WARNING "APIC Verbosity level %s not recognised"
  1079. " use apic=verbose or apic=debug\n", str);
  1080. return -EINVAL;
  1081. }
  1082. return 0;
  1083. }
  1084. early_param("apic", apic_set_verbosity);
  1085. static __init int setup_disableapic(char *str)
  1086. {
  1087. disable_apic = 1;
  1088. clear_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC);
  1089. return 0;
  1090. }
  1091. early_param("disableapic", setup_disableapic);
  1092. /* same as disableapic, for compatibility */
  1093. static __init int setup_nolapic(char *str)
  1094. {
  1095. return setup_disableapic(str);
  1096. }
  1097. early_param("nolapic", setup_nolapic);
  1098. static int __init parse_lapic_timer_c2_ok(char *arg)
  1099. {
  1100. local_apic_timer_c2_ok = 1;
  1101. return 0;
  1102. }
  1103. early_param("lapic_timer_c2_ok", parse_lapic_timer_c2_ok);
  1104. static __init int setup_noapictimer(char *str)
  1105. {
  1106. if (str[0] != ' ' && str[0] != 0)
  1107. return 0;
  1108. disable_apic_timer = 1;
  1109. return 1;
  1110. }
  1111. __setup("noapictimer", setup_noapictimer);
  1112. static __init int setup_apicpmtimer(char *s)
  1113. {
  1114. apic_calibrate_pmtmr = 1;
  1115. notsc_setup(NULL);
  1116. return 0;
  1117. }
  1118. __setup("apicpmtimer", setup_apicpmtimer);