You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "Swatantra-66 (via GitHub)" <gi...@apache.org> on 2026/10/18 09:07:57 UTC
[PR] arch/xtensa/esp32: fix double spinlock unlock in esp32_txint [nuttx]
Swatantra-66 opened a new pull request, #20769:
URL: https://github.com/apache/nuttx/pull/20769
## Summary
Resolves #14594.
In `esp32_txint()` (`arch/xtensa/src/esp32/esp32_serial.c`), when `CONFIG_SUPPRESS_SERIAL_INTS` was active, `spin_unlock_irqrestore(&priv->lock, flags)` was called inside the `if (enable)` block before invoking `uart_xmitchars(dev)`. The execution then exited the `if (enable)` block and hit an unconditional `spin_unlock_irqrestore(&priv->lock, flags)` at the bottom of the function, causing consecutive unlocks on the same lock (issue #14594).
This PR restructures `esp32_txint()` so that:
1. The spinlock is held across register manipulation in both `if (enable)` and `else` branches and released exactly once at the end of the critical section.
2. Under `CONFIG_SUPPRESS_SERIAL_INTS`, `uart_xmitchars(dev)` is called safely after `priv->lock` is released, preventing recursive spinlock deadlocks when `uart_xmitchars` calls back into `txint(dev, false)`.
3. Updated the comment to accurately document that `uart_xmitchars()` runs after the spinlock is released.
## Impact
- **ESP32 SMP & Debugging**: Prevents kernel panics and CPU interrupt state corruption caused by unlocking an already-unlocked spinlock.
- **Concurrency**: Eliminates deadlock risk during recursive upper-half TX character processing.
## Testing
- Verified with `./tools/checkpatch.sh -u HEAD` (0 errors, 0 warnings).
- Verified with `./tools/nxstyle` on `arch/xtensa/src/esp32/esp32_serial.c` (0 errors, 0 warnings).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] arch/xtensa/esp32: fix double spinlock unlock in esp32_txint [nuttx]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20769:
URL: https://github.com/apache/nuttx/pull/20769#issuecomment-6248187126
<!-- membrowse-pr-comment -->
## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report
*No memory changes detected for:*
- [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=59fa92a3224681c08fc6f1d95230ccda4523df06&base=325ff9321b20209cf49d7578c81c1168cc0a8fe0)
- [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=59fa92a3224681c08fc6f1d95230ccda4523df06&base=325ff9321b20209cf49d7578c81c1168cc0a8fe0)
- [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=59fa92a3224681c08fc6f1d95230ccda4523df06&base=325ff9321b20209cf49d7578c81c1168cc0a8fe0)
- [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=59fa92a3224681c08fc6f1d95230ccda4523df06&base=325ff9321b20209cf49d7578c81c1168cc0a8fe0)
- [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=59fa92a3224681c08fc6f1d95230ccda4523df06&base=325ff9321b20209cf49d7578c81c1168cc0a8fe0)
- [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=59fa92a3224681c08fc6f1d95230ccda4523df06&base=325ff9321b20209cf49d7578c81c1168cc0a8fe0)
- [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=59fa92a3224681c08fc6f1d95230ccda4523df06&base=325ff9321b20209cf49d7578c81c1168cc0a8fe0)
- [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=59fa92a3224681c08fc6f1d95230ccda4523df06&base=325ff9321b20209cf49d7578c81c1168cc0a8fe0)
- [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=59fa92a3224681c08fc6f1d95230ccda4523df06&base=325ff9321b20209cf49d7578c81c1168cc0a8fe0)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] arch/xtensa/esp32: fix double spinlock unlock in esp32_txint [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis merged PR #20769:
URL: https://github.com/apache/nuttx/pull/20769
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org