From: "Jan Beulich" Subject: Re: [PATCH] V2 pci uart - better cope with UART being temporarily unavailable Date: Tue, 27 Aug 2013 14:58:20 +0100 Message-ID: <521CCC9C02000078000EECCD@nat28.tlf.novell.com> References: <1377598539-21973-1-git-send-email-tomasz.wroblewski@citrix.com> <521CB72B02000078000EEBE7@nat28.tlf.novell.com> <521CAB67.3020409@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VEJmu-0005RQ-70 for xen-devel@lists.xenproject.org; Tue, 27 Aug 2013 13:58:28 +0000 In-Reply-To: <521CAB67.3020409@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Tomasz Wroblewski Cc: xen-devel , keir@xen.org List-Id: xen-devel@lists.xenproject.org >>> On 27.08.13 at 15:36, Tomasz Wroblewski wrote: >>> --- a/xen/drivers/char/serial.c >>> +++ b/xen/drivers/char/serial.c >>> @@ -111,15 +111,18 @@ static void __serial_putc(struct serial_port *port, > char c) >>> if ( port->tx_log_everything ) >>> { >>> /* Buffer is full: we spin waiting for space to appear. */ >>> - unsigned int n; >>> + int n; >>> >>> while ( (n = port->driver->tx_ready(port)) == 0 ) >>> cpu_relax(); >>> - while ( n-- ) >>> - port->driver->putc( >>> - port, >>> - port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]); >>> - port->txbuf[mask_serial_txbuf_idx(port->txbufp++)] = c; >>> + if (n> 0) >>> + { >>> + while ( n-- ) >> "while ( n--> 0 )" can achieve the same without the extra if() >> and with just a one line change. > Thanks for review - agree with most comments except this one, we need to > avoid executing "port->txbuf[mask_serial_txbuf_idx(port->txbufp++)] = c" > if port is offline, since in this case the while loop will not consume > pull any character out of the buffer, and it will stay full, and we > should just drop the char. The "if" I added pulled the buffer insert > into its body. Indeed. However, we're in a log-everything section, so dropping characters here is not really right. Not sure what to do about this. Jan