drivers: serial: Remove an unnecessary critical section (cs) for SMP
Summary: - I thought this cs is needed to avoid data corruption - For example, while executing uart_xmitchar() in the interrupt handler on CPU0, an application running on CPU1 can call uart_putxmitchar() via write()->uart_write(). - In this case, taking xmit.sem in uart_write() will wait for CPU0 to finish uart_xmitchar() because CPU0 has already taken a cs in uart_xmitchar() then nxsem_wait() on CPU0 takes a new cs inside (and release the cs when returning but it's OK) - Then uart_write() on CPU1 disables UART TX, so uart_xmitchar() on CPU0 will not be called while executing uart_write() on CPU1. - So this critical section in uart_putxmitchar() can be removed. Impact: - None Testing: - Tested with spresense:wifi_smp, esp32-devkitc:smp Reported-by: Xiang Xiao <xiaoxiang@xiaomi.com> Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
parent
be1c8036d5
commit
3ccef09b4e
|
@ -191,10 +191,6 @@ static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, bool oktoblock)
|
|||
int nexthead;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
irqstate_t flags2 = enter_critical_section();
|
||||
#endif
|
||||
|
||||
/* Increment to see what the next head pointer will be.
|
||||
* We need to use the "next" head pointer to determine when the circular
|
||||
* buffer would overrun
|
||||
|
@ -330,10 +326,6 @@ static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, bool oktoblock)
|
|||
|
||||
err_out:
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
leave_critical_section(flags2);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue