SlideShare a Scribd company logo
8
Most read
15
Most read
18
Most read
© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Linux DMA Engine
2© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What to Expect?
DMA Controllers
Types of DMA Transfers
Linux DMA Engine API
Steps for DMA Transfer
3© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
DMA Controllers
Descriptor Buffer
DMA Controller
Device Controller
FIFO
Request
Line
4© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Contiguous Memory DMA
Device Controller
RAM
FIFO
5© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Device Controller
RAM
Scatter Gather DMA
FIFO
6© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Scatter Gather Descriptors
Source
Destination
Size
Configuration
Next
Source
Destination
Size
Configuration
Next
Source
Destination
Size
Configuration
Next
End
Interrupt
7© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Cyclic Transfers
Source
Destination
Size
Configuration
Next
Source
Destination
Size
Configuration
Next
Source
Destination
Size
Configuration
Next
InterruptInterrupt Interrupt
8© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
DMA Controller with Peripherals
RAM
SPI
Controller
Audio
Controller
Network
Controller
Buffer Buffer Buffer
DMA Controller
FIFO FIFO FIFO
9© 2019 SysPlay Workshops <workshop@sysplay.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
The reason its called as slave is due to the fact that
software initiates the DMA transactions to the DMA
controller hardware rather than a hardware device
with a integrated DMA initiating the transfer
Drivers using the DMA Engine are referred to as
a clients
10© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Kernel
Linux DMA Engine...
SoC DMA Driver
DMA Engine Driver
Device Specific Driver
Applicaton
11© 2019 SysPlay Workshops <workshop@sysplay.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
12© 2019 SysPlay Workshops <workshop@sysplay.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;
}
13© 2019 SysPlay Workshops <workshop@sysplay.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);
14© 2019 SysPlay Workshops <workshop@sysplay.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);
15© 2019 SysPlay Workshops <workshop@sysplay.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 *);
16© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Set Controller Params Example
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© 2019 SysPlay Workshops <workshop@sysplay.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
18© 2019 SysPlay Workshops <workshop@sysplay.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;
19© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Submit & Start the DMA 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© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Submit & Start the Transaction
Submit the descriptor to DMA engine
dma_cookie_t dmaengine_submit(struct
dma_async_tx_descriptor *desc);
Start the transaction
dma_async_issue_pending(struct dma_chan *chan);
21© 2019 SysPlay Workshops <workshop@sysplay.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-
drivers.html
22© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What all have we learnt?
DMA Controllers
Types of DMA Transfers
Linux DMA Engine API
Steps for DMA Transfer
23© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Any Queries?

More Related Content

PDF
Linux dma engine
pradeep_tewani
 
PPTX
Linux Kernel MMC Storage driver Overview
RajKumar Rampelli
 
PPTX
Linux SD/MMC device driver
艾鍗科技
 
PPT
Linux SD/MMC Driver Stack
Champ Yen
 
PDF
Kernel Recipes 2018 - Overview of SD/eMMC, their high speed modes and Linux s...
Anne Nicolas
 
PPTX
Linux MMAP & Ioremap introduction
Gene Chang
 
PPTX
Linux Kernel Booting Process (2) - For NLKB
shimosawa
 
PPTX
Linux Initialization Process (1)
shimosawa
 
Linux dma engine
pradeep_tewani
 
Linux Kernel MMC Storage driver Overview
RajKumar Rampelli
 
Linux SD/MMC device driver
艾鍗科技
 
Linux SD/MMC Driver Stack
Champ Yen
 
Kernel Recipes 2018 - Overview of SD/eMMC, their high speed modes and Linux s...
Anne Nicolas
 
Linux MMAP & Ioremap introduction
Gene Chang
 
Linux Kernel Booting Process (2) - For NLKB
shimosawa
 
Linux Initialization Process (1)
shimosawa
 

What's hot (20)

PDF
The Linux Block Layer - Built for Fast Storage
Kernel TLV
 
PPTX
eMMC Embedded Multimedia Card overview
VijayGESYS
 
PPTX
Linux I2C
KaidenYu
 
PPTX
Understanding DPDK algorithmics
Denys Haryachyy
 
PPT
Linux memory
ericrain911
 
PDF
Decompressed vmlinux: linux kernel initialization from page table configurati...
Adrian Huang
 
PDF
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
Adrian Huang
 
PPTX
The TCP/IP Stack in the Linux Kernel
Divye Kapoor
 
PPTX
Linux Initialization Process (2)
shimosawa
 
PPTX
Slab Allocator in Linux Kernel
Adrian Huang
 
PDF
Memory Mapping Implementation (mmap) in Linux Kernel
Adrian Huang
 
PDF
Page cache in Linux kernel
Adrian Huang
 
PPTX
eMMC 5.0 Total IP Solution
Arasan Chip Systems
 
PDF
Sd sdio specsv1
borderj
 
