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: 15169 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4151B23E1A for ; Fri, 1 Mar 2013 00:44:02 +0000 (UTC) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by fiordland.canonical.com (Postfix) with ESMTP id CEA8FA1959D for ; Fri, 1 Mar 2013 00:44:01 +0000 (UTC) Received: by mail-vc0-f169.google.com with SMTP id n10so1650540vcn.28 for ; Thu, 28 Feb 2013 16:44:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=zYBEJMscTBsFaRVSlOrlflppf7OPr1P6zewQqV2JBp0=; b=bBDoqRumFdbAXAidSwC3AwjeXeO+dKJc4d+K22W6bFyidlf461NFt33TA07HzFPIPW WYK48VCiMuAncLir7ofmLAVI0fwM1vEOQscYM1JVv/rYA0QP+eNwz0h6FcQYP3qsdxll 2/acg+2t/k1Z4HmEahDLAo2yRXYno17tgPFMHeDE6FbU0lcVjao7k79K6jTG4hV0ZCmc ynrwi86Ef8zWpvwaQ2ZkbhvhZ44ip6k/0m+Yz964KTEe1vsrYICVPoT+pOJ8dORlmQ9p 0/9lzcvRsPHvgUH5TTWhfXZAoepGQq840SLNMVQXxUUwxjRp41mJtTJ7DJ1j8fa2JWkS WuJA== X-Received: by 10.220.149.82 with SMTP id s18mr3342616vcv.14.1362098641298; Thu, 28 Feb 2013 16:44:01 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp652veb; Thu, 28 Feb 2013 16:44:00 -0800 (PST) X-Received: by 10.66.2.132 with SMTP id 4mr16101260pau.11.1362098640250; Thu, 28 Feb 2013 16:44:00 -0800 (PST) Received: from mail-da0-f52.google.com (mail-da0-f52.google.com [209.85.210.52]) by mx.google.com with ESMTPS id l9si10601256paz.294.2013.02.28.16.43.59 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Feb 2013 16:44:00 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.52 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.210.52; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.52 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) smtp.mail=john.stultz@linaro.org Received: by mail-da0-f52.google.com with SMTP id x33so1111358dad.39 for ; Thu, 28 Feb 2013 16:43:59 -0800 (PST) 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 Cc: Erik Gilling , Maarten Lankhorst , Daniel Vetter , Rob Clark , Sumit Semwal , Greg KH , dri-devel@lists.freedesktop.org, Android Kernel Team , John Stultz 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: ALoCoQmo2dLyzfhlnmY8rbD1YUXNLS3hGac/WG1fwVCLapKd9yI4k9e4I+4x4XSI/0DojzZQ5HLK 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;