Friday, October 14, 2011

In Linux, use the Realtek r8168 driver for RTL8168

I have a Gigabyte GA-P35-DS3R motherboard with a RTL8168 Ethernet chip.
When using the r8169 driver that's part of the Linux kernel, I often lose the connection after S3 suspend. Usually, taking the interface down and back up with ifconfig fixes it, but unloading and reloading the module is sometimes necessary. This problem has been around for a while, and it still exists in the current Linux Mint Debian Edition 3.0.0-1-amd64 kernel. Even adding r8168 to SUSPEND_MODULES doesn't help.

The best solution seems to be using the r8168 driver from Realtek instead. It solved the problems after suspend, and seems to have also sped up suspend a bit. It may have also fixed some hangs I used to get occasionally.

At first, version 8.025.00 refused to build because the src/Makefile didn't recognize that Linux 3 should be treated like Linux 2.6. I fixed this by changing the lines setting KEXT and KFLAG to:
KEXT := ko
KFLAG := 2x
After this, I had no further problems and autorun.sh correctly built and installed the driver. It renames r8169.ko to r8169.bak to deactivate that driver. After confirming that r8168 works properly, it's a good idea to blacklist r8169. It's also necessary to update the initial ramdisk, because r8169 may be loaded from there.


2 comments:

Anonymous said...

Thanks. This was a big help. This worked perfectly for me.

Boris Gjenero said...

It's good to see that the post helped someone.

I've just updated the post. I found I had to rebuild the initial ramdisk to prevent r8169 from loading from there.