gregkh / usbutils

USB utilities for Linux, including lsusb
http://www.linux-usb.org
356 stars 202 forks source link

lsusb: Fixed info read from sysfs when device is on a hub. #103

Closed dfandrich closed 3 years ago

dfandrich commented 4 years ago

The wrong sysfs entry was read in such cases, displaying incorrect information.

Note that this patch will only work for devices connected to a single hub. It will still display the wrong information for devices connected in a chain of two or more hubs.

This PR is mostly to show that there is a problem. This naive solution can definitely be improved, but I'm not sure what the future-proof solution is. I'm a bit surprised there isn't already an API to generate the correct file name already.

gregkh commented 4 years ago

I'm sorry, I don't understand the problem here.

Can you provide specifics as to what is currently wrong?

dfandrich commented 4 years ago

When I run "lsusb" it displays the wrong product name for a number of my devices. For example, here are two lines of the output:

Bus 001 Device 009: ID 03f0:0b4a HP, Inc Live! Cam Sync HD VF0770 Bus 001 Device 004: ID 041e:4095 Creative Technology, Ltd Live! Cam Sync HD [VF0770]

The first device isn't a camera at all but rather a mouse (the second one is correct). The problem is that the wrong /sys file is being read to get the product description. Instead of /sys/bus/usb/devices/1-4.3/product (which contains "USB Optical Mouse") it's reading /sys/bus/usb/devices/1-3/product (which contains "Live! Cam Sync HD VF0770").

gregkh commented 4 years ago

On Mon, Feb 03, 2020 at 02:36:27PM -0800, Dan Fandrich wrote:

When I run "lsusb" it displays the wrong product name for a number of my devices. For example, here are two lines of the output:

Bus 001 Device 009: ID 03f0:0b4a HP, Inc Live! Cam Sync HD VF0770 Bus 001 Device 004: ID 041e:4095 Creative Technology, Ltd Live! Cam Sync HD [VF0770]

The first device isn't a camera at all but rather a mouse (the second one is correct). The problem is that the wrong /sys file is being read to get the product description. Instead of /sys/bus/usb/devices/1-4.3/product (which contains "USB Optical Mouse") it's reading /sys/bus/usb/devices/1-3/product (which contains "Live! Cam Sync HD VF0770").

That's odd, has this always happened?

What kernel version are you using?

Can you provide the output of 'lsusb -v' for these devices as well?

dfandrich commented 4 years ago

The "lsusb -t" view of these two devices is:

/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/9p, 480M
    |__ Port 3: Dev 4, If 2, Class=Audio, Driver=snd-usb-audio, 480M
    |__ Port 3: Dev 4, If 0, Class=Video, Driver=uvcvideo, 480M
    |__ Port 3: Dev 4, If 3, Class=Audio, Driver=snd-usb-audio, 480M
    |__ Port 3: Dev 4, If 1, Class=Video, Driver=uvcvideo, 480M
    |__ Port 4: Dev 5, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 3: Dev 9, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
dfandrich commented 4 years ago

I don't think I noticed this problem ~years ago, but I'm not sure when it started. I think it was already happening before this machine was upgraded, so likely with usbutils-008 and kernel 4.14.145.

Kernel is: Linux colibri 5.4.10-server-1.mga7 #1 SMP Fri Jan 10 00:29:09 UTC 2020 i686 i686 i386 GNU/Linux

lsusb -v for these devices is:

Bus 001 Device 009: ID 03f0:0b4a HP, Inc Live! Cam Sync HD VF0770
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x03f0 HP, Inc
  idProduct          0x0b4a 
  bcdDevice           72.00
  iManufacturer           1 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0022
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      46
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              10

Bus 001 Device 004: ID 041e:4095 Creative Technology, Ltd Live! Cam Sync HD [VF0770]
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x041e Creative Technology, Ltd
  idProduct          0x4095 Live! Cam Sync HD [VF0770]
  bcdDevice           20.20
  iManufacturer           3 
  iProduct                1 
  iSerial                 2 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x04f0
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          4 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass         14 Video
      bFunctionSubClass       3 Video Interface Collection
      bFunctionProtocol       0 
      iFunction               5 
    Interface Descriptor:

[lots more interface descriptor info elided]
dfandrich commented 4 years ago

Removing the hardware database file /lib/udev/hwdb.bin (or wherever it is for you) forces lsusb to go to /sys for the product info and makes this problem easy to see if you have a few devices hooked up to a hub and a few connected directly.

gregkh commented 4 years ago

I can't seem to duplicate this here.

As "proof", here's the output of what is plugged into my box right now:

