From patchwork Wed Jan 10 12:53:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 10155105 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 1EBC5602D8 for ; Wed, 10 Jan 2018 12:53:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CD5128497 for ; Wed, 10 Jan 2018 12:53:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0031428514; Wed, 10 Jan 2018 12:53:49 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 AAD3628497 for ; Wed, 10 Jan 2018 12:53:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5484D6E271; Wed, 10 Jan 2018 12:53:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9E67E6E271 for ; Wed, 10 Jan 2018 12:53:46 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id 143so1792363wma.5 for ; Wed, 10 Jan 2018 04:53:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=OKvpffX9U72YfqwzpHs6F3SSCGjcUqYrokkuOd7yJAo=; b=JYLpA6Ekjqz66cMBeyN0hHPR975j75lt2LaT3GSY+htnnUQ6JqoEa4fmpfbvM0QwoP PV7gIsKfq1jVAcUpsWt7UxZd/pzLAnlq5ZKS3NE8yGSXepfXuxI0csJpt1gmgeM7HraH mDBwJINDbJHLZSKAqTkgrNT4FY2c2RNGAgxYwd2AcXWTg0Xc6I/MF9LBJYM1YQskUiXH /RiWnkBwbIZCNXKhr60+s+yK9HjksrVGdK7z/xC1FGNHJ8fM0itLkjkKw+1hGRL2u5Om qi7clnVDFe1zqNiHhiR49pnbFWcBpEtG4m6MT9Oe9oVrdYj8Xr/6ASPWPA0cNqI7ej5w /MVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=OKvpffX9U72YfqwzpHs6F3SSCGjcUqYrokkuOd7yJAo=; b=j39G6G/dPnAr2nopVUwOEPcOAPspokiosiNmpr7mNwssLCg8ad2lV3+SyuU+rmpwxI MkFQc026Tiym22RHYDhcyAAkC207uGhjtIEDUuHYTpUCPWyLWDFOSzKBCgqIYaMvPKXH C5ZpcjM+To1QVwQFEmPdNchqsGTAsvclpdIWnVzVTIzVDtR200XOpfooE3VIubqWjgQA ESD++ELUaPf2ZPOq0ro6aZFmR+Ol6TQXTchKpVuxYoIF8aAvOXth2Uqgt29PsvxCf0dg 8Tj+W2vd2WCbwOkEQamr682CCaThUGPkTmdMlvibuxtjLjOANCAP6WIbKJP6ysw1Iezc mB1g== X-Gm-Message-State: AKGB3mK3CzaDEWHHNTpa6/FjEawfqtLcw2ePYAfO00OZy9M+TYSxzuN6 hmOJUgxgDMA1Kw1tdRRzc7k= X-Google-Smtp-Source: ACJfBovw/H0h44wYmPnzNePfV/hRwWuvKhG7jMsX23krgVafttZIiLybB/fzcHqhWaiq/gUN+30WJg== X-Received: by 10.28.211.67 with SMTP id k64mr14312933wmg.95.1515588825303; Wed, 10 Jan 2018 04:53:45 -0800 (PST) Received: from baker.fritz.box ([2a02:908:1251:8fc0:4115:ac94:b946:ef2e]) by smtp.gmail.com with ESMTPSA id s86sm17321613wma.29.2018.01.10.04.53.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jan 2018 04:53:44 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: sumit.semwal@linaro.org, gustavo@padovan.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH] dma-buf: make returning the exclusive fence optional Date: Wed, 10 Jan 2018 13:53:41 +0100 Message-Id: <20180110125341.3618-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change reservation_object_get_fences_rcu to make the exclusive fence pointer optional. If not specified the exclusive fence is put into the fence array as well. This is helpful for a couple of cases where we need all fences in a single array. Signed-off-by: Christian König --- drivers/dma-buf/reservation.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index b759a569b7b8..461afa9febd4 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -374,8 +374,9 @@ EXPORT_SYMBOL(reservation_object_copy_fences); * @pshared: the array of shared fence ptrs returned (array is krealloc'd to * the required size, and must be freed by caller) * - * RETURNS - * Zero or -errno + * Retrieve all fences from the reservation object. If the pointer for the + * exclusive fence is not specified the fence is put into the array of the + * shared fences as well. Returns either zero or -ENOMEM. */ int reservation_object_get_fences_rcu(struct reservation_object *obj, struct dma_fence **pfence_excl, @@ -389,8 +390,8 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, do { struct reservation_object_list *fobj; - unsigned seq; - unsigned int i; + unsigned int i, seq; + size_t sz = 0; shared_count = i = 0; @@ -402,9 +403,14 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, goto unlock; fobj = rcu_dereference(obj->fence); - if (fobj) { + if (fobj) + sz += sizeof(*shared) * fobj->shared_max; + + if (!pfence_excl && fence_excl) + sz += sizeof(*shared); + + if (sz) { struct dma_fence **nshared; - size_t sz = sizeof(*shared) * fobj->shared_max; nshared = krealloc(shared, sz, GFP_NOWAIT | __GFP_NOWARN); @@ -420,13 +426,19 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, break; } shared = nshared; - shared_count = fobj->shared_count; - + shared_count = fobj ? fobj->shared_count : 0; for (i = 0; i < shared_count; ++i) { shared[i] = rcu_dereference(fobj->shared[i]); if (!dma_fence_get_rcu(shared[i])) break; } + + if (!pfence_excl && fence_excl) { + shared[i] = fence_excl; + fence_excl = NULL; + ++i; + ++shared_count; + } } if (i != shared_count || read_seqcount_retry(&obj->seq, seq)) { @@ -448,7 +460,8 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, *pshared_count = shared_count; *pshared = shared; - *pfence_excl = fence_excl; + if (pfence_excl) + *pfence_excl = fence_excl; return ret; }