Skip to contentSkip to conversation

serial: bfin_uart: Don't switch baud rate untill the transfer buffer is empty.

PATCH Superseded Sonic Zhang 3 participants 3 messages Nov 7, 2012 – Nov 19, 2012 TTY layer and serial drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: bfin_uart: Don't switch baud rate untill the transfer buffer is empty.

From: Sonic Zhang <[email protected]>

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

---
 drivers/tty/serial/bfin_uart.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/tty/serial/bfin_uart.c +4 -0
index 9242d56..71c0c09 100644
@@ -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);
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 15 lines · Sonic Zhang

From: Sonic Zhang <[email protected]>

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

---
 drivers/tty/serial/bfin_uart.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/tty/serial/bfin_uart.c +0 -0
index 9242d56..71c0c09 100644

drivers/tty/serial/bfin_uart.c bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios, · line 874

Quoted 6 lines
drivers/tty/serial/bfin_uart.c +3 -0
@@ -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

#2 lore raw
Quoted 29 lines

-----Original Message-----
From: Greg Kroah-Hartman [mailto:[email protected]]
Sent: Friday, November 16, 2012 9:00 AM
To: Sonic Zhang
Cc: [email protected]; [email protected]; Zhang, Sonic
Subject: Re: [PATCH] serial: bfin_uart: Don't switch baud rate untill the transfer buffer is empty.

Quoted 17 lines · Sonic Zhang

From: Sonic Zhang <[email protected]>

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

---
 drivers/tty/serial/bfin_uart.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/drivers/tty/serial/bfin_uart.c index 9242d56..71c0c09 100644

drivers/tty/serial/bfin_uart.c +0 -0
@@ -869,6 +869,10 @@ bfin_serial_set_termios(struct uart_port *port,
 struct ktermios *termios,
 
Quoted 9 lines

drivers/tty/serial/bfin_uart.c bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,

Quoted 4 lines
drivers/tty/serial/bfin_uart.c +2 -0
     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))

drivers/tty/serial/bfin_uart.c bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios, · line 874

Quoted 1 line
drivers/tty/serial/bfin_uart.c +1 -0
+            barrier();

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

Sorry, I will add time_after check soon.

Regards,

Sonic

Quoted 5 lines

And why "barrier()"?

thanks,

greg k-h