Make Linux load specific driver for given device (Realtek NIC)

You can force a device to use a certain device using bind. If the device is already owned by a different driver, you first have to unbind it.

If a PCI vendor ID (10ec for Realtek) and device ID combination is not recognized, you can make it get recognized at runtime with:

# echo 10ec 8169 > /sys/bus/pci/drivers/r8169/new_id

Example:

# lspci -s 04: -nnvvv
04:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL-8129 [10ec:8129] (rev 10)
        Subsystem: Coreco Inc RTL8111/8168 PCIe Gigabit Ethernet (misconfigured) [11ec:8129]
        Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Interrupt: pin A routed to IRQ 3
        Region 0: I/O ports at c000 [size=256]
        Region 1: Memory at f7b40000 (32-bit, non-prefetchable) [size=256]
        [virtual] Expansion ROM at f7b00000 [disabled] [size=256K]
        Capabilities: [dc] Power Management version 1
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0-,D1-,D2-,D3hot-,D3cold+)
                Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
        Kernel driver in use: pci-stub

# echo 0000:04:00.0 > /sys/bus/pci/drivers/pci-stub/unbind
# echo 0000:04:00.0 > /sys/bus/pci/drivers/r8169/bind
# lspci -s 04: -nnvvv
04:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL-8129 [10ec:8129] (rev 10)
        Subsystem: Coreco Inc RTL8111/8168 PCIe Gigabit Ethernet (misconfigured) [11ec:8129]
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV+ VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 32 (8000ns min, 8000ns max), Cache Line Size: 64 bytes
        Interrupt: pin A routed to IRQ 19
        Region 0: I/O ports at c000 [size=256]
        Region 1: Memory at f7b40000 (32-bit, non-prefetchable) [size=256]
        [virtual] Expansion ROM at f7b00000 [disabled] [size=256K]
        Capabilities: [dc] Power Management version 1
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0-,D1-,D2-,D3hot-,D3cold+)
                Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
        Kernel driver in use: r8169