direct-io.hg

changeset 5604:f66a730a2c3d

bitkeeper revision 1.1770 (42c2d66cG6YTU0WhG1b97E-InSNWWA)

Ensure global variables required by get_s_time() are initialised before
first use. Rejuggle bootstrap code slightly.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Jun 29 17:12:12 2005 +0000 (2005-06-29)
parents 41a5181f74df
children da2752f150a0
files xen/arch/x86/nmi.c xen/arch/x86/setup.c xen/arch/x86/time.c
line diff
     1.1 --- a/xen/arch/x86/nmi.c	Wed Jun 29 16:22:25 2005 +0000
     1.2 +++ b/xen/arch/x86/nmi.c	Wed Jun 29 17:12:12 2005 +0000
     1.3 @@ -240,7 +240,6 @@ void __pminit setup_apic_nmi_watchdog(vo
     1.4      }
     1.5  
     1.6      init_ac_timer(&nmi_timer[cpu], nmi_timer_fn, NULL, cpu);
     1.7 -    nmi_timer_fn(NULL);
     1.8  
     1.9      nmi_pm_init();
    1.10  }
    1.11 @@ -257,18 +256,33 @@ static unsigned int watchdog_on;
    1.12  void watchdog_disable(void)
    1.13  {
    1.14      unsigned long flags;
    1.15 +
    1.16      spin_lock_irqsave(&watchdog_lock, flags);
    1.17 +
    1.18      if ( watchdog_disable_count++ == 0 )
    1.19          watchdog_on = 0;
    1.20 +
    1.21      spin_unlock_irqrestore(&watchdog_lock, flags);
    1.22  }
    1.23  
    1.24  void watchdog_enable(void)
    1.25  {
    1.26 +    unsigned int  cpu;
    1.27      unsigned long flags;
    1.28 +
    1.29      spin_lock_irqsave(&watchdog_lock, flags);
    1.30 +
    1.31      if ( --watchdog_disable_count == 0 )
    1.32 +    {
    1.33          watchdog_on = 1;
    1.34 +        /*
    1.35 +         * Ensure periodic heartbeats are active. We cannot do this earlier
    1.36 +         * during setup because the timer infrastructure is not available. 
    1.37 +         */
    1.38 +        for_each_online_cpu ( cpu )
    1.39 +            set_ac_timer(&nmi_timer[cpu], NOW());
    1.40 +    }
    1.41 +
    1.42      spin_unlock_irqrestore(&watchdog_lock, flags);
    1.43  }
    1.44  
     2.1 --- a/xen/arch/x86/setup.c	Wed Jun 29 16:22:25 2005 +0000
     2.2 +++ b/xen/arch/x86/setup.c	Wed Jun 29 17:12:12 2005 +0000
     2.3 @@ -75,7 +75,7 @@ unsigned long xenheap_phys_start, xenhea
     2.4  extern void arch_init_memory(void);
     2.5  extern void init_IRQ(void);
     2.6  extern void trap_init(void);
     2.7 -extern void time_init(void);
     2.8 +extern void early_time_init(void);
     2.9  extern void ac_timer_init(void);
    2.10  extern void initialize_keytable(void);
    2.11  extern void early_cpu_init(void);
    2.12 @@ -184,7 +184,7 @@ static void __init start_of_day(void)
    2.13  
    2.14      ac_timer_init();
    2.15  
    2.16 -    time_init();
    2.17 +    early_time_init();
    2.18  
    2.19      arch_init_memory();
    2.20  
    2.21 @@ -205,14 +205,19 @@ static void __init start_of_day(void)
    2.22      for_each_cpu ( i )
    2.23          cpu_set(i, cpu_present_map);
    2.24  
    2.25 -    /* Sanity: We ought to be taking interrupts by now. */
    2.26 -    local_irq_enable();
    2.27 +    /*
    2.28 +     * Initialise higher-level timer functions. We do this fairly late
    2.29 +     * (post-SMP) because the time bases and scale factors need to be updated 
    2.30 +     * regularly, and SMP initialisation can cause a long delay with 
    2.31 +     * interrupts not yet enabled.
    2.32 +     */
    2.33 +    init_xen_time();
    2.34  
    2.35      initialize_keytable();
    2.36  
    2.37      serial_init_postirq();
    2.38  
    2.39 -    init_xen_time();
    2.40 +    BUG_ON(!local_irq_is_enabled());
    2.41  
    2.42      for_each_present_cpu ( i )
    2.43      {
     3.1 --- a/xen/arch/x86/time.c	Wed Jun 29 16:22:25 2005 +0000
     3.2 +++ b/xen/arch/x86/time.c	Wed Jun 29 17:12:12 2005 +0000
     3.3 @@ -239,6 +239,8 @@ static inline u64 get_time_delta(void)
     3.4      u32      low;
     3.5      u64      delta, tsc;
     3.6  
     3.7 +    ASSERT(st_scale_f || st_scale_i);
     3.8 +
     3.9      rdtscll(tsc);
    3.10      low = (u32)(tsc >> rdtsc_bitshift);
    3.11      delta_tsc = (s32)(low - shifted_tsc_irq);
    3.12 @@ -349,13 +351,17 @@ int __init init_xen_time()
    3.13      st_scale_f = scale & 0xffffffff;
    3.14      st_scale_i = scale >> 32;
    3.15  
    3.16 +    local_irq_disable();
    3.17 +
    3.18      /* System time ticks from zero. */
    3.19      rdtscll(full_tsc_irq);
    3.20      stime_irq = (s_time_t)0;
    3.21      shifted_tsc_irq = (u32)(full_tsc_irq >> rdtsc_bitshift);
    3.22  
    3.23      /* Wallclock time starts as the initial RTC time. */
    3.24 -    wc_sec  = get_cmos_time();
    3.25 +    wc_sec = get_cmos_time();
    3.26 +
    3.27 +    local_irq_enable();
    3.28  
    3.29      printk("Time init:\n");
    3.30      printk(".... cpu_freq:    %08X:%08X\n", (u32)(cpu_freq>>32),(u32)cpu_freq);
    3.31 @@ -367,7 +373,7 @@ int __init init_xen_time()
    3.32  
    3.33  
    3.34  /* Early init function. */
    3.35 -void __init time_init(void)
    3.36 +void __init early_time_init(void)
    3.37  {
    3.38      unsigned long ticks_per_frac = calibrate_tsc();
    3.39