Automotive Hardware · Memory and I/O
Direct Memory AccessDMA
Also known as DMA controller, DMA engine, bus mastering
A mechanism that lets peripherals or dedicated DMA engines transfer data between devices and memory without the CPU copying each word, freeing the CPU and enabling high-bandwidth I/O such as camera, network and storage traffic.
Explanation
The CPU sets up a transfer by giving source, destination, length and direction, and the DMA engine or bus-mastering device carries it out, signalling completion with an interrupt. Microcontrollers use DMA for ADC sampling and serial or CAN communication; SoCs rely on it for camera frames, Ethernet packets, PCIe and accelerator buffers.
The Linux kernel's DMA documentation explains why drivers must not hand CPU virtual addresses to devices: devices use bus (DMA) addresses, which an IOMMU may translate and which may cover only part of memory. Drivers use coherent mappings for long-lived buffers shared with a device and streaming mappings for individual transfers, with explicit synchronisation whenever the CPU accesses a streaming buffer between transfers.
On systems whose caches are not DMA-coherent, cache maintenance is required to avoid stale data, and DMA buffers should not share cache lines with other data. DMA also needs security attention: without an IOMMU, a faulty or malicious device can read or overwrite arbitrary memory.
How it works
A driver allocates or maps a buffer to obtain its DMA address, writes descriptors (address, length, flags) into a ring that the device reads, and starts the transfer. The device reads or writes memory directly while caches are cleaned or invalidated as required. On completion the device raises an interrupt, and the driver unmaps or synchronises the buffer before passing the data to software.
Automotive applications
- Camera frame capture into memory
- Ethernet and CAN message buffering
- ADC sampling for motor control
- Feeding data to accelerators
Example
A camera receiver writes each frame into a ring of DMA buffers. The driver maps them once as streaming buffers, synchronises each buffer for CPU access after the frame-complete interrupt, and passes it to the image signal processor, so the CPU never copies pixel data.
An illustrative example: any figures in it are worked numbers, not measurements.
References
- Dynamic DMA mapping Guide (opens in a new tab)
“From a device's point of view, DMA uses the bus address space, but it may be restricted to a subset of that space.”
Definitions are original summaries. Standards text is not reproduced; follow the links for the official publications.