drm: use dma_fence_unwrap_merge() in drm_syncobj
The unwrap merge function is now intended for this use case. 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/20220518135844.3338-6-christian.koenig@amd.com
This commit is contained in:
parent
245a4a7b53
commit
ec8d985ff2
@ -184,6 +184,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/anon_inodes.h>
|
#include <linux/anon_inodes.h>
|
||||||
|
#include <linux/dma-fence-unwrap.h>
|
||||||
#include <linux/file.h>
|
#include <linux/file.h>
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
#include <linux/sched/signal.h>
|
#include <linux/sched/signal.h>
|
||||||
@ -853,57 +854,12 @@ drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
|
|||||||
&args->handle);
|
&args->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Try to flatten a dma_fence_chain into a dma_fence_array so that it can be
|
|
||||||
* added as timeline fence to a chain again.
|
|
||||||
*/
|
|
||||||
static int drm_syncobj_flatten_chain(struct dma_fence **f)
|
|
||||||
{
|
|
||||||
struct dma_fence_chain *chain = to_dma_fence_chain(*f);
|
|
||||||
struct dma_fence *tmp, **fences;
|
|
||||||
struct dma_fence_array *array;
|
|
||||||
unsigned int count;
|
|
||||||
|
|
||||||
if (!chain)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
dma_fence_chain_for_each(tmp, &chain->base)
|
|
||||||
++count;
|
|
||||||
|
|
||||||
fences = kmalloc_array(count, sizeof(*fences), GFP_KERNEL);
|
|
||||||
if (!fences)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
dma_fence_chain_for_each(tmp, &chain->base)
|
|
||||||
fences[count++] = dma_fence_get(tmp);
|
|
||||||
|
|
||||||
array = dma_fence_array_create(count, fences,
|
|
||||||
dma_fence_context_alloc(1),
|
|
||||||
1, false);
|
|
||||||
if (!array)
|
|
||||||
goto free_fences;
|
|
||||||
|
|
||||||
dma_fence_put(*f);
|
|
||||||
*f = &array->base;
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
free_fences:
|
|
||||||
while (count--)
|
|
||||||
dma_fence_put(fences[count]);
|
|
||||||
|
|
||||||
kfree(fences);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int drm_syncobj_transfer_to_timeline(struct drm_file *file_private,
|
static int drm_syncobj_transfer_to_timeline(struct drm_file *file_private,
|
||||||
struct drm_syncobj_transfer *args)
|
struct drm_syncobj_transfer *args)
|
||||||
{
|
{
|
||||||
struct drm_syncobj *timeline_syncobj = NULL;
|
struct drm_syncobj *timeline_syncobj = NULL;
|
||||||
|
struct dma_fence *fence, *tmp;
|
||||||
struct dma_fence_chain *chain;
|
struct dma_fence_chain *chain;
|
||||||
struct dma_fence *fence;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
timeline_syncobj = drm_syncobj_find(file_private, args->dst_handle);
|
timeline_syncobj = drm_syncobj_find(file_private, args->dst_handle);
|
||||||
@ -912,13 +868,14 @@ static int drm_syncobj_transfer_to_timeline(struct drm_file *file_private,
|
|||||||
}
|
}
|
||||||
ret = drm_syncobj_find_fence(file_private, args->src_handle,
|
ret = drm_syncobj_find_fence(file_private, args->src_handle,
|
||||||
args->src_point, args->flags,
|
args->src_point, args->flags,
|
||||||
&fence);
|
&tmp);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_put_timeline;
|
goto err_put_timeline;
|
||||||
|
|
||||||
ret = drm_syncobj_flatten_chain(&fence);
|
fence = dma_fence_unwrap_merge(tmp);
|
||||||
if (ret)
|
dma_fence_put(tmp);
|
||||||
goto err_free_fence;
|
if (!fence)
|
||||||
|
goto err_put_timeline;
|
||||||
|
|
||||||
chain = dma_fence_chain_alloc();
|
chain = dma_fence_chain_alloc();
|
||||||
if (!chain) {
|
if (!chain) {
|
||||||
|
Loading…
Reference in New Issue
Block a user