首先,通过 lspci 命令确定设备的 Domain、Bus、Device、Function 信息:
bryan@bryan-pc:~$ sudo lspci -D
0000:00:00.0 Host bridge: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers (rev 08)
0000:00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16) (rev 08)
0000:00:02.0 VGA compatible controller: Intel Corporation 8th Gen Core Processor Gaussian Mixture Model
0000:00:14.0 USB controller: Intel Corporation 200 Series/Z370 Chipset Family USB 3.0 xHCI Controller
0000:00:14.2 Signal processing controller: Intel Corporation 200 Series PCH Thermal Subsystem
0000:00:15.0 Signal processing controller: Intel Corporation 200 Series PCH Serial IO I2C Controller #0
0000:00:15.1 Signal processing controller: Intel Corporation 200 Series PCH Serial IO I2C Controller #1
0000:00:16.0 Communication controller: Intel Corporation 200 Series PCH CSME HECI #1
0000:00:17.0 SATA controller: Intel Corporation 200 Series PCH SATA controller [AHCI mode]
0000:00:1c.0 PCI bridge: Intel Corporation 200 Series PCH PCI Express Root Port #7 (rev f0)
0000:00:1d.0 PCI bridge: Intel Corporation 200 Series PCH PCI Express Root Port #9 (rev f0)
0000:00:1e.0 Signal processing controller: Intel Corporation 200 Series/Z370 Chipset Family Serial IO UART Controller #0
0000:00:1f.0 ISA bridge: Intel Corporation Device a2cc
0000:00:1f.2 Memory controller: Intel Corporation 200 Series/Z370 Chipset Family Power Management Controller
0000:00:1f.3 Audio device: Intel Corporation 200 Series PCH HD Audio
0000:00:1f.4 SMBus: Intel Corporation 200 Series/Z370 Chipset Family SMBus Controller
0000:01:00.0 PCI bridge: PLX Technology, Inc. Device 8749 (rev ca)
0000:01:00.1 System peripheral: PLX Technology, Inc. Device 87d0 (rev ca)
0000:01:00.2 System peripheral: PLX Technology, Inc. Device 87d0 (rev ca)
0000:01:00.3 System peripheral: PLX Technology, Inc. Device 87d0 (rev ca)
0000:01:00.4 System peripheral: PLX Technology, Inc. Device 87d0 (rev ca)
0000:02:08.0 PCI bridge: PLX Technology, Inc. Device 8749 (rev ca)
0000:02:09.0 PCI bridge: PLX Technology, Inc. Device 8749 (rev ca)
0000:02:10.0 PCI bridge: PLX Technology, Inc. Device 8749 (rev ca)
0000:03:00.0 Memory controller: Xilinx Corporation Device 8038 (rev ff)
0000:06:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)
0000:07:00.0 Network controller: Intel Corporation Dual Band Wireless-AC 3165 Plus Bluetooth (rev 99)
bryan@bryan-pc:~$
假设我们要卸载设备 0000:03:00.0,可以执行命令:
bryan@bryan-pc:~$ echo 1 > /sys/bus/pci/devices/0000\:03\:00.0/remove
如果需要重新对 PCI/PCIe 总线进行枚举,可执行命令:
bryan@bryan-pc:~$ echo 1 > /sys/bus/pci/rescan