匿名
未登录
登录
百问网嵌入式Linux wiki
搜索
查看“Dmaengine overview”的源代码
来自百问网嵌入式Linux wiki
名字空间
页面
讨论
更多
更多
页面选项
Read
查看源代码
历史
←
Dmaengine overview
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
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">[https://www.kernel.org/doc/html/latest/driver-api/dmaengine/provider.html 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 213 212 336 262 [[#Peripheral_DMA_client_drivers| Peripheral DMA client drivers ]] rect 759 212 882 262 [[#Peripheral_DMA_client_drivers| Peripheral DMA client drivers ]] rect 348 272 476 324 [[#Virtual_DMA_channel_support | Virtual DMA channel support ]] rect 476 272 602 324 [[#DMA_Engine | DMA Engine ]] rect 128 385 253 438 [[#STM32_DMAMUX_driver| DMAMUX Driver]] rect 296 385 420 438 [[#STM32_xDMA_driver| DMA Driver ]] rect 655 385 779 438 [[#STM32_xDMA_driver| MDMA Driver]] rect 128 495 253 546 [[#DMAMUX, DMA and MDMA IPs controller | DMAMUX]] rect 296 495 420 546 [[#DMAMUX, DMA and MDMA IPs controller | DMA]] rect 655 495 779 546 [[#DMAMUX, DMA and MDMA IPs controller | MDMA]] rect 213 562 336 609 [[#Peripheral_clients | Peripheral clients]] rect 478 562 602 609 [[#Memories | Memories ]] rect 759 562 881 609 [[#Peripheral_clients | Peripheral clients]] rect 478 643 602 694 [[#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">[https://www.kernel.org/doc/html/latest/driver-api/dmaengine/client.html 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">[https://www.kernel.org/doc/html/latest/driver-api/dmaengine/provider.html 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">[https://www.kernel.org/doc/html/latest/driver-api/dmaengine/client.html 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 [http://intranet.lme.st.com:8000/php-bin/ug_mcdmpu/index.php/Virtual_File_System_(VFS)#.2Fsys_.28sysfs.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>[https://www.kernel.org/doc/html/latest/driver-api/dmaengine/dmatest.html 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 https://www.kernel.org/doc/html/v4.19/driver-api/dmaengine/index.html. ==References== <references /> <noinclude> {{PublicationRequestId | 9635 | 2018-11-13 | AnneJ}} [[Category:DMA]] </noinclude>
该页面使用的模板:
模板:CodeSource
(
查看源代码
)
模板:ImageMap
(
查看源代码
)
模板:PublicationRequestId
(
查看源代码
)
模板:Red
(
查看源代码
)
返回至
Dmaengine overview
。
导航
导航
WIKI首页
官方店铺
资料下载
交流社区
所有页面
所有产品
MPU-Linux开发板
MCU-单片机开发板
Linux开发系列视频
单片机开发系列视频
所有模块配件
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志