diff options
author | Christian König <christian.koenig@amd.com> | 2021-05-05 13:38:12 +0200 |
---|---|---|
committer | Christian König <christian.koenig@amd.com> | 2021-06-14 19:38:34 +0200 |
commit | 440d0f12b52a920f4c78376b3ce7039ba59244c5 (patch) | |
tree | 68275ad9b3385a4fad67c75f281bd44d8c9d0fa2 /include/linux/dma-fence-chain.h | |
parent | 9c61e789546810ee63708568737cb990d2b86605 (diff) | |
download | linux-440d0f12b52a920f4c78376b3ce7039ba59244c5.tar.gz linux-440d0f12b52a920f4c78376b3ce7039ba59244c5.tar.bz2 linux-440d0f12b52a920f4c78376b3ce7039ba59244c5.zip |
dma-buf: add dma_fence_chain_alloc/free v3
Add a common allocation helper. Cleaning up the mix of kzalloc/kmalloc
and some unused code in the selftest.
v2: polish kernel doc a bit
v3: polish kernel doc even a bit more
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210611120301.10595-3-christian.koenig@amd.com
Diffstat (limited to 'include/linux/dma-fence-chain.h')
-rw-r--r-- | include/linux/dma-fence-chain.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/dma-fence-chain.h b/include/linux/dma-fence-chain.h index c6eb3aa45668..54fe3443fd2c 100644 --- a/include/linux/dma-fence-chain.h +++ b/include/linux/dma-fence-chain.h @@ -12,6 +12,7 @@ #include <linux/dma-fence.h> #include <linux/irq_work.h> +#include <linux/slab.h> /** * struct dma_fence_chain - fence to represent an node of a fence chain @@ -67,6 +68,30 @@ to_dma_fence_chain(struct dma_fence *fence) } /** + * dma_fence_chain_alloc + * + * Returns a new struct dma_fence_chain object or NULL on failure. + */ +static inline struct dma_fence_chain *dma_fence_chain_alloc(void) +{ + return kmalloc(sizeof(struct dma_fence_chain), GFP_KERNEL); +}; + +/** + * dma_fence_chain_free + * @chain: chain node to free + * + * Frees up an allocated but not used struct dma_fence_chain object. This + * doesn't need an RCU grace period since the fence was never initialized nor + * published. After dma_fence_chain_init() has been called the fence must be + * released by calling dma_fence_put(), and not through this function. + */ +static inline void dma_fence_chain_free(struct dma_fence_chain *chain) +{ + kfree(chain); +}; + +/** * dma_fence_chain_for_each - iterate over all fences in chain * @iter: current fence * @head: starting point |