Skip to content

Commit dd5bd73

Browse files
authored
Merge pull request #5720 from kjbracey-arm/STM32F7_DMB
Add memory barriers to STM32F7xx Ethernet
2 parents 1ae20c5 + 05e2ae7 commit dd5bd73

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_eth.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,8 @@ HAL_StatusTypeDef HAL_ETH_TransmitFrame(ETH_HandleTypeDef *heth, uint32_t FrameL
717717
heth->TxDesc->Status |=ETH_DMATXDESC_FS|ETH_DMATXDESC_LS;
718718
/* Set frame size */
719719
heth->TxDesc->ControlBufferSize = (FrameLength & ETH_DMATXDESC_TBS1);
720+
/* Ensure rest of descriptor is written to RAM before the OWN bit */
721+
__DMB();
720722
/* Set Own bit of the Tx descriptor Status: gives the buffer back to ETHERNET DMA */
721723
heth->TxDesc->Status |= ETH_DMATXDESC_OWN;
722724
/* Point to next descriptor */
@@ -746,13 +748,18 @@ HAL_StatusTypeDef HAL_ETH_TransmitFrame(ETH_HandleTypeDef *heth, uint32_t FrameL
746748
heth->TxDesc->ControlBufferSize = (size & ETH_DMATXDESC_TBS1);
747749
}
748750

751+
/* Ensure rest of descriptor is written to RAM before the OWN bit */
752+
__DMB();
749753
/* Set Own bit of the Tx descriptor Status: gives the buffer back to ETHERNET DMA */
750754
heth->TxDesc->Status |= ETH_DMATXDESC_OWN;
751755
/* point to next descriptor */
752756
heth->TxDesc = (ETH_DMADescTypeDef *)(heth->TxDesc->Buffer2NextDescAddr);
753757
}
754758
}
755759

760+
/* Ensure all descriptors are written to RAM before checking transmitter status */
761+
__DMB();
762+
756763
/* When Tx Buffer unavailable flag is set: clear it and resume transmission */
757764
if (((heth->Instance)->DMASR & ETH_DMASR_TBUS) != (uint32_t)RESET)
758765
{

0 commit comments

Comments
 (0)