Conversation
Protect runtime HAL init, start, stop, and MAC reconfiguration with the TX mutex to prevent them from racing with packet submission. Recheck the link and HAL state after acquiring the mutex, and handle HAL_ETH_Transmit_IT failures through normal buffer and descriptor cleanup instead of asserting.
This branch has not been deployed
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.
Description
The STM32 network interface checks the PHY link and HAL Ethernet state before waiting for the TX descriptor semaphore and TX mutex. During that interval, the EMAC task can stop or reinitialize Ethernet without taking the TX mutex.
This permits the following task interleaving:
HAL_ETH_STATE_STARTED.state.
HAL_ETH_Transmit_IT().state is still
HAL_ETH_STATE_STARTED.This change:
HAL_ETH_Transmit_IT()failures through the existing normal cleanup path instead of asserting.xReleaseAfterSendset so that the network buffer is released exactly once when HAL has not accepted it.prvReleaseTxPacket()outside the mutex because that function acquires the same mutex internally.All modifications are isolated to
source/portable/NetworkInterface/STM32/NetworkInterface.c.Test Steps
Reproduction before the change:
configASSERT.xTxMutex.HAL_ETH_Stop_IT().HAL_ETH_Transmit_IT()fails and theHAL_ETH_STATE_STARTEDassertion is triggered.Validation for the change:
xTxMutex.pdFAILwithout callingHAL_ETH_Transmit_IT().Static validation performed:
git diff --checkpasses.STM32H745 hardware validation of the patched branch is still pending.
Checklist:
The first item will be checked after completing the STM32H745 hardware validation described above. No STM32 network-interface unit-test harness is currently available in this repository.
Related Issue
None.