From 1040d42e914c82be50086517d783e93e4489f149 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Fri, 21 Nov 2003 02:18:24 +0000 Subject: [PATCH] [CPUFREQ] Fix rounding in longhaul. The FSB guessing screwed up sometimes. If cpu_mhz was greater than the guess we returned zero. --- arch/i386/kernel/cpu/cpufreq/longhaul.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/i386/kernel/cpu/cpufreq/longhaul.c b/arch/i386/kernel/cpu/cpufreq/longhaul.c index c0dd4b2622ab2..24d06b63a72ca 100644 --- a/arch/i386/kernel/cpu/cpufreq/longhaul.c +++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c @@ -170,6 +170,9 @@ static void longhaul_setstate (unsigned int clock_ratio_index) * between that value multiplied by possible FSBs and cpu_mhz which * was calculated at boot time. Really ugly, but no other way to do this. */ + +#define ROUNDING 0xf + static int _guess (int guess, int maxmult) { int target; @@ -177,16 +180,20 @@ static int _guess (int guess, int maxmult) target = ((maxmult/10)*guess); if (maxmult%10 != 0) target += (guess/2); - target &= ~0xf; + target += ROUNDING/2; + target &= ~ROUNDING; return target; } static int guess_fsb(int maxmult) { - int speed = (cpu_khz/1000) & ~0xf; + int speed = (cpu_khz/1000); int i; int speeds[3] = { 66, 100, 133 }; + speed += ROUNDING/2; + speed &= ~ROUNDING; + for (i=0; i<3; i++) { if (_guess(speeds[i],maxmult) == speed) return speeds[i]; -- 2.53.0