netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dwmac-rk: MAC clock should be truned off
@ 2025-05-23 15:15 李哲
  2025-05-23 16:20 ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: 李哲 @ 2025-05-23 15:15 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, jonas, rmk+kernel, david.wu, wens,
	u.kleine-koenig, an.petrous
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
	李哲

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

Signed-off-by: 李哲 <sensor1010@163.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 700858ff6f7c..036e45be5828 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -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,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: dwmac-rk: MAC clock should be truned off
  2025-05-23 15:15 [PATCH] net: dwmac-rk: MAC clock should be truned off 李哲
@ 2025-05-23 16:20 ` Andrew Lunn
       [not found]   ` <2525c791.3415.197029d3705.Coremail.sensor1010@163.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2025-05-23 16:20 UTC (permalink / raw)
  To: 李哲
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, jonas, rmk+kernel, david.wu, wens,
	u.kleine-koenig, an.petrous, netdev, linux-stm32,
	linux-arm-kernel, linux-kernel

On Fri, May 23, 2025 at 08:15:21AM -0700, 李哲 wrote:
> if PHY power-on fails, clockassociated the MAC should
> be disabled during the MAC initialization process

The Subject: line has a typo.

> Signed-off-by: 李哲 <sensor1010@163.com>
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index 700858ff6f7c..036e45be5828 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -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;

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

    Andrew

---
pw-bot: cr

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: [PATCH] net: dwmac-rk: MAC clock should be truned off
       [not found]   ` <2525c791.3415.197029d3705.Coremail.sensor1010@163.com>
@ 2025-05-24 14:48     ` Andrew Lunn
  2025-05-24 19:34       ` Russell King (Oracle)
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2025-05-24 14:48 UTC (permalink / raw)
  To: lizhe
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, jonas, rmk+kernel, david.wu, wens,
	u.kleine-koenig, an.petrous, netdev, linux-stm32,
	linux-arm-kernel, linux-kernel

On Sat, May 24, 2025 at 10:05:47PM +0800, lizhe wrote:
> Hi, Anerdw
> The following is the logic for calling this function: 
> 
> 
> rk_gmac_powerup() {
> 
> ret = phy_power_on(bsp_priv, true);      // here.
> 
> if (ret) {
> 
> gmac_clk_enable(bsp_priv, false);
> 
> return ret;
> 
> }
> 
> }

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

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 700858ff6f7c..036e45be5828 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Re: [PATCH] net: dwmac-rk: MAC clock should be truned off
  2025-05-24 14:48     ` Andrew Lunn
@ 2025-05-24 19:34       ` Russell King (Oracle)
  0 siblings, 0 replies; 4+ messages in thread
From: Russell King (Oracle) @ 2025-05-24 19:34 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: lizhe, andrew+netdev, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, alexandre.torgue, jonas, david.wu, wens,
	u.kleine-koenig, an.petrous, netdev, linux-stm32,
	linux-arm-kernel, linux-kernel

On Sat, May 24, 2025 at 04:48:15PM +0200, Andrew Lunn wrote:
> On Sat, May 24, 2025 at 10:05:47PM +0800, lizhe wrote:
> > Hi, Anerdw
> > The following is the logic for calling this function: 
> > 
> > 
> > rk_gmac_powerup() {
> > 
> > ret = phy_power_on(bsp_priv, true);      // here.
> > 
> > if (ret) {
> > 
> > gmac_clk_enable(bsp_priv, false);
> > 
> > return ret;
> > 
> > }
> > 
> > }
> 
> Ah, there is something funny with your patch. Look at the diff:
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index 700858ff6f7c..036e45be5828 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -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)

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.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-24 19:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-23 15:15 [PATCH] net: dwmac-rk: MAC clock should be truned off 李哲
2025-05-23 16:20 ` Andrew Lunn
     [not found]   ` <2525c791.3415.197029d3705.Coremail.sensor1010@163.com>
2025-05-24 14:48     ` Andrew Lunn
2025-05-24 19:34       ` Russell King (Oracle)

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).