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

HAL_ETH_Transmit_IT() and HAL_ETH_Transmit() do not set HAL_ETH_STATE_BUSY before modifying TX descriptors creating race-condition #71

Open
KarstenHohmeier opened this issue Sep 8, 2024 · 1 comment
Assignees
Labels
bug Something isn't working eth Ethernet-related issue or pull-request hal HAL-LL driver-related issue or pull-request. internal bug tracker Issue confirmed and reported into a ticket in the internal bug tracking system

Comments

@KarstenHohmeier
Copy link

HAL_ETH_Transmit_IT() and HAL_ETH_Transmit() both test gState but do not set it to HAL_ETH_STATE_BUSY before operating on the TX descriptors inside ETH_Prepare_Tx_Descriptors(). This creates a race-condition among themselves and among each other when used concurrently from multiple threads (e.g. preemption under FreeRTOS).

Also Test-and-Set of gState needs to be done atomically (see #70).

if (heth->gState == HAL_ETH_STATE_STARTED)
{
/* Save the packet pointer to release. */
heth->TxDescList.CurrentPacketAddress = (uint32_t *)pTxConfig->pData;
/* Config DMA Tx descriptor by Tx Packet info */
if (ETH_Prepare_Tx_Descriptors(heth, pTxConfig, 1) != HAL_ETH_ERROR_NONE)
{

Expected was at minimum a Test-and-Set like this:

if (heth->gState == HAL_ETH_STATE_READY)
{
heth->gState = HAL_ETH_STATE_BUSY;

@ASEHSTM
Copy link
Contributor

ASEHSTM commented Sep 13, 2024

ST Internal Reference: 191088

@ASEHSTM ASEHSTM added the internal bug tracker Issue confirmed and reported into a ticket in the internal bug tracking system label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working eth Ethernet-related issue or pull-request hal HAL-LL driver-related issue or pull-request. internal bug tracker Issue confirmed and reported into a ticket in the internal bug tracking system
Projects
Development

No branches or pull requests

3 participants