All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Russell King <rmk+lkml@arm.linux.org.uk>
Cc: linux-kernel@vger.kernel.org, alan@lxorguk.ukuu.org.uk,
	"Rafael J. Wysocki" <rjw@sisk.pl>
Subject: Re: [PATCH: 2/2] [SERIAL] avoid stalling suspend if serial port won't drain
Date: Tue, 8 Jan 2008 16:06:10 -0800	[thread overview]
Message-ID: <20080108160610.53694773.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080108115703.GA27179@flint.arm.linux.org.uk>

On Tue, 8 Jan 2008 11:57:03 +0000
Russell King <rmk+lkml@arm.linux.org.uk> wrote:

> Some ports seem to be unable to drain their transmitters on shut down.
> Such a problem can occur if the port is programmed for hardware imposed
> flow control, characters are in the FIFO but the CTS signal is inactive.
> 
> Normally, this isn't a problem because most places where we wait for the
> transmitter to drain have a time-out.  However, there is no timeout in
> the suspend path.
> 
> Give a port 30ms to drain; this is an arbitary value chosen to avoid
> long delays if there are many such ports in the system, while giving a
> reasonable chance for a single port to drain.  Should a port not drain
> within this timeout, issue a warning.
> 
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> 
> diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
> index 3bb5d24..4ce219c 100644
> --- a/drivers/serial/serial_core.c
> +++ b/drivers/serial/serial_core.c
> @@ -1977,6 +1977,7 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *port)
>  
>  	if (state->info && state->info->flags & UIF_INITIALIZED) {
>  		const struct uart_ops *ops = port->ops;
> +		int tries;
>  
>  		state->info->flags = (state->info->flags & ~UIF_INITIALIZED)
>  				     | UIF_SUSPENDED;
> @@ -1990,9 +1991,14 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *port)
>  		/*
>  		 * Wait for the transmitter to empty.
>  		 */
> -		while (!ops->tx_empty(port)) {
> +		for (tries = 3; !ops->tx_empty(port) && tries; tries--) {
>  			msleep(10);
>  		}
> +		if (!tries)
> +			printk(KERN_ERR "%s%s%s%d: Unable to drain transmitter\n",
> +			       port->dev ? port->dev->bus_id : "",
> +			       port->dev ? ": " : "",
> +			       drv->dev_name, port->line);
>  
>  		ops->shutdown(port);
>  	}
> 

One hopes that doing a printk from within uart_suspend_port() will dtrt if
that port is (was?) being used as a console.



  reply	other threads:[~2008-01-09  0:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-08 11:51 [PATCH: 1/2] [SERIAL] avoid waking up closed serial ports on resume Russell King
2008-01-08 11:57 ` [PATCH: 2/2] [SERIAL] avoid stalling suspend if serial port won't drain Russell King
2008-01-09  0:06   ` Andrew Morton [this message]
2008-01-09  1:29     ` Alan Cox
2008-01-09  8:34     ` Russell King
2008-01-11 10:17   ` Pavel Machek
2008-01-13 22:51     ` nigel
2008-01-14  0:49       ` Alan Cox
2008-01-14  2:40         ` nigel
2008-01-14 10:04           ` Russell King
2008-01-14  9:46         ` Russell King
2008-01-13 22:56     ` Benjamin Herrenschmidt
2008-01-14  0:29     ` Russell King
2008-01-14  9:04       ` Pavel Machek
2008-01-14  9:35         ` Russell King
2008-01-14 10:21           ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080108160610.53694773.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=rmk+lkml@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.