From patchwork Tue Oct 31 08:43:06 2017 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: 10033739 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 26E39602B9 for ; Tue, 31 Oct 2017 08:43:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15B46289DE for ; Tue, 31 Oct 2017 08:43:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A704289E1; Tue, 31 Oct 2017 08:43:17 +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 C13DE289DE for ; Tue, 31 Oct 2017 08:43:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4DF686E51F; Tue, 31 Oct 2017 08:43:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 21AF86E511; Tue, 31 Oct 2017 08:43:11 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id z55so15174166wrz.1; Tue, 31 Oct 2017 01:43:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=KjUbodD5NIWAXngcmDneKIjrPX1KsCyFTR18lvtjn14=; b=NQmnz+KYi2OAlfXcutBiAvRt9e2zLMISpbwol0CthoonUIumG7V8GX/sKyd2ln4r1T XqFAA/jwJ+7/FruHHF4XZueZ+gx1yH13QvGltbSWz9VOCWMg5Fq8DWb+DC38aBE/RPUV CavBhoIxmI/mnq5e5DJYDkyfp31/Yf6cRaXoqGDDN+y/4sC14eF1SnBAO+lUq8PBCSLm 3M37kuzN6Lqar5Q66jsk+ySHLbZpAKrheKRJWyJu8N3jkGD2PzNpdJcWNt+VKm84cWXH 55BxARoexWOung/3FLP57Nd1Sbzij03k+i/39LWwHHpNS1ex+8H7SpByyKkKH6o8ARzz NTJA== 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=KjUbodD5NIWAXngcmDneKIjrPX1KsCyFTR18lvtjn14=; b=nuRTNbJudN964HiUSeM+pMaAUuGCWIc2/CrPpY91sQYxoJ8un6K9zSqlvHA1l2XUKY JUVSwPOtRvQP0c6l1v+Z+eNuMlPPYx+5T4Di2k2mFYjBejY9+1iUfv6XIyh/rKbz6mpo FolKkCfGOriu3NEZ03WGHe7blR04phu8sipmwlok1Ufayqg6PSGLfuiv2ZMFhPSdsgvN 4MmjuofTuO8el8YjFwdV1PIhlmDJCtOLXm8Lp9W95p29PjRvMMPs0/QOObRnHMP7YmWY 2xTvQ+mQJoDRjwdy2K3s8RQ8nxQtLqBRZZxenHb4FGygIPZQQJziDv/SUd3Mns9igjfz bP/Q== X-Gm-Message-State: AMCzsaVpq9YLljngwBTBbgmP3waUfpfZCF5mVm+YIb4gWqEN36B156bD MhYltjOlo1UzkQGROe2bH/H6xg== X-Google-Smtp-Source: ABhQp+TZfnDN+L+gkrVt6M0PIVPEKbOpjSgyq0jfo5Jd9aUuuwxrgXxAc6Ra+LJPnI9J105xxABLTQ== X-Received: by 10.223.184.125 with SMTP id u58mr993577wrf.8.1509439390394; Tue, 31 Oct 2017 01:43:10 -0700 (PDT) Received: from localhost.localdomain ([2a02:908:1251:7981:c0f4:45e6:8be5:ed97]) by smtp.gmail.com with ESMTPSA id c17sm1865109wrg.26.2017.10.31.01.43.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Oct 2017 01:43:09 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, sumit.semwal@linaro.org, christian.koenig@amd.com Subject: [PATCH 2/2] dma-buf: try to replace a signaled fence in reservation_object_add_shared_inplace Date: Tue, 31 Oct 2017 09:43:06 +0100 Message-Id: <20171031084306.1986-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171031084306.1986-1-christian.koenig@amd.com> References: <20171031084306.1986-1-christian.koenig@amd.com> 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 The amdgpu issue to also need signaled fences in the reservation objects should be fixed by now. Optimize the handling by replacing a signaled fence when adding a new shared one. Signed-off-by: Christian König --- drivers/dma-buf/reservation.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index 6fc794576997..a3928ce9f311 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -104,7 +104,8 @@ reservation_object_add_shared_inplace(struct reservation_object *obj, struct reservation_object_list *fobj, struct dma_fence *fence) { - u32 i; + struct dma_fence *signaled = NULL; + u32 i, signaled_idx; dma_fence_get(fence); @@ -126,17 +127,28 @@ reservation_object_add_shared_inplace(struct reservation_object *obj, dma_fence_put(old_fence); return; } + + if (!signaled && dma_fence_is_signaled(old_fence)) { + signaled = old_fence; + signaled_idx = i; + } } /* * memory barrier is added by write_seqcount_begin, * fobj->shared_count is protected by this lock too */ - RCU_INIT_POINTER(fobj->shared[fobj->shared_count], fence); - fobj->shared_count++; + if (signaled) { + RCU_INIT_POINTER(fobj->shared[signaled_idx], fence); + } else { + RCU_INIT_POINTER(fobj->shared[fobj->shared_count], fence); + fobj->shared_count++; + } write_seqcount_end(&obj->seq); preempt_enable(); + + dma_fence_put(signaled); } static void