]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
[PATCH] vmi: pit override
authorZachary Amsden <zach@vmware.com>
Mon, 5 Mar 2007 08:30:39 +0000 (00:30 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 5 Mar 2007 15:57:52 +0000 (07:57 -0800)
The time_init_hook in paravirt-ops no longer functions in the correct manner
after the integration of the hrtimers code.  The problem is that now the call
path for time initialization is:

  time_init :
       late_time_init = hpet_time_init;

  late_time_init -> hpet_time_init:
       setup_pit_timer (BAD)
       do_time_init --> (via paravirt.h)
          time_init_hook --> (via arch_hooks.h)
              time_init_hook (in SUBARCH/setup.c)

If this isn't confusing enough, the paravirt case goes through an indirect
function pointer in the paravirt-ops table.  The problem is, by the time the
paravirt hook is called, the pit timer is already enabled.

But paravirt guests have their own timer, and don't want to use the PIT.
Rather than intensify the struggle for power going on here, just make it all
nice and simple and just unconditionally do all timer setup in the
late_time_init hook.  This also has the advantage of enabling timers in the
same place in all code paths, so everyone has the same bugs and we don't have
outliers who break other code because they turn on timer too early or too
late.

So the paravirt-ops time init function is now by default hpet_time_init, which
is the time init function used for native hardware.  Paravirt guests have the
chance to override this when they setup the paravirt-ops table, and should
need no change.

Signed-off-by: Zachary Amsden <zach@vmware.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/i386/kernel/paravirt.c
arch/i386/kernel/time.c
include/asm-i386/paravirt.h
include/asm-i386/time.h

index 871448db1425ffe77a10be780d2fddb6901f2b6c..2ec331e03fa9ede01a5bed5bee5faf1043b9f6dd 100644 (file)
@@ -494,7 +494,7 @@ struct paravirt_ops paravirt_ops = {
        .memory_setup = machine_specific_memory_setup,
        .get_wallclock = native_get_wallclock,
        .set_wallclock = native_set_wallclock,
-       .time_init = time_init_hook,
+       .time_init = hpet_time_init,
        .init_IRQ = native_init_IRQ,
 
        .cpuid = native_cpuid,
index a5350059557a6541c0c96b8f8ba6933073999d05..ccd3734edb8ff46112ff469a01fc3168f28b0d89 100644 (file)
@@ -262,14 +262,22 @@ void notify_arch_cmos_timer(void)
 
 extern void (*late_time_init)(void);
 /* Duplicate of time_init() below, with hpet_enable part added */
-static void __init hpet_time_init(void)
+void __init hpet_time_init(void)
 {
        if (!hpet_enable())
                setup_pit_timer();
-       do_time_init();
+       time_init_hook();
 }
 
+/*
+ * This is called directly from init code; we must delay timer setup in the
+ * HPET case as we can't make the decision to turn on HPET this early in the
+ * boot process.
+ *
+ * The chosen time_init function will usually be hpet_time_init, above, but
+ * in the case of virtual hardware, an alternative function may be substituted.
+ */
 void __init time_init(void)
 {
-       late_time_init = hpet_time_init;
+       late_time_init = choose_time_init();
 }
index 1e4226a85263c73d0b270d33a7bb4a97c6d63f2f..f8319cae2ac5c6b789ed974c0de59a044efd9877 100644 (file)
@@ -186,9 +186,9 @@ static inline int set_wallclock(unsigned long nowtime)
        return paravirt_ops.set_wallclock(nowtime);
 }
 
-static inline void do_time_init(void)
+static inline void (*choose_time_init(void))(void)
 {
-       return paravirt_ops.time_init();
+       return paravirt_ops.time_init;
 }
 
 /* The paravirtualized CPUID instruction. */
index ea8065af825a998654e23a92ffc18e60f34885ec..eac011366dc2c09337abfe3d146bafcb01b1d686 100644 (file)
@@ -28,13 +28,16 @@ static inline int native_set_wallclock(unsigned long nowtime)
        return retval;
 }
 
+extern void (*late_time_init)(void);
+extern void hpet_time_init(void);
+
 #ifdef CONFIG_PARAVIRT
 #include <asm/paravirt.h>
 #else /* !CONFIG_PARAVIRT */
 
 #define get_wallclock() native_get_wallclock()
 #define set_wallclock(x) native_set_wallclock(x)
-#define do_time_init() time_init_hook()
+#define choose_time_init() hpet_time_init
 
 #endif /* CONFIG_PARAVIRT */