Bug 10968

Summary: p4-clockmod reports false frequency
Product: Power Management Reporter: Matthias-Christian Ott (ott)
Component: cpufreqAssignee: cpufreq (cpufreq)
Status: CLOSED CODE_FIX    
Severity: normal CC: bunk, lenb, nm127
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.25.7 Subsystem:
Regression: Yes Bisected commit-id:
Attachments: calculates frequency based on tsc value

Description Matthias-Christian Ott 2008-06-23 10:11:14 UTC
# uname -a
Linux hyperix 2.6.25.7 #2 Sat Jun 21 14:12:02 CEST 2008 i686 Intel(R) Pentium(R) 4 CPU 1.80GHz GenuineIntel GNU/Linux
# cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 15
model		: 1
model name	: Intel(R) Pentium(R) 4 CPU 1.80GHz
stepping	: 2
cpu MHz		: 3650.000
cache size	: 256 KB
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 2
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pebs bts
bogomips	: 3603.33
clflush size	: 64

# cpufreq-info 
cpufrequtils 0.4: cpufreq-info (C) Dominik Brodowski 2004
Report errors and bugs to linux@brodo.de, please.
analyzing CPU 0:
  driver: p4-clockmod
  CPUs which need to switch frequency at the same time: 0
  hardware limits: 3.65 GHz - 14.60 GHz
  available frequency steps: 3.65 GHz, 5.48 GHz, 7.30 GHz, 9.13 GHz, 10.95 GHz, 12.78 GHz, 14.60 GHz
  available cpufreq governors: ondemand, userspace
  current policy: frequency should be within 3.65 GHz and 14.60 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 5.48 GHz (asserted by call to hardware).

Latest working kernel version: 2.6.23 (last version that I tried)

Any suggestions?

To me it seems that the bit shift width is incorrect. I had a similar problems years ago and fixed by adding a different bit shift width for Pentium 4 Model 0 and 1.
Comment 1 Matthias-Christian Ott 2008-07-05 04:40:25 UTC
The bug was introduced in commit ed9cbcd40004904dbe61ccc16d6106a7de38c998. As proposed in bug #7186 the fix seems to be wrong, but worked for most people. 
Comment 2 Matthias-Christian Ott 2008-07-07 06:02:31 UTC
According to the Intel specification there is no such multiplier field in the msr, so the frequency has to be measured by the tsc on Pentium 4 Model 0 and 1.
Does anyone disagree?
Comment 3 Matthias-Christian Ott 2008-07-18 15:08:01 UTC
Created attachment 16881 [details]
calculates frequency based on tsc value

The attached patch should fix the issue forever more, because it conforms now entirely to the specification.
Comment 4 Dominik Brodowski 2008-07-23 11:46:46 UTC
patch looks good. Matthias-Christian, can you submit it with proper signed-off-by-line to davej, and davej can you pick it up with my Acked-by-line, please? Thanks!
Comment 5 Matthias-Christian Ott 2008-07-23 13:51:03 UTC
Patch submitted.
Comment 6 ykzhao 2011-01-06 09:19:21 UTC
*** Bug 11623 has been marked as a duplicate of this bug. ***
Comment 7 Len Brown 2011-07-30 05:47:58 UTC
closed by:


commit 199785eac892a1fa1b71cc22bec58e8b156d9311
Author: Matthias-Christian Ott <ott@mirix.org>
Date:   Fri Feb 20 20:52:17 2009 -0500

    [CPUFREQ] p4-clockmod reports wrong frequency.
    
    http://bugzilla.kernel.org/show_bug.cgi?id=10968
    
    [ Updated for current tree, and fixed compile failure
      when p4-clockmod was built modular -- davej]
    
    From: Matthias-Christian Ott <ott@mirix.org>
    Signed-off-by: Dominik Brodowski <linux@brodo.de>
    Signed-off-by: Dave Jones <davej@redhat.com>