From 242d348fcaebb465d4d9425edb7b3c1c0747d61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fin=20Maa=C3=9F?= Date: Wed, 11 Jun 2025 10:54:20 +0200 Subject: [PATCH] drivers: ethernet: stm32: stop hal before config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make sure the hal is stopped, before configuring the link. The phy can change the speed without notifying a link down in between. Signed-off-by: Fin Maaß --- drivers/ethernet/eth_stm32_hal.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/ethernet/eth_stm32_hal.c b/drivers/ethernet/eth_stm32_hal.c index 12501341ac7..ee8b8ef506f 100644 --- a/drivers/ethernet/eth_stm32_hal.c +++ b/drivers/ethernet/eth_stm32_hal.c @@ -1128,12 +1128,15 @@ static void phy_link_state_changed(const struct device *phy_dev, struct phy_link ARG_UNUSED(phy_dev); + /* The hal also needs to be stopped before changing the MAC config. + * The speed can change without receiving a link down callback before. + */ + eth_stm32_hal_stop(dev); if (state->is_up) { set_mac_config(dev, state); eth_stm32_hal_start(dev); net_eth_carrier_on(dev_data->iface); } else { - eth_stm32_hal_stop(dev); net_eth_carrier_off(dev_data->iface); } }