Bug 5546 - cpu_khz is not initialized if you boot with clock=pit
Summary: cpu_khz is not initialized if you boot with clock=pit
Status: CLOSED CODE_FIX
Alias: None
Product: Timers
Classification: Unclassified
Component: Realtime Clock (show other bugs)
Hardware: i386 Linux
: P2 normal
Assignee: john stultz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-03 18:47 UTC by Tim Mann
Modified: 2006-05-09 17:22 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.6.14
Subsystem:
Regression: ---
Bisected commit-id:


Attachments

Description Tim Mann 2005-11-03 18:47:21 UTC
Most recent kernel where this bug did not occur: None known
Distribution: kernel.org kernel
Hardware Environment: i386
Software Environment: boot with clock=pit on the command line
Problem Description:

The cpu_khz global is not initialized and remains 0 if you boot with clock=pit,
even if the processor does have a TSC.  This may have bad ramifications since
the variable is used in various places scattered around the kernel, though I
didn't check them all to see if they can tolerate cpu_khz = 0.  You can observe
the problem by doing "cat /proc/cpuinfo"; the cpu MHz line says 0.000.

The fix is trivial; call init_cpu_khz() from init_pit(), just as it's called
from the timers/timer_foo.c:init_foo() for other values of foo.  Patch below.

Steps to reproduce:

Boot with clock=pit on the kernel command line.

Patch (tested briefly and seems to work fine):

--- arch/i386/kernel/timers/timer_pit.c~        2005-08-24 18:54:21.000000000 -0700
+++ arch/i386/kernel/timers/timer_pit.c 2005-11-03 18:51:17.000000000 -0800
@@ -29,6 +29,9 @@
                printk(KERN_ERR "Warning: clock= override failed. Defaulting
toPIT\n");

        count_p = LATCH;
+
+       init_cpu_khz();
+
        return 0;
 }
Comment 1 john stultz 2005-11-11 14:03:18 UTC
Looks like Andrew sent this patch to Linus, would you mind testing with
tonight's -git release and verify that it is working properly for you?
Comment 2 john stultz 2005-12-15 15:33:31 UTC
This has been in mainline for a month now, I'm considering it closed.
Comment 3 Tim Mann 2006-05-09 17:22:40 UTC
I finally got a chance to check, and I can confirm it's fixed (tested in
2.6.16.9).  Sorry it took so long to confirm, and thanks for the fix.

Note You need to log in before you can comment on or make changes to this bug.