[PATCH 4/4] drivers/serial: imx: dismiss noisy IRQ events

Philippe Gerum rpm at xenomai.org
Fri Mar 29 18:41:03 CET 2019


Converging to the upstream implementation further, disregard any event
which source is disabled, to help dealing with transitory states of
the hardware (e.g. as triggered by device closure).

Signed-off-by: Philippe Gerum <rpm at xenomai.org>
---
 kernel/drivers/serial/rt_imx_uart.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/kernel/drivers/serial/rt_imx_uart.c b/kernel/drivers/serial/rt_imx_uart.c
index fa9dc64e8..6d95cbcab 100644
--- a/kernel/drivers/serial/rt_imx_uart.c
+++ b/kernel/drivers/serial/rt_imx_uart.c
@@ -463,8 +463,7 @@ static int rt_imx_uart_int(rtdm_irq_t *irq_context)
 	uint64_t timestamp = rtdm_clock_read();
 	struct rt_imx_uart_ctx *ctx;
 	unsigned int usr1, usr2, ucr1;
-	int rbytes = 0;
-	int events = 0;
+	int rbytes = 0, events = 0;
 	int ret = RTDM_IRQ_NONE;
 
 	ctx = rtdm_irq_get_arg(irq_context, struct rt_imx_uart_ctx);
@@ -479,16 +478,19 @@ static int rt_imx_uart_int(rtdm_irq_t *irq_context)
 	 * Read if there is data available
 	 */
 	if (usr1 & USR1_RRDY) {
-		rbytes += rt_imx_uart_rx_chars(ctx, &timestamp);
-		events |= RTSER_EVENT_RXPEND;
+		if (likely(ucr1 & UCR1_RRDYEN)) {
+			rbytes = rt_imx_uart_rx_chars(ctx, &timestamp);
+			events |= RTSER_EVENT_RXPEND;
+		}
 		ret = RTDM_IRQ_HANDLED;
 	}
 
 	/*
 	 * Send data if there is data to be sent
 	 */
-	if ((usr1 & USR1_TRDY) && (ucr1 & UCR1_TXMPTYEN)) {
-		rt_imx_uart_tx_chars(ctx);
+	if (usr1 & USR1_TRDY) {
+		if (likely(ucr1 & UCR1_TXMPTYEN))
+			rt_imx_uart_tx_chars(ctx);
 		ret = RTDM_IRQ_HANDLED;
 	}
 
-- 
2.20.1




More information about the Xenomai mailing list