Loading modules with cold plugged devices

Luca Ellero lroluk at gmail.com
Thu Sep 25 09:54:06 UTC 2014


Hi,
thanks for the replies. See my comments inline

On 24/09/2014 20:19, Isaac Dunham wrote:
> On Wed, Sep 24, 2014 at 07:03:44PM +0200, Natanael Copa wrote:
>> On Wed, 24 Sep 2014 14:15:10 +0200
>> Luca Ellero <lroluk at gmail.com> wrote:
>>
>>> Hi,
>>> I'm trying to load kernel modules at boot time (if needed) but I don't
>>> manage to get it right.
>>> My configuration is the following:
>>> Pandaboard with U-Boot 2014.07, Linux kernel 3.16 and BusyBox 1.22.1
>>>
>>> I have an init script /etc/init.d/rcS like this:
>>>
>>> #!/bin/sh
>>> mount -t proc none /proc
>>> mount -t sysfs none /sys
>>> echo /sbin/mdev > /proc/sys/kernel/hotplug
>>> /sbin/mdev -s
>>>
>>> and a configuration file /etc/mdev.conf containing only the following line:
>>>
>>> $MODALIAS=.*    0:0 660 @modprobe "$MODALIAS"
>>>
>>> Modules are correctly loaded if I plug in a device while the system is
>>> up and running.
>>> For example if I plug-in an USB keyboard the correct module (usbhid) is
>>> loaded.
>>> But if the keyboard is "cold plugged" (when the system is off) and then
>>> I power up the Pandaboard, the module isn't loaded.
>>> Even executing "mdev -s" when the system is up doesn't load the module.
>>> Doesn't "mdev -s" scan /sys entries and load modules (as mdev.conf
>>> points), or am I missing something?
>> No, it does not trigger hotplug events by scanning /sys.
What's the purpose of "mdev -s" then?
Documentation says: scan /sys and populate /dev. But even if I don't run 
"mdev -s" at boot time /dev is populated anyway.
Who populate it then?

>> Alpine Linux does this:
>> find /sys -name modalias | xargs sort -u \
>>    | xargs modprobe -a 2> /dev/null
This doesn't work in my system.
With "modprobe -a" error is:
     modprobe: invalid option -- 'a'
Without -a option it says :
     modprobe: module 'i2c:dummy' not found
> On the Puppy Linux forums[1], it was pointed out that for some hardware,
> there was a MODALIAS line in uevent but not a modalias file
> (for example, this can miss some Broadcom wireless cards).
> Also performance came up; the fastest way was something more like
>
>    grep -h MODALIAS /sys/bus/*/devices/*/uevent | \
>      cut -d= -f2 | xargs modprobe -abq 2>/dev/null

This doesn't work either. Throwing away -a (see previous comment) it says:

modprobe: module 'i2c:twl6030' not found

> Not that it's really significant for most usage; on an Atom N270 at 1.6GHz,
> I tested with echo instead of modprobe and got
> 0.22 seconds (consistently) for a shell script containing the more
> Alpine-like version:
>   find /sys -name modalias |xargs sort -u |xargs echo
>
> and 0.01-0.02 seconds for a shell script containing this version:
>   grep -h MODALIAS /sys/bus/*/devices/*/uevent | \
>     cut -d= -f2 |sort -u |xargs echo
>
>
Anyway I've found a solution to this issue:
     for i in /sys/bus/*/devices/*/uevent; do echo add > $i; done
What do you think about this?

Thanks
Regards
Luca

----
Luca Ellero
http://www.brickedbrain.com





More information about the busybox mailing list