apic_64.c 31 KB

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