Skip to content

Conversation

kbidani
Copy link
Contributor

@kbidani kbidani commented Aug 25, 2025

A race condition could occur in half-duplex master mode when switching from TX to RX.
If a preemption happens immediately after starting the master transfer, the SPI hardware may complete the transfer before the polling loop is entered, causing the CSTART bit to be cleared and resulting in an infinite loop.
This patch adds a check for the EOT flag inside the polling loop in spi_stm32_half_duplex_switch_to_receive(). If EOT is set, the transfer is already complete and the loop is exited, preventing the lockup.

Issues: #94265

@kbidani kbidani force-pushed the fix_spi_half_duplex branch from 7832b2d to ab80caa Compare August 25, 2025 12:31
Copy link

github-actions bot commented Aug 25, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@kbidani kbidani force-pushed the fix_spi_half_duplex branch from 28b21a5 to ab80caa Compare August 25, 2025 13:29
@github-actions github-actions bot added manifest-hal_stm32 DNM (manifest) This PR should not be merged (controlled by action-manifest) and removed manifest manifest-hal_stm32 DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Aug 25, 2025
… mode

This patch adds a check for the EOT (End Of Transfer) flag
inside the polling loop in spi_stm32_half_duplex_switch_to_receive().
If EOT is set, the transfer is alreadycomplete and the loop
is exited, preventing the lockup.

Signed-off-by: Khaoula Bidani <[email protected]>
@kbidani kbidani force-pushed the fix_spi_half_duplex branch from ab80caa to cb0ca63 Compare September 22, 2025 08:00
Copy link

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.

1 participant