aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/dmaengine.h
diff options
context:
space:
mode:
authorLogan Gunthorpe <logang@deltatee.com>2019-12-16 12:01:19 -0700
committerVinod Koul <vkoul@kernel.org>2019-12-24 10:18:32 +0530
commit8ad342a863590b24ce77681b7e081363fb3333f7 (patch)
tree393b6621b115e7cc07ff47e75ab897f929902654 /include/linux/dmaengine.h
parentdmaengine: Move dma_channel_rebalance() infrastructure up in code (diff)
downloadwireguard-linux-8ad342a863590b24ce77681b7e081363fb3333f7.tar.xz
wireguard-linux-8ad342a863590b24ce77681b7e081363fb3333f7.zip
dmaengine: Add reference counting to dma_device struct
Adding a reference count helps drivers to properly implement the unbind while in use case. References are taken and put every time a channel is allocated or freed. Once the final reference is put, the device is removed from the dma_device_list and a release callback function is called to signal the driver to free the memory. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Link: https://lore.kernel.org/r/20191216190120.21374-5-logang@deltatee.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'include/linux/dmaengine.h')
-rw-r--r--include/linux/dmaengine.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 11b15a2e97a0..7927731e3716 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -719,9 +719,14 @@ struct dma_filter {
* will just return a simple status code
* @device_issue_pending: push pending transactions to hardware
* @descriptor_reuse: a submitted transfer can be resubmitted after completion
+ * @device_release: called sometime atfer dma_async_device_unregister() is
+ * called and there are no further references to this structure. This
+ * must be implemented to free resources however many existing drivers
+ * do not and are therefore not safe to unbind while in use.
+ *
*/
struct dma_device {
-
+ struct kref ref;
unsigned int chancnt;
unsigned int privatecnt;
struct list_head channels;
@@ -802,6 +807,7 @@ struct dma_device {
dma_cookie_t cookie,
struct dma_tx_state *txstate);
void (*device_issue_pending)(struct dma_chan *chan);
+ void (*device_release)(struct dma_device *dev);
};
static inline int dmaengine_slave_config(struct dma_chan *chan,