diff mbox

tty: amba-pl011: Report AUTOCTS capability to framework

Message ID 1509368586-26662-1-git-send-email-stefan.wahren@i2se.com (mailing list archive)
State New, archived
Headers show

Commit Message

Stefan Wahren Oct. 30, 2017, 1:03 p.m. UTC
From: Phil Elwell <phil@raspberrypi.org>

The PL011 has full hardware RTS/CTS support which is enabled by
the driver when flow control is requested. However, it doesn't
notify the UART framework of the fact, causing the software CTS
support to be enabled at the same time.

Software CTS triggers the sending of another batch of characters
when CTS becomes asserted. The pl011 interrupt handler processes
the CTIS bit before TXIS, which can cause some characters to be
sent between the time that the TXIS bit first becomes asserted
and the time it is handled by a call to px011_tx_chars. This
would be fine were it not for the optimisation in pl011_tx_char
that assumes the FIFO is half-empty if called from the interrupt
handler and skips the checking of the FIFO status register before
sending each character, leading to data loss if the FIFO is more
than half-full.

Prevent the data loss and improve efficiency by indicating the
AUTOCTS support.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/tty/serial/amba-pl011.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Stefan Wahren Oct. 30, 2017, 11:46 p.m. UTC | #1
Hi Lukas,

> Lukas Wunner <lukas@wunner.de> hat am 31. Oktober 2017 um 00:32 geschrieben:
> 
> 
> On Mon, Oct 30, 2017 at 11:24:31PM +0000, Stefan Wahren wrote:
> > --- a/drivers/tty/serial/amba-pl011.c
> > +++ b/drivers/tty/serial/amba-pl011.c
> > @@ -2029,9 +2029,11 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
> >  
> >  		old_cr |= UART011_CR_CTSEN;
> >  		uap->autorts = true;
> > +		port->status |= UPSTAT_AUTOCTS;
> >  	} else {
> >  		old_cr &= ~(UART011_CR_CTSEN | UART011_CR_RTSEN);
> >  		uap->autorts = false;
> > +		port->status &= ~UPSTAT_AUTOCTS;
> >  	}
> >  
> >  	if (uap->vendor->oversampling) {
> 
> Don't you also need to clear the UPSTAT_AUTOCTS bit in pl011_disable_uart()?
> 
> FWIW I posted a patch to linux-serial on Oct 25 which subsumes the above
> patch, would that work for you?
> 
> https://marc.info/?l=linux-serial&m=150891880104614&w=4

sorry for missing your patch. Mine should be ignored.

> 
> Thanks,
> 
> Lukas
diff mbox

Patch

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 111e6a9..00019b8 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2029,9 +2029,11 @@  pl011_set_termios(struct uart_port *port, struct ktermios *termios,
 
 		old_cr |= UART011_CR_CTSEN;
 		uap->autorts = true;
+		port->status |= UPSTAT_AUTOCTS;
 	} else {
 		old_cr &= ~(UART011_CR_CTSEN | UART011_CR_RTSEN);
 		uap->autorts = false;
+		port->status &= ~UPSTAT_AUTOCTS;
 	}
 
 	if (uap->vendor->oversampling) {