Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stm32h7/serial: Do not wait on TXDMA semaphore #11154

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

niklaut
Copy link
Contributor

@niklaut niklaut commented Nov 8, 2023

If using flow control with a high CTS the thread may be blocked forever on the second transmit attempt due to waiting on the txdma semaphore. The calling thread can then never make progress and release any resources it has taken, thus may cause a deadlock in other parts of the system.

The implementation differs in behavior from interrupt-driven TX and the STM32F7 TXDMA . It should not implicitly wait on a taken semaphore but return immediately and let the upper layers decide on what to do next.

See a more detailed analysis here: PX4/PX4-Autopilot#22302

cc @davids5

If using flow control with a high CTS the thread may be blocked forever
on the second transmit attempt due to waiting on the txdma semaphore.
The calling thread can then never make progress and release any
resources it has taken, thus may cause a deadlock in other parts of the
system.

The implementation differs in behavior from interrupt-driven TX and the
STM32F7 TXDMA . It should not implicitly wait on a taken semaphore but
return immediately and let the upper layers decide on what to do next.
@davids5 davids5 self-requested a review November 8, 2023 14:24
Copy link
Contributor

@davids5 davids5 left a comment

Choose a reason for hiding this comment

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

@niklaut Thank you! I am glad my suggestion worked. I will backport this to PX4 when it comes in.

@davids5 davids5 self-requested a review November 8, 2023 14:25
@davids5 davids5 merged commit 660ac63 into apache:master Nov 8, 2023
26 checks passed
@niklaut niklaut deleted the fix/stm32h7_serial_txdma branch November 9, 2023 10:47
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.

3 participants