Direct Memory Access

Direct Memory Access, or DMA, is the advanced topic that completes our overview of memory issues. DMA is the hardware mechanism that allows peripheral components to transfer their I/O data directly to and from main memory, without the need for the system processor to be involved in the transfer.

To exploit the DMA capabilities of its hardware, the device driver needs to be able to correctly set up the DMA transfer and synchronize with the hardware. Unfortunately, because of its hardware nature, DMA is very system-dependent. Each architecture has its own techniques to manage DMA transfers, and the programming interface is different for each. The kernel can’t offer a unified interface, either, because a driver can’t abstract too much from the underlaying hardware mechanisms. In this chapter, I describe how DMA works with ISA devices and PCI peripherals, as these are currently the most common peripheral interface architectures.

However, I won’t go into much detail about ISA. The ISA implementation of DMA is unnecessarily complicated and not often used in modern peripherals. Nowadays, the ISA bus is used mainly for dumb peripheral interfaces, as hardware manufacturers who need DMA capability tend to use the PCI bus.

Overview of a DMA Data Transfer

Before introducing the programming details, let’s review how a DMA transfer takes place, considering only input transfers to simplify the discussion.

Data transfer can be triggered in two ways: either the software asks ...

Get Linux Device Drivers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.