linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v3] net: phy: smsc: fix printing too many logs
@ 2020-06-20 14:55 Dejin Zheng
  2020-06-20 15:41 ` Andrew Lunn
  2020-06-22 23:09 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Dejin Zheng @ 2020-06-20 14:55 UTC (permalink / raw)
  To: andrew, f.fainelli, hkallweit1, linux, davem, kuba, netdev
  Cc: linux-kernel, Dejin Zheng, Kevin Groeneveld

Commit 7ae7ad2f11ef47 ("net: phy: smsc: use phy_read_poll_timeout()
to simplify the code") will print a lot of logs as follows when Ethernet
cable is not connected:

[    4.473105] SMSC LAN8710/LAN8720 2188000.ethernet-1:00: lan87xx_read_status failed: -110

When wait 640 ms for check ENERGYON bit, the timeout should not be
regarded as an actual error and an error message also should not be
printed. due to a hardware bug in LAN87XX device, it leads to unstable
detection of plugging in Ethernet cable when LAN87xx is in Energy Detect
Power-Down mode. the workaround for it involves, when the link is down,
and at each read_status() call:

- disable EDPD mode, forcing the PHY out of low-power mode
- waiting 640ms to see if we have any energy detected from the media
- re-enable entry to EDPD mode

This is presumably enough to allow the PHY to notice that a cable is
connected, and resume normal operations to negotiate with the partner.
The problem is that when no media is detected, the 640ms wait times
out and this commit was modified to prints an error message. it is an
inappropriate conversion by used phy_read_poll_timeout() to introduce
this bug. so fix this issue by use read_poll_timeout() to replace
phy_read_poll_timeout().

Fixes: 7ae7ad2f11ef47 ("net: phy: smsc: use phy_read_poll_timeout() to simplify the code")
Reported-by: Kevin Groeneveld <kgroeneveld@gmail.com>
Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
---
v2 -> v3:
	- modify commit message to why need this patch. And many thanks
	  to Andrew and Russell for their comments.
v1 -> v2:
	- add more commit message spell out what the change does.

 drivers/net/phy/smsc.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index 93da7d3d0954..74568ae16125 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -122,10 +122,13 @@ static int lan87xx_read_status(struct phy_device *phydev)
 		if (rc < 0)
 			return rc;
 
-		/* Wait max 640 ms to detect energy */
-		phy_read_poll_timeout(phydev, MII_LAN83C185_CTRL_STATUS, rc,
-				      rc & MII_LAN83C185_ENERGYON, 10000,
-				      640000, true);
+		/* Wait max 640 ms to detect energy and the timeout is not
+		 * an actual error.
+		 */
+		read_poll_timeout(phy_read, rc,
+				  rc & MII_LAN83C185_ENERGYON || rc < 0,
+				  10000, 640000, true, phydev,
+				  MII_LAN83C185_CTRL_STATUS);
 		if (rc < 0)
 			return rc;
 
-- 
2.25.0


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

* Re: [PATCH net v3] net: phy: smsc: fix printing too many logs
  2020-06-20 14:55 [PATCH net v3] net: phy: smsc: fix printing too many logs Dejin Zheng
@ 2020-06-20 15:41 ` Andrew Lunn
  2020-06-22 23:09 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2020-06-20 15:41 UTC (permalink / raw)
  To: Dejin Zheng
  Cc: f.fainelli, hkallweit1, linux, davem, kuba, netdev, linux-kernel,
	Kevin Groeneveld

On Sat, Jun 20, 2020 at 10:55:34PM +0800, Dejin Zheng wrote:
> Commit 7ae7ad2f11ef47 ("net: phy: smsc: use phy_read_poll_timeout()
> to simplify the code") will print a lot of logs as follows when Ethernet
> cable is not connected:
> 
> [    4.473105] SMSC LAN8710/LAN8720 2188000.ethernet-1:00: lan87xx_read_status failed: -110
> 
> When wait 640 ms for check ENERGYON bit, the timeout should not be
> regarded as an actual error and an error message also should not be
> printed. due to a hardware bug in LAN87XX device, it leads to unstable
> detection of plugging in Ethernet cable when LAN87xx is in Energy Detect
> Power-Down mode. the workaround for it involves, when the link is down,
> and at each read_status() call:
> 
> - disable EDPD mode, forcing the PHY out of low-power mode
> - waiting 640ms to see if we have any energy detected from the media
> - re-enable entry to EDPD mode
> 
> This is presumably enough to allow the PHY to notice that a cable is
> connected, and resume normal operations to negotiate with the partner.
> The problem is that when no media is detected, the 640ms wait times
> out and this commit was modified to prints an error message. it is an
> inappropriate conversion by used phy_read_poll_timeout() to introduce
> this bug. so fix this issue by use read_poll_timeout() to replace
> phy_read_poll_timeout().
> 
> Fixes: 7ae7ad2f11ef47 ("net: phy: smsc: use phy_read_poll_timeout() to simplify the code")
> Reported-by: Kevin Groeneveld <kgroeneveld@gmail.com>
> Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net v3] net: phy: smsc: fix printing too many logs
  2020-06-20 14:55 [PATCH net v3] net: phy: smsc: fix printing too many logs Dejin Zheng
  2020-06-20 15:41 ` Andrew Lunn
@ 2020-06-22 23:09 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-06-22 23:09 UTC (permalink / raw)
  To: zhengdejin5
  Cc: andrew, f.fainelli, hkallweit1, linux, kuba, netdev,
	linux-kernel, kgroeneveld

From: Dejin Zheng <zhengdejin5@gmail.com>
Date: Sat, 20 Jun 2020 22:55:34 +0800

> Commit 7ae7ad2f11ef47 ("net: phy: smsc: use phy_read_poll_timeout()
> to simplify the code") will print a lot of logs as follows when Ethernet
> cable is not connected:
> 
> [    4.473105] SMSC LAN8710/LAN8720 2188000.ethernet-1:00: lan87xx_read_status failed: -110
> 
> When wait 640 ms for check ENERGYON bit, the timeout should not be
> regarded as an actual error and an error message also should not be
> printed. due to a hardware bug in LAN87XX device, it leads to unstable
> detection of plugging in Ethernet cable when LAN87xx is in Energy Detect
> Power-Down mode. the workaround for it involves, when the link is down,
> and at each read_status() call:
> 
> - disable EDPD mode, forcing the PHY out of low-power mode
> - waiting 640ms to see if we have any energy detected from the media
> - re-enable entry to EDPD mode
> 
> This is presumably enough to allow the PHY to notice that a cable is
> connected, and resume normal operations to negotiate with the partner.
> The problem is that when no media is detected, the 640ms wait times
> out and this commit was modified to prints an error message. it is an
> inappropriate conversion by used phy_read_poll_timeout() to introduce
> this bug. so fix this issue by use read_poll_timeout() to replace
> phy_read_poll_timeout().
> 
> Fixes: 7ae7ad2f11ef47 ("net: phy: smsc: use phy_read_poll_timeout() to simplify the code")
> Reported-by: Kevin Groeneveld <kgroeneveld@gmail.com>
> Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>

Applied and queued up for -stable, thanks.

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

end of thread, other threads:[~2020-06-22 23:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-20 14:55 [PATCH net v3] net: phy: smsc: fix printing too many logs Dejin Zheng
2020-06-20 15:41 ` Andrew Lunn
2020-06-22 23:09 ` David Miller

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