SlideShare a Scribd company logo
1 of 23
© 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

What's hot

XPDS16: Keeping coherency on ARM - Julien Grall, ARM
XPDS16: Keeping coherency on ARM - Julien Grall, ARMXPDS16: Keeping coherency on ARM - Julien Grall, ARM
XPDS16: Keeping coherency on ARM - Julien Grall, ARMThe Linux Foundation
 
Linux SD/MMC device driver
Linux SD/MMC device driverLinux SD/MMC device driver
Linux SD/MMC device driver艾鍗科技
 
Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCKernel TLV
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelDivye Kapoor
 
The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageKernel TLV
 
Linux on ARM 64-bit Architecture
Linux on ARM 64-bit ArchitectureLinux on ARM 64-bit Architecture
Linux on ARM 64-bit ArchitectureRyo Jin
 
Linux kernel memory allocators
Linux kernel memory allocatorsLinux kernel memory allocators
Linux kernel memory allocatorsHao-Ran Liu
 
Virtualization Support in ARMv8+
Virtualization Support in ARMv8+Virtualization Support in ARMv8+
Virtualization Support in ARMv8+Aananth C N
 
Linux 4.x Tracing: Performance Analysis with bcc/BPF
Linux 4.x Tracing: Performance Analysis with bcc/BPFLinux 4.x Tracing: Performance Analysis with bcc/BPF
Linux 4.x Tracing: Performance Analysis with bcc/BPFBrendan Gregg
 
DPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet ProcessingDPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet ProcessingMichelle Holley
 
Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020
Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020
Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020Eric Lin
 
RISC-V Boot Process: One Step at a Time
RISC-V Boot Process: One Step at a TimeRISC-V Boot Process: One Step at a Time
RISC-V Boot Process: One Step at a TimeAtish Patra
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Andriy Berestovskyy
 
twlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsotwlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsoViller Hsiao
 
DPDK in Containers Hands-on Lab
DPDK in Containers Hands-on LabDPDK in Containers Hands-on Lab
DPDK in Containers Hands-on LabMichelle Holley
 

What's hot (20)

XPDS16: Keeping coherency on ARM - Julien Grall, ARM
XPDS16: Keeping coherency on ARM - Julien Grall, ARMXPDS16: Keeping coherency on ARM - Julien Grall, ARM
XPDS16: Keeping coherency on ARM - Julien Grall, ARM
 
I2C Drivers
I2C DriversI2C Drivers
I2C Drivers
 
Linux Network Stack
Linux Network StackLinux Network Stack
Linux Network Stack
 
Dpdk applications
Dpdk applicationsDpdk applications
Dpdk applications
 
Linux SD/MMC device driver
Linux SD/MMC device driverLinux SD/MMC device driver
Linux SD/MMC device driver
 
Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCC
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
Spi drivers
Spi driversSpi drivers
Spi drivers
 
The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast Storage
 
Linux on ARM 64-bit Architecture
Linux on ARM 64-bit ArchitectureLinux on ARM 64-bit Architecture
Linux on ARM 64-bit Architecture
 
Linux kernel memory allocators
Linux kernel memory allocatorsLinux kernel memory allocators
Linux kernel memory allocators
 
Ixgbe internals
Ixgbe internalsIxgbe internals
Ixgbe internals
 
Virtualization Support in ARMv8+
Virtualization Support in ARMv8+Virtualization Support in ARMv8+
Virtualization Support in ARMv8+
 
Linux 4.x Tracing: Performance Analysis with bcc/BPF
Linux 4.x Tracing: Performance Analysis with bcc/BPFLinux 4.x Tracing: Performance Analysis with bcc/BPF
Linux 4.x Tracing: Performance Analysis with bcc/BPF
 
DPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet ProcessingDPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet Processing
 
Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020
Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020
Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020
 
RISC-V Boot Process: One Step at a Time
RISC-V Boot Process: One Step at a TimeRISC-V Boot Process: One Step at a Time
RISC-V Boot Process: One Step at a Time
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)
 
twlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsotwlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdso
 
DPDK in Containers Hands-on Lab
DPDK in Containers Hands-on LabDPDK in Containers Hands-on Lab
DPDK in Containers Hands-on Lab
 

Similar to Linux DMA Engine

An Oracle approach to the Taxi Fare problem
An Oracle approach to the Taxi Fare problemAn Oracle approach to the Taxi Fare problem
An Oracle approach to the Taxi Fare problemJose Rodríguez
 
IBM Notes Traveler Best Practices
IBM Notes Traveler Best PracticesIBM Notes Traveler Best Practices
IBM Notes Traveler Best Practicesjayeshpar2006
 
Open mic on ibm notes traveler best practices
Open mic on ibm notes traveler best practicesOpen mic on ibm notes traveler best practices
Open mic on ibm notes traveler best practicesa8us
 
Detecting Silent Data Corruptions using Linux DMA Debug API
Detecting Silent Data Corruptions using Linux DMA Debug APIDetecting Silent Data Corruptions using Linux DMA Debug API
Detecting Silent Data Corruptions using Linux DMA Debug APISamsung Open Source Group
 
IBM Streams V4.1 Integration with IBM Platform Symphony
IBM Streams V4.1 Integration with IBM Platform SymphonyIBM Streams V4.1 Integration with IBM Platform Symphony
IBM Streams V4.1 Integration with IBM Platform Symphonylisanl
 
A d swincc03_create_project_pt
A d swincc03_create_project_ptA d swincc03_create_project_pt
A d swincc03_create_project_ptconfidencial
 
SAP HANA SPS10- SAP HANA Platform Lifecycle Management
SAP HANA SPS10- SAP HANA Platform Lifecycle ManagementSAP HANA SPS10- SAP HANA Platform Lifecycle Management
SAP HANA SPS10- SAP HANA Platform Lifecycle ManagementSAP Technology
 
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdf
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdfBOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdf
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdfMichaelOLeary82
 
Shared Memory Communications-Direct Memory Access (SMC-D) Overview
Shared Memory Communications-Direct Memory Access (SMC-D) OverviewShared Memory Communications-Direct Memory Access (SMC-D) Overview
Shared Memory Communications-Direct Memory Access (SMC-D) OverviewzOSCommserver
 
November 2012 (New Tuner Admin feature)
November 2012 (New Tuner Admin feature)November 2012 (New Tuner Admin feature)
November 2012 (New Tuner Admin feature)CM-UG.com
 
Trouble shooting apachecloudstack
Trouble shooting apachecloudstackTrouble shooting apachecloudstack
Trouble shooting apachecloudstackSailaja Sunil
 
Help, My Kafka is Broken! (Emma Humber & Gantigmaa Selenge, IBM) Kafka Summit...
Help, My Kafka is Broken! (Emma Humber & Gantigmaa Selenge, IBM) Kafka Summit...Help, My Kafka is Broken! (Emma Humber & Gantigmaa Selenge, IBM) Kafka Summit...
Help, My Kafka is Broken! (Emma Humber & Gantigmaa Selenge, IBM) Kafka Summit...HostedbyConfluent
 
Building Hadoop-as-a-Service with Pivotal Hadoop Distribution, Serengeti, & I...
Building Hadoop-as-a-Service with Pivotal Hadoop Distribution, Serengeti, & I...Building Hadoop-as-a-Service with Pivotal Hadoop Distribution, Serengeti, & I...
Building Hadoop-as-a-Service with Pivotal Hadoop Distribution, Serengeti, & I...EMC
 
Troubleshooting Apache Cloudstack
Troubleshooting Apache CloudstackTroubleshooting Apache Cloudstack
Troubleshooting Apache CloudstackRadhika Puthiyetath
 
