Upgrade emulated UART to 16550A.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 15 lines · Xen staging patchbot-unstable
# HG changeset patch
# User Keir Fraser
# Date 1196864460 0
# Node IDf0ac46de680cc6fe8c91699fdda153b125ae515c# Parentbf21e00155b7dd76653c5340099ecedac7a7de08[QEMU-DM] Upgrade emulated UART to 16550A.This patch adds 16550 emulation to qemu-dm. I still consider it a work in progress, but from my testing, it consistently performs better than the old code already, sometimes considerably so (on my laptop, dumping out data over serial from a HVM DomU -> pty in Dom0 was up to 5.3 times faster than with the old 16450 code). I can consistenly reach full 115200 baud speeds over physical serial lines when the virtual device is backed by a phys port, which I never could with the old code.
Quoted 7 lines
There are still some things to be done. I want to add proper error handling, so that overflow/framing & parity errors on the physical port get detected and reported by the virtual port. Also, now that FIFOs are in place, I believe performance could be improved significantly by putting some code into the hypervisor so that reads & writes from the FIFOs don't have to exit into qemu-dm at all. I'm also reading up on the specs for newer uarts with deeper FIFOs.
I notice with this patch that my HVM domain, which specifies
serial=pty in the config file, no longer boots without me attaching to the console via xm. Previously it would boot regardless of whether I was attached to the console. Is this change in behavior intentional? Note that I'm testing on ia64 where the HVM firmware spews lots of debug info out onto the serial port. Maybe this new UART model isn't dropping transmit chars when there's no client connected as it did before? Thanks,
Alex
Signature · 1 line
Alex Williamson HP Open Source & Linux Org.
As you describe this, it does occur to me as you describe this that serial_xmit() never gives up on trying to retransmit characters out of the FIFO, which isn't very good for backends like pty's or pipes. I'll fix it asap.
Quoted 34 lines · Alex Williamson
Quoted 15 lines · Xen staging patchbot-unstable
# HG changeset patch
# User Keir Fraser
# Date 1196864460 0
# Node IDf0ac46de680cc6fe8c91699fdda153b125ae515c# Parentbf21e00155b7dd76653c5340099ecedac7a7de08[QEMU-DM] Upgrade emulated UART to 16550A.This patch adds 16550 emulation to qemu-dm. I still consider it a work in progress, but from my testing, it consistently performs better than the old code already, sometimes considerably so (on my laptop, dumping out data over serial from a HVM DomU -> pty in Dom0 was up to 5.3 times faster than with the old 16450 code). I can consistenly reach full 115200 baud speeds over physical serial lines when the virtual device is backed by a phys port, which I never could with the old code.
Quoted 7 lines
There are still some things to be done. I want to add proper error handling, so that overflow/framing & parity errors on the physical port get detected and reported by the virtual port. Also, now that FIFOs are in place, I believe performance could be improved significantly by putting some code into the hypervisor so that reads & writes from the FIFOs don't have to exit into qemu-dm at all. I'm also reading up on the specs for newer uarts with deeper FIFOs.
I notice with this patch that my HVM domain, which specifies
serial=pty in the config file, no longer boots without me attaching to the console via xm. Previously it would boot regardless of whether I was attached to the console. Is this change in behavior intentional? Note that I'm testing on ia64 where the HVM firmware spews lots of debug info out onto the serial port. Maybe this new UART model isn't dropping transmit chars when there's no client connected as it did before? Thanks,
Quoted 6 lines
Alex
--
Alex Williamson HP Open Source & Linux Org.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
This patch fixes the issue. It also changes the name of an inappropriately named timer.
Quoted 6 lines · Trolle Selander
As you describe this, it does occur to me as you describe this that
serial_xmit()never gives up on trying to retransmit characters out of the FIFO, which isn't very good for backends like pty's or pipes. I'll fix it asap.
Quoted 46 lines
Quoted 43 lines · Alex Williamson
Quoted 7 lines · Xen staging patchbot-unstable
# HG changeset patch
# User Keir Fraser
# Date 1196864460 0
# Node IDf0ac46de680cc6fe8c91699fdda153b125ae515c# Parentbf21e00155b7dd76653c5340099ecedac7a7de08[QEMU-DM] Upgrade emulated UART to 16550A.Quoted 8 lines
This patch adds 16550 emulation to qemu-dm. I still consider it a work in progress, but from my testing, it consistently performs better than
the old code already, sometimes considerably so (on my laptop, dumping out data over serial from a HVM DomU -> pty in Dom0 was up to 5.3 times faster than with the old 16450 code). I can consistenly reach full 115200 baud speeds over physical serial lines when the virtual device is backed by a phys port, which I never could with the old
code.
Quoted 8 lines
There are still some things to be done. I want to add proper error handling, so that overflow/framing & parity errors on the physical port get detected and reported by the virtual port. Also, now that FIFOs are in place, I believe performance could be improved significantly by putting some code into the hypervisor so that reads & writes from the FIFOs don't have to exit into qemu-dm at all. I'm also reading up on the specs for newer uarts with deeper FIFOs.
I notice with this patch that my HVM domain, which specifies
serial=pty in the config file, no longer boots without me attaching to the console via xm. Previously it would boot regardless of whether I was attached to the console. Is this change in behavior intentional? Note that I'm testing on ia64 where the HVM firmware spews lots of debug info out onto the serial port. Maybe this new UART model isn't droppingtransmit chars when there's no client connected as it did before? Thanks,
Alex
--
Alex Williamson HP Open Source & Linux Org.
tools/ioemu/hw/serial.c +9 -6
@@ -96,6 +96,7 @@#define XMIT_FIFO 0#define RECV_FIFO 1 +#define MAX_XMIT_RETRY 4struct SerialFIFO {uint8_t data[UART_FIFO_LENGTH ];
@@ -136,7 +137,7 @@struct QEMUTimer *fifo_timeout_timer;int timeout_ipending;/* timeout interrupt pending state */ -struct QEMUTimer *fifo_transmit_timer; +struct QEMUTimer *transmit_timer;uint64_t char_transmit_time;/* time to transmit a char in ticks*/
@@ -370,15 +371,17 @@if (qemu_chr_write (s->chr, &s->tsr,1 ) !=1 ) { s->tsr_retry++; -qemu_mod_timer (s->fifo_transmit_timer, new_xmit_ts + s->char_transmit_time ); -return ; +if ( s->tsr_retry <=MAX_XMIT_RETRY ) { +qemu_mod_timer (s->transmit_timer, new_xmit_ts + s->char_transmit_time ); +return ; + } } s->tsr_retry =0 ; s->last_xmit_ts =qemu_get_clock (vm_clock); -if ( s->xmit_fifo.count >0 ) -qemu_mod_timer (s->fifo_transmit_timer, s->last_xmit_ts + s->char_transmit_time ); +if ( !(s->lsr &UART_LSR_THRE ) ) +qemu_mod_timer (s->transmit_timer, s->last_xmit_ts + s->char_transmit_time );if ( s->lsr &UART_LSR_THRE ) { s->lsr |=UART_LSR_TEMT ;
@@ -752,7 +755,7 @@fifo_clear (s,XMIT_FIFO ); s->last_xmit_ts =qemu_get_clock (vm_clock); s->fifo_timeout_timer =qemu_new_timer (vm_clock, (QEMUTimerCB *) fifo_timeout_int, s); - s->fifo_transmit_timer =qemu_new_timer (vm_clock, (QEMUTimerCB *) serial_xmit, s); + s->transmit_timer =qemu_new_timer (vm_clock, (QEMUTimerCB *) serial_xmit, s);register_savevm ("serial" , base,2 , serial_save, serial_load, s);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 2 lines · Trolle Selander
This patch fixes the issue. It also changes the name of an inappropriately named timer.
Hi Trolle,
Yes, with this patch, my HVM domain will eventually boot.
Unfortunately it takes 2 minutes now to get through all the UART timeouts and get to the firmware menu. Prior to the new 16550A UART driver, it took 10 seconds. I think we need to do something smarter than drop characters after some number of timeouts. We're doomed to terrible slowness anytime the console is disconnected that way. Thanks,
Alex
Signature · 1 line
Alex Williamson HP Open Source & Linux Org.
Quoted 4 lines · Alex Williamson
Quoted 2 lines · Trolle Selander
This patch fixes the issue. It also changes the name of an inappropriately named timer.
Quoted 8 lines
Hi Trolle,
Yes, with this patch, my HVM domain will eventually boot.
Unfortunately it takes 2 minutes now to get through all the UART timeouts and get to the firmware menu. Prior to the new 16550A UART driver, it took 10 seconds. I think we need to do something smarter than drop characters after some number of timeouts. We're doomed to terrible slowness anytime the console is disconnected that way. Thanks,
Perhaps we should latch the first timeout and fast-drop bursts of characters until the next character that is not immediately rejected?
-- Keir
That sounds like a workable idea, at least for the non-phys-port case.
Quoted 15 lines · Keir Fraser
Quoted 4 lines · Alex Williamson
Quoted 2 lines · Trolle Selander
This patch fixes the issue. It also changes the name of an inappropriately named timer.
Quoted 8 lines
Hi Trolle,
Yes, with this patch, my HVM domain will eventually boot.
Unfortunately it takes 2 minutes now to get through all the UART timeouts and get to the firmware menu. Prior to the new 16550A UART driver, it took 10 seconds. I think we need to do something smarter than drop characters after some number of timeouts. We're doomed to terrible slowness anytime the console is disconnected that way. Thanks,
Quoted 8 lines
Perhaps we should latch the first timeout and fast-drop bursts of characters
until the next character that is not immediately rejected?-- Keir
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Here's a patch based on Keir's idea. Let's hope this resolves the issue. It also includes the termios.h & sys/ioctl.h include fix discussed earlier, since I didn't see that committed to xen-unstable yet.
Quoted 30 lines · Trolle Selander
That sounds like a workable idea, at least for the non-phys-port case.
Quoted 24 lines · Keir Fraser
Quoted 4 lines · Alex Williamson
Quoted 2 lines · Trolle Selander
This patch fixes the issue. It also changes the name of an inappropriately named timer.
Quoted 8 lines
Hi Trolle,
Yes, with this patch, my HVM domain will eventually boot.
Unfortunately it takes 2 minutes now to get through all the UART timeouts and get to the firmware menu. Prior to the new 16550A UART driver, it took 10 seconds. I think we need to do something smarter than drop characters after some number of timeouts. We're doomed to terrible slowness anytime the console is disconnected that way.Thanks,
Perhaps we should latch the first timeout and fast-drop bursts of characters
until the next character that is not immediately rejected?-- Keir
tools/ioemu/hw/serial.c +14 -13
@@ -26,16 +26,11 @@#include <sys/time.h> #include <time.h> #include <assert.h> +#include <termios.h> +#include <sys/ioctl.h> //#define DEBUG_SERIAL -#define TIOCM_DTR 0x002 -#define TIOCM_RTS 0x004 -#define TIOCM_CTS 0x020 -#define TIOCM_CAR 0x040 -#define TIOCM_RI 0x080 -#define TIOCM_DSR 0x100 -#define UART_LCR_DLAB 0x80/* Divisor latch access bit */ #define UART_IER_MSI 0x08/* Enable Modem status interrupt */
@@ -364,7 +359,7 @@SerialState *s = opaque;uint64_t new_xmit_ts =qemu_get_clock (vm_clock); -if ( s->tsr_retry ==0 ) { +if ( s->tsr_retry <=0 ) {if (s->fcr &UART_FCR_FE ) { s->tsr =fifo_get (s,XMIT_FIFO );if ( !s->xmit_fifo.count )
@@ -376,16 +371,22 @@ }if (qemu_chr_write (s->chr, &s->tsr,1 ) !=1 ) { - s->tsr_retry++; -if ( s->tsr_retry <=MAX_XMIT_RETRY ) { +if ( ( s->tsr_retry >0 ) && ( s->tsr_retry <=MAX_XMIT_RETRY ) ) { + s->tsr_retry++;qemu_mod_timer (s->transmit_timer, new_xmit_ts + s->char_transmit_time );return ; + }else if ( s->poll_msl <0 ) { +/* If we exceed MAX_XMIT_RETRY and the backend is not a real serial port, then +drop any further failed writes instantly, until we get one that goes through. +This is to prevent guests that log to unconnected pipes or pty's from stalling. */ + s->tsr_retry =-1 ; } } - - s->tsr_retry =0 ; - s->last_xmit_ts =qemu_get_clock (vm_clock); +else { + s->tsr_retry =0 ; + } + s->last_xmit_ts =qemu_get_clock (vm_clock);if ( !(s->lsr &UART_LSR_THRE ) )qemu_mod_timer (s->transmit_timer, s->last_xmit_ts + s->char_transmit_time );
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 2 lines · Trolle Selander
Here's a patch based on Keir's idea. Let's hope this resolves the issue.
Great, this seems to work fine. Thanks!
Quoted 2 lines
It also includes the
termios.h&sys/ioctl.hinclude fix discussed earlier, since I didn't see that committed to xen-unstable yet.
This is already in the staging tree, so I only the last 2 chunks of
the patch are necessary. Thanks,
Alex
Signature · 1 line
Alex Williamson HP Open Source & Linux Org.
Alright, good to have this resolved. Here's the patch with only the significant bits, and a signed-off-by line.
Quoted 10 lines · Alex Williamson
Quoted 2 lines · Trolle Selander
Here's a patch based on Keir's idea. Let's hope this resolves the issue.
Great, this seems to work fine. Thanks!
Quoted 2 lines
It also includes the
termios.h&sys/ioctl.hinclude fix discussed earlier, since I didn't see that committed to xen-unstable yet.
Quoted 10 lines
This is already in the staging tree, so I only the last 2 chunks of
the patch are necessary. Thanks,Alex
--
Alex Williamson HP Open Source & Linux Org.
tools/ioemu/hw/serial.c +12 -6
@@ -359,7 +359,7 @@SerialState *s = opaque;uint64_t new_xmit_ts =qemu_get_clock (vm_clock); -if ( s->tsr_retry ==0 ) { +if ( s->tsr_retry <=0 ) {if (s->fcr &UART_FCR_FE ) { s->tsr =fifo_get (s,XMIT_FIFO );if ( !s->xmit_fifo.count )
@@ -371,16 +371,22 @@ }if (qemu_chr_write (s->chr, &s->tsr,1 ) !=1 ) { - s->tsr_retry++; -if ( s->tsr_retry <=MAX_XMIT_RETRY ) { +if ( ( s->tsr_retry >0 ) && ( s->tsr_retry <=MAX_XMIT_RETRY ) ) { + s->tsr_retry++;qemu_mod_timer (s->transmit_timer, new_xmit_ts + s->char_transmit_time );return ; + }else if ( s->poll_msl <0 ) { +/* If we exceed MAX_XMIT_RETRY and the backend is not a real serial port, then +drop any further failed writes instantly, until we get one that goes through. +This is to prevent guests that log to unconnected pipes or pty's from stalling. */ + s->tsr_retry =-1 ; } } - - s->tsr_retry =0 ; - s->last_xmit_ts =qemu_get_clock (vm_clock); +else { + s->tsr_retry =0 ; + } + s->last_xmit_ts =qemu_get_clock (vm_clock);if ( !(s->lsr &UART_LSR_THRE ) )qemu_mod_timer (s->transmit_timer, s->last_xmit_ts + s->char_transmit_time );
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
I'll look into it further, though I'm a bit puzzled as to why it was faster before - the old code would attempt to retransmit every 100ms, for up to 300ms. That's a LOT longer than my code will retry at any kind of sane baud-rates. What guest are you running in the HVM?
At one point I was considering adding a "backend type" field for the qemu char devices to prevent having to detect if the backend device was a physical port from within serial.c. Perhaps I'll need to go back to that plan and treat pty's differently, or simply skip the transmit retries entirely when the backend isn't a physical serial port.
Quoted 14 lines · Alex Williamson
Quoted 2 lines · Trolle Selander
This patch fixes the issue. It also changes the name of an inappropriately named timer.
Hi Trolle,
Yes, with this patch, my HVM domain will eventually boot.
Unfortunately it takes 2 minutes now to get through all the UART timeouts and get to the firmware menu. Prior to the new 16550A UART driver, it took 10 seconds. I think we need to do something smarter than drop characters after some number of timeouts. We're doomed to terrible slowness anytime the console is disconnected that way. Thanks,
Quoted 6 lines
Alex
--
Alex Williamson HP Open Source & Linux Org.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel