Skip to content
systemcoding.dev
Kernels

Find Which Kernel Driver Controls a PCI Device With lspci -k

Use lspci -k on Linux 6.12 to see the kernel driver in use and the modules that could drive each PCI device, and read the same answer from sysfs and modalias.

6 min read
Summarize in AI
Flat illustration of a magnifier over lines of a log, with the Linux, C and GNU logos.

A PCI device that does nothing is nearly always one of three things: no driver matched it, a driver matched but failed, or the wrong driver took it. lspci -k answers all three in one command, because for each device it prints the driver currently in use and the list of modules the kernel believes can handle it. This post uses pciutils 3.13 on Linux 6.12 to read that output, shows the sysfs files behind it so you can script the same check, and walks through the three failure shapes. It is the PCI counterpart of the USB driver lookup with lsusb -t.

How drivers match devices is described in the kernel's PCI driver documentation.

The command and its output

Add -k to a normal listing, and select one device with -s to keep the output short:

Shell
lspci -k -s 00:1f.6
Text
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (10) I219-LM
	Subsystem: Dell Device 0a3e
	Kernel driver in use: e1000e
	Kernel modules: e1000e

The three new lines are the point of the option.

Subsystem is the subsystem vendor and device ID, a second pair of IDs that identifies the board the chip sits on. Some drivers match on it to handle a chip differently on different boards.

Kernel driver in use is the driver bound right now. Its absence means no driver is bound, which is the symptom you are hunting. The name is the driver's registered name, which usually, but not always, equals the module's file name.

Kernel modules lists every module whose alias table matches this device's IDs. It can contain more than one entry. For a device with two possible drivers, such as an Intel GPU handled by i915 or the newer xe, both appear, and the one in use is the one that bound first.

When the module list is longer than the driver in use, the extra names are alternatives, not extra drivers running.

What the output looks like when something is wrong

A device with no driver shows the module line but not the driver line:

Text
03:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8852AE 802.11ax PCIe Wireless Network Adapter
	Subsystem: Realtek Semiconductor Co., Ltd. Device 8852
	Kernel modules: rtw89_8852ae

Here the kernel knows a module that matches (rtw89_8852ae) but nothing loaded it, or it loaded and failed in probe. Two checks separate those cases:

Shell
lsmod | grep rtw89
sudo dmesg | grep -i rtw89

If lsmod shows nothing, the module is not loaded, and sudo modprobe rtw89_8852ae loads it. If it is loaded, the dmesg output shows why probe failed, which is typically a missing firmware file. The exact text is failed to load firmware or Direct firmware load for ... failed with error -2, and the fix is installing the firmware package, as discussed in the firmware lookup post.

A device with neither line has no matching module at all:

Text
04:00.0 Unassigned class [ff00]: Example Corp Device 1234

Nothing in the installed modules claims the ID vendor:1234. Either the kernel is too old for the hardware, the driver is a third-party one that is not installed, or the device really has no Linux driver.

A device bound to the wrong driver shows a name that does not match what you expect, for example a GPU bound to vfio-pci or a placeholder such as pci-stub, which means a passthrough setup or an explicit boot parameter claimed it before the real driver could.

The same answer from sysfs

lspci -k is a view of data in sysfs, and reading it directly works on systems without pciutils. The bound driver is a symbolic link named driver, and the alias a module is matched against is the modalias file:

Shell
readlink /sys/bus/pci/devices/0000:00:1f.6/driver
cat /sys/bus/pci/devices/0000:00:1f.6/modalias
Text
../../../bus/pci/drivers/e1000e
pci:v00008086d00000D4Fsv00001028sd00000A3Ebc02sc00i00

The modalias string encodes the IDs in a fixed format: v is the vendor, d the device, sv and sd the subsystem vendor and device, bc the base class, sc the subclass and i the programming interface. It is what modprobe and udev use to choose a module. Ask the module database directly what matches it:

Shell
modprobe --resolve-alias "$(cat /sys/bus/pci/devices/0000:00:1f.6/modalias)"
Text
e1000e

If this prints nothing, no module installed for the running kernel claims the device. If it prints a name, but the device has no driver, the module is installed and has not been loaded or has failed, and the log tells which.

A small loop prints the state of every device at once, which is handy on a server where you want to find all unbound devices:

Shell
for d in /sys/bus/pci/devices/*; do
    if [ -e "$d/driver" ]; then
        echo "$(basename "$d") $(basename "$(readlink "$d/driver")")"
    else
        echo "$(basename "$d") none"
    fi
done
Text
0000:00:00.0 none
0000:00:02.0 i915
0000:00:1f.6 e1000e
0000:02:00.0 nvme

A host bridge such as 00:00.0 commonly has no driver, and that is normal: it is handled by the PCI core and needs none. A none on an endpoint you expected to work is the one to chase.

How the kernel decides

When a PCI device is discovered, the core compares its IDs against the id_table of each registered driver, in the same way a USB driver matches interfaces. The table entries use PCI_DEVICE(vendor, device) for an exact pair, PCI_DEVICE_CLASS(class, mask) for a class match and PCI_VDEVICE() as a shorthand. The first driver whose entry matches and whose probe returns zero gets the device.

Two overrides change this. The driver_override file in the device directory forces the next bind to a named driver regardless of its table, which is how you hand a device to vfio-pci. And the new_id file of a driver teaches it an extra ID at run time:

Shell
echo "10ee 7021" | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id

After that the driver claims every device with that vendor and device pair that is not already bound. Both are temporary, lasting until reboot or until you undo them.

Reading the result

Think in three outcomes. A bound driver that works means you look elsewhere. A module that matches but is not bound means a load or probe failure, and the kernel log has the reason. No matching module means the driver is missing, and the fix is a newer kernel, a package or an out-of-tree module. Everything else, such as a wrong driver, comes from an override or a boot parameter like pci-stub.ids= or vfio-pci.ids= that someone set on purpose.

A worked diagnosis

Suppose a new Wi-Fi card does nothing after a kernel upgrade. Start with lspci -k -s 03:00.0. If the Kernel driver in use line is present, the problem is above the driver, and you move on to the interface and the radio state. If only the module line appears, run lsmod to check that the module loaded, then read the kernel log around its name. A firmware message points to a package, a message about an unsupported chip revision points to a newer kernel, and a message about a conflicting module points to a blacklist entry or a competing driver such as an older out-of-tree one that is still installed. If no module line appears at all, compare the modalias of the device against modinfo of the driver you expect: the alias: lines in its output list every ID it supports, and a missing entry confirms the ID is new to that driver version. Each step narrows the cause without guessing, and it takes under a minute.

Also inHardware
Share

Keep reading

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.