Skip to contentSkip to conversation

net: dwmac-rk: MAC clock should be truned off

PATCH In review 李哲 3 participants 4 messages May 23, 2025 – May 24, 2025 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore

李哲

author
#0 lore raw

PATCH 1/1 net: dwmac-rk: MAC clock should be truned off

if PHY power-on fails, clockassociated the MAC should be disabled during the MAC initialization process

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +2 -2
index 700858ff6f7c..036e45be5828 100644
@@ -1648,7 +1648,7 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
 static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
 {
 	struct regulator *ldo = bsp_priv->regulator;
-	int ret;
+	int ret = 0;
 	struct device *dev = &bsp_priv->pdev->dev;
 
 	if (enable) {
@@ -1661,7 +1661,7 @@ static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
 			dev_err(dev, "fail to disable phy-supply\n");
 	}
 
-	return 0;
+	return ret;
 }
 
 static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
Signature · 1 line
2.17.1
#1 lore raw
Quoted 2 lines · 李哲

if PHY power-on fails, clockassociated the MAC should be disabled during the MAC initialization process

The Subject: line has a typo.

Quoted 19 lines
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +1 -1
index 700858ff6f7c..036e45be5828 100644
@@ -1648,7 +1648,7 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
 static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
 {
 	struct regulator *ldo = bsp_priv->regulator;
-	int ret;
+	int ret = 0;
 	struct device *dev = &bsp_priv->pdev->dev;
 
 	if (enable) {

drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable) · line 1664

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +1 -1
@@ -1661,7 +1661,7 @@ static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
 			dev_err(dev, "fail to disable phy-supply\n");
 	}
 
-	return 0;
+	return ret;

This does not make much sense to me. How do you get here with ret not being 0?

Andrew

---
pw-bot: cr

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 10 lines · lizhe

Hi, Anerdw
The following is the logic for calling this function:

rk_gmac_powerup() {

ret = phy_power_on(bsp_priv, true); // here.

if (ret) {

Quoted 7 lines

gmac_clk_enable(bsp_priv, false);

return ret;

}

}

Ah, there is something funny with your patch. Look at the diff:

drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +0 -0
index 700858ff6f7c..036e45be5828 100644
@@ -1648,7 +1648,7 @@  static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
 

This line tells you where in the file you are patching, and the function to be patched. This is what i looked at, gmac_clk_enable(). And gmac_clk_enable() has a similar structure, ret declared at the beginning, return 0 at the end. But the only way to that return 0 is without error.

But patch is actually for:

static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable) {
struct regulator *ldo = bsp_priv->regulator;
- int ret;
+ int ret = 0;
struct device *dev = &bsp_priv->pdev->dev;

if (enable) {
@@ -1661,7 +1661,7 @@ static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
dev_err(dev, "fail to disable phy-supply\n");
}

- return 0;
+ return ret;
}

And agree, the error codes are ignored in phy_power_on().

But i have a few questions:

How did you generate this diff? This is the first time i've made this mistake, as far as i know. I trust the context information when reviewing patches. Yet here it is wrong. Why? Is this actually normal? I know diff gets it wrong for python, i don't trust it at all with that language, but i've not noticed such problems with C.

Did you look at the history of phy_power_on()? It looks pretty deliberate ignoring errors. Maybe there is a reason why this happens? git blame and git log might explain why it is like this.

Andrew

#4 lore raw
Quoted 33 lines · Andrew Lunn
Quoted 10 lines · lizhe

Hi, Anerdw
The following is the logic for calling this function:

rk_gmac_powerup() {

ret = phy_power_on(bsp_priv, true); // here.

if (ret) {

Quoted 7 lines

gmac_clk_enable(bsp_priv, false);

return ret;

}

}

Ah, there is something funny with your patch. Look at the diff:

drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +0 -0
index 700858ff6f7c..036e45be5828 100644
@@ -1648,7 +1648,7 @@  static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
 

This line tells you where in the file you are patching, and the function to be patched. This is what i looked at, gmac_clk_enable(). And gmac_clk_enable() has a similar structure, ret declared at the beginning, return 0 at the end. But the only way to that return 0 is without error.

Quoted 3 lines

But patch is actually for:

static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)

Andrew, this is not a problem. This is how diffs work. If the function hasn't actually started at the point the context starts, then the previous function will appear in the comment after the line numbers.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!