Skip to contentSkip to conversation

net: phy: fix phy_init_hw fixup handling

PATCH In review Heiner Kallweit 3 participants 8 messages Dec 23, 2018 – Dec 25, 2018

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

PATCH 1/1 net: phy: fix phy_init_hw fixup handling

Currently we return immediately if callback config_init isn't defined. This prevents the fixups from being executed. I see no dependency between fixups and config_init, therefore change the function to run the fixups also if config_init isn't defined.

Fixes 2f5cb43406d0 ("phylib: Properly reinitialize PHYs after hibernation")
---
 drivers/net/phy/phy_device.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/phy/phy_device.c +7 -5
index e10ac6075..07b1e6751 100644
@@ -1035,20 +1035,22 @@ int phy_init_hw(struct phy_device *phydev)
 	/* Deassert the reset signal */
 	phy_device_reset(phydev, 0);
 
-	if (!phydev->drv || !phydev->drv->config_init)
+	if (!phydev->drv)
 		return 0;
 
 	if (phydev->drv->soft_reset)
 		ret = phydev->drv->soft_reset(phydev);
-
-	if (ret < 0)
+	if (ret)
 		return ret;
 
 	ret = phy_scan_fixups(phydev);
-	if (ret < 0)
+	if (ret)
 		return ret;
 
-	return phydev->drv->config_init(phydev);
+	if (phydev->drv->config_init)
+		ret = phydev->drv->config_init(phydev);
+
+	return ret;
 }
 EXPORT_SYMBOL(phy_init_hw);
 
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 7 lines · Heiner Kallweit

Currently we return immediately if callback config_init isn't defined. This prevents the fixups from being executed. I see no dependency between fixups and config_init, therefore change the function to run the fixups also if config_init isn't defined.

Fixes 2f5cb43406d0 ("phylib: Properly reinitialize PHYs after hibernation")

Hi Heiner

Is this a real fix? It seems like it has been like this forever. Do you know of a PHY which is actually broken?

I think the change does make sense, i just don't know if it should be a fix and included in stable. It might be better to wait until net-next opens again.

Quoted 17 lines
---
 drivers/net/phy/phy_device.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/phy/phy_device.c +1 -1
index e10ac6075..07b1e6751 100644
@@ -1035,20 +1035,22 @@ int phy_init_hw(struct phy_device *phydev)
 	/* Deassert the reset signal */
 	phy_device_reset(phydev, 0);
 
-	if (!phydev->drv || !phydev->drv->config_init)
+	if (!phydev->drv)
 		return 0;
 
 	if (phydev->drv->soft_reset)

drivers/net/phy/phy_device.c int phy_init_hw(struct phy_device *phydev) · line 1048

Quoted 10 lines
drivers/net/phy/phy_device.c +2 -3
 		ret = phydev->drv->soft_reset(phydev);
-
-	if (ret < 0)
+	if (ret)
 		return ret;
 
 	ret = phy_scan_fixups(phydev);
-	if (ret < 0)
+	if (ret)
 		return ret;

These changes from < 0 to any value other than zero should be in a separate patch. This is particularly true for a fix, where we want fixes to be as small as possible. Statistics show fixes more often break stuff than normal development, because they get less testing. So we don't really want to make such a change in a fix for stable.

Thanks
Andrew

Quoted 11 lines
drivers/net/phy/phy_device.c +4 -1
-	return phydev->drv->config_init(phydev);
+	if (phydev->drv->config_init)
+		ret = phydev->drv->config_init(phydev);
+
+	return ret;
 }
 EXPORT_SYMBOL(phy_init_hw);
 
Signature · 1 line
2.20.1
author maintainer
#2 lore raw
Quoted 6 lines · Andrew Lunn
Quoted 5 lines · Heiner Kallweit

Currently we return immediately if callback config_init isn't defined. This prevents the fixups from being executed. I see no dependency between fixups and config_init, therefore change the function to run the fixups also if config_init isn't defined.

Quoted 8 lines
Quoted 2 lines
Fixes 2f5cb43406d0 ("phylib: Properly reinitialize PHYs after hibernation")

Hi Heiner

Is this a real fix? It seems like it has been like this forever. Do you know of a PHY which is actually broken?

Right, the current behavior has been there forever. I'm not aware of any concrete case. I went for "net" because the current code could break a device.

Quoted 4 lines

I think the change does make sense, i just don't know if it should be a fix and included in stable. It might be better to wait until net-next opens again.

Would be fine with me too. Maybe David can advise whether a fix for a potential issue w/o known case qualifies for net.

Quoted 23 lines
Quoted 23 lines
---
 drivers/net/phy/phy_device.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/phy/phy_device.c +2 -3
index e10ac6075..07b1e6751 100644
@@ -1035,20 +1035,22 @@ int phy_init_hw(struct phy_device *phydev)
 	/* Deassert the reset signal */
 	phy_device_reset(phydev, 0);
 
-	if (!phydev->drv || !phydev->drv->config_init)
+	if (!phydev->drv)
 		return 0;
 
 	if (phydev->drv->soft_reset)
 		ret = phydev->drv->soft_reset(phydev);
-
-	if (ret < 0)
+	if (ret)
 		return ret;
 