$ lsusb
Bus 009 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 010 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 008 Device 003: ID 2188:0747 CalDigit Card Reader
Bus 008 Device 005: ID 2109:0812 VIA Labs, Inc. VL812 Hub
Bus 008 Device 004: ID 2109:0812 VIA Labs, Inc. VL812 Hub
Bus 008 Device 002: ID 2109:0812 VIA Labs, Inc. VL812 Hub
Bus 008 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 007 Device 007: ID 1050:0200 Yubico.com Gnubby U2F
Bus 007 Device 006: ID 2109:2812 VIA Labs, Inc. VL812 Hub
Bus 007 Device 009: ID 046d:082d Logitech, Inc. HD Pro Webcam C920
Bus 007 Device 008: ID 0b0e:0422 GN Netcom
Bus 007 Device 005: ID 2109:2812 VIA Labs, Inc. VL812 Hub
Bus 007 Device 004: ID 04d9:1818 Holtek Semiconductor, Inc. Keyboard [Diatec Filco Majestouch 2]
Bus 007 Device 003: ID 045e:0023 Microsoft Corp. Trackball Optical
Bus 007 Device 002: ID 2109:2812 VIA Labs, Inc. VL812 Hub
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 002: ID 0781:558c SanDisk Corp. Extreme SSD
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 002: ID 2188:6533 CalDigit, Inc. CalDigit Thunderbolt 3 Audio
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 0489:e0a2 Foxconn / Hon Hai
Bus 001 Device 002: ID 0c45:6723 Microdia Integrated_Webcam_HD
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

And the 'usb-devices' output is:

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh=12
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev=05.05
S:  Manufacturer=Linux 5.5.0 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:00:14.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=01 Lev=01 Prnt=01 Port=04 Cnt=01 Dev#=  2 Spd=480 MxCh= 0
D:  Ver= 2.01 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0c45 ProdID=6723 Rev=80.08
S:  Manufacturer=CN09357GLOG008C6ADCJA01
S:  Product=Integrated_Webcam_HD
C:  #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=0e(video) Sub=01 Prot=00 Driver=uvcvideo
I:  If#=0x1 Alt= 0 #EPs= 0 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

T:  Bus=01 Lev=01 Prnt=01 Port=06 Cnt=02 Dev#=  3 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0489 ProdID=e0a2 Rev=00.01
C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:  If#=0x0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
I:  If#=0x1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb

T:  Bus=10 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=10000 MxCh= 2
D:  Ver= 3.10 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=1d6b ProdID=0003 Rev=05.05
S:  Manufacturer=Linux 5.5.0 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:3e:00.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=10000 MxCh= 6
D:  Ver= 3.10 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=1d6b ProdID=0003 Rev=05.05
S:  Manufacturer=Linux 5.5.0 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:00:14.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=03 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 2
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev=05.05
S:  Manufacturer=Linux 5.5.0 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:39:00.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=04 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=10000 MxCh= 2
D:  Ver= 3.10 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=1d6b ProdID=0003 Rev=05.05
S:  Manufacturer=Linux 5.5.0 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:39:00.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=05 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 4
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev=05.05
S:  Manufacturer=Linux 5.5.0 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:3c:00.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=05 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  2 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=16 #Cfgs=  1
P:  Vendor=2188 ProdID=6533 Rev=01.01
S:  Manufacturer=CalDigit, Inc.
S:  Product=CalDigit Thunderbolt 3 Audio
C:  #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=100mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=01(audio) Sub=01 Prot=00 Driver=snd-usb-audio
I:  If#=0x1 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio
I:  If#=0x2 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio
I:  If#=0x3 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid

T:  Bus=06 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=5000 MxCh= 4
D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=1d6b ProdID=0003 Rev=05.05
S:  Manufacturer=Linux 5.5.0 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:3c:00.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=06 Lev=01 Prnt=01 Port=03 Cnt=01 Dev#=  2 Spd=5000 MxCh= 0
D:  Ver= 3.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs=  1
P:  Vendor=0781 ProdID=558c Rev=10.12
S:  Manufacturer=SanDisk
S:  Product=Extreme SSD
S:  SerialNumber=313831333530343030323130
C:  #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=896mA
I:  If#=0x0 Alt= 1 #EPs= 4 Cls=08(stor.) Sub=06 Prot=62 Driver=uas

T:  Bus=07 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 4
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev=05.05
S:  Manufacturer=Linux 5.5.0 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:3d:00.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=07 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=480 MxCh= 4
D:  Ver= 2.10 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=2109 ProdID=2812 Rev=90.90
S:  Manufacturer=VIA Labs, Inc.         
S:  Product=USB2.0 Hub             
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=07 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#=  3 Spd=1.5 MxCh= 0
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=045e ProdID=0023 Rev=01.21
S:  Manufacturer=Microsoft
S:  Product=Microsoft Trackball Optical®
C:  #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=usbhid

T:  Bus=07 Lev=02 Prnt=02 Port=01 Cnt=02 Dev#=  4 Spd=1.5 MxCh= 0
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=04d9 ProdID=1818 Rev=01.01
S:  Product=USB Keyboard
C:  #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=100mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=01 Driver=usbhid
I:  If#=0x1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=usbhid

