diff options
author | Rafał Bilski <rafalbilski@interia.pl> | 2007-02-04 09:58:46 -0500 |
---|---|---|
committer | Dave Jones <davej@redhat.com> | 2007-02-04 18:09:19 -0500 |
commit | 46ef955f5c9de0507859a3f9a92989b7425b73cc (patch) | |
tree | d9be8c950b8c735e27e6f0774a69b177ac66d23c /arch/i386/kernel | |
parent | 0d44b2ba287ea98547097ad2b8b0cc5f0589b8d2 (diff) |
[CPUFREQ] Longhaul - Fix guess_fsb function
This is bug reported by John-Marc Chandonia:
> Detected 1002.292 MHz processor.
> longhaul: VIA C3 'Nehemiah B' [C5N] CPU detected. Powersaver supported.
> longhaul: Using throttling support.
> longhaul: Invalid (reserved) FSB!
FSB is correcly guessed for 999.554 MHz CPU.
To fix this error:
- ROUNDING should be range, not mask - at it's current value it is +7 -8,
- more precise calculations inside guess_fsb - 7.5x133MHz is 1000MHz now.
Signed-off-by: Rafal Bilski <rafalbilski@interia.pl>
Signed-off-by: Dave Jones <davej@redhat.com>
Diffstat (limited to 'arch/i386/kernel')
-rw-r--r-- | arch/i386/kernel/cpu/cpufreq/longhaul.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/arch/i386/kernel/cpu/cpufreq/longhaul.c b/arch/i386/kernel/cpu/cpufreq/longhaul.c index 8ea34e951ea3..8b5ad308d656 100644 --- a/arch/i386/kernel/cpu/cpufreq/longhaul.c +++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c | |||
@@ -318,31 +318,19 @@ static void longhaul_setstate(unsigned int clock_ratio_index) | |||
318 | 318 | ||
319 | #define ROUNDING 0xf | 319 | #define ROUNDING 0xf |
320 | 320 | ||
321 | static int _guess(int guess, int mult) | ||
322 | { | ||
323 | int target; | ||
324 | |||
325 | target = ((mult/10)*guess); | ||
326 | if (mult%10 != 0) | ||
327 | target += (guess/2); | ||
328 | target += ROUNDING/2; | ||
329 | target &= ~ROUNDING; | ||
330 | return target; | ||
331 | } | ||
332 | |||
333 | |||
334 | static int guess_fsb(int mult) | 321 | static int guess_fsb(int mult) |
335 | { | 322 | { |
336 | int speed = (cpu_khz/1000); | 323 | int speed = cpu_khz / 1000; |
337 | int i; | 324 | int i; |
338 | int speeds[] = { 66, 100, 133, 200 }; | 325 | int speeds[] = { 666, 1000, 1333, 2000 }; |
339 | 326 | int f_max, f_min; | |
340 | speed += ROUNDING/2; | 327 | |
341 | speed &= ~ROUNDING; | 328 | for (i = 0; i < 4; i++) { |
342 | 329 | f_max = ((speeds[i] * mult) + 50) / 100; | |
343 | for (i=0; i<4; i++) { | 330 | f_max += (ROUNDING / 2); |
344 | if (_guess(speeds[i], mult) == speed) | 331 | f_min = f_max - ROUNDING; |
345 | return speeds[i]; | 332 | if ((speed <= f_max) && (speed >= f_min)) |
333 | return speeds[i] / 10; | ||
346 | } | 334 | } |
347 | return 0; | 335 | return 0; |
348 | } | 336 | } |