如何在 Linux 中找到 USB 控制器的 pci 插槽?

pet*_*erh 12 linux pci usb proc sysfs

我这里有一台几乎通用的 Linux 机器。所以,它有一个 PCI(*-X 等)总线,在一些 USB 控制器上,我在这些 USB 控制器上有 USB 设备。与此类似:

$ lspci|grep USB
00:12.0 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB OHCI0 Controller
00:12.2 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB EHCI Controller
00:13.0 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB OHCI0 Controller
00:13.2 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB EHCI Controller
00:14.5 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB OHCI2 Controller
00:16.0 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB OHCI0 Controller
00:16.2 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB EHCI Controller
02:00.0 USB controller: VIA Technologies, Inc. VL805 USB 3.0 Host Controller (rev 01)
Run Code Online (Sandbox Code Playgroud)

而且,还有一个 USB 设备树,如下所示:

$ lsusb -t
/:  Bus 07.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/4p, 12M
/:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/2p, 12M
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/5p, 12M
    |__ Port 5: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/5p, 12M
    |__ Port 2: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 2: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 3: Dev 12, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 4: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 4: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/4p, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/5p, 480M
    |__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 4, If 0, Class=Wireless, Driver=btusb, 12M
        |__ Port 1: Dev 4, If 1, Class=Wireless, Driver=btusb, 12M
        |__ Port 4: Dev 11, If 0, Class=Vendor Specific Class, Driver=r8712u, 480M
    |__ Port 3: Dev 3, If 0, Class=Vendor Specific Class, Driver=MOSCHIP usb-ethernet driver, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/5p, 480M
    |__ Port 1: Dev 6, If 0, Class=Video, Driver=uvcvideo, 480M
    |__ Port 1: Dev 6, If 1, Class=Video, Driver=uvcvideo, 480M
    |__ Port 1: Dev 6, If 2, Class=Audio, Driver=snd-usb-audio, 480M
    |__ Port 1: Dev 6, If 3, Class=Audio, Driver=snd-usb-audio, 480M
Run Code Online (Sandbox Code Playgroud)

所以,我在 PCI 总线上看到了我的 USB 控制器,也在 USB 控制器上看到了我的 USB 设备。

但是我不知道,哪个USB控制器号(在USB总线上)属于哪个PCI总线号!

怎么找呢?

jim*_*mij 11

这些信息可以从被检索iSerial的详细输出的入口lsusb。最简单的方法是将输出传递给less查看器并使用 手动搜索/,或者例如使用grep

$ lsusb -v 2>/dev/null | grep '^Bus\|iSerial'

Bus 001 Device 029: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard
  iSerial                 0 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  iSerial                 1 0000:00:1d.7
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
  iSerial                 1 0000:00:1d.3
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
  iSerial                 1 0000:00:1d.2
...
Run Code Online (Sandbox Code Playgroud)

  • 如何解释“iSerial 0”或“iSerial 3 NA7DE4PN”的值?(这些似乎不是 PCI 插槽标识符) (3认同)

小智 5

(自版本 起lsusb.py)有一个工具可以立即显示此信息:usbutils002

strohel@mat480s ~ $ lsusb.py -ciu
usb1              1d6b:0002 09 1IF  [USB 2.00,   480 Mbps,   0mA] (xhci-hcd 0000:00:14.0) hub
  1-2               046d:c069 00 1IF  [USB 2.00,   1.5 Mbps,  98mA] (Logitech USB Laser Mouse)
Run Code Online (Sandbox Code Playgroud)

0000:00:14.0是控制器的 PCI 总线 ID:

strohel@mat480s ~ $ lspci | grep 00:14.0
00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller (rev 21)
Run Code Online (Sandbox Code Playgroud)