Ethernet not working/Realtek RTL8169 fails to load

Bug #1876593 reported by Robert Clipsham
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
linux-signed (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

With the latest kernels on Ubuntu 20.04 LTS, my onboard Ethernet has stopped working.

Last known good kernel: Ubuntu 5.4.0-21.25-generic 5.4.27
Current (bad) kernel: Ubuntu 5.4.0-28.32-generic 5.4.30

Ethernet controller:

03:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 03)

Select lines from dmesg with bad kernel:

[ 1.479172] r8169 0000:03:00.0: realtek.ko not loaded, maybe it needs to be added to initramfs?
[ 1.498143] r8169: probe of 0000:03:00.0 failed with error -49

With good kernel:

[ 1.472510] r8169 0000:03:00.0 eth0: RTL8168d/8111d, 6c:f0:49:e7:de:a3, XID 283, IRQ 35
[ 1.472511] r8169 0000:03:00.0 eth0: jumbo features [frames: 9200 bytes, tx checksumming: ko]
[ 8.430734] r8169 0000:03:00.0 eth0: Link is Down
[ 9.241421] r8169 0000:03:00.0 eth0: Link is Up - 100Mbps/Full - flow control off

Revision history for this message
Robert Clipsham (mrmonday) wrote :

Attached log files for:

1. uname -a
2. dmesg
3. cat /proc/version_signature
4. lspci -vnvn

For both good and bad kernels

Revision history for this message
Robert Clipsham (mrmonday) wrote :

Clicked through from packages.ubuntu.com, seems like linux-signed is the right package, not linux-meta

affects: linux-meta (Ubuntu) → linux-signed (Ubuntu)
Revision history for this message
Heiner Kallweit (kalle1) wrote :

Also before the generic PHY driver was loaded as fallback, the actual PHY driver would be RTL8211B.
Did you check what the error message says? Do you have r8169.ko and/or realtek.ko in your initramfs?
And to be sure: In the good case, please report the PHY ID (search for phy_id under /sys).

Revision history for this message
Robert Clipsham (mrmonday) wrote :

Phy ID from good kernel:

$ cat /sys/devices/pci0000:00/0000:00:0a.0/0000:03:00.0/mdio_bus/r8169-300/r8169-300:00/phy_id
0xc2077002

Both r8169.ko and realtek.ko exist in /lib/modules for both the good and bad kernels - I'm not sure if that's what you wanted to know?

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

Thanks, this phy_id value is not a valid Realtek PHY ID. You seem to be affected by a known BIOS bug (few Gigabyte boards from 2009/2010 seem to be affected).
See here: https://bugzilla.kernel.org/show_bug.cgi?id=202275#c7
Please try to enable "LAN Boot ROM" option in BIOS.

Revision history for this message
Robert Clipsham (mrmonday) wrote :

Had to search through the all the menu options twice to find it. Enabling the LAN Boot ROM had no (noticeable) effect.

The only difference I can see from a quick scan through is in the dmesg output of the good kernel giving IRQ 36 instead of IRQ 35.

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

Seems your BIOS was never updated, see https://www.gigabyte.com/Motherboard/GA-890GPA-UD3H-rev-20/support#support-dl-bios. Versions FD and FE include some LAN fixes. Best update to latest version FF and re-test.

Revision history for this message
Robert Clipsham (mrmonday) wrote :

I've flashed the FF bios (interestingly, my CPU was actually unsupported on the BIOS I was running).

Same problem, both with and without the LAN Boot ROM option set. The phy_id remains the same.

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

Revision history for this message
Robert Clipsham (mrmonday) wrote :

Frustratingly, this seems to have now resolved itself, so I can't test the patch. All I did was leave the machine off for a few hours and turn it back on - then it was working again.

I now can't reproduce the problem, with or without the Lan Boot ROM option. The PHY ID now reports as 0x001cc912.

I'll come back to it later and see if it breaks again.

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

Interesting. Did you switch off the machine after flashing the updated BIOS (and before re-testing) or did you just reboot? In the latter case this may be an explanation. Often a BIOS initializes certain things on cold boot only.

Revision history for this message
Robert Clipsham (mrmonday) wrote :

Fairly sure it was just a reboot.

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

Changed status to invalid, because issue was caused by a BIOS bug.

Changed in linux-signed (Ubuntu):
status: New → Invalid
Revision history for this message
Peter Passchier (peter-passchier) wrote :

Just to add: it might be that the r8168-dmks driver works better for your hardware than the kernel's generic r8169, it did in my case.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.