Fast Kafka Apps! (Edoardo Comar and Mickael Maison, IBM) Kafka Summit London ...
Fast Kafka Apps! (Edoardo Comar and Mickael Maison, IBM) Kafka Summit London ...Fast Kafka Apps! (Edoardo Comar and Mickael Maison, IBM) Kafka Summit London ...
Fast Kafka Apps! (Edoardo Comar and Mickael Maison, IBM) Kafka Summit London ...confluent
 
SAP (in)security: Scrubbing SAP clean with SOAP
SAP (in)security: Scrubbing SAP clean with SOAPSAP (in)security: Scrubbing SAP clean with SOAP
SAP (in)security: Scrubbing SAP clean with SOAPChris John Riley
 
Strategy and best practice for modern RPG
Strategy and best practice for modern RPGStrategy and best practice for modern RPG
Strategy and best practice for modern RPGAlemanalfredo
 
Helm Charts Security 101
Helm Charts Security 101Helm Charts Security 101
Helm Charts Security 101Deep Datta
 

Similar to Linux DMA Engine (20)

An Oracle approach to the Taxi Fare problem
An Oracle approach to the Taxi Fare problemAn Oracle approach to the Taxi Fare problem
An Oracle approach to the Taxi Fare problem
 
IBM Notes Traveler Best Practices
IBM Notes Traveler Best PracticesIBM Notes Traveler Best Practices
IBM Notes Traveler Best Practices
 
Open mic on ibm notes traveler best practices
Open mic on ibm notes traveler best practicesOpen mic on ibm notes traveler best practices
Open mic on ibm notes traveler best practices
 
Detecting Silent Data Corruptions using Linux DMA Debug API
Detecting Silent Data Corruptions using Linux DMA Debug APIDetecting Silent Data Corruptions using Linux DMA Debug API
Detecting Silent Data Corruptions using Linux DMA Debug API
 
IBM Streams V4.1 Integration with IBM Platform Symphony
IBM Streams V4.1 Integration with IBM Platform SymphonyIBM Streams V4.1 Integration with IBM Platform Symphony
IBM Streams V4.1 Integration with IBM Platform Symphony
 
A d swincc03_create_project_pt
A d swincc03_create_project_ptA d swincc03_create_project_pt
A d swincc03_create_project_pt
 
SAP HANA SPS10- SAP HANA Platform Lifecycle Management
SAP HANA SPS10- SAP HANA Platform Lifecycle ManagementSAP HANA SPS10- SAP HANA Platform Lifecycle Management
SAP HANA SPS10- SAP HANA Platform Lifecycle Management
 
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdf
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdfBOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdf
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdf
 
Camunda BPM 7.13 Webinar
Camunda BPM 7.13 WebinarCamunda BPM 7.13 Webinar
Camunda BPM 7.13 Webinar
 
Shared Memory Communications-Direct Memory Access (SMC-D) Overview
Shared Memory Communications-Direct Memory Access (SMC-D) OverviewShared Memory Communications-Direct Memory Access (SMC-D) Overview
Shared Memory Communications-Direct Memory Access (SMC-D) Overview
 
November 2012 (New Tuner Admin feature)
November 2012 (New Tuner Admin feature)November 2012 (New Tuner Admin feature)
November 2012 (New Tuner Admin feature)
 
Trouble shooting apachecloudstack
Trouble shooting apachecloudstackTrouble shooting apachecloudstack
Trouble shooting apachecloudstack
 
Stackato Presentation Techzone 2013
Stackato Presentation Techzone 2013Stackato Presentation Techzone 2013
Stackato Presentation Techzone 2013
 
Help, My Kafka is Broken! (Emma Humber & Gantigmaa Selenge, IBM) Kafka Summit...
Help, My Kafka is Broken! (Emma Humber & Gantigmaa Selenge, IBM) Kafka Summit...Help, My Kafka is Broken! (Emma Humber & Gantigmaa Selenge, IBM) Kafka Summit...
Help, My Kafka is Broken! (Emma Humber & Gantigmaa Selenge, IBM) Kafka Summit...
 
