Skip to contentSkip to conversation

Modules and DevFS

DISCUSSION William Knop 4 participants 4 messages Jan 31, 2001 – Feb 1, 2001

lore
Share & tools
lore
#0 lore raw

I decided recently to go bleeding-edge on one of my Linux boxes and discovered I had a problem with module loading while using DevFS.

Correct me if I'm wrong, but DevFS only makes /dev entries when a device is present, and the device is not present until the module is loaded. So if I want to access /dev/hda and the IDE module has not been loaded yet, I will get a message telling me the device doesn't exist or some such instead of autoloading the module and being happy. Same goes for hotswap devices, right? I boot directly into X and have to crash out (otherwise it continually tries to unsuccessfully load X) so I could enable my USB mouse and various other devices.

I realize modularizing the entire IDE subsystem is not really good anyway, because every time it reloads it will rescan the bus... But what about USB? Suppose I don't have any IDE or USB devices, but want support so I can use them later. Especially in the case of USB, plugability is a must for desktop "home" systems.

I also have enabled the "module autoload" feature of DevFS, which conveniently autoloads my 3c59x driver. :)

Does the kernel only autoload modules through userspace request, or can a hardware request cause loading? For instance, inserting a USB peripheral would cause the USB chipset to signal the OS. So therefore the OS can update its device tables and unload the module again when it becomes inactive. This goes for all hot-swap devices, IMHO.

I read all the FAQs and stuff and found nothing that really addresses this, so here I ask if anyone has any idea as to a solution. No doubt I screwed something up somewhere along the line... If my kernel or XF86 config files are needed, I can pull 'em up and post 'em. Also, please CC responses to me because I'm not currently subscribed.

Thanks a bunch,
Will

Box info:
Linux 2.4.1
Abit M/B
P3 550
256MB RAM
AGP Devices:
Nvidia TNT2 AGP display card
PCI Devices:
S3Virge/VX display card
Adaptec 3940UW SCSI card
3Com "Boomerang" ethernet card
ISA Devices:
SB AWE 64 Gold ISA sound card
IDE Drives:
2 CDROM drives
SCSI Drives:
4.5 GB UW drive
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"William" == William Knop <[email protected]> writes:

William> Correct me if I'm wrong, but DevFS only makes /dev William> entries when a device is present, and the device is not William> present until the module is loaded. So if I want to William> access /dev/hda and the IDE module has not been loaded William> yet, I will get a message telling me the device doesn't William> exist or some such instead of autoloading the module and William> being happy. Same goes for hotswap devices, right? I boot William> directly into X and have to crash out (otherwise it William> continually tries to unsuccessfully load X) so I could William> enable my USB mouse and various other devices.

My /etc/modutils/devfsd has

probeall /dev/discs scsi-hosts sd_mod ide-probe-mod ide-disk DAC960

perhaps it should have something similar for /dev/hd*?

As a work around, put something like this:

alias /dev/hdd ide-cd

or (not tested; just guessing):

alias /dev/hd* /dev/ide

in /etc/modutils/aliases, and run update-modules.

William> I realize modularizing the entire IDE subsystem is not William> really good anyway, because every time it reloads it will William> rescan the bus... But what about USB? Suppose I don't William> have any IDE or USB devices, but want support so I can William> use them later. Especially in the case of USB, William> plugability is a must for desktop "home" systems.

I am not really familiar with USB.

Signature · 5 lines
Brian May <[email protected]>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#2 lore raw
In reply to William Knop
Quoted 5 lines · William Knop

Correct me if I'm wrong, but DevFS only makes /dev entries when a device is present, and the device is not present until the module is loaded. So if I want to access /dev/hda and the IDE module has not been loaded yet, I will

One thing that I've noticed with devfs is that all the old-style names are symlinks. Documentation/filesystems/devfs/README, I think is the file that describes this. The actual device file for /dev/hda now is:

/dev/ide/hd/c0b0t0u0

OR

/dev/ide/host0/bus0/target0/lun0/disc

I use the shorter one in my fstab, it makes things neater. It's also a symlink, but I would think that symlink will stay longer than /dev/hda will, anyway. When I rebuild my system, or get a completely new one, everything will probably wind up using /dev/ide/host0... etc.

Quoted 7 lines

I realize modularizing the entire IDE subsystem is not really good anyway, because every time it reloads it will rescan the bus... But what about USB? Suppose I don't have any IDE or USB devices, but want support so I can use them later. Especially in the case of USB, plugability is a must for desktop "home" systems.

Everything is modularized here, including ppp and such, and modprobe is loading everything quite nicely for me. I don't like to run one big kernel, it wastes too much memory, and so I use pretty much *everything* that I can in modules (IDE I can't, because I boot from IDE, but I leave SCSI in a module, becuase I use ide-scsi to burn my CDs and it's not *reqired*).

