From patchwork Thu Jun 23 15:29:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9195485 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 7B16C6075A for ; Thu, 23 Jun 2016 15:31:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C0F628464 for ; Thu, 23 Jun 2016 15:31:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60E0428466; Thu, 23 Jun 2016 15:31:10 +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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D52628464 for ; Thu, 23 Jun 2016 15:31:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 347E06E97C; Thu, 23 Jun 2016 15:31:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw0-f195.google.com (mail-yw0-f195.google.com [209.85.161.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 83ABB6E3BC for ; Thu, 23 Jun 2016 15:30:11 +0000 (UTC) Received: by mail-yw0-f195.google.com with SMTP id v77so11392887ywg.2 for ; Thu, 23 Jun 2016 08:30:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Q9m5jYV3KkznagfCBGESpnKT6C2texGOpi/Xc5gIFrI=; b=Xg5sVwI5QhXrwQTwm1FXCw24yYEa1gC57z40TfRFsAE8ZAu3QWttj2pDC3vm+psM2d +pxTOBRSsa3vpeT9hq+UEGTD7zVqtvSmX92pI04/MYI3u+euSug563G2RyzsRhZkt5ga aZWkhjuPZ7ZCf75CzZFdtCoOyvkLXNsLc4xij5UvH+jND4PnEoRjW9X3iu/r0zvp4X1B JI/+NUJFIvX+yTaKhdweXXqq9+aG4a+CrHiU4KcwNFvOGlwNnti0vcMAWOcKQF9NJU4V JWq320QivtdQ7o1OmltvsCnlmilt4Gt0tJMpO8Gkj5ZODdhBGo8eEZc+tSpkUz4ylHxF 6Hzw== X-Gm-Message-State: ALyK8tK3wV8aCEWJoNT7QZDgbbd8JuG30bHJRaQFjtYXuUn+7Li+fsVBBd7pfdmTmFEmbg== X-Received: by 10.37.1.198 with SMTP id 189mr1640790ybb.110.1466695810234; Thu, 23 Jun 2016 08:30:10 -0700 (PDT) Received: from jade.localdomain ([189.61.225.79]) by smtp.gmail.com with ESMTPSA id l81sm346278ywb.34.2016.06.23.08.30.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jun 2016 08:30:09 -0700 (PDT) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [RFC 1/5] dma-buf/fence: add .teardown() ops Date: Thu, 23 Jun 2016 12:29:46 -0300 Message-Id: <1466695790-2833-2-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1466695790-2833-1-git-send-email-gustavo@padovan.org> References: <1466695790-2833-1-git-send-email-gustavo@padovan.org> Cc: marcheu@google.com, Daniel Stone , seanpaul@google.com, Daniel Vetter , linux-kernel@vger.kernel.org, laurent.pinchart@ideasonboard.com, Gustavo Padovan , John Harrison , m.chehab@samsung.com 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 fence_array requires a function to clean up its state before we are able to call fence_put() and release it. Signed-off-by: Gustavo Padovan --- drivers/dma-buf/fence.c | 7 +++++++ include/linux/fence.h | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c index 4d51f9e..4e61afb 100644 --- a/drivers/dma-buf/fence.c +++ b/drivers/dma-buf/fence.c @@ -185,6 +185,13 @@ void fence_release(struct kref *kref) } EXPORT_SYMBOL(fence_release); +void fence_teardown(struct fence *fence) +{ + if (fence->ops->teardown) + fence->ops->teardown(fence); +} +EXPORT_SYMBOL(fence_teardown); + void fence_free(struct fence *fence) { kfree_rcu(fence, rcu); diff --git a/include/linux/fence.h b/include/linux/fence.h index 44d945e..1d3b671 100644 --- a/include/linux/fence.h +++ b/include/linux/fence.h @@ -114,6 +114,7 @@ struct fence_cb { * @enable_signaling: enable software signaling of fence. * @signaled: [optional] peek whether the fence is signaled, can be null. * @wait: custom wait implementation, or fence_default_wait. + * @teardown: [optional] teardown fence data but not put it * @release: [optional] called on destruction of fence, can be null * @fill_driver_data: [optional] callback to fill in free-form debug info * Returns amount of bytes filled, or -errno. @@ -161,6 +162,10 @@ struct fence_cb { * which should be treated as if the fence is signaled. For example a hardware * lockup could be reported like that. * + * Notes on teardown: + * Can be NULL, this function clean ups the fence data before the fence_put + * call. + * * Notes on release: * Can be NULL, this function allows additional commands to run on * destruction of the fence. Can be called from irq context. @@ -173,6 +178,7 @@ struct fence_ops { bool (*enable_signaling)(struct fence *fence); bool (*signaled)(struct fence *fence); signed long (*wait)(struct fence *fence, bool intr, signed long timeout); + void (*teardown)(struct fence *fence); void (*release)(struct fence *fence); int (*fill_driver_data)(struct fence *fence, void *data, int size); @@ -184,6 +190,7 @@ void fence_init(struct fence *fence, const struct fence_ops *ops, spinlock_t *lock, u64 context, unsigned seqno); void fence_release(struct kref *kref); +void fence_teardown(struct fence *fence); void fence_free(struct fence *fence); /**