mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
staging: sync: Optimize fence merges
If the two fences being merged contain sync_pts from the same timeline, those two pts will be collapsed into a single pt representing the latter of the two. Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com> Cc: Erik Gilling <konkers@android.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Rob Clark <robclark@gmail.com> Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: dri-devel@lists.freedesktop.org Cc: Android Kernel Team <kernel-team@android.com> Signed-off-by: Erik Gilling <konkers@android.com> [jstultz: Whitespace fixes] Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
cc3c5cdc7b
commit
c6f668ce63
@ -312,6 +312,56 @@ static int sync_fence_copy_pts(struct sync_fence *dst, struct sync_fence *src)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sync_fence_merge_pts(struct sync_fence *dst, struct sync_fence *src)
|
||||
{
|
||||
struct list_head *src_pos, *dst_pos, *n;
|
||||
|
||||
list_for_each(src_pos, &src->pt_list_head) {
|
||||
struct sync_pt *src_pt =
|
||||
container_of(src_pos, struct sync_pt, pt_list);
|
||||
bool collapsed = false;
|
||||
|
||||
list_for_each_safe(dst_pos, n, &dst->pt_list_head) {
|
||||
struct sync_pt *dst_pt =
|
||||
container_of(dst_pos, struct sync_pt, pt_list);
|
||||
/* collapse two sync_pts on the same timeline
|
||||
* to a single sync_pt that will signal at
|
||||
* the later of the two
|
||||
*/
|
||||
if (dst_pt->parent == src_pt->parent) {
|
||||
if (dst_pt->parent->ops->compare(dst_pt, src_pt)
|
||||
== -1) {
|
||||
struct sync_pt *new_pt =
|
||||
sync_pt_dup(src_pt);
|
||||
if (new_pt == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
new_pt->fence = dst;
|
||||
list_replace(&dst_pt->pt_list,
|
||||
&new_pt->pt_list);
|
||||
sync_pt_activate(new_pt);
|
||||
sync_pt_free(dst_pt);
|
||||
}
|
||||
collapsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!collapsed) {
|
||||
struct sync_pt *new_pt = sync_pt_dup(src_pt);
|
||||
|
||||
if (new_pt == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
new_pt->fence = dst;
|
||||
list_add(&new_pt->pt_list, &dst->pt_list_head);
|
||||
sync_pt_activate(new_pt);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sync_fence_free_pts(struct sync_fence *fence)
|
||||
{
|
||||
struct list_head *pos, *n;
|
||||
@ -386,7 +436,7 @@ struct sync_fence *sync_fence_merge(const char *name,
|
||||
if (err < 0)
|
||||
goto err;
|
||||
|
||||
err = sync_fence_copy_pts(fence, b);
|
||||
err = sync_fence_merge_pts(fence, b);
|
||||
if (err < 0)
|
||||
goto err;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user