ia64/xen-unstable

changeset 2613:e1abd8945ded

bitkeeper revision 1.1159.1.213 (416517f3vAbY9ISDviAe0Gjenl6dKw)

Take better care of over time consistency in XenLinux.
Avoid spinning on serial line with interrupts disabled in Xen.
author kaf24@freefall.cl.cam.ac.uk
date Thu Oct 07 10:18:27 2004 +0000 (2004-10-07)
parents 2859a2041ab0
children 08b44506fd8f
files linux-2.4.27-xen-sparse/arch/xen/kernel/time.c linux-2.6.8.1-xen-sparse/arch/xen/i386/kernel/time.c xen/drivers/char/serial.c
line diff
     1.1 --- a/linux-2.4.27-xen-sparse/arch/xen/kernel/time.c	Wed Oct 06 23:53:43 2004 +0000
     1.2 +++ b/linux-2.4.27-xen-sparse/arch/xen/kernel/time.c	Thu Oct 07 10:18:27 2004 +0000
     1.3 @@ -224,7 +224,7 @@ static void __get_time_values_from_xen(v
     1.4  }
     1.5  
     1.6  #define TIME_VALUES_UP_TO_DATE \
     1.7 -    (shadow_time_version == HYPERVISOR_shared_info->time_version2)
     1.8 + ({ rmb(); (shadow_time_version == HYPERVISOR_shared_info->time_version2); })
     1.9  
    1.10  
    1.11  /*
    1.12 @@ -393,11 +393,14 @@ static inline void do_timer_interrupt(in
    1.13      unsigned long ticks = 0;
    1.14      long sec_diff;
    1.15  
    1.16 + retry:
    1.17      __get_time_values_from_xen();
    1.18  
    1.19      if ( (delta = (s64)(shadow_system_time + __get_time_delta_usecs() * 1000 -
    1.20  						processed_system_time)) < 0 )
    1.21      {
    1.22 +		if (!TIME_VALUES_UP_TO_DATE)
    1.23 +			goto retry;
    1.24          printk("Timer ISR: Time went backwards: %lld\n", delta);
    1.25          return;
    1.26      }
     2.1 --- a/linux-2.6.8.1-xen-sparse/arch/xen/i386/kernel/time.c	Wed Oct 06 23:53:43 2004 +0000
     2.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/i386/kernel/time.c	Thu Oct 07 10:18:27 2004 +0000
     2.3 @@ -172,7 +172,7 @@ static void __get_time_values_from_xen(v
     2.4  }
     2.5  
     2.6  #define TIME_VALUES_UP_TO_DATE \
     2.7 -	(shadow_time_version == HYPERVISOR_shared_info->time_version2)
     2.8 + ({ rmb(); (shadow_time_version == HYPERVISOR_shared_info->time_version2); })
     2.9  
    2.10  /*
    2.11   * This version of gettimeofday has microsecond resolution
    2.12 @@ -367,12 +367,15 @@ static inline void do_timer_interrupt(in
    2.13  	s64 delta, nsec;
    2.14  	long sec_diff, wtm_nsec;
    2.15  
    2.16 + retry:
    2.17  	__get_time_values_from_xen();
    2.18  
    2.19  	delta = (s64)(shadow_system_time +
    2.20  		      (cur_timer->get_offset() * NSEC_PER_USEC) -
    2.21  		      processed_system_time);
    2.22  	if (delta < 0) {
    2.23 +		if (!TIME_VALUES_UP_TO_DATE)
    2.24 +			goto retry;
    2.25  		printk("Timer ISR: Time went backwards: %lld\n", delta);
    2.26  		return;
    2.27  	}
     3.1 --- a/xen/drivers/char/serial.c	Wed Oct 06 23:53:43 2004 +0000
     3.2 +++ b/xen/drivers/char/serial.c	Thu Oct 07 10:18:27 2004 +0000
     3.3 @@ -132,6 +132,9 @@ static void serial_interrupt(int irq, vo
     3.4  
     3.5  static inline void __serial_putc(uart_t *uart, int handle, unsigned char c)
     3.6  {
     3.7 +    unsigned long flags;
     3.8 +    int space;
     3.9 +
    3.10      if ( (c == '\n') && (handle & SERHND_COOKED) )
    3.11          __serial_putc(uart, handle, '\r');
    3.12  
    3.13 @@ -140,10 +143,13 @@ static inline void __serial_putc(uart_t 
    3.14      else if ( handle & SERHND_LO )
    3.15          c &= 0x7f;
    3.16  
    3.17 -    while ( !(inb(uart->io_base + LSR) & LSR_THRE) )
    3.18 -        barrier();
    3.19 -
    3.20 -    outb(c, uart->io_base + THR);
    3.21 +    do { 
    3.22 +        spin_lock_irqsave(&uart->lock, flags);
    3.23 +        if ( (space = (inb(uart->io_base + LSR) & LSR_THRE)) )
    3.24 +            outb(c, uart->io_base + THR);
    3.25 +        spin_unlock_irqrestore(&uart->lock, flags);
    3.26 +    }
    3.27 +    while ( !space );
    3.28  }
    3.29  
    3.30  #define PARSE_ERR(_f, _a...)                 \
    3.31 @@ -376,32 +382,22 @@ void serial_set_rx_handler(int handle, s
    3.32  void serial_putc(int handle, unsigned char c)
    3.33  {
    3.34      uart_t *uart = &com[handle & SERHND_IDX];
    3.35 -    unsigned long flags;
    3.36  
    3.37      if ( handle == -1 )
    3.38          return;
    3.39  
    3.40 -    spin_lock_irqsave(&uart->lock, flags);
    3.41 -
    3.42      __serial_putc(uart, handle, c);
    3.43 -
    3.44 -    spin_unlock_irqrestore(&uart->lock, flags);
    3.45  }
    3.46  
    3.47  void serial_puts(int handle, const unsigned char *s)
    3.48  {
    3.49      uart_t *uart = &com[handle & SERHND_IDX];
    3.50 -    unsigned long flags;
    3.51  
    3.52      if ( handle == -1 )
    3.53          return;
    3.54  
    3.55 -    spin_lock_irqsave(&uart->lock, flags);
    3.56 -
    3.57      while ( *s != '\0' )
    3.58          __serial_putc(uart, handle, *s++);
    3.59 -
    3.60 -    spin_unlock_irqrestore(&uart->lock, flags);
    3.61  }
    3.62  
    3.63  /* Returns TRUE if given character (*pc) matches the serial handle. */