blino's website

Free software developer and more

Now that the Mandriva kernel has both legacy IDE and libata PATA drivers enabled (and modularized), we may experience some issues because of PCI coldplugging, which is enabled by default in Mandriva. It would load both IDE drivers, probably leading to strange things.

Thus, I've modified our udev rules to ignore IDE controllers at coldplug. These controllers can be matched by their PCI class (PCI_CLASS_STORAGE_IDE is 0x0101, from <pci/header.h>). To differentiate between coldplug and hotplug (ok, not very likely for IDE controllers), the STARTUP environment variable is set by /sbin/start_udev before calling /sbin/udevtrigger.

The new udev rule for automatic PCI modules loading looks this way:

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

It can be easily tested this way:

rmmod <some pci module>
/sbin/udevcontrol env STARTUP=1
udevtrigger
udevsettle
/sbin/udevcontrol env STARTUP=
head /proc/modules

For the record, here's the crazy command line I used to list IDE modules (requiring ide-core) and their matching class (from modaliases), just out of curiosity:

egrep
  `grep ide-core /lib/modules/$(uname -r)/modules.dep
   | perl -ne 'print join("|", map { m|([^/]*).ko| && $1 ne "generic" ? $1 : () } <>) . "\n"'`
  /lib/modules/$(uname -r)/modules.alias
| grep -v 'bc\*'

(yes, I'm insane)

It's a little step that was necessary for current Cooker, but it can also help to switch to PATA drivers in a simple way (by just modifying the driver in our pcitable). And we will probably do so soon, as Alan Cox's libata PATA status looks quite encouraging.



Comments are closed for this story.

Trackbacks are closed for this story.

blosxom Optimised for standards.
Olivier Blin (2005)