Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/phy: micrel: Add workaround for bad autoneg

Very rarely, the KSZ9031 will appear to complete autonegotiation, but
will drop all traffic afterwards. When this happens, the idle error
count will read 0xFF after autonegotiation completes. Reset the PHY
when in that state.

Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Nathan Sullivan and committed by
David S. Miller
d2fd719b ec3661b4

+22 -1
+22 -1
drivers/net/phy/micrel.c
··· 514 514 return 0; 515 515 } 516 516 517 + static int ksz9031_read_status(struct phy_device *phydev) 518 + { 519 + int err; 520 + int regval; 521 + 522 + err = genphy_read_status(phydev); 523 + if (err) 524 + return err; 525 + 526 + /* Make sure the PHY is not broken. Read idle error count, 527 + * and reset the PHY if it is maxed out. 528 + */ 529 + regval = phy_read(phydev, MII_STAT1000); 530 + if ((regval & 0xFF) == 0xFF) { 531 + phy_init_hw(phydev); 532 + phydev->link = 0; 533 + } 534 + 535 + return 0; 536 + } 537 + 517 538 static int ksz8873mll_config_aneg(struct phy_device *phydev) 518 539 { 519 540 return 0; ··· 793 772 .driver_data = &ksz9021_type, 794 773 .config_init = ksz9031_config_init, 795 774 .config_aneg = genphy_config_aneg, 796 - .read_status = genphy_read_status, 775 + .read_status = ksz9031_read_status, 797 776 .ack_interrupt = kszphy_ack_interrupt, 798 777 .config_intr = kszphy_config_intr, 799 778 .suspend = genphy_suspend,