R8152-dkms overlay?

Hello,

T480 with a plugable 2.5Gpbs USB Ethernet adapter, and I keep getting:

$ journalctl -k -f | grep -iE "eth|enp|disconnect"
Jul 27 12:07:57 thinkpad kernel: r8152-cfgselector 2-2: USB disconnect, device number 17
Jul 27 12:07:57 thinkpad kernel: r8152 2-2:1.0 eth0: v1.12.13
Jul 27 12:07:57 thinkpad kernel: r8152 2-2:1.0 enp0s20f0u2: renamed from eth0
Jul 27 12:08:01 thinkpad kernel: r8152 2-2:1.0 enp0s20f0u2: carrier on

I have added kernelParam "usbcore.autosuspend=-1”

I have disabled autosuspend and blacklisted the particular USB from tlp:

USB_AUTOSUSPEND = 0;
USB_BLACKLIST = “0bda:8156”;

I have added a udev rule:

ACTION==“add”, SUBSYSTEM==“usb”, DRIVER==“r8152”, ATTR{power/autosuspend}=“-1”, ATTR{power/control}=“on”

I have disabled EEE using systemd:

systemd.services = {
  disable-eee = {
    description = "Disable Energy Efficient Ethernet on r8152";
    after = [ "network.target" ];
    wantedBy = [ "multi-user.target" ];
    serviceConfig = {
      Type = "oneshot";
      ExecStart = "${pkgs.ethtool}/bin/ethtool --set-eee enp0s20f0u2 eee off";
    };        
  };
};

…and yet (after rebuild and reboot) the problem persists.

The interwebs say another solution is to overlay the r8152 package with the r8152-dkms package (e.g., on Ubuntu).

But there is no r8152-dkms package that I can find for NixOS (stable or unstable).

Could someone point me in the right direction how to add this overlay (or provide another solution)?

TIA

It looks like someone was doing some work on this but it died (?)

r8152 is handled by the r8169 driver in any recent kernel (including the one in 26.05), so any DKMS package is, I believe, a false route.

FWIW I haven’t add that issue on my Gigabyte X870 Eagle motherboard which comes with an r8125 NIC over PCIe, though it takes a few secs for the NIC to come back online on resume.

Hm, lsusb reports the r8152 driver:
Port 002: Dev 006, If 0, Class=Vendor Specific Class, Driver=r8152, 5000M

It’s a plugable, RTL 8156B chipset

I’d implemented boot.kernelPackages = pkgs.linuxPackages_6_18; to overcome the recent copy.fail thing (IIRC) - could that be interfering with the use of r8169? …or maybe r8169 doesn’t work with RTL 8156B. idk.

(I’m running NixOS 26.05 (Yarara) x86_64.)

For others who may run into this problem - I think I’ve fixed it. Here’s what I did:

boot.kernelParams = [ "usbcore.autosuspend=-1" ];

run lsusb to get your device mfr:model:

Bus 002 Device 006: ID >>> 0bda:8156 <<< Realtek Semiconductor Corp. USB 10/100/1G/2.5G LAN

services.udev.extraRules = ‘’
ACTION==“add”, SUBSYSTEM==“usb”, ATTR{idVendor}==“0bda”, ATTR{idProduct}==“8156”, ATTR{power/autosuspend}=“-1”
‘’;

(replace “0bda” with your mfr, “8156” with your module number)

services.tlp.settings = {
USB_AUTOSUSPEND = 0;
USB_BLACKLIST = "0bda:8156"; # replace with yours
RUNTIME_PM_ON_AC = "on";
RUNTIME_PM_ON_BAT = "on";
PCIE_ASPM_ON_AC = "performance";
};

hardware.enableRedistributableFirmware = true;

The USB connection had been toggling off/on, renumbering the USB, and freezing up my ssh sessions every couple of minutes. With the above fixes, no connection losses for at least 45 minutes.

Please chime in if I’m missing anything.

1 Like

…it happened again. Only once in about 6 hours, but…maybe there’s still a better solution.

evidently my issue is a unique to the t480 + RTL8156B.

also trying:

  • upgraded kernelPackage to linux_latest;
  • added kernelParam: “usbcore.quirks=0bda:8156:k” and “pcie_aspm=off”
  • this was not actually an autosuspend issue at all

…now we watch and wait…

…21 hours and not a single drop. Something in that last change did it. Hope this helps someone else out there.