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

Kernel Recipes 2019 - XDP closer integration with network stack
Kernel Recipes 2019 -  XDP closer integration with network stackKernel Recipes 2019 -  XDP closer integration with network stack
Kernel Recipes 2019 - XDP closer integration with network stackAnne Nicolas
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchlinuxlab_conf
 
Linux Networking Explained
Linux Networking ExplainedLinux Networking Explained
Linux Networking ExplainedThomas Graf
 
VLANs in the Linux Kernel
VLANs in the Linux KernelVLANs in the Linux Kernel
VLANs in the Linux KernelKernel TLV
 
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
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecturehugo lu
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver艾鍗科技
 
Static partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VStatic partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VRISC-V International
 
Linux MMAP & Ioremap introduction
Linux MMAP & Ioremap introductionLinux MMAP & Ioremap introduction
Linux MMAP & Ioremap introductionGene Chang
 
Kernel Process Management
Kernel Process ManagementKernel Process Management
Kernel Process Managementpradeep_tewani
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device driversHoucheng Lin
 
Soc architecture and design
Soc architecture and designSoc architecture and design
Soc architecture and designSatya Harish
 
SR-IOV: The Key Enabling Technology for Fully Virtualized HPC Clusters
SR-IOV: The Key Enabling Technology for Fully Virtualized HPC ClustersSR-IOV: The Key Enabling Technology for Fully Virtualized HPC Clusters
SR-IOV: The Key Enabling Technology for Fully Virtualized HPC ClustersGlenn K. Lockwood
 
LAS16-200: SCMI - System Management and Control Interface
LAS16-200:  SCMI - System Management and Control InterfaceLAS16-200:  SCMI - System Management and Control Interface
LAS16-200: SCMI - System Management and Control InterfaceLinaro
 

What's hot (20)

Kernel Recipes 2019 - XDP closer integration with network stack
Kernel Recipes 2019 -  XDP closer integration with network stackKernel Recipes 2019 -  XDP closer integration with network stack
Kernel Recipes 2019 - XDP closer integration with network stack
 
Board Bringup
Board BringupBoard Bringup
Board Bringup
 
Spi drivers
Spi driversSpi drivers
Spi drivers
 
SPI Drivers
SPI DriversSPI Drivers
SPI Drivers
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
 
Linux Networking Explained
Linux Networking ExplainedLinux Networking Explained
Linux Networking Explained
 
VLANs in the Linux Kernel
VLANs in the Linux KernelVLANs in the Linux Kernel
VLANs in the Linux Kernel
 
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
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver
 
Static partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VStatic partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-V
 
Linux MMAP & Ioremap introduction
Linux MMAP & Ioremap introductionLinux MMAP & Ioremap introduction
Linux MMAP & Ioremap introduction
 
Kernel Process Management
Kernel Process ManagementKernel Process Management
Kernel Process Management
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
 
Linux Network Stack
Linux Network StackLinux Network Stack
Linux Network Stack
 
Soc architecture and design
Soc architecture and designSoc architecture and design
Soc architecture and design
 
SR-IOV: The Key Enabling Technology for Fully Virtualized HPC Clusters
SR-IOV: The Key Enabling Technology for Fully Virtualized HPC ClustersSR-IOV: The Key Enabling Technology for Fully Virtualized HPC Clusters
SR-IOV: The Key Enabling Technology for Fully Virtualized HPC Clusters
 
LAS16-200: SCMI - System Management and Control Interface
LAS16-200:  SCMI - System Management and Control InterfaceLAS16-200:  SCMI - System Management and Control Interface
LAS16-200: SCMI - System Management and Control Interface
 
I2C Drivers
I2C DriversI2C Drivers
I2C Drivers
 
I2c drivers
I2c driversI2c drivers
I2c drivers
 

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
 
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
 
Share point 2013’s distributed cache service 6.0 (1)
Share point 2013’s distributed cache service 6.0 (1)Share point 2013’s distributed cache service 6.0 (1)
Share point 2013’s distributed cache service 6.0 (1)Hexaware Technologies
 

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
 
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
 
Share point 2013’s distributed cache service 6.0 (1)
Share point 2013’s distributed cache service 6.0 (1)Share point 2013’s distributed cache service 6.0 (1)
Share point 2013’s distributed cache service 6.0 (1)
 

More from SysPlay eLearning Academy for You (18)

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
 
Linux System
Linux SystemLinux System
Linux System
 

Recently uploaded

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
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
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
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
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 

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?