An Overview of the DMAEngine Subsystem

Similar documents
Bringing display and 3D to the C.H.I.P computer

Bringing display and 3D to the C.H.I.P computer

Supporting a new ARM platform: the Allwinner example

Supporting a new ARM platform: the Allwinner example

Modernizing the NAND framework: The big picture

Free Electrons Company profile Kernel, drivers, embedded Linux and Android development, consulting, training and support

ARM support in the Linux kernel

ARM support in the Linux kernel

I/O Handling. ECE 650 Systems Programming & Engineering Duke University, Spring Based on Operating Systems Concepts, Silberschatz Chapter 13

I + I2C = I3C, what s hiding in this additional I

Ethernet switch support in the Linux kernel

Understand your NAND and drive it within Linux

SpiNNaker Application Programming Interface (API)

Two years of ARM SoC support mainlining: lessons learned

Accelerated Library Framework for Hybrid-x86

Operating Systems 2010/2011

Device Tree as a stable ABI: a fairy tale?

SMP bring up on ARM SoCs

The Journey of an I/O request through the Block Layer

Linux Device Drivers: Case Study of a Storage Controller. Manolis Marazakis FORTH-ICS (CARV)

Kernel maintainership: an oral tradition

Rootfs made easy with Buildroot

UC Santa Barbara. Operating Systems. Christopher Kruegel Department of Computer Science UC Santa Barbara

EFM32 Series 0: DMA (ARM PrimeCell µdma PL230)

Chap. 3. Input/Output

