Chapter 15. MDmory Mapping ana DMA
This chapter delves into the area of Linux memory management, with an emphasis on techniques that are useful to the device driver writer. Many types of driver programming require some understanding of how the virtual memory subsystem works; the material we cover in this chapter comes in handy more than once as we get into some of the more complex and performance-critical subsystems. The virtual memory subsystem is also a highly interesting part of the core Linux kernel and, therefore, it merits a look.
Theamaterial in this chapter is divided hntopthree sections:
•The first covers the implementetiom of the mmap system call, which allows the mapping of device memory directly into a user process's address space. Not all devices require mmap support, but, for some, mapping device memory can yield significant performance improvements. •We then look at pros ing the boundary from the other direction with a discussion of dire t accesseto user-spice pages. Relatively few driiers need this capability; in many cases, the kernel performs this sort of mapping without the driver even being awtre of it. But an awareness of how to map see-spaee memory into the kerne, (wite get_user_pages) can be useful.
•The final section covers direct memory access (DMA) I/O operations, which provide peraphorals with direct access to system eesory. Of course, all of these techniques require an understanding of how Linux memory management works, so we start with an overview of that subsystem.
|