Skip to content

drivers: serial: Remove an unnecessary critical section (cs) for SMP - #3860

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
masayuki2009:serial-smp
Jun 6, 2021
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
masayuki2009:serial-smp

Conversation

@masayuki2009

Copy link
Copy Markdown
Contributor

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

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 <[email protected]>
Signed-off-by: Masayuki Ishikawa <[email protected]>
@masayuki2009

Copy link
Copy Markdown
Contributor Author

@xiaoxiang781216
I rewrote the summary and commit messages.

@xiaoxiang781216
xiaoxiang781216 merged commit 3ccef09 into apache:master Jun 6, 2021
@masayuki2009
masayuki2009 deleted the serial-smp branch June 14, 2021 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants