|
@@ -535,7 +535,8 @@ static void __init lapic_cal_handler(struct clock_event_device *dev)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static int __init calibrate_by_pmtimer(long deltapm, long *delta)
|
|
|
+static int __init
|
|
|
+calibrate_by_pmtimer(long deltapm, long *delta, long *deltatsc)
|
|
|
{
|
|
|
const long pm_100ms = PMTMR_TICKS_PER_SEC / 10;
|
|
|
const long pm_thresh = pm_100ms / 100;
|
|
@@ -557,18 +558,29 @@ static int __init calibrate_by_pmtimer(long deltapm, long *delta)
|
|
|
if (deltapm > (pm_100ms - pm_thresh) &&
|
|
|
deltapm < (pm_100ms + pm_thresh)) {
|
|
|
apic_printk(APIC_VERBOSE, "... PM timer result ok\n");
|
|
|
- } else {
|
|
|
- res = (((u64)deltapm) * mult) >> 22;
|
|
|
- do_div(res, 1000000);
|
|
|
- pr_warning("APIC calibration not consistent "
|
|
|
- "with PM Timer: %ldms instead of 100ms\n",
|
|
|
- (long)res);
|
|
|
- /* Correct the lapic counter value */
|
|
|
- res = (((u64)(*delta)) * pm_100ms);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ res = (((u64)deltapm) * mult) >> 22;
|
|
|
+ do_div(res, 1000000);
|
|
|
+ pr_warning("APIC calibration not consistent "
|
|
|
+ "with PM Timer: %ldms instead of 100ms\n",(long)res);
|
|
|
+
|
|
|
+ /* Correct the lapic counter value */
|
|
|
+ res = (((u64)(*delta)) * pm_100ms);
|
|
|
+ do_div(res, deltapm);
|
|
|
+ pr_info("APIC delta adjusted to PM-Timer: "
|
|
|
+ "%lu (%ld)\n", (unsigned long)res, *delta);
|
|
|
+ *delta = (long)res;
|
|
|
+
|
|
|
+ /* Correct the tsc counter value */
|
|
|
+ if (cpu_has_tsc) {
|
|
|
+ res = (((u64)(*deltatsc)) * pm_100ms);
|
|
|
do_div(res, deltapm);
|
|
|
- pr_info("APIC delta adjusted to PM-Timer: "
|
|
|
- "%lu (%ld)\n", (unsigned long)res, *delta);
|
|
|
- *delta = (long)res;
|
|
|
+ apic_printk(APIC_VERBOSE, "TSC delta adjusted to "
|
|
|
+ "PM-Timer: %lu (%ld) \n",
|
|
|
+ (unsigned long)res, *deltatsc);
|
|
|
+ *deltatsc = (long)res;
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
@@ -579,7 +591,7 @@ static int __init calibrate_APIC_clock(void)
|
|
|
struct clock_event_device *levt = &__get_cpu_var(lapic_events);
|
|
|
void (*real_handler)(struct clock_event_device *dev);
|
|
|
unsigned long deltaj;
|
|
|
- long delta;
|
|
|
+ long delta, deltatsc;
|
|
|
int pm_referenced = 0;
|
|
|
|
|
|
local_irq_disable();
|
|
@@ -609,9 +621,11 @@ static int __init calibrate_APIC_clock(void)
|
|
|
delta = lapic_cal_t1 - lapic_cal_t2;
|
|
|
apic_printk(APIC_VERBOSE, "... lapic delta = %ld\n", delta);
|
|
|
|
|
|
+ deltatsc = (long)(lapic_cal_tsc2 - lapic_cal_tsc1);
|
|
|
+
|
|
|
/* we trust the PM based calibration if possible */
|
|
|
pm_referenced = !calibrate_by_pmtimer(lapic_cal_pm2 - lapic_cal_pm1,
|
|
|
- &delta);
|
|
|
+ &delta, &deltatsc);
|
|
|
|
|
|
/* Calculate the scaled math multiplication factor */
|
|
|
lapic_clockevent.mult = div_sc(delta, TICK_NSEC * LAPIC_CAL_LOOPS,
|
|
@@ -629,11 +643,10 @@ static int __init calibrate_APIC_clock(void)
|
|
|
calibration_result);
|
|
|
|
|
|
if (cpu_has_tsc) {
|
|
|
- delta = (long)(lapic_cal_tsc2 - lapic_cal_tsc1);
|
|
|
apic_printk(APIC_VERBOSE, "..... CPU clock speed is "
|
|
|
"%ld.%04ld MHz.\n",
|
|
|
- (delta / LAPIC_CAL_LOOPS) / (1000000 / HZ),
|
|
|
- (delta / LAPIC_CAL_LOOPS) % (1000000 / HZ));
|
|
|
+ (deltatsc / LAPIC_CAL_LOOPS) / (1000000 / HZ),
|
|
|
+ (deltatsc / LAPIC_CAL_LOOPS) % (1000000 / HZ));
|
|
|
}
|
|
|
|
|
|
apic_printk(APIC_VERBOSE, "..... host bus clock speed is "
|