[clipped]

Quoted 7 lines

I read all the FAQs and stuff and found nothing that really addresses this, so here I ask if anyone has any idea as to a solution. No doubt I screwed something up somewhere along the line... If my kernel or XF86 config files are needed, I can pull 'em up and post 'em. Also, please CC responses to me because I'm not currently subscribed.

I can't help you much more than what I've already said, but best of wishes and luck to you. I would advise that you traverse through /dev/ though, and find out how the new organization is... it's *quite* different from the old method. The symlinks are only there for backwards compatability for the time being - however, I'd expect those to be moved out when pretty much all Linux software is using the new arrangement.

- Mike

===========================================================================
Michael B. Trausch [email protected]
Avid Linux User since April, '96! AIM: ML100Smkr

Contactable via IRC (DALNet) or AIM as ML100Smkr
===========================================================================

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#3 lore raw
In reply to William Knop
Quoted 9 lines · William Knop

I decided recently to go bleeding-edge on one of my Linux boxes and discovered I had a problem with module loading while using DevFS.

Correct me if I'm wrong, but DevFS only makes /dev entries when a device is present, and the device is not present until the module is loaded. So if I want to access /dev/hda and the IDE module has not been loaded yet, I will get a message telling me the device doesn't exist or some such instead of autoloading the module and being happy. Same goes for hotswap devices,

You can have the device autoloaded and be happy, even when using devfs. All you need is to set up the devfsd daemon right.

I have my sound driver as modules - so /dev/dsp don't exist when it isn't loaded. I can still have my sound using programs autoload the driver. I'll show this as an example, as I don't use USB myself.

My /etc/devfsd.conf contains the following, among other things:

LOOKUP          dsp             MODLOAD
LOOKUP          sound           MODLOAD

This is a neat one. Whenever someone tries to lookup "/dev/dsp" devfsd will do a "modprobe /dev/dsp" if the device isn't there. Appropriate aliases in /etc/modules.conf then ensures the correct module is loaded.

REGISTER        sound/.*        MKOLDCOMPAT
UNREGISTER      sound/.*        RMOLDCOMPAT

This ensures old fashioned names like /dev/dsp works, by creating links to /dev/sound/dsp. Few programs ask directly
for /dev/sound/dsp yet.

My modules.conf contains this, among other things:
alias /dev/dsp sound-service-0-3

This maps the "/dev/dsp" probe to the sound driver. Further aliases for sound-service-0-3 follows, but thats just stuff necessary to load ALSA so I won't detail it here.

This happens when a program tries to open the (non-existing) /dev/dsp:
* app tells kernel to open "/dev/dsp"
* devfs realize it isn't there, and pass the request to devfsd
* devfsd does a "modprobe /dev/dsp" because its configuration says so.
* modprobe looks up the real driver in modules.conf, using my aliases. The sound driver modules are loaded.
* The sound modules create /dev/sound/dsp among others
* devfs notice this, and notifiex devfsd which creates the /dev/dsp symlink as devfsd.conf says so.
* devfsd returns to devfs that lets the sound driver continue its initialization. The sound driver finishes and modprobe returns and the first invocation of devfsd finishes.
* devfs continue looking up /dev/dsp. It exists now, so the kernel return a file descriptor to the app in the usual way.

This may seem like a lot - fortunately it is simpler when the driver is in memory.

Quoted 5 lines

I realize modularizing the entire IDE subsystem is not really good anyway, because every time it reloads it will rescan the bus... But what about USB? Suppose I don't have any IDE or USB devices, but want support so I can use them later. Especially in the case of USB, plugability is a must for desktop "home" systems.

Setting up a LOOKUP in devfsd will do the trick. You can run devfsd in debug mode if you want to know exactly what the kernel tries to look up.

As for what to modularize - I believe the idea is to create modules for anything that sits unused for long periods of time, and compile in anything that is used most of the time. So I compile in network adapters and drivers for disks that is mounted all the time. Sound, isdn, floppy and cdrom is used occationally, and goes in modules. Your case might be different.

Quoted 9 lines

I also have enabled the "module autoload" feature of DevFS, which conveniently autoloads my 3c59x driver. :)

Does the kernel only autoload modules through userspace request, or can a hardware request cause loading? For instance, inserting a USB peripheral would cause the USB chipset to signal the OS. So therefore the OS can update its device tables and unload the module again when it becomes inactive. This goes for all hot-swap devices, IMHO.

I believe it is software requests only. The hw can notify the os, _if_ the os has a driver catching the notification. So you'll probably need some part of USB loaded or compiled in to catch the notification. The various devices may the be loaded as the kernel or some userspace daemon parses the request and ask for the module.

Or you can skip this and load the device when a program want to open it, instead of when it is plugged in. You'll simply get an error if the device isn't there.

Helge Hafting
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/