blino's website

Free software developer and more

When multiple display modules matching the same device are loaded at startup by udev coldplug, we can get in a situation where X doesn't start (#32030). This can happen when different versions of nvidia modules (nvidia, , nvidia96xx, nvidia71xx) are installed, which is the case on our live CDs.

To prevent all these modules from being loaded by udev, we can explicitely exclude devices from the display PCI class, like we do for storage controllers:

# modprobe pci devices on cold plug except for:
#  PCI_BASE_CLASS_STORAGE          0x01
ACTION=="add", SUBSYSTEM=="pci", ENV{STARTUP}=="1", SYSFS{modalias}=="?*", \
        ATTRS{class}!="0x01*", \
        RUN+="/sbin/modprobe %s{modalias}"

But adding another match to exclude the display class (PCI_BASE_CLASS_DISPLAY is 0x03 in /usr/include/pci/header.h) did not always work: ATTRS{class}!="0x03*" fails on PCI-Express devices.

That's because the ATTRS{class}!="value" rule walks every parent devices to check that each of them has a class different from "value", while one could think it would match if only one of them has a different value. Thus, when the tested device has a parent device, like with PCI Express devices, the negative ATTRS check is likely to fail.

So, the solution is to use ATTR{class}!="value", which checks only the current device, without walking the parent tree.

To debug this, I built udev with DEBUG=true, and added a ENV{FOO}=BAR operation in the rule I tested, to know quickly if it mached (in the output of udevmonitor --env).

# udevd --daemon --debug-trace --verbose &>udevd-debug.log
# udevcontrol log_priority=debug
# udevcontrol env STARTUP=1
# udevmonitor --env

Then, testing the rule of my video adapter device is just a matter of writting in the uevent file in sysfs:

$ lspci | grep VGA
01:00.0 VGA compatible controller: ATI Technologies Inc Unknown device 94c3
# echo 1 > /sys/devices/pci0000:00/0000:01:00.0/uevent

Comments are closed for this story.

Trackbacks are closed for this story.

blosxom Optimised for standards.
Olivier Blin (2005)