arch/arm/src/imxrt/imxrt_enet.c: Fix a race condition in setting up the Ethernet Tx transfer.

This commit is contained in:
Dave Marples 2018-09-26 10:59:47 -06:00 committed by Gregory Nutt
parent 6e4545a924
commit 4eb118afd1
2 changed files with 12 additions and 3 deletions

View File

@ -461,6 +461,7 @@ static bool imxrt_txringfull(FAR struct imxrt_driver_s *priv)
static int imxrt_transmit(FAR struct imxrt_driver_s *priv) static int imxrt_transmit(FAR struct imxrt_driver_s *priv)
{ {
struct enet_desc_s *txdesc; struct enet_desc_s *txdesc;
irqstate_t flags;
uint32_t regval; uint32_t regval;
uint8_t *buf; uint8_t *buf;
@ -526,9 +527,9 @@ static int imxrt_transmit(FAR struct imxrt_driver_s *priv)
DEBUGASSERT(txdesc->data == buf); DEBUGASSERT(txdesc->data == buf);
} }
/* Start the TX transfer (if it was not already waiting for buffers) */ /* Make the following operations atomic */
putreg32(ENET_TDAR, IMXRT_ENET_TDAR); flags = spin_lock_irqsave();
/* Enable TX interrupts */ /* Enable TX interrupts */
@ -540,6 +541,12 @@ static int imxrt_transmit(FAR struct imxrt_driver_s *priv)
(void)wd_start(priv->txtimeout, IMXRT_TXTIMEOUT, imxrt_txtimeout_expiry, 1, (void)wd_start(priv->txtimeout, IMXRT_TXTIMEOUT, imxrt_txtimeout_expiry, 1,
(wdparm_t)priv); (wdparm_t)priv);
/* Start the TX transfer (if it was not already waiting for buffers) */
putreg32(ENET_TDAR, IMXRT_ENET_TDAR);
spin_unlock_irqrestore(flags);
return OK; return OK;
} }

View File

@ -57,6 +57,7 @@
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
#if defined(CONFIG_I2C_DRIVER) && defined(CONFIG_IMXRT_LPI2C1)
static void imxrt_i2c_register(int bus) static void imxrt_i2c_register(int bus)
{ {
FAR struct i2c_master_s *i2c; FAR struct i2c_master_s *i2c;
@ -77,6 +78,7 @@ static void imxrt_i2c_register(int bus)
} }
} }
} }
#endif
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@ -109,7 +111,7 @@ int imxrt_bringup(void)
} }
#endif #endif
#if defined ( CONFIG_I2C_DRIVER ) & (CONFIG_IMXRT_LPI2C1) #if defined(CONFIG_I2C_DRIVER) && defined(CONFIG_IMXRT_LPI2C1)
imxrt_i2c_register(1); imxrt_i2c_register(1);
#endif #endif