3

I am trying to troubleshoot a problem: usb mouse doesn't work on a freshly installed linux.

I suspect the problem is that there is no suitable kernel module/driver for my usb hardware. Indeed:

$ lspci -knn
...
01:00.0 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b9] (rev 02)
        Subsystem: ASMedia Technology Inc. Device [1b21:1142]
01:00.1 SATA controller [0106]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b5] (rev 02)
        Subsystem: ASMedia Technology Inc. Device [1b21:1062]
        Kernel driver in use: ahci
...

As you can see no kernel driver is reported for USB controller device (I suppose it should be reported in a way similar to driver reported for SATA controller)

So, I need to rebuild kernel with a module which would be suitable for my device. But how can I find out what module should I build? I have information which identifies my device: it's vendor id and hardware id ([1b21:43b9]). How to find out corresponding kernel module name given this information?

  • 1
    @GAD3R lsusb reports nothing. As I understand it is a more high-level command, it can't report anything because there is no kernel driver for USB controller. Is this understanding correct? – lesnik Dec 23 '18 at 18:04
  • 1
    If the kernel module is not built (or not loaded), or if maybe no kernel module for this device even exists, there's no direct way to find out. Which leaves google (in particular if you need a newer kernel than you have) and greping through the kernel sources, both of which I've done with success in the past. – dirkt Dec 23 '18 at 19:02
8

PCI ID 1022:43b9 is an AMD X370 Series Chipset USB 3.1 xHCI Controller. The PCI subsystem ID 1b21:1142 would suggest it might actually be an ASMedia ASM1042A USB 3 controller, possibly integrated into the AMD chipset.

For most USB 3.x controller chips, the appropriate driver module is xhci_pci which depends on module xhci_hcd. Both these modules are part of the standard Linux kernel, so they should be available in all modern Linux distributions. The corresponding kernel configuration options are CONFIG_USB_XHCI_PCI and CONFIG_USB_XHCI_HCD.

Many distributions include the kernel configuration file as /boot/config-<kernel version number>. So, you could run this command:

$ grep XHCI /boot/config-$(uname -r)
CONFIG_USB_XHCI_HCD=m
CONFIG_USB_XHCI_PCI=m
# CONFIG_USB_XHCI_PLATFORM is not set

Here, both xhci_hcd and xhci_pci are configured to be available as modules. If the lines would say ...=y instead, the USB 3 support would be compiled into the main kernel.

PCI ID 1022:43b5, subsystem ID 1b21:1062 is an AHCI SATA (or eSATA) controller, which is already covered by module ahci.

You can look up PCI IDs in PCI ID Repository.

If a driver has been specified by vendor/product IDs, you could use /sbin/modprobe -c | grep '<vendor ID>.*<product ID>'. If you get back a line like this, you've found a match:

alias pci:v0000<vendor ID>:d0000<product ID>sv... <module name>

This information comes from /lib/modules/modules.alias[.bin], which is generated by the depmod command from the device support information embedded in the kernel modules themselves (defined in the source code with a MODULE_DEVICE_TABLE macro). You can also use modinfo <module name> | grep alias to view the hardware support claimed by a particular module.

However, not all modules are specified by vendor/product IDs. Some drivers will cover an entire class of devices; for example, the xhci_pci module claims support of PCI base class 0x0C, subclass 0x03, interface 0x30... which maps to "Serial bus controller", "USB controller" and "XHCI" respectively. This is expressed as

alias:          pci:v*d*sv*sd*bc0Csc03i30*

Note that you should not normally need to do any of these lookups manually unless you've blacklisted some modules or the auto-detection fails for some reason. For example, when the Linux kernel detects the original poster's USB 3 controller, it will cause (the equivalent of) the following command to be executed:

modprobe pci:v00001022d000043b9sv1b21sd1142bc0Csc03i30

which contains all the hardware vendor/device/class/subclass/interface IDs available for the device. If one of the wildcarded aliases on record in modprobe configuration matches this string, the respective module will get loaded automatically.

For USB devices (and indeed for any autoprobeable buses), there is a similar system of module aliases, and a USB ID repository.

If you don't have the appropriate module compiled on your system, your best bet is to use the PCI ID repository to identify the device or the chip used within it. Sometimes the repository entry identifies the Linux kernel module that will provide support for it. If that information is not present, you may need to google using the device/chip model; this will usually allow you to find any alternative/experimental driver modules that have not (yet?) been included in the standard kernel.

  • 2
    Thanks, you are correct. xhci_hcd module was required. I just found it using live usb with another version of linux. lspci -k command showed me the module name. But this doesn't feel like a true way to resolve similar problems. The question still remains - what is a consistent way to find out kernel module given the hardware id's? – lesnik Dec 23 '18 at 18:53
2

If the module isn't built into the kernel (on RedHat 7 and variants, XHCI_HCD is not loaded as a module, but part of the base image) you can look at the modules.aliases file for your kernel.

e.g.

% grep 1B21 /lib/modules/$(uname -r)/modules.alias
alias pci:v00001B21d00000612sv*sd*bc*sc*i* ahci
alias pci:v00001B21d00000611sv*sd*bc*sc*i* ahci
alias pci:v00001B21d00000602sv*sd*bc*sc*i* ahci
alias pci:v00001B21d00000601sv*sd*bc*sc*i* ahci

We can see the "v"endor ID, and "d"evice ID values in this file, and the corresponding module ("ahci") that should be loaded.

We can verify this module handles those drivers:

% modinfo /usr/lib/modules/3.10.0-957.1.3.el7.x86_64/kernel/drivers/ata/ahci.ko.xz
filename:       /usr/lib/modules/3.10.0-957.1.3.el7.x86_64/kernel/drivers/ata/ahci.ko.xz
version:        3.0
license:        GPL
description:    AHCI SATA low-level driver
author:         Jeff Garzik
retpoline:      Y
rhelversion:    7.6
srcversion:     4BCC52C20C316AF69F3584A
....
alias:          pci:v00001B21d00000612sv*sd*bc*sc*i*
alias:          pci:v00001B21d00000611sv*sd*bc*sc*i*
alias:          pci:v00001B21d00000602sv*sd*bc*sc*i*
alias:          pci:v00001B21d00000601sv*sd*bc*sc*i*
...
depends:        libahci,libata
intree:         Y
vermagic:       3.10.0-957.1.3.el7.x86_64 SMP mod_unload modversions 
signer:         CentOS Linux kernel signing key
sig_key:        E7:CE:F3:61:3A:9B:8B:D0:12:FA:E7:49:82:72:15:9B:B1:87:9C:65
sig_hashalgo:   sha256
parm:           marvell_enable:Marvell SATA via AHCI (1 = enabled) (int)

The values in the modules.alias file correspond to:

 v     (vendor)
 d     (device)
 sv    (subvendor)
 sd    (subdevice)
 bc    (bus class)
 sc    (bus subclass)
 i     (interface)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.