2
Most read
6
Most read
8
Most read
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Linux DMA Engine
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
What to Expect
●
DMA Controllers
●
Types of DMA Transfers
●
Linux DMA Engine API
●
Steps for DMA Transfer
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
DMA Controllers
Descriptor Buffer
DMA Controller
Device Controller
FIFO
Request
Line
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Contiguous Memory DMA
Device Controller
RAM
FIFO
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Scatter Gather DMA
Device Controller
RAM
FIFO
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Scatter Gather Descriptors
Source
Destination
Size
Configuration
Next
Source
Destination
Size
Configuration
Next
Source
Destination
Size
Configuration
Next
Interrupt
Interrupt Interrupt
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Cyclic Transfers
Source
Destination
Size
Configuration
Next
Source
Destination
Size
Configuration
Next
Source
Destination
Size
Configuration
Next
Interrupt
Interrupt Interrupt
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
DMA Controller with Peripherals
RAM
SPI
Controller
Audio
Controller
Network
Controller
Buffer Buffer Buffer
DMA Controller
FIFO FIFO FIFO
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Linux DMA Engine
●
The DMA Engine driver works as a layer on the top of
SoC (e.g. TI) specific DMA driver using the slave DMA
API
●
Drivers using the DMA Engine are referred to as a
clients
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Linux DMA Engine...
Kernel
SoC DMA Driver
DMA Engine Driver
Device Specific Driver
Applicaton
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Steps in DMA Transfer
Allocate a
DMA slave
channel
Set Slave &
controller
specific
params
Get a
Descriptor for
the
transaction
Submit the
transaction to
queue it in the
DMA
Start the
Transaction
Wait for it to
complete
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
DMA Channel
●
Header: include/linux/dmaengine.h
●
Data Structure:
struct dma_chan {
struct dma_device;
dma_cookie_t cookie;
chan_id;
client_count;
table_count;
}
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Allocate a DMA Channel
●
Header: include/linux/dmaengine.h
●
APIs:
dma_caps_set(transaction_type, mask);
struct dma_chan
*dma_request_slave_channel(struct device *dev,
const char *name);
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Allocate a DMA Channel Example
●
Set up the capabilities for the channel that will
be requested
dma_cap_mask_t mask;
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE | DMA_PRIVATE,
mask);
Request the DMA channel from the DMA
engine
chan = dma_request_channel(mask, NULL, NULL);
Release the DMA channel
dma_release_channel(chan);
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Set DMA Slave & Controller Params
●
DMA slave channel runtime configuration
Data Structure:
struct dma_slave_config {
enum dma_transfer_direction direction;
dma_addr_t src_addr;
dma_addr_t dst_addr;
enum dma_slave_buswidth src_addr_width;
enum dma_slave_buswidth dst_addr_width;
u32 src_maxburst;
u32 dst_maxburst;
bool device_fc;
unsigned int slave_id;
};
API: dmaengine_slave_config(dma_channel, dma_slave_config *);
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Set Controller Params Examples
struct dma_slave_config cfg;
cfg.src_addr = OMAP2_MCSPI_RX0;
cfg.dst_addr = OMAP2_MCSPI_TX0;
cfg.src_addr_width = width;
cfg.dst_addr_width = width;
cfg.src_maxburst = burst;
cfg.dst_maxburst = burst;
dmaengine_slave_config(dma_channel, cfg);
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Prepare the Descriptor
●
Descriptor is used to describe a DMA transaction
●
struct dma_async_tx_descriptor
*dmaengine_prep_slave_single(parameters);
Parameters:
struct dma_chan *chan
dma_addr_t buff
size_t len
enum dma_transfer_direction dir
unsigned long flags
DMA_PREPARE_INTERRUPT, DMA_CTRL_ACK
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Prepare a Descriptor & Setting the Callback Example
●
Allocate a 1K buffer of cached contiguous memory
char *buf = kmalloc(1024, GFP_KERNEL | GFP_DMA);
Get the physical address for the buffer
dma_buf = dma_map_single(device, buf, 1024,
DMA_TO_DEVICE);
Prepare the descriptor for the DMA transaction
Enum dma_ctrl_flags flags = DMA_CTRL_ACK |
DMA_PREP_INTERRUPT;
chan_des = dma_engine_prep_slave_single(chan, dma_buf,
1024, DMA_MEM_TO_DEV, flags);
Set up the callback function for the descriptor
chan_des->callback = <callback when the transfer completes>;
chan_des->callback_param = cmp;
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Submit & Start the Transaction
●
The dmaengine_submit() function submits the
descriptor to the DMA engine to be put into the
pending queue
The returned cookie can be used to check the progress
The dma_sync_issue_pending() function is used to
start the DMA transaction that was previously put in
pending queue
If the channel is idle, then the first transaction in queue is
started and the subsequent transactions are queued up
On completion of each in queue, the next in queue is
started and a tasklet is triggered. The tasklet will then call
the client driver completion callback routine for notification,
if set
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
What all have we learnt?
●
DMA Controllers
●
Types of DMA Transfers
●
Linux DMA Engine API
●
Steps for DMA Transfer
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
References
●
<kernel src tree>/Documentation/dmaengine/
client.txt
External Video Reference
https://www.xilinx.com/video/soc/linux-dma-in-device-driver
s.html
@ 2021-22 Embitude Trainings <info@embitude.in>
All Rights Reserved
Any Queries?

