]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: stmmac: Return early if invalid in loongson_dwmac_fix_reset()
authorTiezhu Yang <yangtiezhu@loongson.cn>
Mon, 11 Aug 2025 07:35:06 +0000 (15:35 +0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 13 Aug 2025 23:27:42 +0000 (16:27 -0700)
If the MAC controller does not connect to any PHY interface, there is a
missing clock, then the DMA reset fails.

For this case, the DMA_BUS_MODE_SFT_RESET bit is 1 before software reset,
just print an error message which gives a hint the PHY clock is missing,
and then return -EINVAL immediately to avoid waiting for the timeout when
the DMA reset fails in loongson_dwmac_fix_reset().

With this patch, for the normal end user, the computer start faster with
reducing boot time for 2 seconds on the specified mainboard.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Link: https://patch.msgid.link/20250811073506.27513-4-yangtiezhu@loongson.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c

index 4c477d6ce1e61805117f0ab6905c776b03fc1410..6fca0fca4892dc0da67725978bcaaa1ff6266869 100644 (file)
@@ -513,6 +513,11 @@ static int loongson_dwmac_fix_reset(struct stmmac_priv *priv, void __iomem *ioad
 {
        u32 value = readl(ioaddr + DMA_BUS_MODE);
 
+       if (value & DMA_BUS_MODE_SFT_RESET) {
+               netdev_err(priv->dev, "the PHY clock is missing\n");
+               return -EINVAL;
+       }
+
        value |= DMA_BUS_MODE_SFT_RESET;
        writel(value, ioaddr + DMA_BUS_MODE);