Difference between revisions of "Dmaengine overview"
[unchecked revision] | [quality revision] |
m (→System overview)
|
m (→System overview)
|
This article provides basic information about the DMA engine and how STM32 DMA, DMAMUX and MDMA drivers are plugged into it.
Contents
1 Framework purpose[edit]
This article provides basic information about the DMA framework. However it is worth browsing the Kernel documentation related to DMA concept[1].
The direct memory access (DMA) is a feature that allows some hardware subsystems to access memory independently from the central processing unit (CPU).
The DMA can transfer data between peripherals and memory or between memory and memory.
2 System overview[edit]

2.1 Component description[edit]
- Peripheral DMA client drivers:
DMA clients are drivers that are mapped on the DMA API[2].
- DMA engine:
The DMA engine is the engine core on which all clients rely.
Refer to DMA provider[1] for useful information on DMA internal behaviour.
- Virtual DMA channel support:
The virtual DMA channel support manages virtual DMA channels and DMA requests queues. This layer is no used by DMA clients.
- STM32 xDMA driver:
The STM32 xDMA driver is used to develop the DMA engine API.
- STM32 DMAMUX driver:
The STM32 DMAMUX driver request multiplexer allows routing DMA request lines between the device peripherals and the DMA controllers.
- DMAMUX, DMA and MDMA IP controller:
This is the STM32 DMA controller that handles data transfers between peripherals and memories or memory and memory connected to the same bus.
DMAMUX (DMA request router): DMAMUX internal peripheral
DMA: DMA internal peripheral
MDMA : MDMA internal peripheral
- Peripheral clients:
Peripheral clients are peripherals where at least one DMA request line is mapped on DMAMUX.
- Memories:
Memories can be either internal (e.g. SRAM, RETRAM or BCKRAM) or external (DDR).
2.2 APIs description[edit]
Please refer to DMA Engine API Guide[3] for a clear description of the DMA framework API.
In addition, going through Dynamic API[4] provides insight on the DMA memory allocation API. The client has to rely on this API to properly allocate DMA buffers so that they are processed by the DMA engine without any trouble.
The document Dynamic DMA mapping Guide[5] can be read in conjunction with the previous one.
It presents some examples and usecases.
3 Configuration[edit]
3.1 Kernel Configuration[edit]
The DMA engine and driver are enabled throughout menu config (see Menuconfig or how to configure kernel):
For DMA:
Device Drivers -> [*] DMA Engine support -> [*] STMicroelectronics STM32 DMA support
For DMAMUX:
Device Drivers -> [*] DMA Engine support -> [*] STMicroelectronics STM32 dma multiplexer support
For MDMA
Device Drivers -> [*] DMA Engine support -> [*] STMicroelectronics STM32 master dma support
3.2 Device Tree configuration[edit]
The DT configuration can be done using the STM32CubeMX.
Refer to the following articles for a description of the DT configuration:
- For DMA: DMA device tree configuration
- For DMAMUX: DMAMUX device tree configuration
- For MDMA: MDMA device tree configuration
4 How to trace and debug the framework[edit]
4.1 How to trace[edit]
Through menuconfig, enable DMA engine debugging and DMA engine verbose debugging (including STM32 drivers):
Device Drivers -> [*] DMA Engine support -> [*] DMA Engine debugging [*] DMA Engine verbose debugging (NEW)
4.2 How to debug[edit]
4.2.1 devfs[edit]
sysfs entry can be used to browse for available DMA channels.
More information can be found in sysfs.
The following command lists all the registered DMA channels:
Board $> ls /sys/class/dma/ dma0chan0 dma0chan13 dma0chan18 dma0chan22 dma0chan27 dma0chan31 dma0chan8 dma1chan3 dma2chan0 dma2chan5 dma0chan1 dma0chan14 dma0chan19 dma0chan23 dma0chan28 dma0chan4 dma0chan9 dma1chan4 dma2chan1 dma2chan6 dma0chan10 dma0chan15 dma0chan2 dma0chan24 dma0chan29 dma0chan5 dma1chan0 dma1chan5 dma2chan2 dma2chan7 dma0chan11 dma0chan16 dma0chan20 dma0chan25 dma0chan3 dma0chan6 dma1chan1 dma1chan6 dma2chan3 dma0chan12 dma0chan17 dma0chan21 dma0chan26 dma0chan30 dma0chan7 dma1chan2 dma1chan7 dma2chan4
Each channel is expanded as follows:
Board $> ls -la /sys/class/dma/dma0chan0/ total 0 drwxr-xr-x 3 root root 0 Jun 7 21:22 . drwxr-xr-x 34 root root 0 Jun 7 21:22 .. -r--r--r-- 1 root root 4096 Jun 9 13:11 bytes_transferred lrwxrwxrwx 1 root root 0 Jun 9 13:11 device -> ../../../58000000.dma -r--r--r-- 1 root root 4096 Jun 9 13:11 in_use -r--r--r-- 1 root root 4096 Jun 9 13:11 memcpy_count drwxr-xr-x 2 root root 0 Jun 9 13:11 power lrwxrwxrwx 1 root root 0 Jun 9 13:11 subsystem -> ../../../../../../class/dma -rw-r--r-- 1 root root 4096 Jun 7 21:22 uevent
device indicates which DMA driver manages the channel.
echoing in_use indicates whether the channel has been allocated or not.
Board $> cat /sys/class/dma/dma0chan0/in_use 1
4.2.2 Debugfs[edit]
debugfs entries are available. They are documented in Part III - Debug drivers use of the DMA-API[4].
4.2.3 dmatest[edit]
dmatest can be used to validate or debug DMA engine and driver without using client devices. This module is more a test than a debug module. It performs a memory-to-memory copy using standard DMA engine API.
For details on how to use this kernel module, refer to [6].
5 Source code location[edit]
DMA: drivers/dma/stm32-dma.c
MDMA: drivers/dma/stm32-mdma.c
DMAMUX: drivers/dma/stm32-dmamux.c
DMA engine:
- Engine: drivers/dma/dmaengine.c
- Virtual channel support: drivers/dma/virt-dma.c
6 To go further[edit]
Very useful documentation can be found at DMAEngine documentation
7 References[edit]
- ↑ 1.01.1 DMA provider
- ↑ DMA API
- ↑ DMA Engine API Guide
- ↑ 4.04.1 Documentation/DMA-API.txt Dynamic DMA mapping using the generic device
- ↑ Documentation/DMA-API-HOWTO.txt Dynamic DMA mapping Guide
- ↑ driver-api/dmaengine/dmatest.html
This article provides basic information about the DMA engine and how STM32 DMA, DMAMUX and MDMA drivers are plugged into it. == Framework purpose == This article provides basic information about the DMA framework. However it is worth browsing the Kernel documentation related to '''DMA concept'''<ref name="DMA provider">{{DocSource | domain=Linux kernel | path=driver-api/dmaengine/provider.html | text=DMA provider}}</ref>. The direct memory access (DMA) is a feature that allows some hardware subsystems to access memory independently from the central processing unit (CPU). <br>The DMA can transfer data between peripherals and memory or between memory and memory. ==System overview== {{ImageMap| Image: DMA schemas.png {{!}} frame {{!}} center {{!}} DMA Engine rect 176 186 299 236 [[#Peripheral_DMA_client_drivers| Peripheral DMA client drivers ]] rect 722 186 845 236 [[#Peripheral_DMA_client_drivers| Peripheral DMA client drivers ]] rect 311 246 439 298 [[#Virtual_DMA_channel_support | Virtual DMA channel support ]] rect 439 246 565 298 [[#DMA_Engine | DMA Engine ]] rect 91 359 216 412 [[#STM32_DMAMUX_driver| DMAMUX Driver]] rect 259 359 383 412 [[#STM32_xDMA_driver| DMA Driver ]] rect 618 359 742 412 [[#STM32_xDMA_driver| MDMA Driver]] rect 91 469 216 520 [[#DMAMUX, DMA and MDMA IPs controller | DMAMUX]] rect 259 469 383 520 [[#DMAMUX, DMA and MDMA IPs controller | DMA]] rect 618 469 742 520 [[#DMAMUX, DMA and MDMA IPs controller | MDMA]] rect 176 536 299 583 [[#Peripheral_clients | Peripheral clients]] rect 441 536 565656 583 [[#Memories | Memories ]] rect 722 539 844 583 [[#Peripheral_clients | Peripheral clients]] rect 441 617 565656 668 [[#Memories | Memories ]] }} ===Component description=== * '''<span id="Peripheral DMA client drivers">Peripheral DMA client drivers</span>''': DMA clients are drivers that are mapped on the '''DMA API'''<ref name="DMA API">{{DocSource | domain=Linux kernel | path=driver-api/dmaengine/client.html | text=DMA API}}</ref>. * '''<span id="DMA engine">DMA engine</span>''': The DMA engine is the engine core on which all clients rely.<br> Refer to '''DMA provider'''<ref name="DMA provider">{{DocSource | domain=Linux kernel | path=driver-api/dmaengine/provider.html | text=DMA provider}}</ref> for useful information on DMA internal behaviour. * '''<span id="Virtual DMA channel support">Virtual DMA channel support</span>''': The virtual DMA channel support manages virtual DMA channels and DMA requests queues. This layer is no used by DMA clients. * '''<span id="STM32 xDMA driver">STM32 xDMA driver</span>''': The STM32 xDMA driver is used to develop the DMA engine API. * '''<span id="STM32 DMAMUX driver">STM32 DMAMUX driver</span>''': The STM32 DMAMUX driver request multiplexer allows routing DMA request lines between the device peripherals and the DMA controllers. * '''<span id="DMAMUX, DMA and MDMA IPs controller">DMAMUX, DMA and MDMA IP controller</span>''': This is the STM32 DMA controller that handles data transfers between peripherals and memories or memory and memory connected to the same bus. DMAMUX (DMA request router): [[DMAMUX internal peripheral]] <br> DMA: [[DMA internal peripheral]] <br> MDMA : [[MDMA internal peripheral]] <br> * '''<span id="Peripheral clients">Peripheral clients</span>''': Peripheral clients are peripherals where at least one DMA request line is mapped on DMAMUX. * '''<span id="Memories">Memories</span>''': Memories can be either internal (e.g. SRAM, RETRAM or BCKRAM) or external (DDR). ===APIs description=== Please refer to '''DMA Engine API Guide'''<ref name="DMA Engine API Guide">{{DocSource | domain=Linux kernel | path=driver-api/dmaengine/client.html | text=DMA Engine API Guide}}</ref> for a clear description of the DMA framework API. In addition, going through '''Dynamic API'''<ref name="Documentation API">{{CodeSource | Linux kernel | Documentation/DMA-API.txt}} Dynamic DMA mapping using the generic device</ref> provides insight on the DMA memory allocation API. The client has to rely on this API to properly allocate DMA buffers so that they are processed by the DMA engine without any trouble. The document '''Dynamic DMA mapping Guide'''<ref name="DMA mapping Guide">{{CodeSource | Linux kernel | Documentation/DMA-API-HOWTO.txt}} Dynamic DMA mapping Guide</ref> can be read in conjunction with the previous one.<br> It presents some examples and usecases. ==Configuration == ===Kernel Configuration=== The DMA engine and driver are enabled throughout menu config (see [[Menuconfig or how to configure kernel]]): For DMA: Device Drivers -> [*] DMA Engine support -> [*] STMicroelectronics STM32 DMA support For DMAMUX: Device Drivers -> [*] DMA Engine support -> [*] STMicroelectronics STM32 dma multiplexer support For MDMA Device Drivers -> [*] DMA Engine support -> [*] STMicroelectronics STM32 master dma support ===Device Tree configuration=== The DT configuration can be done using the [[STM32CubeMX]]. Refer to the following articles for a description of the DT configuration: * For DMA: [[DMA_device_tree_configuration | DMA device tree configuration]] * For DMAMUX: [[DMAMUX_device_tree_configuration | DMAMUX device tree configuration]] * For MDMA: [[MDMA_device_tree_configuration | MDMA device tree configuration]] ==How to trace and debug the framework== === How to trace === Through menuconfig, enable DMA engine debugging and DMA engine verbose debugging (including STM32 drivers): Device Drivers -> [*] DMA Engine support -> [*] DMA Engine debugging [*] DMA Engine verbose debugging (NEW) === How to debug === ==== devfs ==== '''sysfs''' entry can be used to browse for available DMA channels. More information can be found in [[Pseudo_filesystem#sysfs_-28-2Fsys-29_-_System_filesystem|sysfs]]. The following command lists all the registered DMA channels: '''Board $>''' ls /sys/class/dma/ dma0chan0 dma0chan13 dma0chan18 dma0chan22 dma0chan27 dma0chan31 dma0chan8 dma1chan3 dma2chan0 dma2chan5 dma0chan1 dma0chan14 dma0chan19 dma0chan23 dma0chan28 dma0chan4 dma0chan9 dma1chan4 dma2chan1 dma2chan6 dma0chan10 dma0chan15 dma0chan2 dma0chan24 dma0chan29 dma0chan5 dma1chan0 dma1chan5 dma2chan2 dma2chan7 dma0chan11 dma0chan16 dma0chan20 dma0chan25 dma0chan3 dma0chan6 dma1chan1 dma1chan6 dma2chan3 dma0chan12 dma0chan17 dma0chan21 dma0chan26 dma0chan30 dma0chan7 dma1chan2 dma1chan7 dma2chan4 Each channel is expanded as follows: '''Board $>''' ls -la /sys/class/dma/dma0chan0/ total 0 drwxr-xr-x 3 root root 0 Jun 7 21:22 . drwxr-xr-x 34 root root 0 Jun 7 21:22 .. -r--r--r-- 1 root root 4096 Jun 9 13:11 bytes_transferred lrwxrwxrwx 1 root root 0 Jun 9 13:11 {{Red|'''device -> ../../../58000000.dma'''}} -r--r--r-- 1 root root 4096 Jun 9 13:11 {{Red|'''in_use'''}} -r--r--r-- 1 root root 4096 Jun 9 13:11 memcpy_count drwxr-xr-x 2 root root 0 Jun 9 13:11 power lrwxrwxrwx 1 root root 0 Jun 9 13:11 subsystem -> ../../../../../../class/dma -rw-r--r-- 1 root root 4096 Jun 7 21:22 uevent {{Red|'''device}} indicates which DMA driver manages the channel. echoing {{Red|'''in_use'''}} indicates whether the channel has been allocated or not. '''Board $>''' cat /sys/class/dma/dma0chan0/in_use 1 ==== Debugfs ==== [[Debugfs | debugfs]] entries are available. They are documented in ''Part III - Debug drivers use of the DMA-API''<ref name="Documentation API">{{CodeSource | Linux kernel | Documentation/DMA-API.txt}} Dynamic DMA mapping using the generic device</ref>. ==== dmatest ==== dmatest can be used to validate or debug DMA engine and driver without using client devices. This module is more a test than a debug module. It performs a memory-to-memory copy using standard DMA engine API. For details on how to use this kernel module, refer to <ref name=dmatest>{{DocSource | domain=Linux kernel | path=driver-api/dmaengine/dmatest.html | text=driver-api/dmaengine/dmatest.html}}</ref>. ==Source code location== DMA: {{CodeSource | Linux kernel | drivers/dma/stm32-dma.c}}<br/> MDMA: {{CodeSource | Linux kernel | drivers/dma/stm32-mdma.c}}<br/> DMAMUX: {{CodeSource | Linux kernel | drivers/dma/stm32-dmamux.c}}<br/> DMA engine: <br/> * Engine: {{CodeSource | Linux kernel |drivers/dma/dmaengine.c}}<br> * Virtual channel support: {{CodeSource | Linux kernel | drivers/dma/virt-dma.c}} ==To go further== Very useful documentation can be found at {{DocSource | domain=Linux kernel | path=driver-api/dmaengine/index.html | text=DMAEngine documentation}} ==References==<references /> <noinclude> {{PublicationRequestId | 9635 | 2018-11-13 | AnneJ}} [[Category:DMA]]</noinclude>
Line 22: | Line 22: | ||
rect 618 469 742 520 [[#DMAMUX, DMA and MDMA IPs controller | MDMA]] |
rect 618 469 742 520 [[#DMAMUX, DMA and MDMA IPs controller | MDMA]] |
||
rect 176 536 299 583 [[#Peripheral_clients | Peripheral clients]] |
rect 176 536 299 583 [[#Peripheral_clients | Peripheral clients]] |
||
− | rect 441 536 |
+ | rect 441 536 565 583 [[#Memories | Memories ]] |
rect 722 539 844 583 [[#Peripheral_clients | Peripheral clients]] |
rect 722 539 844 583 [[#Peripheral_clients | Peripheral clients]] |
||
− | rect 441 617 |
+ | rect 441 617 565 668 [[#Memories | Memories ]] |
}} |
}} |
||