From patchwork Fri Jan 12 09:47:27 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: 10160785 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 4806360327 for ; Fri, 12 Jan 2018 13:10:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3687D287C0 for ; Fri, 12 Jan 2018 13:10:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 291AB288E8; Fri, 12 Jan 2018 13:10:09 +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 B2D78287C0 for ; Fri, 12 Jan 2018 13:10:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E78A96E881; Fri, 12 Jan 2018 13:10:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id AA0F16E881 for ; Fri, 12 Jan 2018 13:10:06 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id 81so2336853wmb.1 for ; Fri, 12 Jan 2018 05:10:06 -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=UTEr8EoOFP33xbxls/RTGKpI7dp8X8RpYGNlyP+ahGrBWAbEJH/iHoIRr8jlLqCNYf vf3OLk7Ewt91VVA6et7lk2HKkEnIUfvN5DTH9vqZfKOXyEMUFQKQEvzuGv9/naWUQwnO Ap22jTmwNLomHjSTqmEupa7knhOLpIKLm9xn3vz+aFmQt4SbFP5qD6khWKa2iDpFUP7o iO3+Yv7UxkR9PzF8MQ/I8uOcObycVfyurnHF/hHCHAuK92nf4x/5kQ+QqHqypqP2ia57 X/5d6UXkmvu/iTba+jBz4GGsJ8mqh3996vFpOQDwK/dxk24EEGKnsJzN8GDampjY7a0F 3Ukw== 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=FAKNdaBMnvypLZhpuyJsA+Oj/Pkrs+iXOdk4KqX97zDKLoBes50884SQqJk7fVNFkN E9I9ur9SAJsKNea+yfXnEIMjGXhgOcWAerGZtdhVLVfj1w60uVJkKLje8R19JQw4arId 4HGklqlpsS0DicEMriTF9imlctr0doEOfK39yRr+tidaF7PQF+9kyCyqgYueGQ/5qcaS zxR7UDepGvv46jNJH2A/+O5j4qcs6X2UO5JDFuul4m0H+I437n3+//HPyByMC9dq2SzQ r3xFu37rAvY5uhknOKYIGsdvS4mnSF+8YxvdxPZ+odS7qQoBqxxieqDBr/gIF8Z+Smzt 1Efg== X-Gm-Message-State: AKwxyteYBAf4yxt7fOyoffjkxl/9AvWwXddsIYwPU9eDAr8j+8BaWb8S /KLznTXo1DzwVW7hvYwCcz91Lw== X-Google-Smtp-Source: ACJfBotry05blM0yNMbEcG+3KZceYak1R6WZGalDTp+Ri60wBW7QhvhaCCB+T+DxEuIpIq0uDnK1cA== X-Received: by 10.28.55.146 with SMTP id e140mr3307340wma.4.1515750451599; Fri, 12 Jan 2018 01:47:31 -0800 (PST) Received: from baker.fritz.box ([2a02:908:1251:8fc0:6d3c:530f:8e94:9257]) by smtp.gmail.com with ESMTPSA id p10sm16616345wrh.61.2018.01.12.01.47.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 01:47:30 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: daniel@ffwll.ch, 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 1/3] dma-buf: make returning the exclusive fence optional Date: Fri, 12 Jan 2018 10:47:27 +0100 Message-Id: <20180112094729.17491-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 Acked-by: Daniel Vetter --- 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; }