Repository navigation
arch/arm/imxrt & serial: fix eDMA NCE errors caused by 0-iteration TCD on buffer wrap - #20893
Merged
acassis merged 2 commits intoOct 23, 2026
Merged
Conversation
When the TX circular buffer wraps around with head == 0, uart_xmitchars_dma() previously set nbuffer to the start of the buffer even though nlength was 0. This caused underlying DMA drivers to treat it as an active split transfer with zero length. Set nbuffer to NULL and nlength to 0 when head is 0. Signed-off-by: Sarthak Pandey <[email protected]>
Sarthak-Pandey
requested review from
GUIDINGLI,
Ouss4,
davids5,
jerpelea and
xiaoxiang781216
as code owners
October 22, 2026 17:33
xiaoxiang781216
previously approved these changes
Oct 22, 2026
- In imxrt_dma_send(), verify dev->dmatx.nlength > 0 before setting up a chained TCD. Chaining a TCD with iter == 0 causes eDMA NCE errors and halts the eDMA engine when HOE is enabled. - In imxrt_dmaterminate(), clear CITER and BITER registers so residual zero-iteration states do not trigger repeated NCE errors on channel re-activation. - In imxrt_dmach_xfrsetup(), return -EINVAL if config->iter is 0. Fixes apache#20881 Signed-off-by: Sarthak Pandey <[email protected]>
Sarthak-Pandey
force-pushed
the
fix/imxrt-lpuart-tcd-citer-zero
branch
from
October 22, 2026 21:28
286974f to
f9c6060
Compare
xiaoxiang781216
approved these changes
Oct 23, 2026
|
acassis
approved these changes
Oct 23, 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 #20881
When the TX ring buffer wraps around with
head == 0,uart_xmitchars_dma()setsnbuffer = dev->xmit.bufferandnlength = 0.In
arch/arm/src/imxrt/imxrt_serial.c,imxrt_dma_send()previously only checkedif (dev->dmatx.nbuffer). Consequently, a second chained TCD descriptor was allocated and linked withiter = nlength = 0.Under the i.MX RT eDMA architecture:
TCDn_CITER[CITER] = 0triggers anES[NCE](Descriptor Configuration Error).CONFIG_IMXRT_EDMA_HOE=y(Halt on Error, default), the eDMA engine setsCR[HALT] = 1, freezing all other shared eDMA peripherals (LPSPI IMUs, LPI2C barometers/magnetometers, other UART channels).imxrt_dmaterminate()did not reset CITER/BITER, leaving residual error state and causing errors in pairs upon channel re-activation.Solution:
drivers/serial/serial_dma.c: Inuart_xmitchars_dma(), setnbuffer = NULLandnlength = 0whenhead == 0on wrap-around, protecting all architectures.arch/arm/src/imxrt/imxrt_serial.c: Inimxrt_dma_send(), guard split-transfer descriptor creation withif (dev->dmatx.nbuffer && dev->dmatx.nlength > 0).arch/arm/src/imxrt/imxrt_edma.c:imxrt_dmaterminate(), clearTCD_CITERandTCD_BITERto prevent repeated NCE error traps.imxrt_dmach_xfrsetup(), validateconfig->iter > 0and return-EINVALif 0.Impact
Testing
ES = 0,CR = 0x412), no peripheral pauses or IMU interruptions observed after applying the fix.