PPTX
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
Adrian Huang
 
PPTX
Linux kernel debugging
Hao-Ran Liu
 
PPTX
Linux Memory Management
Ni Zo-Ma
 
PDF
Spi drivers
pradeep_tewani
 
PDF
Linux Kernel - Virtual File System
Adrian Huang
 
PDF
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
Adrian Huang
 
The Linux Block Layer - Built for Fast Storage
Kernel TLV
 
eMMC Embedded Multimedia Card overview
VijayGESYS
 
Linux I2C
KaidenYu
 
Understanding DPDK algorithmics
Denys Haryachyy
 
Linux memory
ericrain911
 
Decompressed vmlinux: linux kernel initialization from page table configurati...
Adrian Huang
 
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
Adrian Huang
 
The TCP/IP Stack in the Linux Kernel
Divye Kapoor
 
Linux Initialization Process (2)
shimosawa
 
Slab Allocator in Linux Kernel
Adrian Huang
 
Memory Mapping Implementation (mmap) in Linux Kernel
Adrian Huang
 
Page cache in Linux kernel
Adrian Huang
 
eMMC 5.0 Total IP Solution
Arasan Chip Systems
 
Sd sdio specsv1
borderj
 
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
Adrian Huang
 
Linux kernel debugging
Hao-Ran Liu
 
Linux Memory Management
Ni Zo-Ma
 
Spi drivers
pradeep_tewani
 
Linux Kernel - Virtual File System
Adrian Huang
 
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
Adrian Huang
 
Ad

Similar to Linux DMA Engine (20)

PPTX
DMA
vipinkmenon
 
PDF
DMA_document__1696148675.pdf
madhav590273
 
PPTX
I/O Management
Keyur Vadodariya
 
PPTX
UNIT-6_OShhshshshshshshshshzbsbsbbsbsbsbsbsbsbsbsnsñjsshsjsjsjsjsjsjjsjsjsjs....
rpampaniya07
 
PPTX
I/O Interfaces: Bridging the Digital and Physical Worlds
Green University of Bangladesh
 
PPTX
Direct Memory Access ppt
OECLIB Odisha Electronics Control Library
 
PPT
07 input output
Sher Shah Merkhel
 
PDF
A transfer from I/O device to memory requires the execution of several instru...
rsaravanakumar13
 
PPT
1 STM32's DMA.ppt
MdRayhanTanvir
 
PDF
Module 3 special purpose programmable devices and their interfacing
Deepak John
 
PPTX
This pot is about computer architecture.
SurendranathReddyNar
 
PDF
Computer architecture
Nguyen Le Hung Nguyen
 
PPT
07_Input Output_Computer Architecture.ppt
fairuzahmed13579
 
PDF
mtcawsc2019_marjanovic_pcie_xilinx_and_fpga_tool
MohammedEladawy4
 
PPTX
Direct memory access (dma)
Zubair Khalid
 
PPT
07 input output
dilip kumar
 
PDF
ITFT_Device management in Operating System
Sneh Prabha
 
PDF
DMA.pdf
Divanshkumar2
 
PPT
Chapter 6 input output
risal07
 
PPTX
Lecture 9.pptx
JavedIqbal549896
 
DMA_document__1696148675.pdf
madhav590273
 
I/O Management
Keyur Vadodariya
 
UNIT-6_OShhshshshshshshshshzbsbsbbsbsbsbsbsbsbsbsnsñjsshsjsjsjsjsjsjjsjsjsjs....
rpampaniya07
 
I/O Interfaces: Bridging the Digital and Physical Worlds
Green University of Bangladesh
 
07 input output
Sher Shah Merkhel
 
A transfer from I/O device to memory requires the execution of several instru...
rsaravanakumar13
 
1 STM32's DMA.ppt
MdRayhanTanvir
 
Module 3 special purpose programmable devices and their interfacing
Deepak John
 
This pot is about computer architecture.
SurendranathReddyNar
 
Computer architecture
Nguyen Le Hung Nguyen
 
07_Input Output_Computer Architecture.ppt
fairuzahmed13579
 
mtcawsc2019_marjanovic_pcie_xilinx_and_fpga_tool
MohammedEladawy4
 
Direct memory access (dma)
Zubair Khalid
 
07 input output
dilip kumar
 
ITFT_Device management in Operating System
Sneh Prabha
 
DMA.pdf
Divanshkumar2
 
Chapter 6 input output
risal07
 
Lecture 9.pptx
JavedIqbal549896
 
Ad

More from SysPlay eLearning Academy for You (20)

PDF
Linux Internals Part - 3
SysPlay eLearning Academy for You
 
PDF
Linux Internals Part - 2
SysPlay eLearning Academy for You
 
PDF
Linux Internals Part - 1
SysPlay eLearning Academy for You
 
PDF
Kernel Timing Management
SysPlay eLearning Academy for You
 
