serial: pl011: Do not clear RX FIFO & RX interrupt in unthrottle.

Message ID 20221110020108.7700-1-delisun@pateo.com.cn
State New
Headers
Series serial: pl011: Do not clear RX FIFO & RX interrupt in unthrottle. |

Commit Message

delisun Nov. 10, 2022, 2:01 a.m. UTC
  Clearing the RX FIFO will cause data loss.
Copy the pl011_enabl_interrupts implementation, and remove the clear
interrupt and FIFO part of the code.

Fixes: 211565b10099 ("serial: pl011: UPSTAT_AUTORTS requires .throttle/unthrottle")
Signed-off-by: delisun <delisun@pateo.com.cn>
---
 drivers/tty/serial/amba-pl011.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
  

Comments

Ilpo Järvinen Nov. 10, 2022, 10:24 a.m. UTC | #1
On Thu, 10 Nov 2022, delisun wrote:

> Clearing the RX FIFO will cause data loss.
> Copy the pl011_enabl_interrupts implementation, and remove the clear
> interrupt and FIFO part of the code.
> 
> Fixes: 211565b10099 ("serial: pl011: UPSTAT_AUTORTS requires .throttle/unthrottle")
> Signed-off-by: delisun <delisun@pateo.com.cn>
> ---
>  drivers/tty/serial/amba-pl011.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
> index 5cdced39eafd..08034e5dcec0 100644
> --- a/drivers/tty/serial/amba-pl011.c
> +++ b/drivers/tty/serial/amba-pl011.c
> @@ -1828,8 +1828,17 @@ static void pl011_enable_interrupts(struct uart_amba_port *uap)
>  static void pl011_unthrottle_rx(struct uart_port *port)
>  {
>  	struct uart_amba_port *uap = container_of(port, struct uart_amba_port, port);
> +	unsigned long flags;
>  
> -	pl011_enable_interrupts(uap);
> +	spin_lock_irqsave(&uap->port.lock, flags);
> +
> +	uap->im = UART011_RTIM;
> +	if (!pl011_dma_rx_running(uap))
> +		uap->im |= UART011_RXIM;
> +
> +	pl011_write(uap->im, uap, REG_IMSC);
> +
> +	spin_unlock_irqrestore(&uap->port.lock, flags);
>  }
>  
>  static int pl011_startup(struct uart_port *port)

Thanks.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
  

Patch

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 5cdced39eafd..08034e5dcec0 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1828,8 +1828,17 @@  static void pl011_enable_interrupts(struct uart_amba_port *uap)
 static void pl011_unthrottle_rx(struct uart_port *port)
 {
 	struct uart_amba_port *uap = container_of(port, struct uart_amba_port, port);
+	unsigned long flags;
 
-	pl011_enable_interrupts(uap);
+	spin_lock_irqsave(&uap->port.lock, flags);
+
+	uap->im = UART011_RTIM;
+	if (!pl011_dma_rx_running(uap))
+		uap->im |= UART011_RXIM;
+
+	pl011_write(uap->im, uap, REG_IMSC);
+
+	spin_unlock_irqrestore(&uap->port.lock, flags);
 }
 
 static int pl011_startup(struct uart_port *port)