~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/dma-fence-unwrap.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 /*
  3  * Copyright (C) 2022 Advanced Micro Devices, Inc.
  4  * Authors:
  5  *      Christian König <christian.koenig@amd.com>
  6  */
  7 
  8 #ifndef __LINUX_DMA_FENCE_UNWRAP_H
  9 #define __LINUX_DMA_FENCE_UNWRAP_H
 10 
 11 struct dma_fence;
 12 
 13 /**
 14  * struct dma_fence_unwrap - cursor into the container structure
 15  *
 16  * Should be used with dma_fence_unwrap_for_each() iterator macro.
 17  */
 18 struct dma_fence_unwrap {
 19         /**
 20          * @chain: potential dma_fence_chain, but can be other fence as well
 21          */
 22         struct dma_fence *chain;
 23         /**
 24          * @array: potential dma_fence_array, but can be other fence as well
 25          */
 26         struct dma_fence *array;
 27         /**
 28          * @index: last returned index if @array is really a dma_fence_array
 29          */
 30         unsigned int index;
 31 };
 32 
 33 struct dma_fence *dma_fence_unwrap_first(struct dma_fence *head,
 34                                          struct dma_fence_unwrap *cursor);
 35 struct dma_fence *dma_fence_unwrap_next(struct dma_fence_unwrap *cursor);
 36 
 37 /**
 38  * dma_fence_unwrap_for_each - iterate over all fences in containers
 39  * @fence: current fence
 40  * @cursor: current position inside the containers
 41  * @head: starting point for the iterator
 42  *
 43  * Unwrap dma_fence_chain and dma_fence_array containers and deep dive into all
 44  * potential fences in them. If @head is just a normal fence only that one is
 45  * returned.
 46  */
 47 #define dma_fence_unwrap_for_each(fence, cursor, head)                  \
 48         for (fence = dma_fence_unwrap_first(head, cursor); fence;       \
 49              fence = dma_fence_unwrap_next(cursor))
 50 
 51 struct dma_fence *__dma_fence_unwrap_merge(unsigned int num_fences,
 52                                            struct dma_fence **fences,
 53                                            struct dma_fence_unwrap *cursors);
 54 
 55 /**
 56  * dma_fence_unwrap_merge - unwrap and merge fences
 57  *
 58  * All fences given as parameters are unwrapped and merged back together as flat
 59  * dma_fence_array. Useful if multiple containers need to be merged together.
 60  *
 61  * Implemented as a macro to allocate the necessary arrays on the stack and
 62  * account the stack frame size to the caller.
 63  *
 64  * Returns NULL on memory allocation failure, a dma_fence object representing
 65  * all the given fences otherwise.
 66  */
 67 #define dma_fence_unwrap_merge(...)                                     \
 68         ({                                                              \
 69                 struct dma_fence *__f[] = { __VA_ARGS__ };              \
 70                 struct dma_fence_unwrap __c[ARRAY_SIZE(__f)];           \
 71                                                                         \
 72                 __dma_fence_unwrap_merge(ARRAY_SIZE(__f), __f, __c);    \
 73         })
 74 
 75 #endif
 76 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php