How the PCI Hot Plug Driver Filesystem Works

Greg describes how the PCI Hot Plug core implements a RAM-based filesystem and how you can do the same for your drivers.
Acknowledgements

I would like to thank Pat Mochel for writing the ddfs/driverfs code upon which a lot of the pcihpfs code was originally based. driverfs is a new filesystem in the 2.5 kernel that will also help driver authors in exporting driver-specific information into user space, as well as provide a tree of all devices, making power management tools much easier.

I would also like to thank Al Viro for answering a lot of VFS-related questions and for enabling a filesystem to be written with such a small amount of code.

Resources

Greg Kroah-Hartman is currently the Linux USB and PCI Hot Plug kernel maintainer. He works for IBM, doing various Linux kernel-related things and can be reached at greg@kroah.com.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: How the PCI Hot Plug Driver Filesystem Works

Anonymous's picture

How do users mount the pcihpfs mount? Where is it located?

Re: How the PCI Hot Plug Driver Filesystem Works

gregkh's picture

To answer the second question first, it can be mounted where ever you want to.

To mount the filesystem do the following:

mount -t pcihpfs none /place/to/mount/pci_hotplug_filesystem

Re: How the PCI Hot Plug Driver Filesystem Works

tho_x_tran's picture

First, I've just switched from Unix to Linux and willing to be educated. So please bear with my comments. Many systems that support Hot Plug PCI probably will have Doorbells and Latches. A hot plug operation on such a system should mostly be automatic, all user has to do is to insert the new card.

For such a system, I guess there should be some kind of a PCI hot-plug daemon running to intercept the "event" and does many things under the nose of the user.

Re: How the PCI Hot Plug Driver Filesystem Works

gregkh's picture

Yes, the individual PCI Hotplug drivers have a thread that watches to see if a latch has been opened or closed. If it changes state, it then goes through the power up (or down) sequence automatically, without user interaction.

Hope this helps.

Re: How the PCI Hot Plug Driver Filesystem Works

Anonymous's picture

Why goe to all the effort to write a new virtual filesystem. procfs was created a long time ago and can do everything you have created.

Is this not reinventing the wheel and making the kernel larger?

Re: How the PCI Hot Plug Driver Filesystem Works

gregkh's picture

procfs is a mess and it is not recommended to put new files into it.

As for making the kernel larger, in the 2.5 kernel, the libfs code that is already present, caused almost all of the filesystem specific code in pci_hotplug_core.c to go away, with only the PCI hotplug specific portions remaining. So there would not be any size savings by using procfs.

Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

Upcoming Webinar
8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
11am CDT, April 29th
Moderated by Linux Journal Contributor Mike Diehl

Sign up now

Sponsored by Skybot