Porting device drivers to the 2.6 kernel
The 2.6 kernel contains a long list of changes which affect device driver
writers. As part of the task of porting the Linux Device
Drivers sample code to 2.6, your humble LWN Kernel Page author is
producing a set of articles describing the changes which must be made.
The articles are Kernel Page as they are written; they will also be
collected here. With luck, this page will be a useful reference for those
who must port drivers to the new kernel.
The creation of these articles is funded by LWN.net subscribers. If you find this material useful, please consider subscribing to LWN to help ensure that more of it gets written.
Except when otherwise specified, all of the articles below are written by LWN editor Jonathan Corbet. The date and kernel version attached to each article notes when the article was last updated.
Recent changesThe most recent changes to this series are:
Getting startedPorting 'hello world' (February, 2003); which covers the changes required to update the simplest possible module to the 2.5 kernel.
Compiling external modules (November, 2003; 2.6.0-test9); how to build modules with the new module loader and kernel build scheme.
More module changes (November, 2003, 2.6.0-test9) covers other changes to the module loading subsystem, including module parameters, use count management, exporting symbols, and more.
Miscellaneous changes is a collection point for changes which are too small to justify their own article. Currently covered topics include kdev_t, designated initializers, and min() and max(). It was last updated on November 3, 2003 (2.6.0-test9).
Support interfacesChar drivers and large dev_t (November 2003, 2.6.0-test9); registration and management of char drivers in the new, large dev_t environment.
The seq_file interface (September 2003; 2.6.0-test6); the easy way to implement virtual files correctly. A standalone example module is provided to demonstrate the use of this interface.
Low-level memory allocation (November, 2003; 2.6.0-test9); changes to functions for allocating chunks of memory and pages, and a description of the new mempool interface.
Per-CPU variables (November, 2003; 2.6.0-test9); the 2.6 interface for maintaining per-CPU data structures.
Timekeeping changes (November, 2003; 2.6.0-test9); changes to how the kernel manages time and time-related events.
The workqueue interface (November, 2003; 2.6.0-test9); a description of the new deferred execution mechanism which replaces task queues (and bottom halves in general).
Creating virtual filesystems with libfs (November, 2003; 2.6.0-test9). This article, which looks at how a kernel module can create its own virtual filesystem, predates the driver porting series but fits in well with it.
Sleeping and mutual exclusionMutual exclusion with seqlocks (November, 2003, 2.6.0-test9); a description of how to use the seqlock (formerly frlock) capability which was merged into 2.5.60.
The preemptible kernel (November, 2003; 2.6.0-test9); a look at how kernel preemption affects driver code and what can be done to work safely in the preemptible environment.
Sleeping and waking up (November, 2003; 2.6.0-test9); new ways of putting processes to sleep with better performance and without race conditions.
Completion events (November, 2003; 2.6.0-test9); documentation for the completion event mechanism.
Using read-copy-update (November, 2003; 2.6.0-test9); working with the read-copy-update mutual exclusion scheme.
Advanced driver tasksDealing with interrupts (January, 2004; 2.6.1-rc2); interrupt handling changes which are visible to device drivers.
Supporting asynchronous I/O (November, 2003; 2.6.0-test9); how to write drivers which support the 2.6 asynchronous I/O interface.
Network drivers (November 2003, 2.6.0-test9); porting network drivers, with an emphasis on the new dynamic net_device allocation functions and NAPI support.
USB driver API changes (July 2003; 2.5.75); how USB drivers have changed in the 2.5 development series. This article was contributed by USB maintainer Greg Kroah-Hartman.
Block driversBlock layer overview (November, 2003; 2.6.0-test9). The block layer has seen extensive changes in the 2.5 development series; this article gives an overview of what has been done while deferring the details for subsequent articles.
A simple block driver (November, 2003; 2.6.0-test9); this article presents the simplest possible block driver (a basic ramdisk implementation) with discussion of how the basic block interfaces have changed in 2.6. Full source to a working driver is included.
The gendisk interface (November, 2003; 2.6.0-test9); how to work with the new generic disk interface, which takes on a rather larger role in 2.6.
The BIO structure (November, 2003; 2.6.0-test9); the new low-level structure representing block I/O operations.
Request queues I (November, 2003; 2.6.0-test9); the basics of block request queues in 2.6, including request processing, request preparation control, and DMA support.
Request queues II (November, 2003, 2.6.0-test9); advanced request queue topics, including command preparation, tagged command queueing, and the "make request" mode of operation.
Memory managementSupporting mmap() (January, 2004 - 2.6.1-rc2); changes in how device drivers support the mmap() system call.
Zero-copy user-space access (November, 2003 - 2.6.0-test9); how to get direct-access to user space to perform zero-copy I/O. If you used the kiobuf interface for this purpose in 2.4, you'll want to look here for the 2.6 equivalent.
Atomic kmaps (November, 2003; 2.6.0-test9); quick access to high-memory via kmap_atomic().
Device modelA device model overview (November, 2003; 2.6.0-test10); an introductory look at the Linux device model and sysfs, with definitions of some commonly encountered terms.
The zen of kobjects (October, 2003; 2.6.0-test6); an attempt to demystify the kobject abstraction and its use in the kernel.
kobjects and sysfs (October, 2003; 2.6.0-test8); a description of the interaction between the kobject type and its representation in sysfs.
kobjects and hotplug events (October, 2003; 2.6.0-test6); an explanation of the kset hotplug operations and how they can be used to control how hotplug events are reported to user space. This article was written by Greg Kroah-Hartman.
Examining a kobject hierarchy (October, 2003; 2.6.0-test9); a visual exploration of the device model data structures behind /sys/block.
Device classes (November, 2003; 2.6.0-test10); how the device class mechanism works.