PDF
Understanding the BBB
SysPlay eLearning Academy for You
 
PDF
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
 
PDF
Introduction to BeagleBone Black
SysPlay eLearning Academy for You
 
PDF
Introduction to BeagleBoard-xM
SysPlay eLearning Academy for You
 
PDF
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
 
PDF
BeagleBone Black Booting Process
SysPlay eLearning Academy for You
 
PDF
BeagleBoard-xM Bootloaders
SysPlay eLearning Academy for You
 
PDF
BeagleBoard-xM Booting Process
SysPlay eLearning Academy for You
 
Linux Internals Part - 3
SysPlay eLearning Academy for You
 
Linux Internals Part - 2
SysPlay eLearning Academy for You
 
Linux Internals Part - 1
SysPlay eLearning Academy for You
 
Kernel Timing Management
SysPlay eLearning Academy for You
 
Understanding the BBB
SysPlay eLearning Academy for You
 
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
 
Introduction to BeagleBone Black
SysPlay eLearning Academy for You
 
Introduction to BeagleBoard-xM
SysPlay eLearning Academy for You
 
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
 
BeagleBone Black Booting Process
SysPlay eLearning Academy for You
 
BeagleBoard-xM Bootloaders
SysPlay eLearning Academy for You
 
BeagleBoard-xM Booting Process
SysPlay eLearning Academy for You
 

Recently uploaded (20)

PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PPT
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
PDF
Software Development Company | KodekX
KodekX
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
This slide provides an overview Technology
mineshkharadi333
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
Software Development Company | KodekX
KodekX
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
This slide provides an overview Technology
mineshkharadi333
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Software Development Methodologies in 2025
KodekX
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 

Linux DMA Engine

  • 1. © 2019 SysPlay Workshops <[email protected]> All Rights Reserved. Linux DMA Engine
  • 2. 2© 2019 SysPlay Workshops <[email protected]> All Rights Reserved. What to Expect? DMA Controllers Types of DMA Transfers Linux DMA Engine API Steps for DMA Transfer
  • 3. 3© 2019 SysPlay Workshops <[email protected]> All Rights Reserved. DMA Controllers Descriptor Buffer DMA Controller Device Controller FIFO Request Line
  • 4. 4© 2019 SysPlay Workshops <[email protected]> All Rights Reserved. Contiguous Memory DMA Device Controller RAM FIFO
  • 5. 5© 2019 SysPlay Workshops <[email protected]> All Rights Reserved. Device Controller RAM Scatter Gather DMA FIFO
  • 6. 6© 2019 SysPlay Workshops <[email protected]> All Rights Reserved. Scatter Gather Descriptors Source Destination Size Configuration Next Source Destination Size Configuration Next Source Destination Size Configuration Next End Interrupt
  • 7. 7© 2019 SysPlay Workshops <[email protected]> All Rights Reserved. Cyclic Transfers Source Destination Size Configuration Next Source Destination Size Configuration Next Source Destination Size Configuration Next InterruptInterrupt Interrupt
  • 8. 8© 2019 SysPlay Workshops <[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. 9© 2019 SysPlay Workshops <[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 The reason its called as slave is due to the fact that software initiates the DMA transactions to the DMA controller hardware rather than a hardware device with a integrated DMA initiating the transfer Drivers using the DMA Engine are referred to as a clients
  • 10. 10© 2019 SysPlay Workshops <[email protected]> All Rights Reserved. Kernel Linux DMA Engine... SoC DMA Driver DMA Engine Driver Device Specific Driver Applicaton
  • 11. 11© 2019 SysPlay Workshops <[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. 12© 2019 SysPlay Workshops <[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. 13© 2019 SysPlay Workshops <[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. 14© 2019 SysPlay Workshops <[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. 15© 2019 SysPlay Workshops <[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. 16© 2019 SysPlay Workshops <[email protected]> All Rights Reserved. Set Controller Params Example 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. 17© 2019 SysPlay Workshops <[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. 18© 2019 SysPlay Workshops <[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. 19© 2019 SysPlay Workshops <[email protected]> All Rights Reserved. Submit & Start the DMA 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. 20© 2019 SysPlay Workshops <[email protected]> All Rights Reserved. Submit & Start the Transaction Submit the descriptor to DMA engine dma_cookie_t dmaengine_submit(struct dma_async_tx_descriptor *desc); Start the transaction dma_async_issue_pending(struct dma_chan *chan);
  • 21. 21© 2019 SysPlay Workshops <[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- drivers.html
  • 22. 22© 2019 SysPlay Workshops <[email protected]> All Rights Reserved. What all have we learnt? DMA Controllers Types of DMA Transfers Linux DMA Engine API Steps for DMA Transfer
  • 23. 23© 2019 SysPlay Workshops <[email protected]> All Rights Reserved. Any Queries?