More Related Content

PDF
Spi drivers
PPTX
Linux Initialization Process (2)
PPTX
Linux MMAP & Ioremap introduction
PDF
Arm device tree and linux device drivers
PDF
I2c drivers
PDF
Kernel Process Management
Spi drivers
Linux Initialization Process (2)
Linux MMAP & Ioremap introduction
Arm device tree and linux device drivers
I2c drivers
Kernel Process Management

What's hot (20)

PDF
I2C Subsystem In Linux-2.6.24
PPTX
Linux Kernel Booting Process (1) - For NLKB
PPTX
Linux kernel debugging
PPT
Linux kernel memory allocators
PDF
Network Drivers
PDF
Character drivers
PDF
Introduction to Linux Drivers
PPTX
U-Boot presentation 2013
PDF
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
PDF
BusyBox for Embedded Linux
PPT
Basic Linux Internals
PDF
Linux Internals - Part II
PDF
Linux Kernel - Virtual File System
PPTX
Slab Allocator in Linux Kernel
PDF
spinlock.pdf
PDF
Network Programming: Data Plane Development Kit (DPDK)
PDF
Embedded Linux Kernel - Build your custom kernel
PDF
Process Address Space: The way to create virtual address (page table) of user...
PDF
Memory Mapping Implementation (mmap) in Linux Kernel
ODP
Linux Internals - Kernel/Core
I2C Subsystem In Linux-2.6.24
Linux Kernel Booting Process (1) - For NLKB
Linux kernel debugging
Linux kernel memory allocators
Network Drivers
Character drivers
Introduction to Linux Drivers
U-Boot presentation 2013
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
BusyBox for Embedded Linux
Basic Linux Internals
Linux Internals - Part II
Linux Kernel - Virtual File System
Slab Allocator in Linux Kernel
spinlock.pdf
Network Programming: Data Plane Development Kit (DPDK)
Embedded Linux Kernel - Build your custom kernel
Process Address Space: The way to create virtual address (page table) of user...
Memory Mapping Implementation (mmap) in Linux Kernel
Linux Internals - Kernel/Core
Ad

Similar to Linux dma engine (20)

