Skip to contentSkip to conversation

Geode GXm driver not handling frequency change properly?

DISCUSSION Lincoln Smith 2 participants 2 messages Jul 4, 2004

lore
Share & tools
lore
#0 lore raw

I have a Geode GX1 233 in a little SBC machine operating as a wireless router. I was experimenting with the cpufreq driver and things just didn't seem to work properly. The frequency checks in 2.6.7 seem to have illuminated the problem. The interpretation of the target frequency seems to be inverted. The frequency written to scaling_setspeed is interpreted as the length of time to turn the processor "off" for. The realized frequency is cpu_maxfreq - scaling_setspeed.

Some dmesg output to illustrate.

cpufreq:suspend modulation w/ duration of ON:1888 us, OFF:4800 us cpufreq:suspend modulation w/ clock speed: 167848 kHz.
Warning: CPU frequency out of sync: cpufreq and timing core thinks of 167848, is 66020 kHz.

cpufreq:suspend modulation w/ duration of ON:1120 us, OFF:864 us cpufreq:suspend modulation w/ clock speed: 101846 kHz.
Warning: CPU frequency out of sync: cpufreq and timing core thinks of 101846, is 132022 kHz.

cpufreq:suspend modulation w/ duration of ON:3712 us, OFF:672 us cpufreq:suspend modulation w/ clock speed: 35848 kHz.
Losing some ticks... checking if CPU frequency changed.
Warning: CPU frequency out of sync: cpufreq and timing core thinks of 35848, is 198020 kHz.

In each case the actual frequency is the maximum frequency (about 233 MHz) minus the requested frequency.

The solution is likely trivial? I will look at it but someone else will probably be faster than me.

Cheers
Lincoln Smith

#1 lore raw

Hi,

Quoted 7 lines

I have a Geode GX1 233 in a little SBC machine operating as a wireless router. I was experimenting with the cpufreq driver and things just didn't seem to work properly. The frequency checks in 2.6.7 seem to have illuminated the problem. The interpretation of the target frequency seems to be inverted. The frequency written to scaling_setspeed is interpreted as the length of time to turn the processor "off" for. The realized frequency is cpu_maxfreq - scaling_setspeed.

Thanks for reporting this issue. Could you try out the attached patch, please?

Many thanks,
Dominik

When doing "clock modulation" (i.e. stopping the CPU clock for certain amounts of time), the frequency equals the maximum frequency multiplied with the "on" duration divided by the "on and off" duration. So, at the one place inside gx-suspmod where this is broken, this needs to be fixed.

arch/i386/kernel/cpu/cpufreq/gx-suspmod.c renamed from arch/i386/kernel/cpu/cpufreq/gx-suspmod.c.original +1 -1
@@ -242,7 +242,7 @@
 	for (i=max_duration; i>0; i--) {
 		tmp_off = ((khz * i) / stock_freq) & 0xff; 
 		tmp_on = i - tmp_off;
-		tmp_freq = (stock_freq * tmp_off) / i;
+		tmp_freq = (stock_freq * tmp_on) / i;
 		/* if this relation is closer to khz, use this. If it's equal,
 		 * prefer it, too - lower latency */
 		if (abs(tmp_freq - khz) <= abs(old_tmp_freq - khz)) {