* [PATCH net-next v3 0/3] Refine stmmac code
@ 2025-08-11 7:35 Tiezhu Yang
2025-08-11 7:35 ` [PATCH net-next v3 1/3] net: stmmac: Check stmmac_hw_setup() in stmmac_resume() Tiezhu Yang
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Tiezhu Yang @ 2025-08-11 7:35 UTC (permalink / raw)
To: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Maxime Chevallier, netdev, linux-kernel
Here are three small patches to refine stmmac code when debugging and
testing the problem "Failed to reset the dma".
v3:
-- Add a new patch to change the first parameter of fix_soc_reset().
-- Print an error message which gives a hint the PHY clock is missing.
v2:
-- Update the commit message of patch #1 to explain the background.
-- Add Reviewed-by tag for patch #2, no code changes.
Tiezhu Yang (3):
net: stmmac: Check stmmac_hw_setup() in stmmac_resume()
net: stmmac: Change first parameter of fix_soc_reset()
net: stmmac: Return early if invalid in loongson_dwmac_fix_reset()
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 6 +++---
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 7 ++++++-
drivers/net/ethernet/stmicro/stmmac/hwif.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 ++++++++-
include/linux/stmmac.h | 2 +-
5 files changed, 19 insertions(+), 7 deletions(-)
--
2.42.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next v3 1/3] net: stmmac: Check stmmac_hw_setup() in stmmac_resume()
2025-08-11 7:35 [PATCH net-next v3 0/3] Refine stmmac code Tiezhu Yang
@ 2025-08-11 7:35 ` Tiezhu Yang
2025-08-11 7:35 ` [PATCH net-next v3 2/3] net: stmmac: Change first parameter of fix_soc_reset() Tiezhu Yang
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Tiezhu Yang @ 2025-08-11 7:35 UTC (permalink / raw)
To: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Maxime Chevallier, netdev, linux-kernel
stmmac_hw_setup() may return 0 on success and an appropriate negative
integer as defined in errno.h file on failure, just check it and then
return early if failed in stmmac_resume().
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index f1abf4242cd2..b2d87d3e4a65 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -7975,7 +7975,14 @@ int stmmac_resume(struct device *dev)
stmmac_free_tx_skbufs(priv);
stmmac_clear_descriptors(priv, &priv->dma_conf);
- stmmac_hw_setup(ndev, false);
+ ret = stmmac_hw_setup(ndev, false);
+ if (ret < 0) {
+ netdev_err(priv->dev, "%s: Hw setup failed\n", __func__);
+ mutex_unlock(&priv->lock);
+ rtnl_unlock();
+ return ret;
+ }
+
stmmac_init_coalesce(priv);
phylink_rx_clk_stop_block(priv->phylink);
stmmac_set_rx_mode(ndev);
--
2.42.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next v3 2/3] net: stmmac: Change first parameter of fix_soc_reset()
2025-08-11 7:35 [PATCH net-next v3 0/3] Refine stmmac code Tiezhu Yang
2025-08-11 7:35 ` [PATCH net-next v3 1/3] net: stmmac: Check stmmac_hw_setup() in stmmac_resume() Tiezhu Yang
@ 2025-08-11 7:35 ` Tiezhu Yang
2025-08-11 7:35 ` [PATCH net-next v3 3/3] net: stmmac: Return early if invalid in loongson_dwmac_fix_reset() Tiezhu Yang
2025-08-13 23:40 ` [PATCH net-next v3 0/3] Refine stmmac code patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Tiezhu Yang @ 2025-08-11 7:35 UTC (permalink / raw)
To: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Maxime Chevallier, netdev, linux-kernel
In order to use netdev_err() to print message in the callback function of
fix_soc_reset(), change fix_soc_reset() to have "struct stmmac_priv *" as
its first parameter.
This is preparation for later patch, no functionality change.
Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 6 +++---
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/hwif.c | 2 +-
include/linux/stmmac.h | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
index 889e2bb6f7f5..c2d9e89f0063 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
@@ -49,7 +49,7 @@ struct imx_dwmac_ops {
u32 flags;
bool mac_rgmii_txclk_auto_adj;
- int (*fix_soc_reset)(void *priv, void __iomem *ioaddr);
+ int (*fix_soc_reset)(struct stmmac_priv *priv, void __iomem *ioaddr);
int (*set_intf_mode)(struct plat_stmmacenet_data *plat_dat);
void (*fix_mac_speed)(void *priv, int speed, unsigned int mode);
};
@@ -265,9 +265,9 @@ static void imx93_dwmac_fix_speed(void *priv, int speed, unsigned int mode)
writel(old_ctrl, dwmac->base_addr + MAC_CTRL_REG);
}
-static int imx_dwmac_mx93_reset(void *priv, void __iomem *ioaddr)
+static int imx_dwmac_mx93_reset(struct stmmac_priv *priv, void __iomem *ioaddr)
{
- struct plat_stmmacenet_data *plat_dat = priv;
+ struct plat_stmmacenet_data *plat_dat = priv->plat;
u32 value = readl(ioaddr + DMA_BUS_MODE);
/* DMA SW reset */
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index e1591e6217d4..bb376c69016d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -509,7 +509,7 @@ static int loongson_dwmac_acpi_config(struct pci_dev *pdev,
}
/* Loongson's DWMAC device may take nearly two seconds to complete DMA reset */
-static int loongson_dwmac_fix_reset(void *priv, void __iomem *ioaddr)
+static int loongson_dwmac_fix_reset(struct stmmac_priv *priv, void __iomem *ioaddr)
{
u32 value = readl(ioaddr + DMA_BUS_MODE);
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c
index 99635b37044a..3f7c765dcb79 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.c
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c
@@ -100,7 +100,7 @@ int stmmac_reset(struct stmmac_priv *priv, void __iomem *ioaddr)
return -EINVAL;
if (plat && plat->fix_soc_reset)
- return plat->fix_soc_reset(plat, ioaddr);
+ return plat->fix_soc_reset(priv, ioaddr);
return stmmac_do_callback(priv, dma, reset, ioaddr);
}
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 26ddf95d23f9..330694641a95 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -238,7 +238,7 @@ struct plat_stmmacenet_data {
int (*set_clk_tx_rate)(void *priv, struct clk *clk_tx_i,
phy_interface_t interface, int speed);
void (*fix_mac_speed)(void *priv, int speed, unsigned int mode);
- int (*fix_soc_reset)(void *priv, void __iomem *ioaddr);
+ int (*fix_soc_reset)(struct stmmac_priv *priv, void __iomem *ioaddr);
int (*serdes_powerup)(struct net_device *ndev, void *priv);
void (*serdes_powerdown)(struct net_device *ndev, void *priv);
int (*mac_finish)(struct net_device *ndev,
--
2.42.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next v3 3/3] net: stmmac: Return early if invalid in loongson_dwmac_fix_reset()
2025-08-11 7:35 [PATCH net-next v3 0/3] Refine stmmac code Tiezhu Yang
2025-08-11 7:35 ` [PATCH net-next v3 1/3] net: stmmac: Check stmmac_hw_setup() in stmmac_resume() Tiezhu Yang
2025-08-11 7:35 ` [PATCH net-next v3 2/3] net: stmmac: Change first parameter of fix_soc_reset() Tiezhu Yang
@ 2025-08-11 7:35 ` Tiezhu Yang
2025-08-13 23:40 ` [PATCH net-next v3 0/3] Refine stmmac code patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Tiezhu Yang @ 2025-08-11 7:35 UTC (permalink / raw)
To: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Maxime Chevallier, netdev, linux-kernel
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>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index bb376c69016d..05f195a18548 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -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);
--
2.42.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v3 0/3] Refine stmmac code
2025-08-11 7:35 [PATCH net-next v3 0/3] Refine stmmac code Tiezhu Yang
` (2 preceding siblings ...)
2025-08-11 7:35 ` [PATCH net-next v3 3/3] net: stmmac: Return early if invalid in loongson_dwmac_fix_reset() Tiezhu Yang
@ 2025-08-13 23:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-13 23:40 UTC (permalink / raw)
To: Tiezhu Yang
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, maxime.chevallier,
netdev, linux-kernel
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 11 Aug 2025 15:35:03 +0800 you wrote:
> Here are three small patches to refine stmmac code when debugging and
> testing the problem "Failed to reset the dma".
>
> v3:
> -- Add a new patch to change the first parameter of fix_soc_reset().
> -- Print an error message which gives a hint the PHY clock is missing.
>
> [...]
Here is the summary with links:
- [net-next,v3,1/3] net: stmmac: Check stmmac_hw_setup() in stmmac_resume()
https://git.kernel.org/netdev/net-next/c/6896c2449a18
- [net-next,v3,2/3] net: stmmac: Change first parameter of fix_soc_reset()
https://git.kernel.org/netdev/net-next/c/139235103f60
- [net-next,v3,3/3] net: stmmac: Return early if invalid in loongson_dwmac_fix_reset()
https://git.kernel.org/netdev/net-next/c/bfd9d893edfa
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-08-13 23:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-11 7:35 [PATCH net-next v3 0/3] Refine stmmac code Tiezhu Yang
2025-08-11 7:35 ` [PATCH net-next v3 1/3] net: stmmac: Check stmmac_hw_setup() in stmmac_resume() Tiezhu Yang
2025-08-11 7:35 ` [PATCH net-next v3 2/3] net: stmmac: Change first parameter of fix_soc_reset() Tiezhu Yang
2025-08-11 7:35 ` [PATCH net-next v3 3/3] net: stmmac: Return early if invalid in loongson_dwmac_fix_reset() Tiezhu Yang
2025-08-13 23:40 ` [PATCH net-next v3 0/3] Refine stmmac code patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).