Skip to content

Commit

Permalink
ethernet: stm32h7: fix tx semaphore timeout bug
Browse files Browse the repository at this point in the history
Incomplete memory write causes issues with ethernet
transmission on stm32h747_disco_m7 board.
TxCpltCallback is never called, causing waiting for
tx_int_sem to timeout, and occationally hangs
ethernet communication.

Tested with 700 000 connections on dumb http server,
as well as 5min continuous MCU reset every 7s with
continuous GET requests.

Fixes issue #29915

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
  • Loading branch information
emillindq committed Nov 12, 2020
1 parent 9d1c475 commit 8ed12ae
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/ethernet/eth_stm32_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,17 @@ static int eth_tx(const struct device *dev, struct net_pkt *pkt)
/* Reset TX complete interrupt semaphore before TX request*/
k_sem_reset(&dev_data->tx_int_sem);

/* Memory barriers (e.g. __DSB()) should flush Tx descriptors
* into memory. Incomplete writing of Tx descriptors may occur
* with different compilation levels
*/
__DSB();

/* tx_buffer is allocated on function stack, we need */
/* to wait for the transfer to complete */
/* So it is not freed before the interrupt happens */
hal_ret = HAL_ETH_Transmit_IT(heth, &tx_config);
__DSB();

if (hal_ret != HAL_OK) {
LOG_ERR("HAL_ETH_Transmit: failed!");
Expand Down

0 comments on commit 8ed12ae

Please sign in to comment.