Skip to content

Conversation

@djiatsaf-st
Copy link
Contributor

This PR adds a mechanism to prevent a possible race condition between the DMA interrupt and the timeout callback in async_user_callback

FIxes #76799

@github-actions github-actions bot added platform: STM32 ST Micro STM32 area: UART Universal Asynchronous Receiver-Transmitter labels Jun 10, 2025
etienne-lms
etienne-lms previously approved these changes Jun 10, 2025
etienne-lms
etienne-lms previously approved these changes Jun 11, 2025
@djiatsaf-st djiatsaf-st force-pushed the fix_issue_76799 branch 2 times, most recently from 4831bb7 to 3b2e97d Compare June 12, 2025 07:21
Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed something: commit message header line should state the commit relates the stm32 uart driver only, e.g.:
drivers: serial: stm32: prevent race condition

The async_user_callback could be triggered from
both the DMA transfer complete interrupt and
a k_work queue timeout. Since the timeout runs
outside of an ISR context, it could be interrupted
by the DMA ISR. This might leads to a race condition
where both paths access and modify shared
DMA buffer state (offset and length) simultaneously,
causing data corruption or out-of-sequence processing.

Introduces proper synchronization to prevent concurrent
access to shared DMA buffer variables,
ensuring consistent and reliable data handling.

Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
@sonarqubecloud
Copy link

@dkalowsk dkalowsk merged commit 26a43ca into zephyrproject-rtos:main Jun 12, 2025
26 checks passed
@tkem
Copy link

tkem commented Jun 12, 2025

Yee-haw! Thanks everybody involved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: UART Universal Asynchronous Receiver-Transmitter platform: STM32 ST Micro STM32

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drivers: serial: stm32: Data loss & possible hardfault

7 participants