ia64/xen-unstable

changeset 18806:ed8524f4a044

x86: Re-initialise HPET on resume from S3

Signed-off-by: Guanqun Lu <guanqun.lu@intel.com>
Signed-off-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Nov 18 15:55:14 2008 +0000 (2008-11-18)
parents 85fda344dba7
children f09a1d5d4338
files xen/arch/x86/hpet.c xen/arch/x86/time.c
line diff
     1.1 --- a/xen/arch/x86/hpet.c	Tue Nov 18 15:39:31 2008 +0000
     1.2 +++ b/xen/arch/x86/hpet.c	Tue Nov 18 15:55:14 2008 +0000
     1.3 @@ -264,15 +264,10 @@ int hpet_legacy_irq_tick(void)
     1.4  
     1.5  u64 hpet_setup(void)
     1.6  {
     1.7 -    static u64 hpet_rate;
     1.8 -    static int initialised;
     1.9 +    u64 hpet_rate;
    1.10      u32 hpet_id, hpet_period, cfg;
    1.11      int i;
    1.12  
    1.13 -    if ( initialised )
    1.14 -        return hpet_rate;
    1.15 -    initialised = 1;
    1.16 -
    1.17      if ( hpet_address == 0 )
    1.18          return 0;
    1.19  
     2.1 --- a/xen/arch/x86/time.c	Tue Nov 18 15:39:31 2008 +0000
     2.2 +++ b/xen/arch/x86/time.c	Tue Nov 18 15:55:14 2008 +0000
     2.3 @@ -60,6 +60,7 @@ struct platform_timesource {
     2.4      u64 frequency;
     2.5      u64 (*read_counter)(void);
     2.6      int (*init)(struct platform_timesource *);
     2.7 +    void (*resume)(struct platform_timesource *);
     2.8      int counter_bits;
     2.9  };
    2.10  
    2.11 @@ -396,12 +397,21 @@ static int init_hpet(struct platform_tim
    2.12      return 1;
    2.13  }
    2.14  
    2.15 +static void resume_hpet(struct platform_timesource *pts)
    2.16 +{
    2.17 +    u64 hpet_rate = hpet_setup();
    2.18 +
    2.19 +    BUG_ON(hpet_rate == 0);
    2.20 +    pts->frequency = hpet_rate;
    2.21 +}
    2.22 +
    2.23  static struct platform_timesource plt_hpet =
    2.24  {
    2.25      .name = "HPET",
    2.26      .read_counter = read_hpet_count,
    2.27      .counter_bits = 32,
    2.28 -    .init = init_hpet
    2.29 +    .init = init_hpet,
    2.30 +    .resume = resume_hpet
    2.31  };
    2.32  
    2.33  /************************************************************
    2.34 @@ -566,6 +576,10 @@ static void platform_time_calibration(vo
    2.35  
    2.36  static void resume_platform_timer(void)
    2.37  {
    2.38 +    /* Timer source can be reset when backing from S3 to S0 */
    2.39 +    if ( plt_src.resume )
    2.40 +        plt_src.resume(&plt_src);
    2.41 +
    2.42      /* No change in platform_stime across suspend/resume. */
    2.43      platform_timer_stamp = plt_stamp64;
    2.44      plt_stamp = plt_src.read_counter();
    2.45 @@ -1214,13 +1228,13 @@ int time_resume(void)
    2.46  {
    2.47      /*u64 tmp = */init_pit_and_calibrate_tsc();
    2.48  
    2.49 -    disable_pit_irq();
    2.50 -
    2.51      /* Disable this while calibrate_tsc_ap() also is skipped. */
    2.52      /*set_time_scale(&this_cpu(cpu_time).tsc_scale, tmp);*/
    2.53  
    2.54      resume_platform_timer();
    2.55  
    2.56 +    disable_pit_irq();
    2.57 +
    2.58      init_percpu_time();
    2.59  
    2.60      do_settime(get_cmos_time() + cmos_utc_offset, 0, NOW());