PDF
DMA_document__1696148675.pdf
PPTX
PDF
DMA.pdf
PPT
1 STM32's DMA.ppt
PDF
Module 3 special purpose programmable devices and their interfacing
PPT
Direct Memory Access (DMA).ppt
PPTX
Direct Memory Access (DMA) PRA.1233.pptx
ODP
Direct Memory Access (DMA)-Working and Implementation
PPTX
Direct Memory Access
PPTX
Lecture 5.pptx
PPTX
Steen_Dissertation_March5
PDF
mtcawsc2019_marjanovic_pcie_xilinx_and_fpga_tool
PPTX
I/O Interfaces: Bridging the Digital and Physical Worlds
PPTX
3.Direct-Memory-Access-DMA-Overview.pptx
PPTX
Direct Memory Access(DMA).pptx ppt ppt ppt
PPTX
DMA information of microprocessor.Shows how it performs
PPTX
Aryan_camemoryhierchyandmanagements.pptx
PPTX
DMA presentation [By- Digvijay]
PPTX
PPTX
Direct memory access (dma)
DMA_document__1696148675.pdf
DMA.pdf
1 STM32's DMA.ppt
Module 3 special purpose programmable devices and their interfacing
Direct Memory Access (DMA).ppt
Direct Memory Access (DMA) PRA.1233.pptx
Direct Memory Access (DMA)-Working and Implementation
Direct Memory Access
Lecture 5.pptx
Steen_Dissertation_March5
mtcawsc2019_marjanovic_pcie_xilinx_and_fpga_tool
I/O Interfaces: Bridging the Digital and Physical Worlds
3.Direct-Memory-Access-DMA-Overview.pptx
Direct Memory Access(DMA).pptx ppt ppt ppt
DMA information of microprocessor.Shows how it performs
Aryan_camemoryhierchyandmanagements.pptx
DMA presentation [By- Digvijay]
Direct memory access (dma)
Ad

Recently uploaded (20)

PDF
Guide to Food Delivery App Development.pdf
PDF
Internet Download Manager IDM Crack powerful download accelerator New Version...
PPTX
Computer Software - Technology and Livelihood Education
PDF
AI-Powered Fuzz Testing: The Future of QA
PDF
MiniTool Power Data Recovery 12.6 Crack + Portable (Latest Version 2025)
PPTX
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
PDF
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
PPTX
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
PDF
E-Commerce Website Development Companyin india
PPTX
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
PPTX
string python Python Strings: Literals, Slicing, Methods, Formatting, and Pra...
PDF
Sun and Bloombase Spitfire StoreSafe End-to-end Storage Security Solution
PDF
AI Guide for Business Growth - Arna Softech
PPTX
Chapter 1 - Transaction Processing and Mgt.pptx
PPTX
Presentation by Samna Perveen And Subhan Afzal.pptx
PPTX
Full-Stack Developer Courses That Actually Land You Jobs
PPTX
Plex Media Server 1.28.2.6151 With Crac5 2022 Free .
PPTX
HackYourBrain__UtrechtJUG__11092025.pptx
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
PPT
3.Software Design for software engineering
Guide to Food Delivery App Development.pdf
Internet Download Manager IDM Crack powerful download accelerator New Version...
Computer Software - Technology and Livelihood Education
AI-Powered Fuzz Testing: The Future of QA
MiniTool Power Data Recovery 12.6 Crack + Portable (Latest Version 2025)
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
E-Commerce Website Development Companyin india
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
string python Python Strings: Literals, Slicing, Methods, Formatting, and Pra...
Sun and Bloombase Spitfire StoreSafe End-to-end Storage Security Solution
AI Guide for Business Growth - Arna Softech
Chapter 1 - Transaction Processing and Mgt.pptx
Presentation by Samna Perveen And Subhan Afzal.pptx
Full-Stack Developer Courses That Actually Land You Jobs
Plex Media Server 1.28.2.6151 With Crac5 2022 Free .
HackYourBrain__UtrechtJUG__11092025.pptx
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
3.Software Design for software engineering