Quoted 11 lines

drivers/net/phy/phy_device.c int phy_init_hw(struct phy_device *phydev) · line 1048

Quoted 4 lines
drivers/net/phy/phy_device.c +1 -1
 	ret = phy_scan_fixups(phydev);
-	if (ret < 0)
+	if (ret)
 		return ret;

These changes from < 0 to any value other than zero should be in a separate patch. This is particularly true for a fix, where we want fixes to be as small as possible. Statistics show fixes more often break stuff than normal development, because they get less testing. So we don't really want to make such a change in a fix for stable.

Agree. I'll provide a v2 then for either net or net-next (once it's open again).

Quoted 15 lines

Thanks
Andrew

Quoted 11 lines
drivers/net/phy/phy_device.c +4 -1
-	return phydev->drv->config_init(phydev);
+	if (phydev->drv->config_init)
+		ret = phydev->drv->config_init(phydev);
+
+	return ret;
 }
 EXPORT_SYMBOL(phy_init_hw);
 
Signature · 1 line
2.20.1
maintainer
#3 lore raw
Quoted 10 lines · Heiner Kallweit
Quoted 9 lines · Andrew Lunn
Quoted 7 lines · Heiner Kallweit

Currently we return immediately if callback config_init isn't defined. This prevents the fixups from being executed. I see no dependency between fixups and config_init, therefore change the function to run the fixups also if config_init isn't defined.

Fixes 2f5cb43406d0 ("phylib: Properly reinitialize PHYs after hibernation")
Quoted 8 lines
Quoted 5 lines

Hi Heiner

Is this a real fix? It seems like it has been like this forever. Do you know of a PHY which is actually broken?

Right, the current behavior has been there forever. I'm not aware of any concrete case. I went for "net" because the current code could break a device.

Hi Heiner

https://www.kernel.org/doc/html/v4.15/process/stable-kernel-rules.html

The 4th bullet point:

o It must fix a real bug that bothers people (not a, “This could be a problem...” type thing).

Andrew

author maintainer
#4 lore raw
Quoted 20 lines · Andrew Lunn
Quoted 10 lines · Heiner Kallweit
Quoted 9 lines · Andrew Lunn
Quoted 7 lines · Heiner Kallweit

Currently we return immediately if callback config_init isn't defined. This prevents the fixups from being executed. I see no dependency between fixups and config_init, therefore change the function to run the fixups also if config_init isn't defined.

Fixes 2f5cb43406d0 ("phylib: Properly reinitialize PHYs after hibernation")
Quoted 8 lines
Quoted 5 lines

Hi Heiner

Is this a real fix? It seems like it has been like this forever. Do you know of a PHY which is actually broken?

Right, the current behavior has been there forever. I'm not aware of any concrete case. I went for "net" because the current code could break a device.

Quoted 9 lines

Hi Heiner

https://www.kernel.org/doc/html/v4.15/process/stable-kernel-rules.html

The 4th bullet point:

o It must fix a real bug that bothers people (not a, “This could be a problem...” type thing).

OK, this answers the question. Thanks.

Quoted 2 lines

Andrew

Heiner

maintainer
#5 lore raw
In reply to Heiner Kallweit

From: Heiner Kallweit <[email protected]>
Date: Sun, 23 Dec 2018 15:00:26 +0100

Quoted 7 lines

Currently we return immediately if callback config_init isn't defined. This prevents the fixups from being executed. I see no dependency between fixups and config_init, therefore change the function to run the fixups also if config_init isn't defined.

Fixes 2f5cb43406d0 ("phylib: Properly reinitialize PHYs after hibernation")

As per the discussion, let's defer this to when net-next opens back up.

author maintainer
#6 lore raw
Quoted 8 lines · David Miller

From: Heiner Kallweit <[email protected]>
Date: Sun, 23 Dec 2018 15:00:26 +0100

Quoted 5 lines

Currently we return immediately if callback config_init isn't defined. This prevents the fixups from being executed. I see no dependency between fixups and config_init, therefore change the function to run the fixups also if config_init isn't defined.

Quoted 5 lines
Quoted 2 lines
Fixes 2f5cb43406d0 ("phylib: Properly reinitialize PHYs after hibernation")

As per the discussion, let's defer this to when net-next opens back up.

For my understanding, are you going to pick up deferred patches like this when net-next opens or should I resubmit?

Thanks

maintainer
#7 lore raw

From: Heiner Kallweit <[email protected]>
Date: Tue, 25 Dec 2018 09:30:45 +0100

Quoted 9 lines · David Miller
Quoted 8 lines

From: Heiner Kallweit <[email protected]>
Date: Sun, 23 Dec 2018 15:00:26 +0100

Quoted 5 lines

Currently we return immediately if callback config_init isn't defined. This prevents the fixups from being executed. I see no dependency between fixups and config_init, therefore change the function to run the fixups also if config_init isn't defined.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Fixes 2f5cb43406d0 ("phylib: Properly reinitialize PHYs after hibernation")

As per the discussion, let's defer this to when net-next opens back up.

For my understanding, are you going to pick up deferred patches like this when net-next opens or should I resubmit?

You always need to resubmit, it is the only sane way for me to keep track of things.

Thanks for asking.