From 863fef4a5400aef81901fd04ea0e2802b27b37ad Mon Sep 17 00:00:00 2001 From: Ron Smith Date: Fri, 3 Sep 2021 21:15:00 -0400 Subject: [PATCH] drivers: serial: uart_sam0: fix |= incorrectly clearing all INTFLAGS. fix uart_sam0_irq_update to only clear the RXS bit by writing only the RXS bitflag to the INTFLAG register. Performing an |= opperation with the bitflag for RXS incorrectly clears all pending interrupts set since writing 1 to a INTFLAG clears that bit field. This causes a race condition on when TXC will be cleared before all bytes have finished being clocked out on tx and TXC being set 1 again. If tx finishes first, any driver using uart_irq_tx_complete will deadlock the system. Signed-off-by: Ron Smith --- drivers/serial/uart_sam0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/serial/uart_sam0.c b/drivers/serial/uart_sam0.c index c4d5d23746..4aeb79fb2d 100644 --- a/drivers/serial/uart_sam0.c +++ b/drivers/serial/uart_sam0.c @@ -889,7 +889,7 @@ static int uart_sam0_irq_update(const struct device *dev) | SERCOM_USART_INTENCLR_CTSIC | SERCOM_USART_INTENCLR_RXS; #else - regs->INTFLAG.reg |= SERCOM_USART_INTENCLR_RXS; + regs->INTFLAG.reg = SERCOM_USART_INTENCLR_RXS; #endif return 1; }