USB ethernet adapter (Realtek r8153) keeps disconnecting

Solution 1:

While writing the question I found the source of the bug on the kernel mailing list. The r8152 driver which is responsible for managing my r8153 adapter cannot handle the usb autosuspend (done for power saving reasons). Blacklisting the device for usb autosuspend solves the disconnects and is done like so:

Find out the usb id of your device (0bda:8153 in my case) by using lsusb, which gives me:

Bus 004 Device 003: ID 0bda:8153 Realtek Semiconductor Corp.

Now you open /etc/default/tlp and search for USB_BLACKLIST and add an entry for your device:

USB_BLACKLIST="0bda:8153"

You may need to reboot, after which your ethernet connection should be stable again.

Solution 2:

You can also do this using kernel udev rules. I created udev rules both to turn off usb autosuspend for the device and also turn off Turbo Mode of the CPU (which may help too):

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0bda", ATTR{idProduct}=="8153", TEST=="power/control", ATTR{power/control}="on"
KERNEL=="cpu",RUN+="/bin/sh -c 'echo -n 1 > /sys/devices/system/cpu/intel_pstate/no_turbo'"

Put the above in a file: /etc/udev/rules.d/50-cpu-custom.rules