From patchwork Thu Jun 23 15:29:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9195471 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 5E0D56075A for ; Thu, 23 Jun 2016 15:30:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F37E2842E for ; Thu, 23 Jun 2016 15:30:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43A2A28464; Thu, 23 Jun 2016 15:30:33 +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 E96552842E for ; Thu, 23 Jun 2016 15:30:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 45FC86E97A; Thu, 23 Jun 2016 15:30:28 +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 9302B6E3BC for ; Thu, 23 Jun 2016 15:30:15 +0000 (UTC) Received: by mail-yw0-f195.google.com with SMTP id f75so11413660ywb.3 for ; Thu, 23 Jun 2016 08:30:15 -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=4U7n7rcJjgoarbamdRggwmExmgukh5AGelf136IJ0yE=; b=ITVa+UC0sTga6QO/k/y8XREoKwy7FML8no7Z5WJpXKbm1drTOxSXAz0Fzkn4puXS8W REUWwA1Zq/O7qQ5s2Ul0C/zQbwlpDFeuO7zkDaUlXW7m/rHp+fME01fCLf23MShJgyrd dR13Oimln5n0EYguSHRlz9jixOn7lWiRU1ouo09gAqUlO2O+O2HqJrEkELld0ik+o2Ws egDzzmp4SI9Udv3vXhxjfFg10GttNtjzar4JnGx4DQW57xow2Np6NdNvMb0OSZCovYgi JTs6B7nDNOP/BRGV4Oat9zvAp5LvzLgTtth64sI7fqTdEg4qRd5cqwniO26AhifW1oMG hhYg== X-Gm-Message-State: ALyK8tIpt8GPijIJcAAi+uzuI3T/Fh+G4Yj1gNuwri/uj3aKC/M6pPo1StEY6ERArW0KRQ== X-Received: by 10.129.145.136 with SMTP id i130mr15498546ywg.1.1466695814425; Thu, 23 Jun 2016 08:30:14 -0700 (PDT) Received: from jade.localdomain ([189.61.225.79]) by smtp.gmail.com with ESMTPSA id l81sm346278ywb.34.2016.06.23.08.30.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jun 2016 08:30:13 -0700 (PDT) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [RFC 2/5] dma-buf/fence-array: add fence_array_teardown() Date: Thu, 23 Jun 2016 12:29:47 -0300 Message-Id: <1466695790-2833-3-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 When using fences in sync files we need to clean up everything when the sync file needs to be freed, thus we need to teardown fence_array, by removing the callback of its fences and putting extra references to the fence_array base fence. Signed-off-by: Gustavo Padovan --- drivers/dma-buf/fence-array.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/dma-buf/fence-array.c b/drivers/dma-buf/fence-array.c index a8731c8..601448a 100644 --- a/drivers/dma-buf/fence-array.c +++ b/drivers/dma-buf/fence-array.c @@ -79,6 +79,21 @@ static bool fence_array_signaled(struct fence *fence) return atomic_read(&array->num_pending) <= 0; } +static void fence_array_teardown(struct fence *fence) +{ + struct fence_array *array = to_fence_array(fence); + struct fence_array_cb *cb = (void *)(&array[1]); + int i; + + for (i = 0; i < array->num_fences; i++) { + if (fence_is_signaled(array->fences[i])) + continue; + + fence_remove_callback(array->fences[i], &cb[i].cb); + fence_put(&array->base); + } +} + static void fence_array_release(struct fence *fence) { struct fence_array *array = to_fence_array(fence); @@ -97,6 +112,7 @@ const struct fence_ops fence_array_ops = { .enable_signaling = fence_array_enable_signaling, .signaled = fence_array_signaled, .wait = fence_default_wait, + .teardown = fence_array_teardown, .release = fence_array_release, };