From d68c8ec5608e2c4f0315c29e17b584400b12ed69 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Tue, 26 Sep 2023 13:48:58 +0300 Subject: [PATCH] stm32_eth: Fix excessively long critical section in ifdown handler stm32_ifdown() holds critical section when calling stm32_ethreset(). That function used to call up_mdelay(10) while waiting for the ethernet peripheral reset to complete. This resulted in excessively long critical section time with interrupts disabled. The actual expected delay is a few clock ticks of the 50 MHz clock domain. This commit changes polling interval to 1us and maximum to 10us. --- arch/arm/src/stm32/stm32_eth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/stm32/stm32_eth.c b/arch/arm/src/stm32/stm32_eth.c index ae75009d79..ff4bc8ecb7 100644 --- a/arch/arm/src/stm32/stm32_eth.c +++ b/arch/arm/src/stm32/stm32_eth.c @@ -3542,6 +3542,7 @@ static int stm32_ethreset(struct stm32_ethmac_s *priv) /* Wait for software reset to complete. The SR bit is cleared automatically * after the reset operation has completed in all core clock domains. + * Should take at most a few clock ticks of the 50 MHz domain. */ retries = 10; @@ -3549,7 +3550,7 @@ static int stm32_ethreset(struct stm32_ethmac_s *priv) retries > 0) { retries--; - up_mdelay(10); + up_udelay(1); } if (retries == 0)