Building Hadoop-as-a-Service with Pivotal Hadoop Distribution, Serengeti, & I...
Building Hadoop-as-a-Service with Pivotal Hadoop Distribution, Serengeti, & I...Building Hadoop-as-a-Service with Pivotal Hadoop Distribution, Serengeti, & I...
Building Hadoop-as-a-Service with Pivotal Hadoop Distribution, Serengeti, & I...
 
Troubleshooting Apache Cloudstack
Troubleshooting Apache CloudstackTroubleshooting Apache Cloudstack
Troubleshooting Apache Cloudstack
 
Fast Kafka Apps! (Edoardo Comar and Mickael Maison, IBM) Kafka Summit London ...
Fast Kafka Apps! (Edoardo Comar and Mickael Maison, IBM) Kafka Summit London ...Fast Kafka Apps! (Edoardo Comar and Mickael Maison, IBM) Kafka Summit London ...
Fast Kafka Apps! (Edoardo Comar and Mickael Maison, IBM) Kafka Summit London ...
 
SAP (in)security: Scrubbing SAP clean with SOAP
SAP (in)security: Scrubbing SAP clean with SOAPSAP (in)security: Scrubbing SAP clean with SOAP
SAP (in)security: Scrubbing SAP clean with SOAP
 
Strategy and best practice for modern RPG
Strategy and best practice for modern RPGStrategy and best practice for modern RPG
Strategy and best practice for modern RPG
 
Helm Charts Security 101
Helm Charts Security 101Helm Charts Security 101
Helm Charts Security 101
 

More from SysPlay eLearning Academy for You

More from SysPlay eLearning Academy for You (19)

Linux Internals Part - 3
Linux Internals Part - 3Linux Internals Part - 3
Linux Internals Part - 3
 
Linux Internals Part - 2
Linux Internals Part - 2Linux Internals Part - 2
Linux Internals Part - 2
 
Linux Internals Part - 1
Linux Internals Part - 1Linux Internals Part - 1
Linux Internals Part - 1
 
Kernel Timing Management
Kernel Timing ManagementKernel Timing Management
Kernel Timing Management
 
Understanding the BBB
Understanding the BBBUnderstanding the BBB
Understanding the BBB
 
POSIX Threads
POSIX ThreadsPOSIX Threads
POSIX Threads
 
Cache Management
Cache ManagementCache Management
Cache Management
 
SPI Drivers
SPI DriversSPI Drivers
SPI Drivers
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
Introduction to BeagleBone Black
Introduction to BeagleBone BlackIntroduction to BeagleBone Black
Introduction to BeagleBone Black
 
Introduction to BeagleBoard-xM
Introduction to BeagleBoard-xMIntroduction to BeagleBoard-xM
Introduction to BeagleBoard-xM
 
Platform Drivers
Platform DriversPlatform Drivers
Platform Drivers
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
BeagleBone Black Booting Process
BeagleBone Black Booting ProcessBeagleBone Black Booting Process
BeagleBone Black Booting Process
 
BeagleBoard-xM Bootloaders
BeagleBoard-xM BootloadersBeagleBoard-xM Bootloaders
BeagleBoard-xM Bootloaders
 
BeagleBoard-xM Booting Process
BeagleBoard-xM Booting ProcessBeagleBoard-xM Booting Process
BeagleBoard-xM Booting Process
 
Serial Drivers
Serial DriversSerial Drivers
Serial Drivers
 
SPI Drivers
SPI DriversSPI Drivers
SPI Drivers
 
Linux System
Linux SystemLinux System
Linux System
 

Recently uploaded

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Recently uploaded (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Linux DMA Engine

  • 1. © 2019 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Linux DMA Engine
  • 2. 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. 3© 2019 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. DMA Controllers Descriptor Buffer DMA Controller Device Controller FIFO Request Line
  • 4. 4© 2019 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Contiguous Memory DMA Device Controller RAM FIFO
  • 5. 5© 2019 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Device Controller RAM Scatter Gather DMA FIFO
  • 6. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 23© 2019 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Any Queries?