mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-01-14 13:39:10 +00:00
serial/amba-pl011: Unconditionally poll for FIFO space before each TX char
Commit 734745caeb9f155ab58918834a8c70e83fa6afd3 serial/amba-pl011: (Activate TX IRQ passively) introduces a race which causes the driver sometimes to attempt to write a character to the TX FIFO when the FIFO is already full. The PL011 does not guarantee its behaviour when the FIFO is overfilled. In practice, this can cause duplicate and/or dropped characters to be output on the wire. The problem is common enough to be readily observable on the ARM Juno platform when the PL011 UART is used as the console and DMA is not in use. This patch fixes this problem by always polling for space before each character is written to the FIFO. This will be amended to a less brute-force approach in a later commit, but this patch should help ensure correct behaviour for now. Signed-off-by: Dave Martin <Dave.Martin@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e26081808e
commit
43dd1f9a5b
@ -1249,20 +1249,19 @@ __acquires(&uap->port.lock)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Transmit a character
|
* Transmit a character
|
||||||
* There must be at least one free entry in the TX FIFO to accept the char.
|
|
||||||
*
|
*
|
||||||
* Returns true if the FIFO might have space in it afterwards;
|
* Returns true if the character was successfully queued to the FIFO.
|
||||||
* returns false if the FIFO definitely became full.
|
* Returns false otherwise.
|
||||||
*/
|
*/
|
||||||
static bool pl011_tx_char(struct uart_amba_port *uap, unsigned char c)
|
static bool pl011_tx_char(struct uart_amba_port *uap, unsigned char c)
|
||||||
{
|
{
|
||||||
|
if (readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF)
|
||||||
|
return false; /* unable to transmit character */
|
||||||
|
|
||||||
writew(c, uap->port.membase + UART01x_DR);
|
writew(c, uap->port.membase + UART01x_DR);
|
||||||
uap->port.icount.tx++;
|
uap->port.icount.tx++;
|
||||||
|
|
||||||
if (likely(uap->tx_irq_seen > 1))
|
return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
return !(readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool pl011_tx_chars(struct uart_amba_port *uap)
|
static bool pl011_tx_chars(struct uart_amba_port *uap)
|
||||||
@ -1296,7 +1295,8 @@ static bool pl011_tx_chars(struct uart_amba_port *uap)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (uap->port.x_char) {
|
if (uap->port.x_char) {
|
||||||
pl011_tx_char(uap, uap->port.x_char);
|
if (!pl011_tx_char(uap, uap->port.x_char))
|
||||||
|
goto done;
|
||||||
uap->port.x_char = 0;
|
uap->port.x_char = 0;
|
||||||
--count;
|
--count;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user