Skip to contentSkip to conversation

speedstep-smi: GET_SPEEDSTEP_FREQS may return bogus values

PATCH New Dominik Brodowski 1 participant 1 message Jul 27, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 speedstep-smi: GET_SPEEDSTEP_FREQS may return bogus values

On at least one system, the GET_SPEEDSTEP_FREQS call to the BIOS returns obviously incorrect data (0 and 4 MHz...). So, check whether the results look sane, if not, use the already existing workaround for ancient speedstep systems. Thanks to Pierre Maziere for reporting this issue and testing the fix.

arch/i386/kernel/cpu/cpufreq/speedstep-smi.c +6 -1
@@ -115,6 +115,11 @@
 		: "=a" (result), "=b" (high_mhz), "=c" (low_mhz), "=d" (state), "=D" (edi)
 		: "a" (command), "b" (function), "c" (state), "d" (smi_port), "S" (0)
 	);
+
+	/* abort if results are obviously incorrect... */
+	if ((high_mhz + low_mhz) < 600)
+		return -EINVAL;
+
 	*high = high_mhz * 1000;
 	*low  = low_mhz  * 1000;
 
@@ -180,7 +185,7 @@
 	local_irq_restore(flags);
 
 	if (new_state == state) {
-		dprintk(KERN_INFO "cpufreq: change to %u MHz succeeded after %u tries with result %u\n", (freqs.new / 1000), retry, result);
+		dprintk(KERN_INFO "cpufreq: change to %u MHz succeeded after %u tries with result %u\n", (speedstep_freqs[new_state].frequency / 1000), retry, result);
 	} else {
 		printk(KERN_ERR "cpufreq: change failed with new_state %u and result %u\n", new_state, result);
 	}