sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget//translations/zh_CN/driver-api/dmaengine/clientmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget//translations/zh_TW/driver-api/dmaengine/clientmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget//translations/it_IT/driver-api/dmaengine/clientmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget//translations/ja_JP/driver-api/dmaengine/clientmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget//translations/ko_KR/driver-api/dmaengine/clientmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget//translations/sp_SP/driver-api/dmaengine/clientmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hDMA Engine API Guideh]hDMA Engine API Guide}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhI/var/lib/git/docbuild/linux/Documentation/driver-api/dmaengine/client.rsthKubh paragraph)}(h(Vinod Koul h]h(Vinod Koul }(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubhnote)}(hVFor DMA Engine usage in async_tx please see: ``Documentation/crypto/async-tx-api.rst``h]h)}(hVFor DMA Engine usage in async_tx please see: ``Documentation/crypto/async-tx-api.rst``h](h-For DMA Engine usage in async_tx please see: }(hhhhhNhNubhliteral)}(h)``Documentation/crypto/async-tx-api.rst``h]h%Documentation/crypto/async-tx-api.rst}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubeh}(h]h ]h"]h$]h&]uh1hhhhKhhubah}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hBelow is a guide to device driver writers on how to use the Slave-DMA API of the DMA Engine. This is applicable only for slave DMA usage only.h]hBelow is a guide to device driver writers on how to use the Slave-DMA API of the DMA Engine. This is applicable only for slave DMA usage only.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hhh](h)}(h DMA usageh]h DMA usage}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(h0The slave DMA usage consists of following steps:h]h0The slave DMA usage consists of following steps:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh bullet_list)}(hhh](h list_item)}(hAllocate a DMA slave channel h]h)}(hAllocate a DMA slave channelh]hAllocate a DMA slave channel}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj%ubah}(h]h ]h"]h$]h&]uh1j#hj hhhhhNubj$)}(h-Set slave and controller specific parameters h]h)}(h,Set slave and controller specific parametersh]h,Set slave and controller specific parameters}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj=ubah}(h]h ]h"]h$]h&]uh1j#hj hhhhhNubj$)}(h!Get a descriptor for transaction h]h)}(h Get a descriptor for transactionh]h Get a descriptor for transaction}(hjYhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjUubah}(h]h ]h"]h$]h&]uh1j#hj hhhhhNubj$)}(hSubmit the transaction h]h)}(hSubmit the transactionh]hSubmit the transaction}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjmubah}(h]h ]h"]h$]h&]uh1j#hj hhhhhNubj$)}(h:Issue pending requests and wait for callback notification h]h)}(h9Issue pending requests and wait for callback notificationh]h9Issue pending requests and wait for callback notification}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j#hj hhhhhNubeh}(h]h ]h"]h$]h&]bullet-uh1jhhhKhhhhubh)}(h$The details of these operations are:h]h$The details of these operations are:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubhenumerated_list)}(hhh](j$)}(hXAllocate a DMA slave channel Channel allocation is slightly different in the slave DMA context, client drivers typically need a channel from a particular DMA controller only and even in some cases a specific channel is desired. To request a channel dma_request_chan() API is used. Interface: .. code-block:: c struct dma_chan *dma_request_chan(struct device *dev, const char *name); Which will find and return the ``name`` DMA channel associated with the 'dev' device. The association is done via DT, ACPI or board file based dma_slave_map matching table. A channel allocated via this interface is exclusive to the caller, until dma_release_channel() is called. h](h)}(hAllocate a DMA slave channelh]hAllocate a DMA slave channel}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hChannel allocation is slightly different in the slave DMA context, client drivers typically need a channel from a particular DMA controller only and even in some cases a specific channel is desired. To request a channel dma_request_chan() API is used.h]hChannel allocation is slightly different in the slave DMA context, client drivers typically need a channel from a particular DMA controller only and even in some cases a specific channel is desired. To request a channel dma_request_chan() API is used.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK!hjubh)}(h Interface:h]h Interface:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK&hjubh literal_block)}(hHstruct dma_chan *dma_request_chan(struct device *dev, const char *name);h]hHstruct dma_chan *dma_request_chan(struct device *dev, const char *name);}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveforcelanguagechighlight_args}uh1jhhhK(hjubh)}(hWhich will find and return the ``name`` DMA channel associated with the 'dev' device. The association is done via DT, ACPI or board file based dma_slave_map matching table.h](hWhich will find and return the }(hjhhhNhNubh)}(h``name``h]hname}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh DMA channel associated with the ‘dev’ device. The association is done via DT, ACPI or board file based dma_slave_map matching table.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK,hjubh)}(hiA channel allocated via this interface is exclusive to the caller, until dma_release_channel() is called.h]hiA channel allocated via this interface is exclusive to the caller, until dma_release_channel() is called.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK0hjubeh}(h]h ]h"]h$]h&]uh1j#hjhhhhhNubj$)}(hXSet slave and controller specific parameters Next step is always to pass some specific information to the DMA driver. Most of the generic information which a slave DMA can use is in struct dma_slave_config. This allows the clients to specify DMA direction, DMA addresses, bus widths, DMA burst lengths etc for the peripheral. If some DMA controllers have more parameters to be sent then they should try to embed struct dma_slave_config in their controller specific structure. That gives flexibility to client to pass more parameters, if required. Interface: .. code-block:: c int dmaengine_slave_config(struct dma_chan *chan, struct dma_slave_config *config) Please see the dma_slave_config structure definition in dmaengine.h for a detailed explanation of the struct members. Please note that the 'direction' member will be going away as it duplicates the direction given in the prepare call. h](h)}(h,Set slave and controller specific parametersh]h,Set slave and controller specific parameters}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK3hj1ubh)}(hXNext step is always to pass some specific information to the DMA driver. Most of the generic information which a slave DMA can use is in struct dma_slave_config. This allows the clients to specify DMA direction, DMA addresses, bus widths, DMA burst lengths etc for the peripheral.h]hXNext step is always to pass some specific information to the DMA driver. Most of the generic information which a slave DMA can use is in struct dma_slave_config. This allows the clients to specify DMA direction, DMA addresses, bus widths, DMA burst lengths etc for the peripheral.}(hjChhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK5hj1ubh)}(hIf some DMA controllers have more parameters to be sent then they should try to embed struct dma_slave_config in their controller specific structure. That gives flexibility to client to pass more parameters, if required.h]hIf some DMA controllers have more parameters to be sent then they should try to embed struct dma_slave_config in their controller specific structure. That gives flexibility to client to pass more parameters, if required.}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK;hj1ubh)}(h Interface:h]h Interface:}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK@hj1ubj)}(hdint dmaengine_slave_config(struct dma_chan *chan, struct dma_slave_config *config)h]hdint dmaengine_slave_config(struct dma_chan *chan, struct dma_slave_config *config)}hjmsbah}(h]h ]h"]h$]h&]jjjjjj}uh1jhhhKBhj1ubh)}(hPlease see the dma_slave_config structure definition in dmaengine.h for a detailed explanation of the struct members. Please note that the 'direction' member will be going away as it duplicates the direction given in the prepare call.h]hPlease see the dma_slave_config structure definition in dmaengine.h for a detailed explanation of the struct members. Please note that the ‘direction’ member will be going away as it duplicates the direction given in the prepare call.}(hj|hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKGhj1ubeh}(h]h ]h"]h$]h&]uh1j#hjhhhhhNubj$)}(h!Get a descriptor for transaction h]h)}(h Get a descriptor for transactionh]h Get a descriptor for transaction}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKLhjubah}(h]h ]h"]h$]h&]uh1j#hjhhhhhNubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix.uh1jhhhhhhhKubh block_quote)}(hXJFor slave usage the various modes of slave transfers supported by the DMA-engine are: - slave_sg: DMA a list of scatter gather buffers from/to a peripheral - peripheral_dma_vec: DMA an array of scatter gather buffers from/to a peripheral. Similar to slave_sg, but uses an array of dma_vec structures instead of a scatterlist. - dma_cyclic: Perform a cyclic DMA operation from/to a peripheral till the operation is explicitly stopped. - interleaved_dma: This is common to Slave as well as M2M clients. For slave address of devices' fifo could be already known to the driver. Various types of operations could be expressed by setting appropriate values to the 'dma_interleaved_template' members. Cyclic interleaved DMA transfers are also possible if supported by the channel by setting the DMA_PREP_REPEAT transfer flag. A non-NULL return of this transfer API represents a "descriptor" for the given transaction. Interface: .. code-block:: c struct dma_async_tx_descriptor *dmaengine_prep_slave_sg( struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, enum dma_data_direction direction, unsigned long flags); struct dma_async_tx_descriptor *dmaengine_prep_peripheral_dma_vec( struct dma_chan *chan, const struct dma_vec *vecs, size_t nents, enum dma_data_direction direction, unsigned long flags); struct dma_async_tx_descriptor *dmaengine_prep_dma_cyclic( struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, size_t period_len, enum dma_data_direction direction); struct dma_async_tx_descriptor *dmaengine_prep_interleaved_dma( struct dma_chan *chan, struct dma_interleaved_template *xt, unsigned long flags); The peripheral driver is expected to have mapped the scatterlist for the DMA operation prior to calling dmaengine_prep_slave_sg(), and must keep the scatterlist mapped until the DMA operation has completed. The scatterlist must be mapped using the DMA struct device. If a mapping needs to be synchronized later, dma_sync_*_for_*() must be called using the DMA struct device, too. So, normal setup should look like this: .. code-block:: c struct device *dma_dev = dmaengine_get_dma_device(chan); nr_sg = dma_map_sg(dma_dev, sgl, sg_len); if (nr_sg == 0) /* error */ desc = dmaengine_prep_slave_sg(chan, sgl, nr_sg, direction, flags); Once a descriptor has been obtained, the callback information can be added and the descriptor must then be submitted. Some DMA engine drivers may hold a spinlock between a successful preparation and submission so it is important that these two operations are closely paired. .. note:: Although the async_tx API specifies that completion callback routines cannot submit any new operations, this is not the case for slave/cyclic DMA. For slave DMA, the subsequent transaction may not be available for submission prior to callback function being invoked, so slave DMA callbacks are permitted to prepare and submit a new transaction. For cyclic DMA, a callback function may wish to terminate the DMA via dmaengine_terminate_async(). Therefore, it is important that DMA engine drivers drop any locks before calling the callback function which may cause a deadlock. Note that callbacks will always be invoked from the DMA engines tasklet, never from interrupt context. **Optional: per descriptor metadata** DMAengine provides two ways for metadata support. DESC_METADATA_CLIENT The metadata buffer is allocated/provided by the client driver and it is attached to the descriptor. .. code-block:: c int dmaengine_desc_attach_metadata(struct dma_async_tx_descriptor *desc, void *data, size_t len); DESC_METADATA_ENGINE The metadata buffer is allocated/managed by the DMA driver. The client driver can ask for the pointer, maximum size and the currently used size of the metadata and can directly update or read it. Because the DMA driver manages the memory area containing the metadata, clients must make sure that they do not try to access or get the pointer after their transfer completion callback has run for the descriptor. If no completion callback has been defined for the transfer, then the metadata must not be accessed after issue_pending. In other words: if the aim is to read back metadata after the transfer is completed, then the client must use completion callback. .. code-block:: c void *dmaengine_desc_get_metadata_ptr(struct dma_async_tx_descriptor *desc, size_t *payload_len, size_t *max_len); int dmaengine_desc_set_metadata_len(struct dma_async_tx_descriptor *desc, size_t payload_len); Client drivers can query if a given mode is supported with: .. code-block:: c bool dmaengine_is_metadata_mode_supported(struct dma_chan *chan, enum dma_desc_metadata_mode mode); Depending on the used mode client drivers must follow different flow. DESC_METADATA_CLIENT - DMA_MEM_TO_DEV / DEV_MEM_TO_MEM: 1. prepare the descriptor (dmaengine_prep_*) construct the metadata in the client's buffer 2. use dmaengine_desc_attach_metadata() to attach the buffer to the descriptor 3. submit the transfer - DMA_DEV_TO_MEM: 1. prepare the descriptor (dmaengine_prep_*) 2. use dmaengine_desc_attach_metadata() to attach the buffer to the descriptor 3. submit the transfer 4. when the transfer is completed, the metadata should be available in the attached buffer DESC_METADATA_ENGINE - DMA_MEM_TO_DEV / DEV_MEM_TO_MEM: 1. prepare the descriptor (dmaengine_prep_*) 2. use dmaengine_desc_get_metadata_ptr() to get the pointer to the engine's metadata area 3. update the metadata at the pointer 4. use dmaengine_desc_set_metadata_len() to tell the DMA engine the amount of data the client has placed into the metadata buffer 5. submit the transfer - DMA_DEV_TO_MEM: 1. prepare the descriptor (dmaengine_prep_*) 2. submit the transfer 3. on transfer completion, use dmaengine_desc_get_metadata_ptr() to get the pointer to the engine's metadata area 4. read out the metadata from the pointer .. note:: When DESC_METADATA_ENGINE mode is used the metadata area for the descriptor is no longer valid after the transfer has been completed (valid up to the point when the completion callback returns if used). Mixed use of DESC_METADATA_CLIENT / DESC_METADATA_ENGINE is not allowed, client drivers must use either of the modes per descriptor. h](h)}(hUFor slave usage the various modes of slave transfers supported by the DMA-engine are:h]hUFor slave usage the various modes of slave transfers supported by the DMA-engine are:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKNhjubj)}(hhh](j$)}(hDslave_sg: DMA a list of scatter gather buffers from/to a peripheral h]h)}(hCslave_sg: DMA a list of scatter gather buffers from/to a peripheralh]hCslave_sg: DMA a list of scatter gather buffers from/to a peripheral}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKQhjubah}(h]h ]h"]h$]h&]uh1j#hjubj$)}(hperipheral_dma_vec: DMA an array of scatter gather buffers from/to a peripheral. Similar to slave_sg, but uses an array of dma_vec structures instead of a scatterlist. h]h)}(hperipheral_dma_vec: DMA an array of scatter gather buffers from/to a peripheral. Similar to slave_sg, but uses an array of dma_vec structures instead of a scatterlist.h]hperipheral_dma_vec: DMA an array of scatter gather buffers from/to a peripheral. Similar to slave_sg, but uses an array of dma_vec structures instead of a scatterlist.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKShjubah}(h]h ]h"]h$]h&]uh1j#hjubj$)}(hjdma_cyclic: Perform a cyclic DMA operation from/to a peripheral till the operation is explicitly stopped. h]h)}(hidma_cyclic: Perform a cyclic DMA operation from/to a peripheral till the operation is explicitly stopped.h]hidma_cyclic: Perform a cyclic DMA operation from/to a peripheral till the operation is explicitly stopped.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKWhjubah}(h]h ]h"]h$]h&]uh1j#hjubj$)}(hXinterleaved_dma: This is common to Slave as well as M2M clients. For slave address of devices' fifo could be already known to the driver. Various types of operations could be expressed by setting appropriate values to the 'dma_interleaved_template' members. Cyclic interleaved DMA transfers are also possible if supported by the channel by setting the DMA_PREP_REPEAT transfer flag. h]h)}(hX~interleaved_dma: This is common to Slave as well as M2M clients. For slave address of devices' fifo could be already known to the driver. Various types of operations could be expressed by setting appropriate values to the 'dma_interleaved_template' members. Cyclic interleaved DMA transfers are also possible if supported by the channel by setting the DMA_PREP_REPEAT transfer flag.h]hXinterleaved_dma: This is common to Slave as well as M2M clients. For slave address of devices’ fifo could be already known to the driver. Various types of operations could be expressed by setting appropriate values to the ‘dma_interleaved_template’ members. Cyclic interleaved DMA transfers are also possible if supported by the channel by setting the DMA_PREP_REPEAT transfer flag.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKZhjubah}(h]h ]h"]h$]h&]uh1j#hjubeh}(h]h ]h"]h$]h&]jjuh1jhhhKQhjubh)}(h[A non-NULL return of this transfer API represents a "descriptor" for the given transaction.h]h_A non-NULL return of this transfer API represents a “descriptor” for the given transaction.}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKahjubh)}(h Interface:h]h Interface:}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKdhjubj)}(hX$struct dma_async_tx_descriptor *dmaengine_prep_slave_sg( struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, enum dma_data_direction direction, unsigned long flags); struct dma_async_tx_descriptor *dmaengine_prep_peripheral_dma_vec( struct dma_chan *chan, const struct dma_vec *vecs, size_t nents, enum dma_data_direction direction, unsigned long flags); struct dma_async_tx_descriptor *dmaengine_prep_dma_cyclic( struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, size_t period_len, enum dma_data_direction direction); struct dma_async_tx_descriptor *dmaengine_prep_interleaved_dma( struct dma_chan *chan, struct dma_interleaved_template *xt, unsigned long flags);h]hX$struct dma_async_tx_descriptor *dmaengine_prep_slave_sg( struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, enum dma_data_direction direction, unsigned long flags); struct dma_async_tx_descriptor *dmaengine_prep_peripheral_dma_vec( struct dma_chan *chan, const struct dma_vec *vecs, size_t nents, enum dma_data_direction direction, unsigned long flags); struct dma_async_tx_descriptor *dmaengine_prep_dma_cyclic( struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, size_t period_len, enum dma_data_direction direction); struct dma_async_tx_descriptor *dmaengine_prep_interleaved_dma( struct dma_chan *chan, struct dma_interleaved_template *xt, unsigned long flags);}hjLsbah}(h]h ]h"]h$]h&]jjjjjj}uh1jhhhKfhjubh)}(hXThe peripheral driver is expected to have mapped the scatterlist for the DMA operation prior to calling dmaengine_prep_slave_sg(), and must keep the scatterlist mapped until the DMA operation has completed. The scatterlist must be mapped using the DMA struct device. If a mapping needs to be synchronized later, dma_sync_*_for_*() must be called using the DMA struct device, too. So, normal setup should look like this:h]hXThe peripheral driver is expected to have mapped the scatterlist for the DMA operation prior to calling dmaengine_prep_slave_sg(), and must keep the scatterlist mapped until the DMA operation has completed. The scatterlist must be mapped using the DMA struct device. If a mapping needs to be synchronized later, dma_sync_*_for_*() must be called using the DMA struct device, too. So, normal setup should look like this:}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKzhjubj)}(hstruct device *dma_dev = dmaengine_get_dma_device(chan); nr_sg = dma_map_sg(dma_dev, sgl, sg_len); if (nr_sg == 0) /* error */ desc = dmaengine_prep_slave_sg(chan, sgl, nr_sg, direction, flags);h]hstruct device *dma_dev = dmaengine_get_dma_device(chan); nr_sg = dma_map_sg(dma_dev, sgl, sg_len); if (nr_sg == 0) /* error */ desc = dmaengine_prep_slave_sg(chan, sgl, nr_sg, direction, flags);}hjisbah}(h]h ]h"]h$]h&]jjjjjj}uh1jhhhKhjubh)}(hXOnce a descriptor has been obtained, the callback information can be added and the descriptor must then be submitted. Some DMA engine drivers may hold a spinlock between a successful preparation and submission so it is important that these two operations are closely paired.h]hXOnce a descriptor has been obtained, the callback information can be added and the descriptor must then be submitted. Some DMA engine drivers may hold a spinlock between a successful preparation and submission so it is important that these two operations are closely paired.}(hjxhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hXAlthough the async_tx API specifies that completion callback routines cannot submit any new operations, this is not the case for slave/cyclic DMA. For slave DMA, the subsequent transaction may not be available for submission prior to callback function being invoked, so slave DMA callbacks are permitted to prepare and submit a new transaction. For cyclic DMA, a callback function may wish to terminate the DMA via dmaengine_terminate_async(). Therefore, it is important that DMA engine drivers drop any locks before calling the callback function which may cause a deadlock. Note that callbacks will always be invoked from the DMA engines tasklet, never from interrupt context.h](h)}(hAlthough the async_tx API specifies that completion callback routines cannot submit any new operations, this is not the case for slave/cyclic DMA.h]hAlthough the async_tx API specifies that completion callback routines cannot submit any new operations, this is not the case for slave/cyclic DMA.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hFor slave DMA, the subsequent transaction may not be available for submission prior to callback function being invoked, so slave DMA callbacks are permitted to prepare and submit a new transaction.h]hFor slave DMA, the subsequent transaction may not be available for submission prior to callback function being invoked, so slave DMA callbacks are permitted to prepare and submit a new transaction.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hbFor cyclic DMA, a callback function may wish to terminate the DMA via dmaengine_terminate_async().h]hbFor cyclic DMA, a callback function may wish to terminate the DMA via dmaengine_terminate_async().}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hTherefore, it is important that DMA engine drivers drop any locks before calling the callback function which may cause a deadlock.h]hTherefore, it is important that DMA engine drivers drop any locks before calling the callback function which may cause a deadlock.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hfNote that callbacks will always be invoked from the DMA engines tasklet, never from interrupt context.h]hfNote that callbacks will always be invoked from the DMA engines tasklet, never from interrupt context.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhjubh)}(h%**Optional: per descriptor metadata**h]hstrong)}(hjh]h!Optional: per descriptor metadata}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(h1DMAengine provides two ways for metadata support.h]h1DMAengine provides two ways for metadata support.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hDESC_METADATA_CLIENTh]hDESC_METADATA_CLIENT}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(heThe metadata buffer is allocated/provided by the client driver and it is attached to the descriptor. h]h)}(hdThe metadata buffer is allocated/provided by the client driver and it is attached to the descriptor.h]hdThe metadata buffer is allocated/provided by the client driver and it is attached to the descriptor.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(hint dmaengine_desc_attach_metadata(struct dma_async_tx_descriptor *desc, void *data, size_t len);h]hint dmaengine_desc_attach_metadata(struct dma_async_tx_descriptor *desc, void *data, size_t len);}hj#sbah}(h]h ]h"]h$]h&]jjjjjj}uh1jhhhKhjubh)}(hDESC_METADATA_ENGINEh]hDESC_METADATA_ENGINE}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hXThe metadata buffer is allocated/managed by the DMA driver. The client driver can ask for the pointer, maximum size and the currently used size of the metadata and can directly update or read it. Because the DMA driver manages the memory area containing the metadata, clients must make sure that they do not try to access or get the pointer after their transfer completion callback has run for the descriptor. If no completion callback has been defined for the transfer, then the metadata must not be accessed after issue_pending. In other words: if the aim is to read back metadata after the transfer is completed, then the client must use completion callback. h](h)}(hThe metadata buffer is allocated/managed by the DMA driver. The client driver can ask for the pointer, maximum size and the currently used size of the metadata and can directly update or read it.h]hThe metadata buffer is allocated/managed by the DMA driver. The client driver can ask for the pointer, maximum size and the currently used size of the metadata and can directly update or read it.}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj@ubh)}(hXBecause the DMA driver manages the memory area containing the metadata, clients must make sure that they do not try to access or get the pointer after their transfer completion callback has run for the descriptor. If no completion callback has been defined for the transfer, then the metadata must not be accessed after issue_pending. In other words: if the aim is to read back metadata after the transfer is completed, then the client must use completion callback.h]hXBecause the DMA driver manages the memory area containing the metadata, clients must make sure that they do not try to access or get the pointer after their transfer completion callback has run for the descriptor. If no completion callback has been defined for the transfer, then the metadata must not be accessed after issue_pending. In other words: if the aim is to read back metadata after the transfer is completed, then the client must use completion callback.}(hjRhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj@ubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(hvoid *dmaengine_desc_get_metadata_ptr(struct dma_async_tx_descriptor *desc, size_t *payload_len, size_t *max_len); int dmaengine_desc_set_metadata_len(struct dma_async_tx_descriptor *desc, size_t payload_len);h]hvoid *dmaengine_desc_get_metadata_ptr(struct dma_async_tx_descriptor *desc, size_t *payload_len, size_t *max_len); int dmaengine_desc_set_metadata_len(struct dma_async_tx_descriptor *desc, size_t payload_len);}hjfsbah}(h]h ]h"]h$]h&]jjjjjj}uh1jhhhKhjubh)}(h;Client drivers can query if a given mode is supported with:h]h;Client drivers can query if a given mode is supported with:}(hjuhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hnbool dmaengine_is_metadata_mode_supported(struct dma_chan *chan, enum dma_desc_metadata_mode mode);h]hnbool dmaengine_is_metadata_mode_supported(struct dma_chan *chan, enum dma_desc_metadata_mode mode);}hjsbah}(h]h ]h"]h$]h&]jjjjjj}uh1jhhhKhjubh)}(hEDepending on the used mode client drivers must follow different flow.h]hEDepending on the used mode client drivers must follow different flow.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hDESC_METADATA_CLIENTh]hDESC_METADATA_CLIENT}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hX - DMA_MEM_TO_DEV / DEV_MEM_TO_MEM: 1. prepare the descriptor (dmaengine_prep_*) construct the metadata in the client's buffer 2. use dmaengine_desc_attach_metadata() to attach the buffer to the descriptor 3. submit the transfer - DMA_DEV_TO_MEM: 1. prepare the descriptor (dmaengine_prep_*) 2. use dmaengine_desc_attach_metadata() to attach the buffer to the descriptor 3. submit the transfer 4. when the transfer is completed, the metadata should be available in the attached buffer h]j)}(hhh](j$)}(hDMA_MEM_TO_DEV / DEV_MEM_TO_MEM: 1. prepare the descriptor (dmaengine_prep_*) construct the metadata in the client's buffer 2. use dmaengine_desc_attach_metadata() to attach the buffer to the descriptor 3. submit the transfer h](h)}(h DMA_MEM_TO_DEV / DEV_MEM_TO_MEM:h]h DMA_MEM_TO_DEV / DEV_MEM_TO_MEM:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hhh](j$)}(hWprepare the descriptor (dmaengine_prep_*) construct the metadata in the client's bufferh]h)}(hWprepare the descriptor (dmaengine_prep_*) construct the metadata in the client's bufferh]hYprepare the descriptor (dmaengine_prep_*) construct the metadata in the client’s buffer}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j#hjubj$)}(hKuse dmaengine_desc_attach_metadata() to attach the buffer to the descriptorh]h)}(hKuse dmaengine_desc_attach_metadata() to attach the buffer to the descriptorh]hKuse dmaengine_desc_attach_metadata() to attach the buffer to the descriptor}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j#hjubj$)}(hsubmit the transfer h]h)}(hsubmit the transferh]hsubmit the transfer}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j#hjubeh}(h]h ]h"]h$]h&]jjjhjjuh1jhjubeh}(h]h ]h"]h$]h&]uh1j#hjubj$)}(hXDMA_DEV_TO_MEM: 1. prepare the descriptor (dmaengine_prep_*) 2. use dmaengine_desc_attach_metadata() to attach the buffer to the descriptor 3. submit the transfer 4. when the transfer is completed, the metadata should be available in the attached buffer h](h)}(hDMA_DEV_TO_MEM:h]hDMA_DEV_TO_MEM:}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hhh](j$)}(h)prepare the descriptor (dmaengine_prep_*)h]h)}(hj5h]h)prepare the descriptor (dmaengine_prep_*)}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj3ubah}(h]h ]h"]h$]h&]uh1j#hj0ubj$)}(hKuse dmaengine_desc_attach_metadata() to attach the buffer to the descriptorh]h)}(hKuse dmaengine_desc_attach_metadata() to attach the buffer to the descriptorh]hKuse dmaengine_desc_attach_metadata() to attach the buffer to the descriptor}(hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjJubah}(h]h ]h"]h$]h&]uh1j#hj0ubj$)}(hsubmit the transferh]h)}(hjdh]hsubmit the transfer}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjbubah}(h]h ]h"]h$]h&]uh1j#hj0ubj$)}(hXwhen the transfer is completed, the metadata should be available in the attached buffer h]h)}(hWwhen the transfer is completed, the metadata should be available in the attached bufferh]hWwhen the transfer is completed, the metadata should be available in the attached buffer}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjyubah}(h]h ]h"]h$]h&]uh1j#hj0ubeh}(h]h ]h"]h$]h&]jjjhjjuh1jhjubeh}(h]h ]h"]h$]h&]uh1j#hjubeh}(h]h ]h"]h$]h&]jjuh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjubh)}(hDESC_METADATA_ENGINEh]hDESC_METADATA_ENGINE}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hX- DMA_MEM_TO_DEV / DEV_MEM_TO_MEM: 1. prepare the descriptor (dmaengine_prep_*) 2. use dmaengine_desc_get_metadata_ptr() to get the pointer to the engine's metadata area 3. update the metadata at the pointer 4. use dmaengine_desc_set_metadata_len() to tell the DMA engine the amount of data the client has placed into the metadata buffer 5. submit the transfer - DMA_DEV_TO_MEM: 1. prepare the descriptor (dmaengine_prep_*) 2. submit the transfer 3. on transfer completion, use dmaengine_desc_get_metadata_ptr() to get the pointer to the engine's metadata area 4. read out the metadata from the pointer h]j)}(hhh](j$)}(hXoDMA_MEM_TO_DEV / DEV_MEM_TO_MEM: 1. prepare the descriptor (dmaengine_prep_*) 2. use dmaengine_desc_get_metadata_ptr() to get the pointer to the engine's metadata area 3. update the metadata at the pointer 4. use dmaengine_desc_set_metadata_len() to tell the DMA engine the amount of data the client has placed into the metadata buffer 5. submit the transfer h](h)}(h DMA_MEM_TO_DEV / DEV_MEM_TO_MEM:h]h DMA_MEM_TO_DEV / DEV_MEM_TO_MEM:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hhh](j$)}(h)prepare the descriptor (dmaengine_prep_*)h]h)}(hjh]h)prepare the descriptor (dmaengine_prep_*)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j#hjubj$)}(hVuse dmaengine_desc_get_metadata_ptr() to get the pointer to the engine's metadata areah]h)}(hVuse dmaengine_desc_get_metadata_ptr() to get the pointer to the engine's metadata areah]hXuse dmaengine_desc_get_metadata_ptr() to get the pointer to the engine’s metadata area}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j#hjubj$)}(h"update the metadata at the pointerh]h)}(hjh]h"update the metadata at the pointer}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j#hjubj$)}(huse dmaengine_desc_set_metadata_len() to tell the DMA engine the amount of data the client has placed into the metadata bufferh]h)}(huse dmaengine_desc_set_metadata_len() to tell the DMA engine the amount of data the client has placed into the metadata bufferh]huse dmaengine_desc_set_metadata_len() to tell the DMA engine the amount of data the client has placed into the metadata buffer}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j#hjubj$)}(hsubmit the transfer h]h)}(hsubmit the transferh]hsubmit the transfer}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj1ubah}(h]h ]h"]h$]h&]uh1j#hjubeh}(h]h ]h"]h$]h&]jjjhjjuh1jhjubeh}(h]h ]h"]h$]h&]uh1j#hjubj$)}(hDMA_DEV_TO_MEM: 1. prepare the descriptor (dmaengine_prep_*) 2. submit the transfer 3. on transfer completion, use dmaengine_desc_get_metadata_ptr() to get the pointer to the engine's metadata area 4. read out the metadata from the pointer h](h)}(hDMA_DEV_TO_MEM:h]hDMA_DEV_TO_MEM:}(hjYhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjUubj)}(hhh](j$)}(h)prepare the descriptor (dmaengine_prep_*)h]h)}(hjlh]h)prepare the descriptor (dmaengine_prep_*)}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjjubah}(h]h ]h"]h$]h&]uh1j#hjgubj$)}(hsubmit the transferh]h)}(hjh]hsubmit the transfer}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j#hjgubj$)}(hnon transfer completion, use dmaengine_desc_get_metadata_ptr() to get the pointer to the engine's metadata areah]h)}(hnon transfer completion, use dmaengine_desc_get_metadata_ptr() to get the pointer to the engine's metadata areah]hpon transfer completion, use dmaengine_desc_get_metadata_ptr() to get the pointer to the engine’s metadata area}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j#hjgubj$)}(h'read out the metadata from the pointer h]h)}(h&read out the metadata from the pointerh]h&read out the metadata from the pointer}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j#hjgubeh}(h]h ]h"]h$]h&]jjjhjjuh1jhjUubeh}(h]h ]h"]h$]h&]uh1j#hjubeh}(h]h ]h"]h$]h&]jjuh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjubh)}(hXPWhen DESC_METADATA_ENGINE mode is used the metadata area for the descriptor is no longer valid after the transfer has been completed (valid up to the point when the completion callback returns if used). Mixed use of DESC_METADATA_CLIENT / DESC_METADATA_ENGINE is not allowed, client drivers must use either of the modes per descriptor.h](h)}(hWhen DESC_METADATA_ENGINE mode is used the metadata area for the descriptor is no longer valid after the transfer has been completed (valid up to the point when the completion callback returns if used).h]hWhen DESC_METADATA_ENGINE mode is used the metadata area for the descriptor is no longer valid after the transfer has been completed (valid up to the point when the completion callback returns if used).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hMixed use of DESC_METADATA_CLIENT / DESC_METADATA_ENGINE is not allowed, client drivers must use either of the modes per descriptor.h]hMixed use of DESC_METADATA_CLIENT / DESC_METADATA_ENGINE is not allowed, client drivers must use either of the modes per descriptor.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubeh}(h]h ]h"]h$]h&]uh1hhjubeh}(h]h ]h"]h$]h&]uh1jhhhKNhhhhubj)}(hhh](j$)}(hXSubmit the transaction Once the descriptor has been prepared and the callback information added, it must be placed on the DMA engine drivers pending queue. Interface: .. code-block:: c dma_cookie_t dmaengine_submit(struct dma_async_tx_descriptor *desc) This returns a cookie can be used to check the progress of DMA engine activity via other DMA engine calls not covered in this document. dmaengine_submit() will not start the DMA operation, it merely adds it to the pending queue. For this, see step 5, dma_async_issue_pending. .. note:: After calling ``dmaengine_submit()`` the submitted transfer descriptor (``struct dma_async_tx_descriptor``) belongs to the DMA engine. Consequently, the client must consider invalid the pointer to that descriptor. h](h)}(hSubmit the transactionh]hSubmit the transaction}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(hOnce the descriptor has been prepared and the callback information added, it must be placed on the DMA engine drivers pending queue.h]hOnce the descriptor has been prepared and the callback information added, it must be placed on the DMA engine drivers pending queue.}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h Interface:h]h Interface:}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjubj)}(hCdma_cookie_t dmaengine_submit(struct dma_async_tx_descriptor *desc)h]hCdma_cookie_t dmaengine_submit(struct dma_async_tx_descriptor *desc)}hj=sbah}(h]h ]h"]h$]h&]jjjjjj}uh1jhhhM hjubh)}(hThis returns a cookie can be used to check the progress of DMA engine activity via other DMA engine calls not covered in this document.h]hThis returns a cookie can be used to check the progress of DMA engine activity via other DMA engine calls not covered in this document.}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(hdmaengine_submit() will not start the DMA operation, it merely adds it to the pending queue. For this, see step 5, dma_async_issue_pending.h]hdmaengine_submit() will not start the DMA operation, it merely adds it to the pending queue. For this, see step 5, dma_async_issue_pending.}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(hAfter calling ``dmaengine_submit()`` the submitted transfer descriptor (``struct dma_async_tx_descriptor``) belongs to the DMA engine. Consequently, the client must consider invalid the pointer to that descriptor.h]h)}(hAfter calling ``dmaengine_submit()`` the submitted transfer descriptor (``struct dma_async_tx_descriptor``) belongs to the DMA engine. Consequently, the client must consider invalid the pointer to that descriptor.h](hAfter calling }(hjlhhhNhNubh)}(h``dmaengine_submit()``h]hdmaengine_submit()}(hjthhhNhNubah}(h]h ]h"]h$]h&]uh1hhjlubh$ the submitted transfer descriptor (}(hjlhhhNhNubh)}(h"``struct dma_async_tx_descriptor``h]hstruct dma_async_tx_descriptor}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjlubhk) belongs to the DMA engine. Consequently, the client must consider invalid the pointer to that descriptor.}(hjlhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhubah}(h]h ]h"]h$]h&]uh1hhjubeh}(h]h ]h"]h$]h&]uh1j#hj hhhNhNubj$)}(hXIssue pending DMA requests and wait for callback notification The transactions in the pending queue can be activated by calling the issue_pending API. If channel is idle then the first transaction in queue is started and subsequent ones queued up. On completion of each DMA operation, the next in queue is started and a tasklet triggered. The tasklet will then call the client driver completion callback routine for notification, if set. Interface: .. code-block:: c void dma_async_issue_pending(struct dma_chan *chan); h](h)}(h=Issue pending DMA requests and wait for callback notificationh]h=Issue pending DMA requests and wait for callback notification}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(hThe transactions in the pending queue can be activated by calling the issue_pending API. If channel is idle then the first transaction in queue is started and subsequent ones queued up.h]hThe transactions in the pending queue can be activated by calling the issue_pending API. If channel is idle then the first transaction in queue is started and subsequent ones queued up.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(hOn completion of each DMA operation, the next in queue is started and a tasklet triggered. The tasklet will then call the client driver completion callback routine for notification, if set.h]hOn completion of each DMA operation, the next in queue is started and a tasklet triggered. The tasklet will then call the client driver completion callback routine for notification, if set.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM"hjubh)}(h Interface:h]h Interface:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM&hjubj)}(h4void dma_async_issue_pending(struct dma_chan *chan);h]h4void dma_async_issue_pending(struct dma_chan *chan);}hjsbah}(h]h ]h"]h$]h&]jjjjjj}uh1jhhhM(hjubeh}(h]h ]h"]h$]h&]uh1j#hj hhhNhNubeh}(h]h ]h"]h$]h&]jjjhjjstartKuh1jhhhhhhhMubh)}(hhh](h)}(h Further APIsh]h Further APIs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhM-ubj)}(hhh](j$)}(hXTerminate APIs .. code-block:: c int dmaengine_terminate_sync(struct dma_chan *chan) int dmaengine_terminate_async(struct dma_chan *chan) int dmaengine_terminate_all(struct dma_chan *chan) /* DEPRECATED */ This causes all activity for the DMA channel to be stopped, and may discard data in the DMA FIFO which hasn't been fully transferred. No callback functions will be called for any incomplete transfers. Two variants of this function are available. dmaengine_terminate_async() might not wait until the DMA has been fully stopped or until any running complete callbacks have finished. But it is possible to call dmaengine_terminate_async() from atomic context or from within a complete callback. dmaengine_synchronize() must be called before it is safe to free the memory accessed by the DMA transfer or free resources accessed from within the complete callback. dmaengine_terminate_sync() will wait for the transfer and any running complete callbacks to finish before it returns. But the function must not be called from atomic context or from within a complete callback. dmaengine_terminate_all() is deprecated and should not be used in new code. h](h)}(hTerminate APIsh]hTerminate APIs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM/hjubj)}(hint dmaengine_terminate_sync(struct dma_chan *chan) int dmaengine_terminate_async(struct dma_chan *chan) int dmaengine_terminate_all(struct dma_chan *chan) /* DEPRECATED */h]hint dmaengine_terminate_sync(struct dma_chan *chan) int dmaengine_terminate_async(struct dma_chan *chan) int dmaengine_terminate_all(struct dma_chan *chan) /* DEPRECATED */}hj(sbah}(h]h ]h"]h$]h&]jjjjjj}uh1jhhhM1hjubh)}(hThis causes all activity for the DMA channel to be stopped, and may discard data in the DMA FIFO which hasn't been fully transferred. No callback functions will be called for any incomplete transfers.h]hThis causes all activity for the DMA channel to be stopped, and may discard data in the DMA FIFO which hasn’t been fully transferred. No callback functions will be called for any incomplete transfers.}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM7hjubh)}(h,Two variants of this function are available.h]h,Two variants of this function are available.}(hjEhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM;hjubh)}(hXdmaengine_terminate_async() might not wait until the DMA has been fully stopped or until any running complete callbacks have finished. But it is possible to call dmaengine_terminate_async() from atomic context or from within a complete callback. dmaengine_synchronize() must be called before it is safe to free the memory accessed by the DMA transfer or free resources accessed from within the complete callback.h]hXdmaengine_terminate_async() might not wait until the DMA has been fully stopped or until any running complete callbacks have finished. But it is possible to call dmaengine_terminate_async() from atomic context or from within a complete callback. dmaengine_synchronize() must be called before it is safe to free the memory accessed by the DMA transfer or free resources accessed from within the complete callback.}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM=hjubh)}(hdmaengine_terminate_sync() will wait for the transfer and any running complete callbacks to finish before it returns. But the function must not be called from atomic context or from within a complete callback.h]hdmaengine_terminate_sync() will wait for the transfer and any running complete callbacks to finish before it returns. But the function must not be called from atomic context or from within a complete callback.}(hjahhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMDhjubh)}(hKdmaengine_terminate_all() is deprecated and should not be used in new code.h]hKdmaengine_terminate_all() is deprecated and should not be used in new code.}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMHhjubeh}(h]h ]h"]h$]h&]uh1j#hjhhhhhNubj$)}(hPause API .. code-block:: c int dmaengine_pause(struct dma_chan *chan) This pauses activity on the DMA channel without data loss. h](h)}(h Pause APIh]h Pause API}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMJhjubj)}(h*int dmaengine_pause(struct dma_chan *chan)h]h*int dmaengine_pause(struct dma_chan *chan)}hjsbah}(h]h ]h"]h$]h&]jjjjjj}uh1jhhhMLhjubh)}(h:This pauses activity on the DMA channel without data loss.h]h:This pauses activity on the DMA channel without data loss.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMPhjubeh}(h]h ]h"]h$]h&]uh1j#hjhhhhhNubj$)}(hResume API .. code-block:: c int dmaengine_resume(struct dma_chan *chan) Resume a previously paused DMA channel. It is invalid to resume a channel which is not currently paused. h](h)}(h Resume APIh]h Resume API}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMRhjubj)}(h+int dmaengine_resume(struct dma_chan *chan)h]h+int dmaengine_resume(struct dma_chan *chan)}hjsbah}(h]h ]h"]h$]h&]jjjjjj}uh1jhhhMThjubh)}(hhResume a previously paused DMA channel. It is invalid to resume a channel which is not currently paused.h]hhResume a previously paused DMA channel. It is invalid to resume a channel which is not currently paused.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMXhjubeh}(h]h ]h"]h$]h&]uh1j#hjhhhhhNubj$)}(hXCheck Txn complete .. code-block:: c enum dma_status dma_async_is_tx_complete(struct dma_chan *chan, dma_cookie_t cookie, dma_cookie_t *last, dma_cookie_t *used) This can be used to check the status of the channel. Please see the documentation in include/linux/dmaengine.h for a more complete description of this API. This can be used in conjunction with dma_async_is_complete() and the cookie returned from dmaengine_submit() to check for completion of a specific DMA transaction. .. note:: Not all DMA engine drivers can return reliable information for a running DMA channel. It is recommended that DMA engine users pause or stop (via dmaengine_terminate_all()) the channel before using this API. h](h)}(hCheck Txn completeh]hCheck Txn complete}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM[hjubj)}(henum dma_status dma_async_is_tx_complete(struct dma_chan *chan, dma_cookie_t cookie, dma_cookie_t *last, dma_cookie_t *used)h]henum dma_status dma_async_is_tx_complete(struct dma_chan *chan, dma_cookie_t cookie, dma_cookie_t *last, dma_cookie_t *used)}hjsbah}(h]h ]h"]h$]h&]jjjjjj}uh1jhhhM]hjubh)}(hThis can be used to check the status of the channel. Please see the documentation in include/linux/dmaengine.h for a more complete description of this API.h]hThis can be used to check the status of the channel. Please see the documentation in include/linux/dmaengine.h for a more complete description of this API.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMbhjubh)}(hThis can be used in conjunction with dma_async_is_complete() and the cookie returned from dmaengine_submit() to check for completion of a specific DMA transaction.h]hThis can be used in conjunction with dma_async_is_complete() and the cookie returned from dmaengine_submit() to check for completion of a specific DMA transaction.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMfhjubh)}(hNot all DMA engine drivers can return reliable information for a running DMA channel. It is recommended that DMA engine users pause or stop (via dmaengine_terminate_all()) the channel before using this API.h]h)}(hNot all DMA engine drivers can return reliable information for a running DMA channel. It is recommended that DMA engine users pause or stop (via dmaengine_terminate_all()) the channel before using this API.h]hNot all DMA engine drivers can return reliable information for a running DMA channel. It is recommended that DMA engine users pause or stop (via dmaengine_terminate_all()) the channel before using this API.}(hj. hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMlhj* ubah}(h]h ]h"]h$]h&]uh1hhjubeh}(h]h ]h"]h$]h&]uh1j#hjhhhNhNubj$)}(hX=Synchronize termination API .. code-block:: c void dmaengine_synchronize(struct dma_chan *chan) Synchronize the termination of the DMA channel to the current context. This function should be used after dmaengine_terminate_async() to synchronize the termination of the DMA channel to the current context. The function will wait for the transfer and any running complete callbacks to finish before it returns. If dmaengine_terminate_async() is used to stop the DMA channel this function must be called before it is safe to free memory accessed by previously submitted descriptors or to free any resources accessed within the complete callback of previously submitted descriptors. The behavior of this function is undefined if dma_async_issue_pending() has been called between dmaengine_terminate_async() and this function.h](h)}(hSynchronize termination APIh]hSynchronize termination API}(hjL hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMqhjH ubj)}(h1void dmaengine_synchronize(struct dma_chan *chan)h]h1void dmaengine_synchronize(struct dma_chan *chan)}hjZ sbah}(h]h ]h"]h$]h&]jjjjjj}uh1jhhhMshjH ubh)}(hFSynchronize the termination of the DMA channel to the current context.h]hFSynchronize the termination of the DMA channel to the current context.}(hji hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMwhjH ubh)}(hThis function should be used after dmaengine_terminate_async() to synchronize the termination of the DMA channel to the current context. The function will wait for the transfer and any running complete callbacks to finish before it returns.h]hThis function should be used after dmaengine_terminate_async() to synchronize the termination of the DMA channel to the current context. The function will wait for the transfer and any running complete callbacks to finish before it returns.}(hjw hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMyhjH ubh)}(hX If dmaengine_terminate_async() is used to stop the DMA channel this function must be called before it is safe to free memory accessed by previously submitted descriptors or to free any resources accessed within the complete callback of previously submitted descriptors.h]hX If dmaengine_terminate_async() is used to stop the DMA channel this function must be called before it is safe to free memory accessed by previously submitted descriptors or to free any resources accessed within the complete callback of previously submitted descriptors.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM~hjH ubh)}(hThe behavior of this function is undefined if dma_async_issue_pending() has been called between dmaengine_terminate_async() and this function.h]hThe behavior of this function is undefined if dma_async_issue_pending() has been called between dmaengine_terminate_async() and this function.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjH ubeh}(h]h ]h"]h$]h&]uh1j#hjhhhhhNubeh}(h]h ]h"]h$]h&]jjjhjjuh1jhjhhhhhM/ubeh}(h] further-apisah ]h"] further apisah$]h&]uh1hhhhhhhhM-ubeh}(h] dma-usageah ]h"] dma usageah$]h&]uh1hhhhhhhhKubeh}(h]dma-engine-api-guideah ]h"]dma engine api guideah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerj error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(j j j j j j u nametypes}(j j j uh}(j hj hj ju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]hsystem_message)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "4" (ordinal 4)h]h>Enumerated list start value not ordinal-1: “4” (ordinal 4)}(hjO hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjL ubah}(h]h ]h"]h$]h&]levelKtypeINFOsourcehlineKuh1jJ hhhhhhhMubatransform_messages] transformerN include_log] decorationNhhub.