ia64/xen-unstable

changeset 16564:180e4a77e805

qemu 16550 uart: Fast-drop bursts of transmitted characters to avoid
stalling due to a disconnected pipe or pty.
Signed-off-by: Trolle Selander <trolle.selander@gmail.com>
author Keir Fraser <keir.fraser@citrix.com>
date Sat Dec 08 15:46:04 2007 +0000 (2007-12-08)
parents d4a3479e68ce
children c3286cb2fc59
files tools/ioemu/hw/serial.c
line diff
     1.1 --- a/tools/ioemu/hw/serial.c	Fri Dec 07 18:24:33 2007 +0000
     1.2 +++ b/tools/ioemu/hw/serial.c	Sat Dec 08 15:46:04 2007 +0000
     1.3 @@ -359,7 +359,7 @@ static void serial_xmit(void *opaque) {
     1.4      SerialState *s = opaque;
     1.5      uint64_t new_xmit_ts = qemu_get_clock(vm_clock);
     1.6      
     1.7 -    if ( s->tsr_retry == 0 ) {
     1.8 +    if ( s->tsr_retry <= 0 ) {
     1.9          if (s->fcr & UART_FCR_FE) {
    1.10              s->tsr = fifo_get(s,XMIT_FIFO);
    1.11              if ( !s->xmit_fifo.count )
    1.12 @@ -371,16 +371,22 @@ static void serial_xmit(void *opaque) {
    1.13      }
    1.14  
    1.15      if ( qemu_chr_write(s->chr, &s->tsr, 1) != 1 ) {
    1.16 -        s->tsr_retry++;
    1.17 -        if ( s->tsr_retry <= MAX_XMIT_RETRY ) {
    1.18 +        if ( ( s->tsr_retry > 0 ) && ( s->tsr_retry <= MAX_XMIT_RETRY ) ) {
    1.19 +            s->tsr_retry++;
    1.20              qemu_mod_timer(s->transmit_timer,  new_xmit_ts + s->char_transmit_time );
    1.21              return;
    1.22 +        } else if ( s->poll_msl < 0 ) {
    1.23 +            /* If we exceed MAX_XMIT_RETRY and the backend is not a real serial port, then
    1.24 +            drop any further failed writes instantly, until we get one that goes through.
    1.25 +            This is to prevent guests that log to unconnected pipes or pty's from stalling. */
    1.26 +            s->tsr_retry = -1;
    1.27          }
    1.28      }
    1.29 - 
    1.30 -    s->tsr_retry = 0;
    1.31 +    else {
    1.32 +        s->tsr_retry = 0;
    1.33 +    }
    1.34 +
    1.35      s->last_xmit_ts = qemu_get_clock(vm_clock);
    1.36 -
    1.37      if ( !(s->lsr & UART_LSR_THRE) )
    1.38          qemu_mod_timer(s->transmit_timer, s->last_xmit_ts + s->char_transmit_time );
    1.39