Specifying the kernel booting modules loading order

March 20th, 2007

Tags:

After upgrading to madwifi svn (now released 0.9.3), I found I encountered maybe a seldom problem: the linux kernel module loading order.

In the latest madwifi, it provides three different rate control algorithms, ONOE, AMRR and SAMPLE, instead of only SAMPLE in the previous version. Though SAMPLE is the most advanced one and is used by default, the other two must have ability to take over it’s job. So modules dependency relationship can’t be hardcode into source. But when you insert these modules to /etc/modules for kernel loading when booting, the kernel will take ath_pci first, which depends on ath_rate_sample or other rate control modules. So, the ath_pci can’t be loaded completely success but was still loaded, and reports:

Unable to load needed module: ath_rate_sample; no support for automatic module loading<3>Error loading module “ath_rate_sample”

Then, if you still want to use it, you must reload ath_pci manually, for ath_rate_sample is loaded after ath_pci, but the former didn’t know it, and it can’t specify ath_rate_sample as its depend modules for this can be specify when it was loading.

UPDATE: Thank Matt tell me the real reason: The “automatic module loading” wasn’t open when we compiling the kernel (and in fact error message tell me of that clearly…).
So, please recompile your kernel with “automatic modules loading”(CONFIG_KMOD=y), and recompile your madwifi modules with your new kernel. Then try to load it normally. It’s more useful…
It seems silly to try to load these modules manually… I’m sorry…

SO PLEASE FORGET THE THING BELOW EXCEPT YOU REALLY ENCOUNTER SOME UGLY MODULES…

The only method to solve this is to specify the kernel modules loading order, but the loading order seems can’t be specify simply by /etc/modules (I checked module-init-tools, but don’t understand why it don’t load the modules by order — it meant to do it…). So I add a script in /etc/init.d/ to do this, and link it to /etc/rcS.d/S21load-madwifi.sh(just after module-init-tools)

1 #!/bin/bash
2 #load-madwifi.sh
3
4 modprobe -r ath_pci
5 modprobe -r wlan_tkip
6 modprobe -r wlan_scan_sta
7 modprobe -r ath_rate_sample
8
9 modprobe ath_rate_sample
10 modprobe wlan_scan_sta
11 modprobe wlan_tkip
12 modprobe ath_pci

If you are a debian user, you can simply use:

sudo modconf –load-before ath_rate_sample –load-before \
wlan_scan_sta –load-before wlan_tkip –load-only ath_pci

That’s it.