DMAengine controller documentation
==================================
DMAengine控制器文档=
Hardware Introduction
+++++++++++++++++++++
硬件介绍++
Most of the Slave DMA controllers have the same general principles of operations.
大多数从DMA控制器具有相同的一般操作原理。
They have a given number of channels to use for the DMA transfers, and a given number of requests lines.
它们有给定数量的通道用于DMA传输,以及给定数量的请求行。
Requests and channels are pretty much orthogonal. Channels can be used to serve several to any requests. To simplify, channels are the entities that will be doing the copy, and requests what endpoints are involved.
请求和通道几乎是正交的。通道可用于服务多个请求到任何请求。为了简化,通道是将进行复制的实体,并请求涉及哪些端点。
The request lines actually correspond to physical lines going from the DMA-eligible devices to the controller itself. Whenever the device will want to start a transfer, it will assert a DMA request (DRQ) by asserting that request line.
请求线路实际上对应于从DMA合格设备到控制器本身的物理线路。每当设备想要开始传输时,它将通过断言该请求行来断言DMA请求(DRQ)。
A very simple DMA controller would only take into account a single parameter: the transfer size. At each clock cycle, it would transfer a byte of data from one buffer to another, until the transfer size has been reached.
一个非常简单的DMA控制器只考虑一个参数:传输大小。在每个时钟周期,它会将一个字节的数据从一个缓冲器传输到另一个缓冲器,直到达到传输大小。
That wouldn't work well in the real world, since slave devices might require a specific number of bits to be transferred in a single cycle. For example, we may want to transfer as much data as the physical bus allows to maximize performances when doing a simple memory copy operation, but our audio device could have a narrower FIFO that requires data to be written exactly 16 or 24 bits at a time. This is why most if not all of the DMA controllers can adjust this, using a parameter called the transfer width.
这在真实的世界中不会很好地工作,因为从设备可能需要在单个周期中传输特定数量的位。例如,在执行简单的内存复制操作时,我们可能希望传输物理总线所允许的尽可能多的数据,以最大限度地提高性能,但我们的音频设备可能具有较窄的FIFO,需要一次精确写入16位或24位数据。这就是为什么大多数(如果不是所有的话)DMA控制器可以使用称为传输宽度的参数来调整这一点。
Moreover, some DMA controllers, whenever the RAM is used as a source or destination, can group the reads or writes in memory into a buffer, so instead of having a lot of small memory accesses, which is not really efficient, you'll get several bigger transfers. This is done using a parameter called the burst size, that defines how many single reads/writes it's allowed to do without the controller splitting the transfer into smaller sub-transfers.
此外,一些DMA控制器,每当RAM被用作源或目的地时,可以将内存中的读取或写入分组到缓冲区中,因此,您将获得几个更大的传输,而不是进行大量的小型内存访问,这不是真正有效的。这是使用一个称为突发大小的参数来完成的,该参数定义了在控制器不将传输拆分为更小的子传输的情况下允许进行多少单次读取/写入。
Our theoretical DMA controller would then only be able to do transfers that involve a single contiguous block of data. However, some of the transfers we usually have are not, and want to copy data from non-contiguous buffers to a contiguous buffer, which is called scatter-gather.
我们理论上的DMA控制器只能进行涉及单个连续数据块的传输。然而,我们通常进行的一些传输不是这样的,并且希望将数据从非连续缓冲区复制到连续缓冲区,这称为分散-聚集。
DMAEngine, at least for mem2dev transfers, require support for scatter-gather. So we're left with two cases here: either we have a quite simple DMA controller that doesn't support it, and we'll have to implement it in software, or we have a more advanced DMA controller, that implements in hardware scatter-gather.
DMAEngine,至少对于mem 2dev传输,需要支持分散-聚集。因此,我们这里只剩下两种情况:要么我们有一个非常简单的DMA控制器,不支持它,我们必须在软件中实现它,要么我们有一个更高级的DMA控制器,在硬件中实现分散-聚集。
The latter are usually programmed using a collection of chunks to transfer, and whenever the transfer is started, the controller will go over that collection, doing whatever we programmed there.
后者通常使用要传输的块的集合进行编程,每当传输开始时,控制器将遍历该集合,执行我们在那里编程的任何操作。
This collection is usually either a table or a linked list. You will then push either the address of the table and its number of elements, or the first item of the list to one channel of the DMA controller, and whenever a DRQ will be asserted, it will go through the collection to know where to fetch the data from.
这个集合通常是一个表或一个链表。然后,您将把表的地址及其元素数或列表的第一项推送到DMA控制器的一个通道,每当DRQ被断言时,它将通过收集来了解从哪里获取数据。
Either way, the format of this collection is completely dependent on your hardware. Each DMA controller will require a different structure, but all of them will require, for every chunk, at least the source and destination addresses, whether it should increment these addresses or not and the three parameters we saw earlier: the burst size, the transfer width and the transfer size.
无论哪种方式,此集合的格式完全取决于您的硬件。每个DMA控制器都需要不同的结构,但对于每个块,它们都至少需要源地址和目的地址,是否应该增加这些地址以及我们之前看到的三个参数:突发大小,传输宽度和传输大小。
The one last thing is that usually, slave devices won't issue DRQ by default, and you have to enable this in your slave device driver first whenever you're willing to use DMA.
最后一件事是,通常,从设备不会发出DRQ默认情况下,你必须在你的从设备驱动程序中启用这一点,每当你愿意使用DMA。
These were just the general memory-to-memory (also called mem2mem) or memory-to-device (mem2dev) kind of transfers. Most devices often support other kind of transfers or memory operations that dmaengine support and will be detailed later in this document.
这些只是一般的内存到内存(也称为mem2dev)或内存到设备(mem2dev)类型的传输。大多数设备通常支持dmaengine支持的其他类型的传输或内存操作,稍后将在本文中详细介绍。
DMA Support in Linux
++++++++++++++++++++
Linux中的DMA支持++
Historically, DMA controller drivers have been implemented using the async TX API, to offload operations such as memory copy, XOR, cryptography, etc., basically any memory to memory operation.
在历史上,DMA控制器驱动器已经使用PCI TX API来实现,以卸载诸如存储器复制、XOR、加密等操作,基本上任何内存到内存的操作。
Over time, the need for memory to device transfers arose, and dmaengine was extended. Nowadays, the async TX API is written as a layer on top of dmaengine, and acts as a client. Still, dmaengine accommodates that API in some cases, and made some design choices to ensure that it stayed compatible.
随着时间的推移,内存到设备传输的需求出现了,dmaengine也得到了扩展。如今,DMAC TX API被编写为dmaengine之上的一层,并充当客户端。尽管如此,dmaengine在某些情况下还是支持该API,并做出了一些设计选择以确保它保持兼容性。
For more information on the Async TX API, please look the relevant documentation file in Documentation/crypto/async-tx-api.txt.
有关Async TX API的更多信息,请查看Documentation/crypto/Cryptoc-tx-api.txt中的相关文档文件。
DMAEngine Registration
++++++++++++++++++++++
DMAEngine注册++
struct dma_device Initialization
--------------------------------
结构dma_device配置-
Just like any other kernel framework, the whole DMAEngine registration relies on the driver filling a structure and registering against the framework. In our case, that structure is dma_device.
就像任何其他内核框架一样,整个DMAEngine注册依赖于驱动程序填充结构并针对框架进行注册。在我们的例子中,这个结构是dma_device。
The first thing you need to do in your driver is to allocate this structure. Any of the usual memory allocators will do, but you'll also need to initialize a few fields in there:
你需要在你的驱动中做的第一件事就是分配这个结构。任何常见的内存分配器都可以,但你还需要初始化其中的一些字段:
* channels: should be initialized as a list using the
INIT_LIST_HEAD macro for example
* channels:应该使用INIT_LIST_HEAD宏将其初始化为列表,例如
* src_addr_widths:
- should contain a bitmask of the supported source transfer width
* src_addr_widths:-应该包含支持的源传输宽度的位掩码
* dst_addr_widths:
- should contain a bitmask of the supported destination transfer
width
* dst_addr_widths:-应该包含支持的目标传输宽度的位掩码
* directions:
- should contain a bitmask of the supported slave directions
(i.e. excluding mem2mem transfers)
* directions:-应该包含支持的从属方向的位掩码(即不包括内存传输)
* residue_granularity:
- Granularity of the transfer residue reported to dma_set_residue.
- This can be either:
+ Descriptor
-> Your device doesn't support any kind of residue
reporting. The framework will only know that a particular
transaction descriptor is done.
+ Segment
-> Your device is able to report which chunks have been
transferred
+ Burst
-> Your device is able to report which burst have been
transferred
* residue_granularity:-报告给dma_set_residue的传输残差的粒度。- 这可以是:+描述符->您的设备不支持任何类型的残留报告。框架将只知道特定的事务描述符已经完成。+ Segment -> Your device is able to report which chunks have been transferred + Burst -> Your device is able to report which burst have been transferred
* dev: should hold the pointer to the struct device associated
to your current driver instance.
* dev:应该保存指向与当前驱动程序实例关联的结构设备的指针。
Supported transaction types
---------------------------
支持的交易类型-
The next thing you need is to set which transaction types your device (and driver) supports.
您需要做的下一件事是设置您的设备(和驱动程序)支持哪些事务类型。
Our dma_device structure has a field called cap_mask that holds the various types of transaction supported, and you need to modify this mask using the dma_cap_set function, with various flags depending on transaction types you support as an argument.
我们的dma_device结构有一个名为cap_mask的字段,它保存了支持的各种类型的事务,您需要使用dma_cap_set函数修改此掩码,并根据您支持的事务类型将各种标志作为参数。
All those capabilities are defined in the dma_transaction_type enum, in include/linux/dmaengine.h
所有这些功能都在dma_transaction_type枚举中定义,位于include/linux/dmaengine.h中
Currently, the types available are:
* DMA_MEMCPY
- The device is able to do memory to memory copies
目前,可用的类型有:* DMA_MEMCPY -设备能够进行内存到内存的复制
* DMA_XOR
- The device is able to perform XOR operations on memory areas
- Used to accelerate XOR intensive tasks, such as RAID5
* DMA_XOR -设备能够对内存区域执行XOR操作-用于加速XOR密集型任务,如RAID 5
* DMA_XOR_VAL
- The device is able to perform parity check using the XOR
algorithm against a memory buffer.
* DMA_XOR_瓦尔-设备能够使用XOR算法对内存缓冲区执行奇偶校验。
* DMA_PQ
- The device is able to perform RAID6 P+Q computations, P being a
simple XOR, and Q being a Reed-Solomon algorithm.
* DMA_PQ -该器件能够执行RAID 6 P+Q计算,P是简单的XOR,Q是Reed-Solomon算法。
* DMA_PQ_VAL
- The device is able to perform parity check using RAID6 P+Q
algorithm against a memory buffer.
* DMA_PQ_瓦尔-器件能够使用RAID 6 P+Q算法对内存缓冲区执行奇偶校验。
* DMA_INTERRUPT
- The device is able to trigger a dummy transfer that will
generate periodic interrupts
- Used by the client drivers to register a callback that will be
called on a regular basis through the DMA controller interrupt
* DMA_INTERRUPT -设备能够触发将生成周期性中断的虚拟传输-由客户端驱动程序用于注册将通过DMA控制器中断定期调用的回调
* DMA_SG
- The device supports memory to memory scatter-gather
transfers.
- Even though a plain memcpy can look like a particular case of a
scatter-gather transfer, with a single chunk to transfer, it's a
distinct transaction type in the mem2mem transfers case
* DMA_SG -设备支持内存到内存的分散-聚集传输。- 尽管普通的memcpy看起来像是一个特殊的分散-聚集传输,只有一个块要传输,但它在mem 2 pagetransferscase中是一个不同的事务类型
* DMA_PRIVATE
- The devices only supports slave transfers, and as such isn't
available for async transfers.
* DMA_PRIVATE -这些设备仅支持从设备传输,因此不适用于DMA传输。
* DMA_ASYNC_TX
- Must not be set by the device, and will be set by the framework
if needed
- /* TODO: What is it about? */
* DMA_ASYNC_TX -不能由设备设置,如果需要,将由框架设置- /* TODO:它是关于什么的?*/
* DMA_SLAVE
- The device can handle device to memory transfers, including
scatter-gather transfers.
- While in the mem2mem case we were having two distinct types to
deal with a single chunk to copy or a collection of them, here,
we just have a single transaction type that is supposed to
handle both.
- If you want to transfer a single contiguous memory buffer,
simply build a scatter list with only one item.
* DMA_SLAVE -设备可以处理设备到内存的传输,包括分散-聚集传输。- 在mem 2bers的情况下,我们有两个不同的类型来处理要复制的单个块或它们的集合,而在这里,我们只有一个事务类型来处理这两个事务。- 如果您想传输单个连续的内存缓冲区,只需构建一个仅包含一项的散点列表。
* DMA_CYCLIC
- The device can handle cyclic transfers.
- A cyclic transfer is a transfer where the chunk collection will
loop over itself, with the last item pointing to the first.
- It's usually used for audio transfers, where you want to operate
on a single ring buffer that you will fill with your audio data.
* DMA_CYCLIC -设备可以处理循环传输。- 循环传输是块集合将循环遍历自身的传输,最后一项指向第一项。- 它通常用于音频传输,您希望在单个环形缓冲区上操作,并将音频数据填充该缓冲区。
* DMA_INTERLEAVE
- The device supports interleaved transfer.
- These transfers can transfer data from a non-contiguous buffer
to a non-contiguous buffer, opposed to DMA_SLAVE that can
transfer data from a non-contiguous data set to a continuous
destination buffer.
- It's usually used for 2d content transfers, in which case you
want to transfer a portion of uncompressed data directly to the
display to print it
* DMA_INTERLEAVE -设备支持交错传输。- 这些传输可以将数据从非连续缓冲区传输到非连续缓冲区,而DMA_SLAVE可以将数据从非连续数据集传输到连续目标缓冲区。- 它通常用于2d内容传输,在这种情况下,您希望将未压缩数据的一部分直接传输到显示器以进行打印
These various types will also affect how the source and destination addresses change over time.
这些不同的类型还将影响源地址和目标地址如何随着时间的推移而变化。
Addresses pointing to RAM are typically incremented (or decremented) after each transfer. In case of a ring buffer, they may loop (DMA_CYCLIC). Addresses pointing to a device's register (e.g. a FIFO) are typically fixed.
指向RAM的指针通常在每次传输后递增(或递减)。在环形缓冲区的情况下,它们可以循环(DMA_CYCLIC)。指向设备的寄存器(例如FIFO)的指针通常是固定的。
Device operations
-----------------
器械操作-
Our dma_device structure also requires a few function pointers in order to implement the actual logic, now that we described what operations we were able to perform.
我们的dma_device结构还需要一些函数指针来实现实际的逻辑,现在我们描述了我们能够执行的操作。
The functions that we have to fill in there, and hence have to implement, obviously depend on the transaction types you reported as supported.
我们必须在那里填写的函数,因此必须实现,显然取决于您报告的支持的事务类型。
* device_alloc_chan_resources
* device_free_chan_resources
- These functions will be called whenever a driver will call
dma_request_channel or dma_release_channel for the first/last
time on the channel associated to that driver.
- They are in charge of allocating/freeing all the needed
resources in order for that channel to be useful for your
driver.
- These functions can sleep.
* device_alloc_chan_resources * device_free_chan_resources -当驱动程序在与该驱动程序关联的通道上第一次/最后一次调用dma_request_channel或dma_release_channel时,将调用这些函数。- 他们负责分配/释放所有所需的资源,以便该通道对您的驱动程序有用。- 这些功能可以睡眠。
* device_prep_dma_*
- These functions are matching the capabilities you registered
previously.
- These functions all take the buffer or the scatterlist relevant
for the transfer being prepared, and should create a hardware
descriptor or a list of hardware descriptors from it
- These functions can be called from an interrupt context
- Any allocation you might do should be using the GFP_NOWAIT
flag, in order not to potentially sleep, but without depleting
the emergency pool either.
- Drivers should try to pre-allocate any memory they might need
during the transfer setup at probe time to avoid putting to
much pressure on the nowait allocator.
* device_prep_dma_* -这些功能与您之前注册的功能相匹配。- 这些函数都采用与准备的传输相关的缓冲区或散点列表,并应从中创建硬件描述符或硬件描述符列表-这些函数可以从中断上下文调用-您可能执行的任何分配都应使用GFP_NOWAIT标志,以便不可能休眠,但也不会耗尽紧急池。- 驱动程序应该尝试在探测时的传输设置过程中预先分配他们可能需要的任何内存,以避免给nowait分配器带来太大的压力。
- It should return a unique instance of the
dma_async_tx_descriptor structure, that further represents this
particular transfer.
- 它应该返回dma_tdc_tx_descriptor结构的唯一实例,该结构进一步表示此特定传输。
- This structure can be initialized using the function
dma_async_tx_descriptor_init.
- You'll also need to set two fields in this structure:
+ flags:
TODO: Can it be modified by the driver itself, or
should it be always the flags passed in the arguments
- 此结构可以使用函数dma_dmc_tx_descriptor_init初始化。- 您还需要在此结构中设置两个字段:+ flags:TODO:它可以由驱动程序本身修改吗,还是应该始终是参数中传递的标志
+ tx_submit: A pointer to a function you have to implement,
that is supposed to push the current
transaction descriptor to a pending queue, waiting
for issue_pending to be called.
- In this structure the function pointer callback_result can be
initialized in order for the submitter to be notified that a
transaction has completed. In the earlier code the function pointer
callback has been used. However it does not provide any status to the
transaction and will be deprecated. The result structure defined as
dmaengine_result that is passed in to callback_result has two fields:
+ result: This provides the transfer result defined by
dmaengine_tx_result. Either success or some error
condition.
+ residue: Provides the residue bytes of the transfer for those that
support residue.
+ tx_submit:一个指向你必须实现的函数的指针,该函数应该将当前的事务描述符推到挂起队列,等待issue_pending被调用。- 在这个结构中,函数指针callback_result可以被初始化,以便通知子进程事务已经完成。在前面的代码中,使用了函数指针回调。但是,它不提供事务的任何状态,因此将被弃用。传递给callback_result的定义为dmaengine_result的结果结构有两个字段:+ result:这提供了由dmaengine_tx_result定义的传输结果。成功或错误条件。+ residue:为支持residue的用户提供传输的residue字节。
* device_issue_pending
- Takes the first transaction descriptor in the pending queue,
and starts the transfer. Whenever that transfer is done, it
should move to the next transaction in the list.
- This function can be called in an interrupt context
* device_issue_pending -获取挂起队列中的第一个事务描述符,并开始传输。每当完成该传输时,它应该移动到列表中的下一个事务。- 此函数可以在中断上下文中调用
* device_tx_status
- Should report the bytes left to go over on the given channel
- Should only care about the transaction descriptor passed as
argument, not the currently active one on a given channel
- The tx_state argument might be NULL
- Should use dma_set_residue to report it
- In the case of a cyclic transfer, it should only take into
account the current period.
- This function can be called in an interrupt context.
* device_tx_status -应该报告给定通道上剩余的字节数-应该只关心作为参数传递的事务描述符,而不是给定通道上当前活动的事务描述符-tx_state参数可能为NULL -应该使用dma_set_residue来报告它-在循环传输的情况下,它应该只考虑当前周期。- 该函数可以在中断上下文中调用。
* device_config
- Reconfigures the channel with the configuration given as
argument
- This command should NOT perform synchronously, or on any
currently queued transfers, but only on subsequent ones
- In this case, the function will receive a dma_slave_config
structure pointer as an argument, that will detail which
configuration to use.
- Even though that structure contains a direction field, this
field is deprecated in favor of the direction argument given to
the prep_* functions
- This call is mandatory for slave operations only. This should NOT be
set or expected to be set for memcpy operations.
If a driver support both, it should use this call for slave
operations only and not for memcpy ones.
* device_config -使用作为参数给出的配置重新配置通道-此命令不应同步执行,也不应对任何当前排队的传输执行,而应仅对后续传输执行-在这种情况下,函数将接收一个dma_slave_config结构指针作为参数,该指针将详细说明要使用的配置。- 尽管该结构包含一个direction字段,但该字段已被弃用,以支持为prep_* 函数提供的direction参数-此调用仅对从属操作是强制性的。对于memcpy操作,不应设置或期望设置此参数。如果驱动程序支持两者,则它应该仅将此调用用于从操作,而不用于memcpy操作。
* device_pause
- Pauses a transfer on the channel
- This command should operate synchronously on the channel,
pausing right away the work of the given channel
* device_pause -暂停通道上的传输-此命令应在通道上同步操作,立即暂停给定通道的工作
* device_resume
- Resumes a transfer on the channel
- This command should operate synchronously on the channel,
resuming right away the work of the given channel
* device_resume -恢复通道上的传输-该命令应在通道上同步操作,立即恢复给定通道的工作
* device_terminate_all
- Aborts all the pending and ongoing transfers on the channel
- For aborted transfers the complete callback should not be called
- Can be called from atomic context or from within a complete
callback of a descriptor. Must not sleep. Drivers must be able
to handle this correctly.
- Termination may be asynchronous. The driver does not have to
wait until the currently active transfer has completely stopped.
See device_synchronize.
* device_terminate_all -中止通道上所有挂起和正在进行的传输-对于已中止的传输,不应调用完整的回调-可以从原子上下文或描述符的完整回调中调用。一定不能睡。驾驶员必须能够正确处理此问题。- 终止可以是异步的。驱动程序不必等到当前活动的传输完全停止。请参见device_synchronize。
* device_synchronize
- Must synchronize the termination of a channel to the current
context.
- Must make sure that memory for previously submitted
descriptors is no longer accessed by the DMA controller.
- Must make sure that all complete callbacks for previously
submitted descriptors have finished running and none are
scheduled to run.
- May sleep.
* device_synchronize -必须将通道的终止同步到当前上下文。- 必须确保DMA控制器不再访问以前提交的描述符的内存。- 必须确保以前提交的描述符的所有完整回调都已完成运行,并且没有计划运行。- 可以睡觉。
Misc notes (stuff that should be documented, but don't really know where to put them)
------------------------------------------------------------------
* dma_run_dependencies
- Should be called at the end of an async TX transfer, and can be
ignored in the slave transfers case.
- Makes sure that dependent operations are run before marking it
as complete.
Misc notes(应该记录下来,但不知道放在哪里的东西)- - 在将相关操作标记为完成之前,确保运行相关操作。
* dma_cookie_t
- it's a DMA transaction ID that will increment over time.
- Not really relevant any more since the introduction of virt-dma
that abstracts it away.
* dma_cookie_t -这是一个DMA事务ID,将随着时间的推移而增加。- 自从virt-dma的引入将其抽象化后,它就不再真正相关了。
* DMA_CTRL_ACK
- If clear, the descriptor cannot be reused by provider until the
client acknowledges receipt, i.e. has has a chance to establish any
dependency chains
- This can be acked by invoking async_tx_ack()
- If set, does not mean descriptor can be reused
* DMA_CTRL_ACK -如果清除,则在客户端确认接收之前,提供程序不能重用描述符,即有机会建立任何依赖链-这可以通过调用DMAC_tx_ack()来确认-如果设置,则不意味着可以重用描述符
* DMA_CTRL_REUSE
- If set, the descriptor can be reused after being completed. It should
not be freed by provider if this flag is set.
- The descriptor should be prepared for reuse by invoking
dmaengine_desc_set_reuse() which will set DMA_CTRL_REUSE.
- dmaengine_desc_set_reuse() will succeed only when channel support
reusable descriptor as exhibited by capablities
- As a consequence, if a device driver wants to skip the dma_map_sg() and
dma_unmap_sg() in between 2 transfers, because the DMA'd data wasn't used,
it can resubmit the transfer right after its completion.
- Descriptor can be freed in few ways
- Clearing DMA_CTRL_REUSE by invoking dmaengine_desc_clear_reuse()
and submitting for last txn
- Explicitly invoking dmaengine_desc_free(), this can succeed only
when DMA_CTRL_REUSE is already set
- Terminating the channel
* DMA_CTRL_REUSE -如果设置,则描述符可以在完成后重复使用。如果设置了此标志,则提供程序不应释放它。- 应该通过调用dmaengine_desc_set_reuse()来准备描述符以供重用,这将设置DMA_CTRL_REUSE。- dmaengine_desc_set_reuse()仅在通道支持可重用描述符时才能成功-因此,如果设备驱动程序希望在两次传输之间跳过dma_map_sg()和dma_unmap_sg(),因为DMA的数据未被使用,它可以在传输完成后立即重新提交传输。- 可以通过几种方式释放描述符-通过调用dmaengine_desc_clear_reuse()清除DMA_CTRL_REUSE并提交最后一个txn -显式调用dmaengine_desc_free(),仅当已设置DMA_CTRL_REUSE时才能成功-终止通道
General Design Notes
--------------------
一般设计注意事项--
Most of the DMAEngine drivers you'll see are based on a similar design that handles the end of transfer interrupts in the handler, but defer most work to a tasklet, including the start of a new transfer whenever the previous transfer ended.
您将看到的大多数DMAEngine驱动程序都基于类似的设计,在处理程序中处理传输中断的结束,但将大多数工作推迟到tasklet,包括在前一次传输结束时开始新的传输。
This is a rather inefficient design though, because the inter-transfer latency will be not only the interrupt latency, but also the scheduling latency of the tasklet, which will leave the channel idle in between, which will slow down the global transfer rate.
然而,这是一个相当低效的设计,因为传输间延迟不仅是中断延迟,而且是小任务的调度延迟,这将使通道空闲,这将降低全局传输速率。
You should avoid this kind of practice, and instead of electing a new transfer in your tasklet, move that part to the interrupt handler in order to have a shorter idle window (that we can't really avoid anyway).
你应该避免这种做法,而不是在你的tasklet中选择一个新的传输,把那部分移动到中断处理程序中,以便有一个更短的空闲窗口(我们无论如何都不能真正避免)。
Glossary -------- 词汇表--
Burst: A number of consecutive read or write operations
that can be queued to buffers before being flushed to
memory.
Chunk: A contiguous collection of bursts Transfer: A collection of chunks (be it contiguous or not)
突发:在刷新到内存之前可以排队到缓冲区的连续读或写操作的数量。Chunk:一个连续的突发集合传输:一个块的集合(无论是连续的还是不连续的)