Drivers
使 Linux 為給定設備載入特定驅動程序(Realtek NIC)
這是執行 Linux 3.11(Mint 發行版,但我認為這不重要)的老式機器(AMD K8,Nvidia 晶片組)上的驅動程序問題。
claudius ~ # uname -a Linux claudius 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux claudius ~ # lspci 00:00.0 Host bridge: NVIDIA Corporation nForce3 250Gb Host Bridge (rev a1) 00:01.0 ISA bridge: NVIDIA Corporation nForce3 250Gb LPC Bridge (rev a2) 00:01.1 SMBus: NVIDIA Corporation nForce 250Gb PCI System Management (rev a1) 00:02.0 USB controller: NVIDIA Corporation CK8S USB Controller (rev a1) 00:02.1 USB controller: NVIDIA Corporation CK8S USB Controller (rev a1) 00:02.2 USB controller: NVIDIA Corporation nForce3 EHCI USB 2.0 Controller (rev a2) 00:05.0 Bridge: NVIDIA Corporation CK8S Ethernet Controller (rev a2) 00:08.0 IDE interface: NVIDIA Corporation CK8S Parallel ATA Controller (v2.5) (rev a2) 00:0a.0 IDE interface: NVIDIA Corporation nForce3 Serial ATA Controller (rev a2) 00:0b.0 PCI bridge: NVIDIA Corporation nForce3 250Gb AGP Host to PCI Bridge (rev a2) 00:0e.0 PCI bridge: NVIDIA Corporation nForce3 250Gb PCI-to-PCI Bridge (rev a2) 00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration 00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] K8 [Athlon64/Opteron] Address Map 00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] K8 [Athlon64/Opteron] DRAM Controller 00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] K8 [Athlon64/Opteron] Miscellaneous Control 01:00.0 VGA compatible controller: NVIDIA Corporation NV34 [GeForce FX 5200] (rev a1) 02:05.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8169 PCI Gigabit Ethernet Controller (rev 10)
我希望核心為我的 Realtek 8169 PCI 乙太網卡載入一個替代驅動程序,您可以在列表末尾看到它作為
02:05.0
. 這是詳細資訊:claudius ~ # lspci -s 02:05.0 -vv -nn 02:05.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8169 PCI Gigabit Ethernet Controller [10ec:8169] (rev 10) Subsystem: Realtek Semiconductor Co., Ltd. RTL8169/8110 Family PCI Gigabit Ethernet NIC [10ec:8169] 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 19 Region 0: I/O ports at e800 [size=256] Region 1: Memory at febffc00 (32-bit, non-prefetchable) [size=256] Expansion ROM at febc0000 [disabled] [size=128K] Capabilities: [dc] Power Management version 2 Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0-,D1+,D2+,D3hot+,D3cold+) Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
問題是
r8169
根本行不通。它甚至可能使 Linux 崩潰。我把它列入黑名單/etc/modprobe.d/
。解決方案似乎是使用
r8168
驅動程序。(這個網站上也有一個相關的問題。)你可以從 Realtek 下載原始碼,編譯並安裝它,我也是這樣做的。如果你modprobe r8168
,它載入正常但不與硬體相關聯,所以卡不會出現在ifconfig
.我認為這與
modalias
(編碼硬體資訊)和設備/驅動程序映射有關/lib/modules/*/modules.alias
。claudius ~ # cat /sys/devices/pci0000\:00/0000\:00\:0e.0/0000\:02\:05.0/modalias pci:v000010ECd00008169sv000010ECsd00008169bc02sc00i00
這是我的名片。這是系統中的 Realtek 驅動程序映射:
claudius ~ # grep r816 /lib/modules/3.11.0-12-generic/modules.alias alias pci:v00001186d00004300sv00001186sd00004C00bc*sc*i* r8169 alias pci:v000010ECd00008169sv*sd*bc*sc*i* r8169 alias pci:v000010ECd00008167sv*sd*bc*sc*i* r8169 alias pci:v00001186d00004300sv00001186sd00004B10bc*sc*i* r8168 alias pci:v000010ECd00008168sv*sd*bc*sc*i* r8168
我嘗試將此行添加到文件的末尾(知道您不應該進行手動編輯):
alias pci:v000010ECd00008169sv000010ECsd00008169bc02sc00i00 r8168
然後解除安裝並重新載入
r8168
,但這並沒有配置卡,並且dmesg
.將我的 NIC 映射到
r8168
驅動程序的正確方法是什麼?我是否必須重建驅動程序才能聲稱它可以處理我的卡?還是我必須在適當的位置添加一些配置數據?
您可以使用綁定強制設備使用特定設備。如果該設備已由不同的驅動程序擁有,您首先必須取消綁定它。
如果無法辨識 PCI 供應商 ID(
10ec
用於 Realtek)和設備 ID 組合,您可以在執行時使其得到辨識:# echo 10ec 8169 > /sys/bus/pci/drivers/r8169/new_id
例子:
# 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