Comment 9 for bug 1876593

Revision history for this message
Heiner Kallweit (kalle1) wrote :

Typically it helps to do a rmmod r8169 + modprobe r8169 to work around the BIOS bug.
Maybe also a PHY soft reset helps to make the PHY behave sanely again.
Can you test whether the following fixes the issue for you?

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 8b665f2ec..9b1ad5d45 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -5104,6 +5104,17 @@ static int r8169_mdio_write_reg(struct mii_bus *mii_bus, int phyaddr,
  return 0;
 }

+static void rtl_phy_soft_reset(struct rtl8169_private *tp)
+{
+ int i = 30;
+
+ rtl_writephy(tp, MII_BMCR, BMCR_ANENABLE | BMCR_RESET);
+
+ do {
+ msleep(20);
+ } while (rtl_readphy(tp, MII_BMCR) & BMCR_RESET && --i);
+}
+
 static int r8169_mdio_register(struct rtl8169_private *tp)
 {
  struct pci_dev *pdev = tp->pci_dev;
@@ -5123,6 +5134,11 @@ static int r8169_mdio_register(struct rtl8169_private *tp)
  new_bus->read = r8169_mdio_read_reg;
  new_bus->write = r8169_mdio_write_reg;

+ /* A BIOS bug causes few boards to report an invalid PHY ID otherwise */
+ if (tp->mac_version == RTL_GIGA_MAC_VER_25 ||
+ tp->mac_version == RTL_GIGA_MAC_VER_26)
+ rtl_phy_soft_reset(tp);
+
  ret = devm_mdiobus_register(new_bus);
  if (ret)
   return ret;
--
2.26.2