From patchwork Sat Jul 29 15:22:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9870201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 86BC060353 for ; Sun, 30 Jul 2017 04:33:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 777B528621 for ; Sun, 30 Jul 2017 04:33:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C61B28634; Sun, 30 Jul 2017 04:33:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E530D28621 for ; Sun, 30 Jul 2017 04:33:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BBE356FC9D; Sun, 30 Jul 2017 04:30:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x243.google.com (mail-qk0-x243.google.com [IPv6:2607:f8b0:400d:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9DB4B89175 for ; Sat, 29 Jul 2017 16:19:10 +0000 (UTC) Received: by mail-qk0-x243.google.com with SMTP id d136so23502093qkg.3 for ; Sat, 29 Jul 2017 09:19:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TNEra2czLaN61lt83S4VBE7DgstcYxEN5rdrfwPseFA=; b=GxQno+Z9JsQMtwaWZlu4+XEnaujUXboHFGKymO6EwivTcwP9wC47uKHtUp1vHiUL16 kN+CmDvQRChH42L8Hu6Ssrp0XxsILZdtlyOJy0I8CgImLKdgYFsciAAYyRTlxvV6qI4A E+iZmA6EfD0ko/rkoYeqk2taANvO//ayes4I/zF6VmGpUtfOqAPJfklNFMhSucIaYglB sbzBKHNLgNR9t1gnWpS3zNlwndlx4zqkVJgA9nnVE9vAzIIO9SObMZMLE6OXUIZWVXAI 8OnxPgdWs/barZXA9sZG2stb+/cV9DywMjTl5jNGGbu/cRqsVBvWwSJ9G4CwjXhuUROo hPyA== X-Gm-Message-State: AIVw112glgSt2iAb4YJxI5uQMieWtc3DGU3obZklSOG8skkzKhQHpjfo QFcNmjY4m0j545Xyxt0= X-Received: by 10.55.183.65 with SMTP id h62mr15192436qkf.35.1501341741811; Sat, 29 Jul 2017 08:22:21 -0700 (PDT) Received: from localhost.localdomain ([187.35.198.81]) by smtp.gmail.com with ESMTPSA id c204sm8737392qkb.32.2017.07.29.08.22.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Jul 2017 08:22:21 -0700 (PDT) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] dma-buf/sw_sync: move timeline_fence_ops around Date: Sat, 29 Jul 2017 12:22:15 -0300 Message-Id: <20170729152217.8362-1-gustavo@padovan.org> X-Mailer: git-send-email 2.9.4 Cc: Gustavo Padovan X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gustavo Padovan We are going to use timeline_fence_signaled() in a internal function in the next commit. Cc: Chris Wilson Signed-off-by: Gustavo Padovan Reviewed-by: Chris Wilson --- drivers/dma-buf/sw_sync.c | 138 +++++++++++++++++++++++----------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c index af1bc84..ef0cc08 100644 --- a/drivers/dma-buf/sw_sync.c +++ b/drivers/dma-buf/sw_sync.c @@ -125,6 +125,75 @@ static void sync_timeline_put(struct sync_timeline *obj) kref_put(&obj->kref, sync_timeline_free); } +static const char *timeline_fence_get_driver_name(struct dma_fence *fence) +{ + return "sw_sync"; +} + +static const char *timeline_fence_get_timeline_name(struct dma_fence *fence) +{ + struct sync_timeline *parent = dma_fence_parent(fence); + + return parent->name; +} + +static void timeline_fence_release(struct dma_fence *fence) +{ + struct sync_pt *pt = dma_fence_to_sync_pt(fence); + struct sync_timeline *parent = dma_fence_parent(fence); + + if (!list_empty(&pt->link)) { + unsigned long flags; + + spin_lock_irqsave(fence->lock, flags); + if (!list_empty(&pt->link)) { + list_del(&pt->link); + rb_erase(&pt->node, &parent->pt_tree); + } + spin_unlock_irqrestore(fence->lock, flags); + } + + sync_timeline_put(parent); + dma_fence_free(fence); +} + +static bool timeline_fence_signaled(struct dma_fence *fence) +{ + struct sync_timeline *parent = dma_fence_parent(fence); + + return !__dma_fence_is_later(fence->seqno, parent->value); +} + +static bool timeline_fence_enable_signaling(struct dma_fence *fence) +{ + return true; +} + +static void timeline_fence_value_str(struct dma_fence *fence, + char *str, int size) +{ + snprintf(str, size, "%d", fence->seqno); +} + +static void timeline_fence_timeline_value_str(struct dma_fence *fence, + char *str, int size) +{ + struct sync_timeline *parent = dma_fence_parent(fence); + + snprintf(str, size, "%d", parent->value); +} + +static const struct dma_fence_ops timeline_fence_ops = { + .get_driver_name = timeline_fence_get_driver_name, + .get_timeline_name = timeline_fence_get_timeline_name, + .enable_signaling = timeline_fence_enable_signaling, + .signaled = timeline_fence_signaled, + .wait = dma_fence_default_wait, + .release = timeline_fence_release, + .fence_value_str = timeline_fence_value_str, + .timeline_value_str = timeline_fence_timeline_value_str, +}; + /** * sync_timeline_signal() - signal a status change on a sync_timeline * @obj: sync_timeline to signal @@ -216,75 +285,6 @@ static struct sync_pt *sync_pt_create(struct sync_timeline *obj, return pt; } -static const char *timeline_fence_get_driver_name(struct dma_fence *fence) -{ - return "sw_sync"; -} - -static const char *timeline_fence_get_timeline_name(struct dma_fence *fence) -{ - struct sync_timeline *parent = dma_fence_parent(fence); - - return parent->name; -} - -static void timeline_fence_release(struct dma_fence *fence) -{ - struct sync_pt *pt = dma_fence_to_sync_pt(fence); - struct sync_timeline *parent = dma_fence_parent(fence); - - if (!list_empty(&pt->link)) { - unsigned long flags; - - spin_lock_irqsave(fence->lock, flags); - if (!list_empty(&pt->link)) { - list_del(&pt->link); - rb_erase(&pt->node, &parent->pt_tree); - } - spin_unlock_irqrestore(fence->lock, flags); - } - - sync_timeline_put(parent); - dma_fence_free(fence); -} - -static bool timeline_fence_signaled(struct dma_fence *fence) -{ - struct sync_timeline *parent = dma_fence_parent(fence); - - return !__dma_fence_is_later(fence->seqno, parent->value); -} - -static bool timeline_fence_enable_signaling(struct dma_fence *fence) -{ - return true; -} - -static void timeline_fence_value_str(struct dma_fence *fence, - char *str, int size) -{ - snprintf(str, size, "%d", fence->seqno); -} - -static void timeline_fence_timeline_value_str(struct dma_fence *fence, - char *str, int size) -{ - struct sync_timeline *parent = dma_fence_parent(fence); - - snprintf(str, size, "%d", parent->value); -} - -static const struct dma_fence_ops timeline_fence_ops = { - .get_driver_name = timeline_fence_get_driver_name, - .get_timeline_name = timeline_fence_get_timeline_name, - .enable_signaling = timeline_fence_enable_signaling, - .signaled = timeline_fence_signaled, - .wait = dma_fence_default_wait, - .release = timeline_fence_release, - .fence_value_str = timeline_fence_value_str, - .timeline_value_str = timeline_fence_timeline_value_str, -}; - /* * *WARNING* *