Lecture Topics. Announcements. Today: Operating System Overview (Stallings, chapter , ) Next: Processes (Stallings, chapter

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 09, SPRING 2013

Operating System: Chap13 I/O Systems. National Tsing-Hua University 2016, Fall Semester

Writing drivers for the Linux Crypto subsystem

CSE 4/521 Introduction to Operating Systems. Lecture 24 I/O Systems (Overview, Application I/O Interface, Kernel I/O Subsystem) Summer 2018

Chapter-6. SUBJECT:- Operating System TOPICS:- I/O Management. Created by : - Sanjay Patel

CS2506 Quick Revision

CSE380 - Operating Systems. Communicating with Devices

The Kernel Abstraction

Ben Walker Data Center Group Intel Corporation

[08] IO SUBSYSTEM 1. 1

Memory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts

An Introduction to SPI-NOR Subsystem. By Vignesh R Texas Instruments India

I/O Devices. Nima Honarmand (Based on slides by Prof. Andrea Arpaci-Dusseau)

CSE 4/521 Introduction to Operating Systems. Lecture 12 Main Memory I (Background, Swapping) Summer 2018

Embedded Linux kernel and driver development training 5-day session

RA3 - Cortex-A15 implementation

I/O Design, I/O Subsystem, I/O-Handler Device Driver, Buffering, Disks, RAID January WT 2008/09

Chapter 8: Memory-Management Strategies

Events, Memory Management

I/O SYSTEMS. Sunu Wibirama

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

CHAPTER 8: MEMORY MANAGEMENT. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Signals, Synchronization. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han

X10 specific Optimization of CPU GPU Data transfer with Pinned Memory Management

Chapter 8: Main Memory. Operating System Concepts 9 th Edition

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

What is an Operating System? A Whirlwind Tour of Operating Systems. How did OS evolve? How did OS evolve?

Chapter 8: Main Memory

CSE 380 Computer Operating Systems

OP-TEE Using TrustZone to Protect Our Own Secrets

Memory Mapped I/O. Michael Jantz. Prasad Kulkarni. EECS 678 Memory Mapped I/O Lab 1

CSCE Introduction to Computer Systems Spring 2019

Chapter 5 - Input / Output

Today: I/O Systems. Architecture of I/O Systems

SCSI is often the best choice of bus for high-specification systems. It has many advantages over IDE, these include:

Chapter 8: Main Memory

Accelerating Storage with NVM Express SSDs and P2PDMA Stephen Bates, PhD Chief Technology Officer

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Chapter 8: Memory- Management Strategies

QEMU Backup. Maxim Nestratov, Virtuozzo Vladimir Sementsov-Ogievskiy, Virtuozzo

CIS Operating Systems Memory Management Cache and Demand Paging. Professor Qiang Zeng Spring 2018

GPUDIRECT: INTEGRATING THE GPU WITH A NETWORK INTERFACE DAVIDE ROSSETTI, SW COMPUTE TEAM

EMBEDDED TRAINING IN BANGALORE

Network device drivers in Linux

A tour of the ARM architecture and its Linux support

Announcement. Exercise #2 will be out today. Due date is next Monday

Background. Contiguous Memory Allocation

CSE 120 Principles of Operating Systems

BlazePPS (Blaze Packet Processing System) CSEE W4840 Project Design

Introduction. CS3026 Operating Systems Lecture 01

CIS Operating Systems Memory Management Cache. Professor Qiang Zeng Fall 2017

Generic Buffer Sharing Mechanism for Mediated Devices

FPGA Manager. State of the Union. Moritz Fischer, National Instruments

The University of the West Indies, St. Augustine INFO 2603 Platform Technologies /2018 Semester 1 Lab 1 - Wednesday 13th September 2017

Groking the Linux SPI Subsystem FOSDEM Matt Porter

Memory Management. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory

Adding a Second Ethernet Driver to NET+OS

6.9. Communicating to the Outside World: Cluster Networking

Welcome to this presentation of the STM32 direct memory access controller (DMA). It covers the main features of this module, which is widely used to

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

QUESTION BANK UNIT I

Ausgewählte Betriebssysteme - Mark Russinovich & David Solomon (used with permission of authors)

Engineer-to-Engineer Note

GCMA: Guaranteed Contiguous Memory Allocator. SeongJae Park

-Device. -Physical or virtual thing that does something -Software + hardware to operate a device (Controller runs port, Bus, device)

Process Time. Steven M. Bellovin January 25,

I/O Hardwares. Some typical device, network, and data base rates

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission 1

<Insert Picture Here> DIF, DIX and Linux Data Integrity

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

Multichannel DMA API User s Guide

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

CIS Operating Systems I/O Systems & Secondary Storage. Professor Qiang Zeng Fall 2017

<Insert Picture Here> Linux Data Integrity

Transcription:

Embedded Linux Conference 2015 An Overview of the DMAEngine Subsystem Maxime Ripard maxime@bootlin.com Copyright 2004-2018, Bootlin. Creative Commons BY-SA 3.0 license. embedded Linux and kernel engineering Corrections, suggestions, contributions and translations are welcome! - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 1/1

Maxime Ripard Embedded Linux engineer and trainer at Bootlin Embedded Linux development: kernel and driver development, system integration, boot time and power consumption optimization, consulting, etc. Embedded Linux training, Linux driver development training and Android system development training, with materials freely available under a Creative Commons license. http://bootlin.com Contributions Kernel support for the sunxi SoCs from Allwinner Contributor to few open-source projects, Buildroot, an open-source, simple and fast embedded Linux build system, Barebox, a modern bootloader. Living in Toulouse, south west of France - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 2/1

An Overview of the DMAEngine Subsystem Introduction - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 3/1

Device DMA vs... - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 4/1

... DMA Controllers - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 5/1

Transfer Width - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 6/1

Burst Size - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 7/1

Scatter Gather - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 8/1

Scatter Gather Descriptors - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 9/1

Cyclic Transfers - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 10/1

Realistic DMA Controller - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 11/1

An Overview of the DMAEngine Subsystem Linux Support - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 12/1

APIs DMAEngine Merged in 2006, in 2.6.18 Subsystem to handle memory-to-device transfers Async TX Merged in 2007, in 2.6.23 Initially part of the raid5 code to support the XScale offload engines Subsystem to handle memory to memory operations (memcpy, XOR, etc.) Implemented on top of dmaengine, but takes many shortcuts, instead of being a real client. - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 13/1

Slave consumer API 1. Request a channel: dma_request_channel, or one of its variants 2. Configure the channel for our use: dmaengine_slave_config 3. Get a transaction descriptor for our transfer: dmaengine_prep_* 4. Put the transaction in the driver pending queue: dmaengine_submit 5. Issue pending requests (blocks and calls back your driver to give an update on the transfer status): dmaengine_issue_pending - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 14/1

An Overview of the DMAEngine Subsystem Slave Controller Drivers - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 15/1

struct dma_device and its Fields DMAEngine, like any framework, relies on a structure you have to fill with various pieces of information in order to do its job properly. Mostly: channels Initialized list of the channels supported by the driver, of the size of the number of channels supported by your driver * align Alignment in bytes for the Async TX buffers - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 16/1

DMA Transfer Types 1/2 The next step is to set which transfer types your driver supports This is done through the function dma_cap_set, which takes various flags as an argument: DMA_MEMCPY Memory to memory copy DMA_SG Memory to memory scatter gather DMA_INTERLEAVE Memory to memory interleaved transfer DMA_XOR Memory to memory XOR DMA_XOR_VAL Memory buffer parity check using XOR - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 17/1

DMA Transfer Types 2/2 DMA_PQ Memory to memory P+Q computation DMA_PQ_VAL Memory buffer parity check using P+Q DMA_INTERRUPT The device is able to generate a dummy transfer that will generate interrupts DMA_SLAVE Memory to device transfers DMA_CYCLIC The device is able to handle cyclic transfers - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 18/1

Weird Transfer Types DMA_PRIVATE Async TX doesn t go through dma_request_channel but circumvents it, and just starts using any random channel it can. It does so unless you set this flag DMA_ASYNC_TX Set by the core when you support all Async TX transfer types Used only if ASYNC_TX_ENABLE_CHANNEL_SWITCH is enabled Used by dma_find_channel, which is a non-exclusive equivalent of dma_request_channel, used only by Async TX - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 19/1

Channels Resources Allocation device_alloc_chan_resources and device_free_chan_resources Called by the framework when your channel is first requested Allows to allocate custom resources for your channel, and free them when you re done Optional (since 3.20) - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 20/1

Transaction Descriptor Retrieval Functions device_prep_dma_* Optional, but have to match the transfer types you declared Should create both the software descriptor, for Linux and clients to identify the transfer, and the hardware descriptor matching it for the dma controller. Should also ensure that the parameters of this transfer match what the driver supports - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 21/1

Submitting Pending Jobs device_issue_pending Should take the first descriptor of the transaction and start it Should go through all the descriptors in the list, notifying the client using an optional callback of the status of the transfer - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 22/1

Transfer Status Reporting device_tx_status Reports the current state of a given transaction descriptor Does so using the dma_set_residue function, and returns only a flag saying whether it s done or in progress. This is where the granularity we used earlier comes into action. - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 23/1

Channel configuration device_control Takes an additional flag, to give the type of control to do on the channel DMA_PAUSE Pause a given channel DMA_RESUME Resume a given channel DMA_TERMINATE_ALL Aborts all transfers on a given channel DMA_SLAVE_CONFIG Configures a given channel with new parameters - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 24/1

Capabilities device_slave_caps Returns various pieces of information about the controller Can the transfer be paused? terminated? Which transfer widths are supported? Which slave directions are supported? Used by generic layers to get an idea of what the device they re going to use is capable of (only ASoC so far) - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 25/1

An Overview of the DMAEngine Subsystem Recent Developments - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 26/1

Generic Capabilities (3.20) Removal of device_slave_caps, and moved the logic in the framework Introduction of new variables in struct dma_device * width Bitmask of supported transfer width, both as source and destination directions Bitmask of the supported slave directions (memory to device, device to memory, device to device) granularity Granularity of the transfer residue your controller can provide: bursts, chunks or descriptors Split of the device_control function in four independent functions: device_config, device_pause, device_resume, device_terminate_all - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 27/1

Scheduled DMA Many DMA controllers have more requests than channels These drivers usually have all the scheduling code Plus, every driver has a lot of administrative code, that is not trivial to get right (callback deferral, allocation of the descriptors, etc.), yet similar from one driver to another Scheduled DMA framework abstracts away most of it, and only a few things remain in the drivers: Interrupt management LLI related functions (iterators, configuration, etc.) Scheduling hints Channel management (pause, resume, residues, etc.) - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 28/1

Questions? Suggestions? Comments? Maxime Ripard maxime@bootlin.com Slides under CC-BY-SA 3.0 http://bootlin.com/pub/conferences/2015/elc/ripard-dmaengine - Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 29/1