Repository navigation
drivers/serial: Fix zero-length second TX DMA transfer descriptor on buffer wrap - #20894
Merged
xiaoxiang781216 merged 2 commits intoOct 26, 2026
Merged
Conversation
Swatantra-66
requested review from
GUIDINGLI,
davids5,
gustavonihei,
jerpelea,
pussuw and
xiaoxiang781216
as code owners
October 22, 2026 17:50
xiaoxiang781216
previously approved these changes
Oct 22, 2026
|
xiaoxiang781216
previously approved these changes
Oct 23, 2026
Swatantra-66
force-pushed
the
fix/serial-dma-zero-length-wrap
branch
from
October 23, 2026 06:43
15ef5ba to
bd227c3
Compare
xiaoxiang781216
previously approved these changes
Oct 23, 2026
Contributor
|
@Swatantra-66 why close this pr? |
Contributor
Author
|
Reopened, I thought it might be redundant after #20893 merged and the issue was closed. |
acassis
previously approved these changes
Oct 24, 2026
Contributor
|
@Swatantra-66 please check if it is redundant and if not, please fix the conflicting files |
Swatantra-66
dismissed stale reviews from acassis and xiaoxiang781216
via
October 24, 2026 13:34
cc99993
Swatantra-66
force-pushed
the
fix/serial-dma-zero-length-wrap
branch
from
October 24, 2026 13:34
bd227c3 to
cc99993
Compare
Check that both dev->dmatx.nbuffer != NULL and dev->dmatx.nlength > 0 before configuring the second transfer descriptor. This defends against configuring an illegal descriptor with iter = 0 (CITER = 0 on eDMA) in case a zero-length second segment is passed. Also fix nxstyle indentation of switch case labels in imx9_ioctl. Signed-off-by: Swatantra Yadav <[email protected]>
Check that both dev->dmatx.nbuffer != NULL and dev->dmatx.nlength > 0 before configuring the second transfer descriptor. Also fix nxstyle indentation of switch case labels in imx9_ioctl. Signed-off-by: Swatantra Yadav <[email protected]>
Swatantra-66
force-pushed
the
fix/serial-dma-zero-length-wrap
branch
from
October 24, 2026 14:15
cc99993 to
3c9c010
Compare
Contributor
Author
|
@acassis , conflicts resolved |
Contributor
Author
|
The failure in Build / Linux (arm-nxp) is an upstream issue caused by the recent pollevent_t change merged into nuttx-apps master (waiting on #20796 in nuttx). It is unrelated to this PR's imx9_lpuart changes. |
xiaoxiang781216
approved these changes
Oct 24, 2026
Contributor
|
let's ignore ci error instead wasting ci resource by retrigger. |
GUIDINGLI
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a critical bug where serial TX DMA sets up a zero-length second transfer descriptor on buffer wrap, triggering illegal hardware configuration errors on eDMA engines.
Root Cause
In
drivers/serial/serial_dma.c(uart_xmitchars_dma()), when the transmit circular buffer wraps withhead == 0andtail > 0:xfer->nbufferwas assigneddev->xmit.buffereven thoughxfer->nlength == 0.Across chip drivers (
imxrt_serial.c,nxxx_lpuart.c,imx9_lpuart.c,s32k1xx_serial.c,s32k3xx_serial.c), the code checks:Because
nbuffer != NULL, the driver configures a second DMA descriptor withiter = nlength = 0(orCITER = BITER = 0). On NXP eDMA controllers (i.MX RT, S32K, MCX-N, i.MX9),CITER = 0is an illegal descriptor configuration. The eDMA hardware detects this, assertsES[NCE](Non-zero Configuration Error), and setsCR[HALT] = 1, which halts the entire eDMA engine chip-wide and causes SPI, I2C, and UART peripherals to lock up.Fix
drivers/serial/serial_dma.c:uart_xmitchars_dma(): Only setxfer->nbufferandxfer->nlengthifdev->xmit.head > 0. Ifhead == 0, explicitly setxfer->nbuffer = NULL; xfer->nlength = 0;.uart_xmitchars_done(): Clean upxfer->buffer = xfer->nbuffer = NULL;on completion.arch/armandarch/arm64:imxrt,mcx-nxxx,imx9,s32k1xx, ands32k3xxserial drivers by checkingif (dev->dmatx.nbuffer != NULL && dev->dmatx.nlength > 0).Fixes: #20881
Impact
ES[NCE]configuration errors and chip-wide DMA halt on i.MX RT, S32K, MCX, and i.MX9 during serial TX DMA operations.CONFIG_SERIAL_TXDMA.Testing
tools/checkpatch.sh -u: all checks pass.