linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround
@ 2017-12-21  0:45 Grygorii Strashko
  2017-12-21  9:21 ` Andrew Lunn
  2017-12-26 17:27 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Grygorii Strashko @ 2017-12-21  0:45 UTC (permalink / raw)
  To: Florian Fainelli, Andrew Lunn, netdev
  Cc: linux-kernel, Sekhar Nori, Grygorii Strashko

Under some circumstances driver will perform PHY reset in
ksz9031_read_status() to fix autoneg failure case (idle error count =
0xFF). When this happens ksz9031 will not detect link status change any
more when connecting to Netgear 1G switch (link can be recovered sometimes by
restarting netdevice "ifconfig down up"). Reproduced with TI am572x board
equipped with ksz9031 PHY while connecting to Netgear 1G switch.

Fix the issue by reconfiguring autonegotiation after PHY reset in
ksz9031_read_status().

Fixes: d2fd719bcb0e ("net/phy: micrel: Add workaround for bad autoneg")
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/phy/micrel.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index ab46141..422ff63 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -624,6 +624,7 @@ static int ksz9031_read_status(struct phy_device *phydev)
 		phydev->link = 0;
 		if (phydev->drv->config_intr && phy_interrupt_is_valid(phydev))
 			phydev->drv->config_intr(phydev);
+		return genphy_config_aneg(phydev);
 	}
 
 	return 0;
-- 
2.10.5

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

* Re: [PATCH] net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround
  2017-12-21  0:45 [PATCH] net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround Grygorii Strashko
@ 2017-12-21  9:21 ` Andrew Lunn
  2017-12-21 20:18   ` Grygorii Strashko
  2017-12-26 17:27 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2017-12-21  9:21 UTC (permalink / raw)
  To: Grygorii Strashko; +Cc: Florian Fainelli, netdev, linux-kernel, Sekhar Nori

On Wed, Dec 20, 2017 at 06:45:10PM -0600, Grygorii Strashko wrote:
> Under some circumstances driver will perform PHY reset in
> ksz9031_read_status() to fix autoneg failure case (idle error count =
> 0xFF). When this happens ksz9031 will not detect link status change any
> more when connecting to Netgear 1G switch (link can be recovered sometimes by
> restarting netdevice "ifconfig down up"). Reproduced with TI am572x board
> equipped with ksz9031 PHY while connecting to Netgear 1G switch.
> 
> Fix the issue by reconfiguring autonegotiation after PHY reset in
> ksz9031_read_status().

Hi Grygorii

I can understand the fix.

But i'm wondering if there is a better way to do this. Can you call
phy_stop() and phy_start(). You then get the core phy code doing the
same initialisation as what happened the first time. However, i know
this is not easy. _read_status() is being called from the middle of
the state machine, and trying to change the state of the state machine
at this point is problematic.

   Andrew

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

* Re: [PATCH] net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround
  2017-12-21  9:21 ` Andrew Lunn
@ 2017-12-21 20:18   ` Grygorii Strashko
  0 siblings, 0 replies; 4+ messages in thread
From: Grygorii Strashko @ 2017-12-21 20:18 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Florian Fainelli, netdev, linux-kernel, Sekhar Nori



On 12/21/2017 03:21 AM, Andrew Lunn wrote:
> On Wed, Dec 20, 2017 at 06:45:10PM -0600, Grygorii Strashko wrote:
>> Under some circumstances driver will perform PHY reset in
>> ksz9031_read_status() to fix autoneg failure case (idle error count =
>> 0xFF). When this happens ksz9031 will not detect link status change any
>> more when connecting to Netgear 1G switch (link can be recovered sometimes by
>> restarting netdevice "ifconfig down up"). Reproduced with TI am572x board
>> equipped with ksz9031 PHY while connecting to Netgear 1G switch.
>>
>> Fix the issue by reconfiguring autonegotiation after PHY reset in
>> ksz9031_read_status().
> 
> Hi Grygorii
> 
> I can understand the fix.
> 
> But i'm wondering if there is a better way to do this. Can you call
> phy_stop() and phy_start(). You then get the core phy code doing the
> same initialisation as what happened the first time. However, i know
> this is not easy. _read_status() is being called from the middle of
> the state machine, and trying to change the state of the state machine
> at this point is problematic.

It will not work. 
phy_state_machine()->mutex_lock(&phydev->lock);->phy_read_status()->phy_stop()->mutex_lock(&phydev->lock);
at least as is.

This is error recovery, which is, per my understanding, signalizing about hw or
configuration issue. What i'm thinking about is - may be it'll be reasonable
to add err message here:
         if ((regval & 0xFF) == 0xFF) {
+               dev_err_once(&phydev->mdio.dev,
+                            "PHY reset due idle error count maxed out");


-- 
regards,
-grygorii

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

* Re: [PATCH] net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround
  2017-12-21  0:45 [PATCH] net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround Grygorii Strashko
  2017-12-21  9:21 ` Andrew Lunn
@ 2017-12-26 17:27 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-12-26 17:27 UTC (permalink / raw)
  To: grygorii.strashko; +Cc: f.fainelli, andrew, netdev, linux-kernel, nsekhar

From: Grygorii Strashko <grygorii.strashko@ti.com>
Date: Wed, 20 Dec 2017 18:45:10 -0600

> Under some circumstances driver will perform PHY reset in
> ksz9031_read_status() to fix autoneg failure case (idle error count =
> 0xFF). When this happens ksz9031 will not detect link status change any
> more when connecting to Netgear 1G switch (link can be recovered sometimes by
> restarting netdevice "ifconfig down up"). Reproduced with TI am572x board
> equipped with ksz9031 PHY while connecting to Netgear 1G switch.
> 
> Fix the issue by reconfiguring autonegotiation after PHY reset in
> ksz9031_read_status().
> 
> Fixes: d2fd719bcb0e ("net/phy: micrel: Add workaround for bad autoneg")
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

Applied and queued up for -stable.

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

end of thread, other threads:[~2017-12-26 17:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-21  0:45 [PATCH] net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround Grygorii Strashko
2017-12-21  9:21 ` Andrew Lunn
2017-12-21 20:18   ` Grygorii Strashko
2017-12-26 17:27 ` 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).