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.
This commit is contained in:
Julian Oes 2021-04-29 14:23:15 +02:00 committed by Xiang Xiao
parent 886009f15f
commit 644a0cd525

View File

@ -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