diff options
author | Alok Kataria <akataria@vmware.com> | 2008-06-23 21:21:56 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-24 07:53:46 -0400 |
commit | f3f3149f35b9195ef4b761b1353fc0766b5f53be (patch) | |
tree | 96e67c82e8ea6ce57ce5f83a8036f87a8d534867 /init/calibrate.c | |
parent | 6ff10de374cc68ff2024247793176dc8a1b317ea (diff) |
x86: use cpu_khz for loops_per_jiffy calculation, cleanup
As suggested by Ingo, remove all references to tsc from init/calibrate.c
TSC is x86 specific, and using tsc in variable names in a generic file should
be avoided. lpj_tsc is now called lpj_fine, since it is related to fine tuning
of lpj value. Also tsc_rate_* is called timer_rate_*
Signed-off-by: Alok N Kataria <akataria@vmware.com>
Cc: Arjan van de Ven <arjan@infradead.org>
Cc: Daniel Hecht <dhecht@vmware.com>
Cc: Tim Mann <mann@vmware.com>
Cc: Zach Amsden <zach@vmware.com>
Cc: Sahil Rihan <srihan@vmware.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'init/calibrate.c')
-rw-r--r-- | init/calibrate.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/init/calibrate.c b/init/calibrate.c index 86286974dada..7963e3fc51d9 100644 --- a/init/calibrate.c +++ b/init/calibrate.c | |||
@@ -10,7 +10,7 @@ | |||
10 | #include <linux/timex.h> | 10 | #include <linux/timex.h> |
11 | #include <linux/smp.h> | 11 | #include <linux/smp.h> |
12 | 12 | ||
13 | unsigned long lpj_tsc; | 13 | unsigned long lpj_fine; |
14 | unsigned long preset_lpj; | 14 | unsigned long preset_lpj; |
15 | static int __init lpj_setup(char *str) | 15 | static int __init lpj_setup(char *str) |
16 | { | 16 | { |
@@ -35,9 +35,9 @@ static unsigned long __cpuinit calibrate_delay_direct(void) | |||
35 | unsigned long pre_start, start, post_start; | 35 | unsigned long pre_start, start, post_start; |
36 | unsigned long pre_end, end, post_end; | 36 | unsigned long pre_end, end, post_end; |
37 | unsigned long start_jiffies; | 37 | unsigned long start_jiffies; |
38 | unsigned long tsc_rate_min, tsc_rate_max; | 38 | unsigned long timer_rate_min, timer_rate_max; |
39 | unsigned long good_tsc_sum = 0; | 39 | unsigned long good_timer_sum = 0; |
40 | unsigned long good_tsc_count = 0; | 40 | unsigned long good_timer_count = 0; |
41 | int i; | 41 | int i; |
42 | 42 | ||
43 | if (read_current_timer(&pre_start) < 0 ) | 43 | if (read_current_timer(&pre_start) < 0 ) |
@@ -81,22 +81,24 @@ static unsigned long __cpuinit calibrate_delay_direct(void) | |||
81 | } | 81 | } |
82 | read_current_timer(&post_end); | 82 | read_current_timer(&post_end); |
83 | 83 | ||
84 | tsc_rate_max = (post_end - pre_start) / DELAY_CALIBRATION_TICKS; | 84 | timer_rate_max = (post_end - pre_start) / |
85 | tsc_rate_min = (pre_end - post_start) / DELAY_CALIBRATION_TICKS; | 85 | DELAY_CALIBRATION_TICKS; |
86 | timer_rate_min = (pre_end - post_start) / | ||
87 | DELAY_CALIBRATION_TICKS; | ||
86 | 88 | ||
87 | /* | 89 | /* |
88 | * If the upper limit and lower limit of the tsc_rate is | 90 | * If the upper limit and lower limit of the timer_rate is |
89 | * >= 12.5% apart, redo calibration. | 91 | * >= 12.5% apart, redo calibration. |
90 | */ | 92 | */ |
91 | if (pre_start != 0 && pre_end != 0 && | 93 | if (pre_start != 0 && pre_end != 0 && |
92 | (tsc_rate_max - tsc_rate_min) < (tsc_rate_max >> 3)) { | 94 | (timer_rate_max - timer_rate_min) < (timer_rate_max >> 3)) { |
93 | good_tsc_count++; | 95 | good_timer_count++; |
94 | good_tsc_sum += tsc_rate_max; | 96 | good_timer_sum += timer_rate_max; |
95 | } | 97 | } |
96 | } | 98 | } |
97 | 99 | ||
98 | if (good_tsc_count) | 100 | if (good_timer_count) |
99 | return (good_tsc_sum/good_tsc_count); | 101 | return (good_timer_sum/good_timer_count); |
100 | 102 | ||
101 | printk(KERN_WARNING "calibrate_delay_direct() failed to get a good " | 103 | printk(KERN_WARNING "calibrate_delay_direct() failed to get a good " |
102 | "estimate for loops_per_jiffy.\nProbably due to long platform interrupts. Consider using \"lpj=\" boot option.\n"); | 104 | "estimate for loops_per_jiffy.\nProbably due to long platform interrupts. Consider using \"lpj=\" boot option.\n"); |
@@ -111,8 +113,8 @@ static unsigned long __cpuinit calibrate_delay_direct(void) {return 0;} | |||
111 | * bit takes on average 1.5/HZ seconds. This (like the original) is a little | 113 | * bit takes on average 1.5/HZ seconds. This (like the original) is a little |
112 | * better than 1% | 114 | * better than 1% |
113 | * For the boot cpu we can skip the delay calibration and assign it a value | 115 | * For the boot cpu we can skip the delay calibration and assign it a value |
114 | * calculated based on the tsc frequency. | 116 | * calculated based on the timer frequency. |
115 | * For the rest of the CPUs we cannot assume that the tsc frequency is same as | 117 | * For the rest of the CPUs we cannot assume that the timer frequency is same as |
116 | * the cpu frequency, hence do the calibration for those. | 118 | * the cpu frequency, hence do the calibration for those. |
117 | */ | 119 | */ |
118 | #define LPS_PREC 8 | 120 | #define LPS_PREC 8 |
@@ -126,11 +128,11 @@ void __cpuinit calibrate_delay(void) | |||
126 | loops_per_jiffy = preset_lpj; | 128 | loops_per_jiffy = preset_lpj; |
127 | printk(KERN_INFO | 129 | printk(KERN_INFO |
128 | "Calibrating delay loop (skipped) preset value.. "); | 130 | "Calibrating delay loop (skipped) preset value.. "); |
129 | } else if ((smp_processor_id() == 0) && lpj_tsc) { | 131 | } else if ((smp_processor_id() == 0) && lpj_fine) { |
130 | loops_per_jiffy = lpj_tsc; | 132 | loops_per_jiffy = lpj_fine; |
131 | printk(KERN_INFO | 133 | printk(KERN_INFO |
132 | "Calibrating delay loop (skipped), " | 134 | "Calibrating delay loop (skipped), " |
133 | "using tsc calculated value.. "); | 135 | "value calculated using timer frequency.. "); |
134 | } else if ((loops_per_jiffy = calibrate_delay_direct()) != 0) { | 136 | } else if ((loops_per_jiffy = calibrate_delay_direct()) != 0) { |
135 | printk(KERN_INFO | 137 | printk(KERN_INFO |
136 | "Calibrating delay using timer specific routine.. "); | 138 | "Calibrating delay using timer specific routine.. "); |