Skip to contentSkip to conversation

Longhaul - Fix guess_fsb function

PATCH New Rafał Bilski 1 participant 1 message Jan 14, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Longhaul - Fix guess_fsb function

This is bug reported by John-Marc Chandonia:

Quoted 4 lines

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.

---

arch/i386/kernel/cpu/cpufreq/longhaul.c +0 -0
@@ -322,11 +322,9 @@ static int _guess(int guess, int mult)
{
	int target;

- target = ((mult/10)*guess);
- if (mult%10 != 0)
- target += (guess/2);
- target += ROUNDING/2;
- target &= ~ROUNDING;
+ target = mult * guess;
+ target += 50;

+	target /= 100;
	return target;
}

@@ -335,14 +333,14 @@ static int guess_fsb(int mult)

{
	int speed = (cpu_khz/1000);
	int i;

- int speeds[] = { 66, 100, 133, 200 };
-
- speed += ROUNDING/2;
- speed &= ~ROUNDING;
+ int speeds[] = { 666, 1000, 1333, 2000 };
+ int f_max, f_min;

	for (i=0; i<4; i++) {

- if (_guess(speeds[i], mult) == speed)
- return speeds[i];
+ f_max = _guess(speeds[i], mult) + (ROUNDING/2);
+ f_min = f_max - ROUNDING;
+ if ((speed <= f_max) && (speed >= f_min))

+			return (speeds[i]/10);
	}
	return 0;
}

----------------------------------------------------------------------
Jak to sie robi po francusku? Zobacz >> http://link.interia.pl/f19e0