diff options
| -rw-r--r-- | arch/x86/include/asm/tsc.h | 2 | ||||
| -rw-r--r-- | arch/x86/kernel/tsc.c | 7 | ||||
| -rw-r--r-- | arch/x86/kernel/tsc_msr.c | 28 |
3 files changed, 17 insertions, 20 deletions
diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h index 57ae63cd6ee2..94605c0e9cee 100644 --- a/arch/x86/include/asm/tsc.h +++ b/arch/x86/include/asm/tsc.h | |||
| @@ -66,6 +66,6 @@ extern void tsc_save_sched_clock_state(void); | |||
| 66 | extern void tsc_restore_sched_clock_state(void); | 66 | extern void tsc_restore_sched_clock_state(void); |
| 67 | 67 | ||
| 68 | /* MSR based TSC calibration for Intel Atom SoC platforms */ | 68 | /* MSR based TSC calibration for Intel Atom SoC platforms */ |
| 69 | int try_msr_calibrate_tsc(unsigned long *fast_calibrate); | 69 | unsigned long try_msr_calibrate_tsc(void); |
| 70 | 70 | ||
| 71 | #endif /* _ASM_X86_TSC_H */ | 71 | #endif /* _ASM_X86_TSC_H */ |
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index acb3b606613e..cfbe99f88830 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c | |||
| @@ -653,13 +653,10 @@ unsigned long native_calibrate_tsc(void) | |||
| 653 | 653 | ||
| 654 | /* Calibrate TSC using MSR for Intel Atom SoCs */ | 654 | /* Calibrate TSC using MSR for Intel Atom SoCs */ |
| 655 | local_irq_save(flags); | 655 | local_irq_save(flags); |
| 656 | i = try_msr_calibrate_tsc(&fast_calibrate); | 656 | fast_calibrate = try_msr_calibrate_tsc(); |
| 657 | local_irq_restore(flags); | 657 | local_irq_restore(flags); |
| 658 | if (i >= 0) { | 658 | if (fast_calibrate) |
| 659 | if (i == 0) | ||
| 660 | pr_warn("Fast TSC calibration using MSR failed\n"); | ||
| 661 | return fast_calibrate; | 659 | return fast_calibrate; |
| 662 | } | ||
| 663 | 660 | ||
| 664 | local_irq_save(flags); | 661 | local_irq_save(flags); |
| 665 | fast_calibrate = quick_pit_calibrate(); | 662 | fast_calibrate = quick_pit_calibrate(); |
diff --git a/arch/x86/kernel/tsc_msr.c b/arch/x86/kernel/tsc_msr.c index 8b5434f4389f..5dfff5809e74 100644 --- a/arch/x86/kernel/tsc_msr.c +++ b/arch/x86/kernel/tsc_msr.c | |||
| @@ -77,21 +77,18 @@ static int match_cpu(u8 family, u8 model) | |||
| 77 | 77 | ||
| 78 | /* | 78 | /* |
| 79 | * Do MSR calibration only for known/supported CPUs. | 79 | * Do MSR calibration only for known/supported CPUs. |
| 80 | * Return values: | 80 | * |
| 81 | * -1: CPU is unknown/unsupported for MSR based calibration | 81 | * Returns the calibration value or 0 if MSR calibration failed. |
| 82 | * 0: CPU is known/supported, but calibration failed | ||
| 83 | * 1: CPU is known/supported, and calibration succeeded | ||
| 84 | */ | 82 | */ |
| 85 | int try_msr_calibrate_tsc(unsigned long *fast_calibrate) | 83 | unsigned long try_msr_calibrate_tsc(void) |
| 86 | { | 84 | { |
| 87 | int cpu_index; | ||
| 88 | u32 lo, hi, ratio, freq_id, freq; | 85 | u32 lo, hi, ratio, freq_id, freq; |
| 86 | unsigned long res; | ||
| 87 | int cpu_index; | ||
| 89 | 88 | ||
| 90 | cpu_index = match_cpu(boot_cpu_data.x86, boot_cpu_data.x86_model); | 89 | cpu_index = match_cpu(boot_cpu_data.x86, boot_cpu_data.x86_model); |
| 91 | if (cpu_index < 0) | 90 | if (cpu_index < 0) |
| 92 | return -1; | 91 | return 0; |
| 93 | |||
| 94 | *fast_calibrate = 0; | ||
| 95 | 92 | ||
| 96 | if (freq_desc_tables[cpu_index].msr_plat) { | 93 | if (freq_desc_tables[cpu_index].msr_plat) { |
| 97 | rdmsr(MSR_PLATFORM_INFO, lo, hi); | 94 | rdmsr(MSR_PLATFORM_INFO, lo, hi); |
| @@ -103,7 +100,7 @@ int try_msr_calibrate_tsc(unsigned long *fast_calibrate) | |||
| 103 | pr_info("Maximum core-clock to bus-clock ratio: 0x%x\n", ratio); | 100 | pr_info("Maximum core-clock to bus-clock ratio: 0x%x\n", ratio); |
| 104 | 101 | ||
| 105 | if (!ratio) | 102 | if (!ratio) |
| 106 | return 0; | 103 | goto fail; |
| 107 | 104 | ||
| 108 | /* Get FSB FREQ ID */ | 105 | /* Get FSB FREQ ID */ |
| 109 | rdmsr(MSR_FSB_FREQ, lo, hi); | 106 | rdmsr(MSR_FSB_FREQ, lo, hi); |
| @@ -112,16 +109,19 @@ int try_msr_calibrate_tsc(unsigned long *fast_calibrate) | |||
| 112 | pr_info("Resolved frequency ID: %u, frequency: %u KHz\n", | 109 | pr_info("Resolved frequency ID: %u, frequency: %u KHz\n", |
| 113 | freq_id, freq); | 110 | freq_id, freq); |
| 114 | if (!freq) | 111 | if (!freq) |
| 115 | return 0; | 112 | goto fail; |
| 116 | 113 | ||
| 117 | /* TSC frequency = maximum resolved freq * maximum resolved bus ratio */ | 114 | /* TSC frequency = maximum resolved freq * maximum resolved bus ratio */ |
| 118 | *fast_calibrate = freq * ratio; | 115 | res = freq * ratio; |
| 119 | pr_info("TSC runs at %lu KHz\n", *fast_calibrate); | 116 | pr_info("TSC runs at %lu KHz\n", res); |
| 120 | 117 | ||
| 121 | #ifdef CONFIG_X86_LOCAL_APIC | 118 | #ifdef CONFIG_X86_LOCAL_APIC |
| 122 | lapic_timer_frequency = (freq * 1000) / HZ; | 119 | lapic_timer_frequency = (freq * 1000) / HZ; |
| 123 | pr_info("lapic_timer_frequency = %d\n", lapic_timer_frequency); | 120 | pr_info("lapic_timer_frequency = %d\n", lapic_timer_frequency); |
| 124 | #endif | 121 | #endif |
| 122 | return res; | ||
| 125 | 123 | ||
| 126 | return 1; | 124 | fail: |
| 125 | pr_warn("Fast TSC calibration using MSR failed\n"); | ||
| 126 | return 0; | ||
| 127 | } | 127 | } |
