linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] serial: bfin_uart: Don't switch baud rate untill the transfer buffer is empty.
@ 2012-11-07  4:55 Sonic Zhang
  2012-11-16  0:59 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Sonic Zhang @ 2012-11-07  4:55 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman; +Cc: uclinux-dist-devel, Sonic Zhang

From: Sonic Zhang <sonic.zhang@analog.com>

set_termios may be invoked before the former data transfer is completed. Block until the
tranfer is done.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
 drivers/tty/serial/bfin_uart.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c
index 9242d56..71c0c09 100644
--- a/drivers/tty/serial/bfin_uart.c
+++ b/drivers/tty/serial/bfin_uart.c
@@ -869,6 +869,10 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
 
 	UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15);
 
+	/* Wait till the transfer buffer is empty */
+	while (UART_GET_GCTL(uart) & UCEN && !(UART_GET_LSR(uart) & TEMT))
+		barrier();
+
 	/* Disable UART */
 	ier = UART_GET_IER(uart);
 	UART_PUT_GCTL(uart, UART_GET_GCTL(uart) & ~UCEN);
-- 
1.7.0.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] serial: bfin_uart: Don't switch baud rate untill the transfer buffer is empty.
  2012-11-07  4:55 [PATCH] serial: bfin_uart: Don't switch baud rate untill the transfer buffer is empty Sonic Zhang
@ 2012-11-16  0:59 ` Greg Kroah-Hartman
  2012-11-19  6:31   ` Zhang, Sonic
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2012-11-16  0:59 UTC (permalink / raw)
  To: Sonic Zhang; +Cc: linux-serial, uclinux-dist-devel, Sonic Zhang

On Wed, Nov 07, 2012 at 12:55:42PM +0800, Sonic Zhang wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
> 
> set_termios may be invoked before the former data transfer is completed. Block until the
> tranfer is done.
> 
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> ---
>  drivers/tty/serial/bfin_uart.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c
> index 9242d56..71c0c09 100644
> --- a/drivers/tty/serial/bfin_uart.c
> +++ b/drivers/tty/serial/bfin_uart.c
> @@ -869,6 +869,10 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
>  
>  	UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15);
>  
> +	/* Wait till the transfer buffer is empty */
> +	while (UART_GET_GCTL(uart) & UCEN && !(UART_GET_LSR(uart) & TEMT))
> +		barrier();

Where is the "the hardware is hung" break out of this loop?

And why "barrier()"?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] serial: bfin_uart: Don't switch baud rate untill the transfer buffer is empty.
  2012-11-16  0:59 ` Greg Kroah-Hartman
@ 2012-11-19  6:31   ` Zhang, Sonic
  0 siblings, 0 replies; 3+ messages in thread
From: Zhang, Sonic @ 2012-11-19  6:31 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Sonic Zhang
  Cc: linux-serial@vger.kernel.org,
	uclinux-dist-devel@blackfin.uclinux.org



>-----Original Message-----
>From: Greg Kroah-Hartman [mailto:gregkh@linuxfoundation.org]
>Sent: Friday, November 16, 2012 9:00 AM
>To: Sonic Zhang
>Cc: linux-serial@vger.kernel.org; uclinux-dist-devel@blackfin.uclinux.org; Zhang,
>Sonic
>Subject: Re: [PATCH] serial: bfin_uart: Don't switch baud rate untill the transfer
>buffer is empty.
>
>On Wed, Nov 07, 2012 at 12:55:42PM +0800, Sonic Zhang wrote:
>> From: Sonic Zhang <sonic.zhang@analog.com>
>>
>> set_termios may be invoked before the former data transfer is
>> completed. Block until the tranfer is done.
>>
>> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
>> ---
>>  drivers/tty/serial/bfin_uart.c |    4 ++++
>>  1 files changed, 4 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/tty/serial/bfin_uart.c
>> b/drivers/tty/serial/bfin_uart.c index 9242d56..71c0c09 100644
>> --- a/drivers/tty/serial/bfin_uart.c
>> +++ b/drivers/tty/serial/bfin_uart.c
>> @@ -869,6 +869,10 @@ bfin_serial_set_termios(struct uart_port *port,
>> struct ktermios *termios,
>>
>>      UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15);
>>
>> +    /* Wait till the transfer buffer is empty */
>> +    while (UART_GET_GCTL(uart) & UCEN && !(UART_GET_LSR(uart) &
>TEMT))
>> +            barrier();
>
>Where is the "the hardware is hung" break out of this loop?
>

Sorry, I will add time_after check soon.

Regards,

Sonic

>And why "barrier()"?
>
>thanks,
>
>greg k-h



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-11-19  6:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-07  4:55 [PATCH] serial: bfin_uart: Don't switch baud rate untill the transfer buffer is empty Sonic Zhang
2012-11-16  0:59 ` Greg Kroah-Hartman
2012-11-19  6:31   ` Zhang, Sonic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).