Linux dma engine

  • 1. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Linux DMA Engine
  • 2. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved What to Expect ● DMA Controllers ● Types of DMA Transfers ● Linux DMA Engine API ● Steps for DMA Transfer
  • 3. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved DMA Controllers Descriptor Buffer DMA Controller Device Controller FIFO Request Line
  • 4. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Contiguous Memory DMA Device Controller RAM FIFO
  • 5. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Scatter Gather DMA Device Controller RAM FIFO
  • 6. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Scatter Gather Descriptors Source Destination Size Configuration Next Source Destination Size Configuration Next Source Destination Size Configuration Next Interrupt Interrupt Interrupt
  • 7. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Cyclic Transfers Source Destination Size Configuration Next Source Destination Size Configuration Next Source Destination Size Configuration Next Interrupt Interrupt Interrupt
  • 8. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved DMA Controller with Peripherals RAM SPI Controller Audio Controller Network Controller Buffer Buffer Buffer DMA Controller FIFO FIFO FIFO
  • 9. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Linux DMA Engine ● The DMA Engine driver works as a layer on the top of SoC (e.g. TI) specific DMA driver using the slave DMA API ● Drivers using the DMA Engine are referred to as a clients
  • 10. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Linux DMA Engine... Kernel SoC DMA Driver DMA Engine Driver Device Specific Driver Applicaton
  • 11. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Steps in DMA Transfer Allocate a DMA slave channel Set Slave & controller specific params Get a Descriptor for the transaction Submit the transaction to queue it in the DMA Start the Transaction Wait for it to complete
  • 12. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved DMA Channel ● Header: include/linux/dmaengine.h ● Data Structure: struct dma_chan { struct dma_device; dma_cookie_t cookie; chan_id; client_count; table_count; }
  • 13. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Allocate a DMA Channel ● Header: include/linux/dmaengine.h ● APIs: dma_caps_set(transaction_type, mask); struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name);
  • 14. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Allocate a DMA Channel Example ● Set up the capabilities for the channel that will be requested dma_cap_mask_t mask; dma_cap_zero(mask); dma_cap_set(DMA_SLAVE | DMA_PRIVATE, mask); Request the DMA channel from the DMA engine chan = dma_request_channel(mask, NULL, NULL); Release the DMA channel dma_release_channel(chan);
  • 15. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Set DMA Slave & Controller Params ● DMA slave channel runtime configuration Data Structure: struct dma_slave_config { enum dma_transfer_direction direction; dma_addr_t src_addr; dma_addr_t dst_addr; enum dma_slave_buswidth src_addr_width; enum dma_slave_buswidth dst_addr_width; u32 src_maxburst; u32 dst_maxburst; bool device_fc; unsigned int slave_id; }; API: dmaengine_slave_config(dma_channel, dma_slave_config *);
  • 16. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Set Controller Params Examples struct dma_slave_config cfg; cfg.src_addr = OMAP2_MCSPI_RX0; cfg.dst_addr = OMAP2_MCSPI_TX0; cfg.src_addr_width = width; cfg.dst_addr_width = width; cfg.src_maxburst = burst; cfg.dst_maxburst = burst; dmaengine_slave_config(dma_channel, cfg);
  • 17. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Prepare the Descriptor ● Descriptor is used to describe a DMA transaction ● struct dma_async_tx_descriptor *dmaengine_prep_slave_single(parameters); Parameters: struct dma_chan *chan dma_addr_t buff size_t len enum dma_transfer_direction dir unsigned long flags DMA_PREPARE_INTERRUPT, DMA_CTRL_ACK
  • 18. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Prepare a Descriptor & Setting the Callback Example ● Allocate a 1K buffer of cached contiguous memory char *buf = kmalloc(1024, GFP_KERNEL | GFP_DMA); Get the physical address for the buffer dma_buf = dma_map_single(device, buf, 1024, DMA_TO_DEVICE); Prepare the descriptor for the DMA transaction Enum dma_ctrl_flags flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT; chan_des = dma_engine_prep_slave_single(chan, dma_buf, 1024, DMA_MEM_TO_DEV, flags); Set up the callback function for the descriptor chan_des->callback = <callback when the transfer completes>; chan_des->callback_param = cmp;
  • 19. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Submit & Start the Transaction ● The dmaengine_submit() function submits the descriptor to the DMA engine to be put into the pending queue The returned cookie can be used to check the progress The dma_sync_issue_pending() function is used to start the DMA transaction that was previously put in pending queue If the channel is idle, then the first transaction in queue is started and the subsequent transactions are queued up On completion of each in queue, the next in queue is started and a tasklet is triggered. The tasklet will then call the client driver completion callback routine for notification, if set
  • 20. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved What all have we learnt? ● DMA Controllers ● Types of DMA Transfers ● Linux DMA Engine API ● Steps for DMA Transfer
  • 21. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved References ● <kernel src tree>/Documentation/dmaengine/ client.txt External Video Reference https://www.xilinx.com/video/soc/linux-dma-in-device-driver s.html
  • 22. @ 2021-22 Embitude Trainings <[email protected]> All Rights Reserved Any Queries?