T:  Bus=07 Lev=02 Prnt=02 Port=03 Cnt=03 Dev#=  5 Spd=480 MxCh= 4
D:  Ver= 2.10 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=2109 ProdID=2812 Rev=90.90
S:  Manufacturer=VIA Labs, Inc.         
S:  Product=USB2.0 Hub             
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=07 Lev=03 Prnt=05 Port=00 Cnt=01 Dev#=  8 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0b0e ProdID=0422 Rev=02.07
S:  Product=Jabra SPEAK 510 USB
S:  SerialNumber=1C48F938017C020700
C:  #Ifs= 4 Cfg#= 1 Atr=c0 MxPwr=500mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=01(audio) Sub=01 Prot=00 Driver=snd-usb-audio
I:  If#=0x1 Alt= 1 #EPs= 1 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio
I:  If#=0x2 Alt= 1 #EPs= 1 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio
I:  If#=0x3 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid

T:  Bus=07 Lev=03 Prnt=05 Port=02 Cnt=02 Dev#=  9 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=046d ProdID=082d Rev=00.11
S:  Product=HD Pro Webcam C920
S:  SerialNumber=F8EE46FF
C:  #Ifs= 4 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=0e(video) Sub=01 Prot=00 Driver=uvcvideo
I:  If#=0x1 Alt= 9 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
I:  If#=0x2 Alt= 0 #EPs= 0 Cls=01(audio) Sub=01 Prot=00 Driver=snd-usb-audio
I:  If#=0x3 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio

T:  Bus=07 Lev=03 Prnt=05 Port=03 Cnt=03 Dev#=  6 Spd=480 MxCh= 4
D:  Ver= 2.10 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=2109 ProdID=2812 Rev=90.90
S:  Manufacturer=VIA Labs, Inc.         
S:  Product=USB2.0 Hub             
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=07 Lev=04 Prnt=06 Port=02 Cnt=01 Dev#=  7 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1050 ProdID=0200 Rev=00.97
S:  Manufacturer=Yubico
S:  Product=Yubico Gnubby (gnubby1)
C:  #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=30mA
I:  If#=0x0 Alt= 0 #EPs= 2 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid

T:  Bus=08 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=5000 MxCh= 4
D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=1d6b ProdID=0003 Rev=05.05
S:  Manufacturer=Linux 5.5.0 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:3d:00.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=08 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=5000 MxCh= 4
D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=2109 ProdID=0812 Rev=90.91
S:  Manufacturer=VIA Labs, Inc.         
S:  Product=USB3.0 Hub             
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=08 Lev=02 Prnt=02 Port=03 Cnt=01 Dev#=  4 Spd=5000 MxCh= 4
D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=2109 ProdID=0812 Rev=90.91
S:  Manufacturer=VIA Labs, Inc.         
S:  Product=USB3.0 Hub             
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=08 Lev=03 Prnt=04 Port=03 Cnt=01 Dev#=  5 Spd=5000 MxCh= 4
D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=2109 ProdID=0812 Rev=90.91
S:  Manufacturer=VIA Labs, Inc.         
S:  Product=USB3.0 Hub             
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=08 Lev=01 Prnt=01 Port=03 Cnt=02 Dev#=  3 Spd=5000 MxCh= 0
D:  Ver= 3.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs=  1
P:  Vendor=2188 ProdID=0747 Rev=10.38
S:  Manufacturer=CalDigit
S:  Product=Card Reader 
S:  SerialNumber=000000000010
C:  #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=896mA
I:  If#=0x0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage

T:  Bus=09 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 2
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev=05.05
S:  Manufacturer=Linux 5.5.0 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:3e:00.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

usb-devices pulls from the sysfs files directly (it's a bash script), so I think things look in sync here. What am I missing?

Can you verify it against usb-devices?

dfandrich commented 4 years ago

Which of those devices are connected to a hub? What does lsusb -t say? You should see some of the same files being opened more than once for those using "strace -e trace=file lsusb |& grep '/sys.*product' " If your devices are installed in such a way that there is no "shadow" device at the port when loading the wrong /sys file, then you'll just see a blank rather than wrong info. You also seem to have a lot of similar hubs plugged into hubs so when it says "hub" it might be displaying the wrong one, but you wouldn't be able to tell. I'll take a closer look at your log to see what might be happening. usb-devices works correctly for me on my system.

dfandrich commented 4 years ago

Is your lsusb output with the hardware database file deleted so it's actually reading from /sys? Because I think it should be showing the bug by displaying "Card Reader" for your device "Bus 008 Device 005: ID 2109:0812 VIA Labs, Inc. VL812 Hub" instead of Hub (i.e., the product from your device "Bus 008 Device 003: ID 2188:0747 CalDigit Card Reader").

dfandrich commented 4 years ago

Thanks for the pointer ValZapod@. I've reused the lsusb -t code that walks the sysfs tree to implement the fix in the latest patch.

tormodvolden commented 3 years ago

In case it hasn't been pointed out clearly already: The code introduced in commit dddb696e0 uses the pair of values returned by libusb_get_bus_number() and libusb_get_port_number() to find the device under /sys/bus/usb/devices but this pair does not identify all devices properly - several different devices have the same pair of values, giving the same product string.

This is also explained in pull request #108 (and #110).

Another example was reported here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=968358

gregkh commented 3 years ago

Should now be fixed with the changes merged in #110 If not, please let me know, thanks and sorry for the long delay with this.