From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Egger Subject: [PATCH] xen: more robust serial port driver Date: Tue, 28 Jul 2009 16:07:05 +0200 Message-ID: <200907281607.06109.Christoph.Egger@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_KYwbKkgXufN+0aU" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --Boundary-00=_KYwbKkgXufN+0aU Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi! Attached patch adds a check if the fifo is usable before we actually use it. Signed-off-by: Christoph Egger -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632 --Boundary-00=_KYwbKkgXufN+0aU Content-Type: text/x-diff; charset="us-ascii"; name="xen_serial.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen_serial.diff" diff -r 8af26fef898c xen/drivers/char/ns16550.c --- a/xen/drivers/char/ns16550.c Fri Jul 24 12:08:54 2009 +0100 +++ b/xen/drivers/char/ns16550.c Tue Jul 28 16:01:48 2009 +0200 @@ -16,6 +16,7 @@ #include #include #include +#include /* * Configure serial port with a string: @@ -115,8 +116,10 @@ static char ns_read_reg(struct ns16550 * static void ns_write_reg(struct ns16550 *uart, int reg, char c) { - if ( uart->remapped_io_base == NULL ) - return outb(c, uart->io_base + reg); + if ( uart->remapped_io_base == NULL ) { + outb(c, uart->io_base + reg); + return; + } writeb(c, uart->remapped_io_base + reg); } @@ -181,6 +184,7 @@ static void __devinit ns16550_init_preir unsigned int divisor; /* I/O ports are distinguished by their size (16 bits). */ + uart->remapped_io_base = NULL; if ( uart->io_base >= 0x10000 ) uart->remapped_io_base = (char *)ioremap(uart->io_base, 8); @@ -212,10 +216,15 @@ static void __devinit ns16550_init_preir /* Enable and clear the FIFOs. Set a large trigger threshold. */ ns_write_reg(uart, FCR, FCR_ENABLE | FCR_CLRX | FCR_CLTX | FCR_TRG14); + udelay(100); /* Check this really is a 16550+. Otherwise we have no FIFOs. */ - if ( (ns_read_reg(uart, IIR) & 0xc0) == 0xc0 ) - port->tx_fifo_size = 16; + port->tx_fifo_size = 1; + if ( (ns_read_reg(uart, IIR) & 0xc0) == 0xc0 ) { + /* We have a FIFO. Check if we have a *working* FIFO. */ + if ( (ns_read_reg(uart, FCR) & FCR_TRG14) == FCR_TRG14 ) + port->tx_fifo_size = 16; + } } static void __devinit ns16550_init_postirq(struct serial_port *port) --Boundary-00=_KYwbKkgXufN+0aU Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_KYwbKkgXufN+0aU--