From patchwork Fri Mar 1 00:43:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 2201551 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 80C5ADF24C for ; Fri, 1 Mar 2013 12:43:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 712D5E6448 for ; Fri, 1 Mar 2013 04:43:24 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-da0-f44.google.com (mail-da0-f44.google.com [209.85.210.44]) by gabe.freedesktop.org (Postfix) with ESMTP id AF346E60F3 for ; Thu, 28 Feb 2013 16:43:59 -0800 (PST) Received: by mail-da0-f44.google.com with SMTP id z20so1109240dae.17 for ; Thu, 28 Feb 2013 16:43:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=zYBEJMscTBsFaRVSlOrlflppf7OPr1P6zewQqV2JBp0=; b=DwJzDd2XMGJ5a8X8EP9tGzmkxKo+God+XEzERN5+YVrHNZxYRtCzyEUCAy9PVgHTl2 gjVL5cz5ebEXODCnhaga9eXYW6Ki9rk6o68+cFRagYIet9hAJ4F8CpsKHuzlUl2VQnD0 pZoxzFmguBpyc6CIHSiKo4Lm0VS6227Bf9ghfvh7h05EJaIJHpQBbXfyY4a4GfChDvtK P9lPmlVix7kjqksR9Tg7hDq6WJi4PzX/KQh2rvbKlsPXFBkTpASDMoBzMy/secPPMKjI Clnf9NcklWS9FN4vRnE48O/h6xPveCTopiMzdyEpkCcecwx0iS5gCs8UyYrqDSfvlAvm UdEA== X-Received: by 10.66.251.227 with SMTP id zn3mr15817653pac.178.1362098639809; Thu, 28 Feb 2013 16:43:59 -0800 (PST) Received: from localhost.localdomain (c-24-21-54-107.hsd1.or.comcast.net. [24.21.54.107]) by mx.google.com with ESMTPS id dx17sm10914892pac.17.2013.02.28.16.43.58 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Feb 2013 16:43:58 -0800 (PST) From: John Stultz To: lkml Subject: [PATCH 13/30] staging: sync: Optimize fence merges Date: Thu, 28 Feb 2013 16:43:09 -0800 Message-Id: <1362098606-26469-14-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1362098606-26469-1-git-send-email-john.stultz@linaro.org> References: <1362098606-26469-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQl58/LeZrZvz/+WScmtTDWQMH9Irx12XpTJMSW5AsXDRjSgIFMOL1Z5vGUOkCrFk6U5snIU X-Mailman-Approved-At: Fri, 01 Mar 2013 04:21:18 -0800 Cc: Daniel Vetter , dri-devel@lists.freedesktop.org, Rob Clark , John Stultz , Greg KH , Android Kernel Team X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org From: Erik Gilling 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 Cc: Erik Gilling Cc: Daniel Vetter Cc: Rob Clark Cc: Sumit Semwal Cc: Greg KH Cc: dri-devel@lists.freedesktop.org Cc: Android Kernel Team Signed-off-by: Erik Gilling [jstultz: Whitespace fixes] Signed-off-by: John Stultz --- drivers/staging/android/sync.c | 52 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 2afbd69..6cb7c88 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -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;