forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dma-buf: cleanup dma_fence_unwrap implementation
Move the code from the inline functions into exported functions. Signed-off-by: Christian König <[email protected]> Acked-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
- Loading branch information
1 parent
0c5064f
commit 01357a5
Showing
3 changed files
with
64 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* dma-fence-util: misc functions for dma_fence objects | ||
* | ||
* Copyright (C) 2022 Advanced Micro Devices, Inc. | ||
* Authors: | ||
* Christian König <[email protected]> | ||
*/ | ||
|
||
#include <linux/dma-fence.h> | ||
#include <linux/dma-fence-array.h> | ||
#include <linux/dma-fence-chain.h> | ||
#include <linux/dma-fence-unwrap.h> | ||
|
||
/* Internal helper to start new array iteration, don't use directly */ | ||
static struct dma_fence * | ||
__dma_fence_unwrap_array(struct dma_fence_unwrap *cursor) | ||
{ | ||
cursor->array = dma_fence_chain_contained(cursor->chain); | ||
cursor->index = 0; | ||
return dma_fence_array_first(cursor->array); | ||
} | ||
|
||
/** | ||
* dma_fence_unwrap_first - return the first fence from fence containers | ||
* @head: the entrypoint into the containers | ||
* @cursor: current position inside the containers | ||
* | ||
* Unwraps potential dma_fence_chain/dma_fence_array containers and return the | ||
* first fence. | ||
*/ | ||
struct dma_fence *dma_fence_unwrap_first(struct dma_fence *head, | ||
struct dma_fence_unwrap *cursor) | ||
{ | ||
cursor->chain = dma_fence_get(head); | ||
return __dma_fence_unwrap_array(cursor); | ||
} | ||
EXPORT_SYMBOL_GPL(dma_fence_unwrap_first); | ||
|
||
/** | ||
* dma_fence_unwrap_next - return the next fence from a fence containers | ||
* @cursor: current position inside the containers | ||
* | ||
* Continue unwrapping the dma_fence_chain/dma_fence_array containers and return | ||
* the next fence from them. | ||
*/ | ||
struct dma_fence *dma_fence_unwrap_next(struct dma_fence_unwrap *cursor) | ||
{ | ||
struct dma_fence *tmp; | ||
|
||
++cursor->index; | ||
tmp = dma_fence_array_next(cursor->array, cursor->index); | ||
if (tmp) | ||
return tmp; | ||
|
||
cursor->chain = dma_fence_chain_walk(cursor->chain); | ||
return __dma_fence_unwrap_array(cursor); | ||
} | ||
EXPORT_SYMBOL_GPL(dma_fence_unwrap_next); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* | ||
* fence-chain: chain fences together in a timeline | ||
* | ||
* Copyright (C) 2022 Advanced Micro Devices, Inc. | ||
* Authors: | ||
* Christian König <[email protected]> | ||
|
@@ -10,8 +8,7 @@ | |
#ifndef __LINUX_DMA_FENCE_UNWRAP_H | ||
#define __LINUX_DMA_FENCE_UNWRAP_H | ||
|
||
#include <linux/dma-fence-chain.h> | ||
#include <linux/dma-fence-array.h> | ||
struct dma_fence; | ||
|
||
/** | ||
* struct dma_fence_unwrap - cursor into the container structure | ||
|
@@ -33,50 +30,9 @@ struct dma_fence_unwrap { | |
unsigned int index; | ||
}; | ||
|
||
/* Internal helper to start new array iteration, don't use directly */ | ||
static inline struct dma_fence * | ||
__dma_fence_unwrap_array(struct dma_fence_unwrap * cursor) | ||
{ | ||
cursor->array = dma_fence_chain_contained(cursor->chain); | ||
cursor->index = 0; | ||
return dma_fence_array_first(cursor->array); | ||
} | ||
|
||
/** | ||
* dma_fence_unwrap_first - return the first fence from fence containers | ||
* @head: the entrypoint into the containers | ||
* @cursor: current position inside the containers | ||
* | ||
* Unwraps potential dma_fence_chain/dma_fence_array containers and return the | ||
* first fence. | ||
*/ | ||
static inline struct dma_fence * | ||
dma_fence_unwrap_first(struct dma_fence *head, struct dma_fence_unwrap *cursor) | ||
{ | ||
cursor->chain = dma_fence_get(head); | ||
return __dma_fence_unwrap_array(cursor); | ||
} | ||
|
||
/** | ||
* dma_fence_unwrap_next - return the next fence from a fence containers | ||
* @cursor: current position inside the containers | ||
* | ||
* Continue unwrapping the dma_fence_chain/dma_fence_array containers and return | ||
* the next fence from them. | ||
*/ | ||
static inline struct dma_fence * | ||
dma_fence_unwrap_next(struct dma_fence_unwrap *cursor) | ||
{ | ||
struct dma_fence *tmp; | ||
|
||
++cursor->index; | ||
tmp = dma_fence_array_next(cursor->array, cursor->index); | ||
if (tmp) | ||
return tmp; | ||
|
||
cursor->chain = dma_fence_chain_walk(cursor->chain); | ||
return __dma_fence_unwrap_array(cursor); | ||
} | ||
struct dma_fence *dma_fence_unwrap_first(struct dma_fence *head, | ||
struct dma_fence_unwrap *cursor); | ||
struct dma_fence *dma_fence_unwrap_next(struct dma_fence_unwrap *cursor); | ||
|
||
/** | ||
* dma_fence_unwrap_for_each - iterate over all fences in containers | ||
|