From 644a0cd52573070082d2431d9e1f81a09de57fc9 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 29 Apr 2021 14:23:15 +0200 Subject: [PATCH] drivers/serial: fix Rx interrupt enable for cdcacm This is addressing an issue where Rx interrupts were not restored for cdcacm after the buffer had been filled (in a burst). The Rx interrupts were only restored after the watchdog timeout of 200ms fired. This happened because CONFIG_SERIAL_RXDMA was set, however, for the cdcacm driver this does not actually matter as it is relying on uart_enablerxint to be called via the ops table. This patch makes sure that uart_enablerxint and uart_disablerxint are always called, independent of CONFIG_SERIAL_RXDMA, relying on the ops table to be correct for the case where it should be only a no-op. --- drivers/serial/serial.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index ea64a7c07e..b33d1fa80a 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -900,17 +900,13 @@ static ssize_t uart_read(FAR struct file *filep, else { -#ifdef CONFIG_SERIAL_RXDMA - /* Disable all interrupts and test again... - * uart_disablerxint() is insufficient for the check in DMA mode. - */ + /* Disable all interrupts and test again... */ flags = enter_critical_section(); -#else + /* Disable Rx interrupts and test again... */ uart_disablerxint(dev); -#endif /* If the Rx ring buffer still empty? Bytes may have been added * between the last time that we checked and when we disabled @@ -927,14 +923,12 @@ static ssize_t uart_read(FAR struct file *filep, /* Notify DMA that there is free space in the RX buffer */ uart_dmarxfree(dev); -#else +#endif /* Wait with the RX interrupt re-enabled. All interrupts are * disabled briefly to assure that the following operations * are atomic. */ - flags = enter_critical_section(); - /* Re-enable UART Rx interrupts */ uart_enablerxint(dev); @@ -952,7 +946,6 @@ static ssize_t uart_read(FAR struct file *filep, leave_critical_section(flags); continue; } -#endif #ifdef CONFIG_SERIAL_REMOVABLE /* Check again if the removable device is still connected @@ -1020,11 +1013,9 @@ static ssize_t uart_read(FAR struct file *filep, * the loop. */ -#ifdef CONFIG_SERIAL_RXDMA leave_critical_section(flags); -#else + uart_enablerxint(dev); -#endif } } } @@ -1037,11 +1028,9 @@ static ssize_t uart_read(FAR struct file *filep, leave_critical_section(flags); #endif -#ifndef CONFIG_SERIAL_RXDMA /* RX interrupt could be disabled by RX buffer overflow. Enable it now. */ uart_enablerxint(dev); -#endif #ifdef CONFIG_SERIAL_IFLOWCONTROL #ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS