Skip to content

Commit 6f195d6

Browse files
lopsided98kuba-moo
authored andcommitted
net: stmmac: dwmac-stm32: fix resume on STM32 MCU
The STM32MP1 keeps clk_rx enabled during suspend, and therefore the driver does not enable the clock in stm32_dwmac_init() if the device was suspended. The problem is that this same code runs on STM32 MCUs, which do disable clk_rx during suspend, causing the clock to never be re-enabled on resume. This patch adds a variant flag to indicate that clk_rx remains enabled during suspend, and uses this to decide whether to enable the clock in stm32_dwmac_init() if the device was suspended. This approach fixes this specific bug with limited opportunity for unintended side-effects, but I have a follow up patch that will refactor the clock configuration and hopefully make it less error prone. Fixes: 6528e02 ("net: ethernet: stmmac: add adaptation for stm32mp157c.") Signed-off-by: Ben Wolsieffer <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0add5c5 commit 6f195d6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ struct stm32_ops {
104104
int (*parse_data)(struct stm32_dwmac *dwmac,
105105
struct device *dev);
106106
u32 syscfg_eth_mask;
107+
bool clk_rx_enable_in_suspend;
107108
};
108109

109110
static int stm32_dwmac_init(struct plat_stmmacenet_data *plat_dat)
@@ -121,7 +122,8 @@ static int stm32_dwmac_init(struct plat_stmmacenet_data *plat_dat)
121122
if (ret)
122123
return ret;
123124

124-
if (!dwmac->dev->power.is_suspended) {
125+
if (!dwmac->ops->clk_rx_enable_in_suspend ||
126+
!dwmac->dev->power.is_suspended) {
125127
ret = clk_prepare_enable(dwmac->clk_rx);
126128
if (ret) {
127129
clk_disable_unprepare(dwmac->clk_tx);
@@ -513,7 +515,8 @@ static struct stm32_ops stm32mp1_dwmac_data = {
513515
.suspend = stm32mp1_suspend,
514516
.resume = stm32mp1_resume,
515517
.parse_data = stm32mp1_parse_data,
516-
.syscfg_eth_mask = SYSCFG_MP1_ETH_MASK
518+
.syscfg_eth_mask = SYSCFG_MP1_ETH_MASK,
519+
.clk_rx_enable_in_suspend = true
517520
};
518521

519522
static const struct of_device_id stm32_dwmac_match[] = {

0 commit comments

Comments
 (0)