Skip to content

Day99 - Linux DMA Engine Framework

Goal

Understand the overall architecture of the Linux DMA Engine Framework before learning individual DMA APIs and controller implementations.

The objective of this lab is to become familiar with:

  • DMA subsystem organization
  • DMA Engine Framework
  • DMA controller drivers
  • Public DMA Engine APIs
  • Linux kernel source layout

No driver implementation is required in this lab.


Lab Environment

  • Raspberry Pi 5
  • Raspberry Pi OS (64-bit)
  • Linux Kernel Source
  • Terminal

Lab 1 - Explore DMA Controller Drivers

Objective

Explore the DMA controller drivers supported by Linux.

Procedure

List all DMA controller drivers.

cd <linux-kernel>

ls drivers/dma

Expected Observation

Examples:

drivers/dma/

bcm2835-dma.c
pl330.c
dw/
idxd/
xilinx/
...

Each driver corresponds to one hardware DMA controller implementation.


Lab 2 - Explore DMA Engine Users

Objective

Find kernel drivers that use the DMA Engine Framework.

Procedure

Search for DMA channel allocation.

grep -R "dma_request_chan" drivers

Expected Observation

The API is used by many subsystems, including:

  • SPI
  • MMC
  • UART
  • IIO
  • Media
  • Audio
  • Networking

This demonstrates that the DMA Engine Framework is shared across multiple client drivers.


Lab 3 - Explore Public DMA APIs

Objective

Locate the public DMA Engine interface.

Procedure

Open:

include/linux/dmaengine.h

Locate the following objects:

struct dma_device;
struct dma_chan;
struct dma_async_tx_descriptor;

Also locate common DMA Engine APIs.

Examples:

dma_request_chan()

dmaengine_submit()

dma_async_issue_pending()

dma_release_channel()

The purpose of this lab is only to recognize the available interfaces.


Lab 4 - Explore DMA Engine Framework

Objective

Locate the DMA Engine Framework implementation.

Procedure

Open:

drivers/dma/dmaengine.c

Observe that this file implements the generic DMA Engine Framework rather than any hardware-specific controller.

Do not study the implementation details yet.


Lab 5 - Explore DMA Controller Drivers

Objective

Compare the DMA Engine Framework with hardware-specific implementations.

Procedure

Open one DMA controller driver.

Examples:

drivers/dma/bcm2835-dma.c

or

drivers/dma/pl330.c

Observe that these drivers interact directly with DMA controller registers and hardware resources.

Unlike dmaengine.c, these files contain controller-specific implementations.


Summary

In this lab, we explored the overall organization of the Linux DMA subsystem.

The key takeaway is that Linux separates DMA support into three layers:

Client Driver
DMA Engine Framework
DMA Controller Driver

Client drivers interact only with the DMA Engine Framework.

The framework provides a common programming interface, while individual DMA controller drivers handle hardware-specific operations.

Future labs will gradually explore channel allocation, descriptors, transactions, callbacks, and DMA controller internals.