From patchwork Thu Aug 9 11:37:11 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: 10561217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3DA19139A for ; Thu, 9 Aug 2018 11:38:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DADB2A6F5 for ; Thu, 9 Aug 2018 11:38:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21F462A6F8; Thu, 9 Aug 2018 11:38:02 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable 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 9F0FD2A6F5 for ; Thu, 9 Aug 2018 11:38:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F5836E72C; Thu, 9 Aug 2018 11:37:29 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6FB276E710; Thu, 9 Aug 2018 11:37:21 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id c13-v6so4885979wrt.1; Thu, 09 Aug 2018 04:37:21 -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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gvLN/1F7jn9AXRbixDKbHM3d9uV9fu4mZzks2tDfC5U=; b=KsdA87q0+MS4GTCI5St7jH6YCbNRe+BJJ3OR8CJyoMOOqendN4XGfrkqaeIVuIw/R6 Kzx4jiQZuIKYjk8FE0zIc0zhZSxjawEjCRpdB1SY/+uXNHluWufVxpmWNZpSLV9PIzIo xkzXOfK7nbqVg9HhK3dwX9ubffgctFINEOKQaUChr9mFk5kjfJSCVnrcTENXaHVsfj04 FrMTWKk1Ov78H6rDIo8YuZ4r0QSvOWPCwno8SpnYZHnaL0fEHxPSKZhs+cZrjyj4Udmn CffvBiMuVDpIVrsmJn1PcVuhfeWlNpHMp9QP31phNbjFA/qI655GqmwbtORmXCBgZ2O7 ezSg== X-Gm-Message-State: AOUpUlEOhMjngdBbZUJhfxlNSp38AmPzDmws0HVWFGSzTvhBMn784Qk/ wmbiM58GE2ekcmQy28RlTKtuEF7v X-Google-Smtp-Source: AA+uWPzFVAohMjvatVokOT0P1bHXjFCk2ky7JKZQRn1B32GFxwFml1fUjMcybjMUUGxDzhBhpSmz2A== X-Received: by 2002:adf:eac8:: with SMTP id o8-v6mr1135483wrn.150.1533814639657; Thu, 09 Aug 2018 04:37:19 -0700 (PDT) Received: from baker.fritz.box ([2a02:908:1257:4460:3d33:c568:5cf9:1c03]) by smtp.gmail.com with ESMTPSA id v5-v6sm4734842wru.60.2018.08.09.04.37.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 04:37:19 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Thu, 9 Aug 2018 13:37:11 +0200 Message-Id: <20180809113713.48024-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180809113713.48024-1-christian.koenig@amd.com> References: <20180809113713.48024-1-christian.koenig@amd.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 4/6] dma-buf: add writes_only flag to reservation_object_get_fences_rcu X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP That allows us to only retreive fences of write operations. Signed-off-by: Christian König --- drivers/dma-buf/reservation.c | 19 +++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 3 ++- drivers/gpu/drm/i915/i915_gem.c | 4 ++-- drivers/gpu/drm/i915/i915_request.c | 2 +- drivers/gpu/drm/i915/i915_sw_fence.c | 2 +- include/linux/reservation.h | 1 + 9 files changed, 27 insertions(+), 12 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index 0f98384b86d4..f5dc17aa5efb 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -316,6 +316,7 @@ EXPORT_SYMBOL(reservation_object_copy_fences); * reservation_object_get_fences_rcu - Get an object's shared and exclusive * fences without update side lock held * @obj: the reservation object + * @writes_only: if true then only write operations are returned * @pfence_excl: the returned exclusive fence (or NULL) * @pshared_count: the number of shared fences returned * @pshared: the array of shared fence ptrs returned (array is krealloc'd to @@ -326,6 +327,7 @@ EXPORT_SYMBOL(reservation_object_copy_fences); * shared fences as well. Returns either zero or -ENOMEM. */ int reservation_object_get_fences_rcu(struct reservation_object *obj, + bool writes_only, struct dma_fence **pfence_excl, unsigned *pshared_count, struct dma_fence ***pshared) @@ -358,6 +360,7 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, if (sz) { struct dma_fence **nshared; + unsigned int j; nshared = krealloc(shared, sz, GFP_NOWAIT | __GFP_NOWARN); @@ -374,13 +377,20 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, } shared = nshared; shared_count = fobj ? fobj->shared_count : 0; - for (i = 0; i < shared_count; ++i) { - void *e = rcu_dereference(fobj->shared[i]); + for (i = 0, j = 0; j < shared_count; ++j) { + void *e = rcu_dereference(fobj->shared[j]); + + if (writes_only && + !reservation_object_shared_is_write(e)) + continue; shared[i] = reservation_object_shared_fence(e); if (!dma_fence_get_rcu(shared[i])) - break; + goto drop_references; + + i++; } + shared_count = i; if (!pfence_excl && fence_excl) { shared[i] = fence_excl; @@ -390,7 +400,8 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, } } - if (i != shared_count || read_seqcount_retry(&obj->seq, seq)) { + if (read_seqcount_retry(&obj->seq, seq)) { +drop_references: while (i--) dma_fence_put(shared[i]); dma_fence_put(fence_excl); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 7d6a36bca9dd..a6d2ba4b4d2d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c @@ -200,7 +200,8 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc, goto unpin; } - r = reservation_object_get_fences_rcu(new_abo->tbo.resv, &work->excl, + r = reservation_object_get_fences_rcu(new_abo->tbo.resv, false, + &work->excl, &work->shared_count, &work->shared); if (unlikely(r != 0)) { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c index 3a072a7a39f0..82de4eb38dff 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c @@ -112,7 +112,8 @@ void amdgpu_pasid_free_delayed(struct reservation_object *resv, unsigned count; int r; - r = reservation_object_get_fences_rcu(resv, NULL, &count, &fences); + r = reservation_object_get_fences_rcu(resv, false, NULL, + &count, &fences); if (r) goto fallback; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 015613b4f98b..e1bb6f13de41 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -1841,7 +1841,7 @@ static void amdgpu_vm_prt_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) unsigned i, shared_count; int r; - r = reservation_object_get_fences_rcu(resv, &excl, + r = reservation_object_get_fences_rcu(resv, false, &excl, &shared_count, &shared); if (r) { /* Not enough memory to grab the fence list, as last resort diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c index 5f4a872a88dd..fda8be5be574 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c @@ -188,7 +188,8 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit) continue; if (bo->flags & ETNA_SUBMIT_BO_WRITE) { - ret = reservation_object_get_fences_rcu(robj, &bo->excl, + ret = reservation_object_get_fences_rcu(robj, false, + &bo->excl, &bo->nr_shared, &bo->shared); if (ret) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 0415420e1cfd..85013933e827 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -517,7 +517,7 @@ i915_gem_object_wait_reservation(struct reservation_object *resv, unsigned int count, i; int ret; - ret = reservation_object_get_fences_rcu(resv, + ret = reservation_object_get_fences_rcu(resv, false, &excl, &count, &shared); if (ret) return ret; @@ -619,7 +619,7 @@ i915_gem_object_wait_priority(struct drm_i915_gem_object *obj, unsigned int count, i; int ret; - ret = reservation_object_get_fences_rcu(obj->resv, + ret = reservation_object_get_fences_rcu(obj->resv, false, &excl, &count, &shared); if (ret) return ret; diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c index f187250e60c6..8b5d87353f54 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -981,7 +981,7 @@ i915_request_await_object(struct i915_request *to, struct dma_fence **shared; unsigned int count, i; - ret = reservation_object_get_fences_rcu(obj->resv, + ret = reservation_object_get_fences_rcu(obj->resv, false, &excl, &count, &shared); if (ret) return ret; diff --git a/drivers/gpu/drm/i915/i915_sw_fence.c b/drivers/gpu/drm/i915/i915_sw_fence.c index 1de5173e53a2..1da2c5a99e47 100644 --- a/drivers/gpu/drm/i915/i915_sw_fence.c +++ b/drivers/gpu/drm/i915/i915_sw_fence.c @@ -499,7 +499,7 @@ int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, struct dma_fence **shared; unsigned int count, i; - ret = reservation_object_get_fences_rcu(resv, + ret = reservation_object_get_fences_rcu(resv, false, &excl, &count, &shared); if (ret) return ret; diff --git a/include/linux/reservation.h b/include/linux/reservation.h index d73bf025df4b..c6defd955aa3 100644 --- a/include/linux/reservation.h +++ b/include/linux/reservation.h @@ -296,6 +296,7 @@ void reservation_object_add_excl_fence(struct reservation_object *obj, struct dma_fence *fence); int reservation_object_get_fences_rcu(struct reservation_object *obj, + bool writes_only, struct dma_fence **pfence_excl, unsigned *pshared_count, struct dma_fence ***pshared);