@@ -369,12 +369,7 @@ static void __init lapic_cal_handler(struct clock_event_device *dev)
369
369
}
370
370
}
371
371
372
- /*
373
- * Setup the boot APIC
374
- *
375
- * Calibrate and verify the result.
376
- */
377
- void __init setup_boot_APIC_clock (void )
372
+ static int __init calibrate_APIC_clock (void )
378
373
{
379
374
struct clock_event_device * levt = & __get_cpu_var (lapic_events );
380
375
const long pm_100ms = PMTMR_TICKS_PER_SEC /10 ;
@@ -384,24 +379,6 @@ void __init setup_boot_APIC_clock(void)
384
379
long delta , deltapm ;
385
380
int pm_referenced = 0 ;
386
381
387
- /*
388
- * The local apic timer can be disabled via the kernel
389
- * commandline or from the CPU detection code. Register the lapic
390
- * timer as a dummy clock event source on SMP systems, so the
391
- * broadcast mechanism is used. On UP systems simply ignore it.
392
- */
393
- if (local_apic_timer_disabled ) {
394
- /* No broadcast on UP ! */
395
- if (num_possible_cpus () > 1 ) {
396
- lapic_clockevent .mult = 1 ;
397
- setup_APIC_timer ();
398
- }
399
- return ;
400
- }
401
-
402
- apic_printk (APIC_VERBOSE , "Using local APIC timer interrupts.\n"
403
- "calibrating APIC timer ...\n" );
404
-
405
382
local_irq_disable ();
406
383
407
384
/* Replace the global interrupt handler */
@@ -486,21 +463,18 @@ void __init setup_boot_APIC_clock(void)
486
463
calibration_result / (1000000 / HZ ),
487
464
calibration_result % (1000000 / HZ ));
488
465
489
- local_apic_timer_verify_ok = 1 ;
490
-
491
466
/*
492
467
* Do a sanity check on the APIC calibration result
493
468
*/
494
469
if (calibration_result < (1000000 / HZ )) {
495
470
local_irq_enable ();
496
471
printk (KERN_WARNING
497
472
"APIC frequency too slow, disabling apic timer\n" );
498
- /* No broadcast on UP ! */
499
- if (num_possible_cpus () > 1 )
500
- setup_APIC_timer ();
501
- return ;
473
+ return -1 ;
502
474
}
503
475
476
+ local_apic_timer_verify_ok = 1 ;
477
+
504
478
/* We trust the pm timer based calibration */
505
479
if (!pm_referenced ) {
506
480
apic_printk (APIC_VERBOSE , "... verify APIC timer\n" );
@@ -540,22 +514,55 @@ void __init setup_boot_APIC_clock(void)
540
514
if (!local_apic_timer_verify_ok ) {
541
515
printk (KERN_WARNING
542
516
"APIC timer disabled due to verification failure.\n" );
517
+ return -1 ;
518
+ }
519
+
520
+ return 0 ;
521
+ }
522
+
523
+ /*
524
+ * Setup the boot APIC
525
+ *
526
+ * Calibrate and verify the result.
527
+ */
528
+ void __init setup_boot_APIC_clock (void )
529
+ {
530
+ /*
531
+ * The local apic timer can be disabled via the kernel
532
+ * commandline or from the CPU detection code. Register the lapic
533
+ * timer as a dummy clock event source on SMP systems, so the
534
+ * broadcast mechanism is used. On UP systems simply ignore it.
535
+ */
536
+ if (local_apic_timer_disabled ) {
543
537
/* No broadcast on UP ! */
544
- if (num_possible_cpus () == 1 )
545
- return ;
546
- } else {
547
- /*
548
- * If nmi_watchdog is set to IO_APIC, we need the
549
- * PIT/HPET going. Otherwise register lapic as a dummy
550
- * device.
551
- */
552
- if (nmi_watchdog != NMI_IO_APIC )
553
- lapic_clockevent .features &= ~CLOCK_EVT_FEAT_DUMMY ;
554
- else
555
- printk (KERN_WARNING "APIC timer registered as dummy,"
556
- " due to nmi_watchdog=%d!\n" , nmi_watchdog );
538
+ if (num_possible_cpus () > 1 ) {
539
+ lapic_clockevent .mult = 1 ;
540
+ setup_APIC_timer ();
541
+ }
542
+ return ;
543
+ }
544
+
545
+ apic_printk (APIC_VERBOSE , "Using local APIC timer interrupts.\n"
546
+ "calibrating APIC timer ...\n" );
547
+
548
+ if (calibrate_APIC_clock ()) {
549
+ /* No broadcast on UP ! */
550
+ if (num_possible_cpus () > 1 )
551
+ setup_APIC_timer ();
552
+ return ;
557
553
}
558
554
555
+ /*
556
+ * If nmi_watchdog is set to IO_APIC, we need the
557
+ * PIT/HPET going. Otherwise register lapic as a dummy
558
+ * device.
559
+ */
560
+ if (nmi_watchdog != NMI_IO_APIC )
561
+ lapic_clockevent .features &= ~CLOCK_EVT_FEAT_DUMMY ;
562
+ else
563
+ printk (KERN_WARNING "APIC timer registered as dummy,"
564
+ " due to nmi_watchdog=%d!\n" , nmi_watchdog );
565
+
559
566
/* Setup the lapic or request the broadcast */
560
567
setup_APIC_timer ();
561
568
}
0 commit comments