From patchwork Tue Oct 24 13:55:52 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: 10024639 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 212DF60245 for ; Tue, 24 Oct 2017 13:56:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 181072862B for ; Tue, 24 Oct 2017 13:56:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CE5E28A09; Tue, 24 Oct 2017 13:56:01 +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 BDAF92862B for ; Tue, 24 Oct 2017 13:56:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 976A46E11F; Tue, 24 Oct 2017 13:55:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F8456E09D; Tue, 24 Oct 2017 13:55:57 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id l8so7905151wre.12; Tue, 24 Oct 2017 06:55:57 -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=2xascptlpR2jw3R5Y3yDeSDwlpZAkLB3nO625UL3poA=; b=brhday1rSkFQcI+1f0Zct6SQvdjawGVUsXCPSsCz/5Oy+GPw4Zxi2XmAPgfS2oEHf8 MDVAXtz8PJ20zrt82F+A/ZO43IqGV7vYNMaksnCTpyOw8MQOdiw20q/kcsHxX1b7v8c/ YhLoCDXGm3dAVUaikj4gTeNqRlni1XGK+sF5bMP2/PoqqqBu2q6+eg0cgZSUoAUJPmoE b38p7IGmGgnDDzNRmdlW5lvX2ffQGnKFpBg0CgwrrFMmEMR4CPg4npQP1dEAcV75ykZS NZccCXpQirA43f1tF5ijiljkqECMITFjQ/jqf8sDn18+MHa99RHrGTk7ovSZhj+/djjS ezNA== 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=2xascptlpR2jw3R5Y3yDeSDwlpZAkLB3nO625UL3poA=; b=cpwXt4YOrnX84atSyPacWhgMzQ0zMFuE34D1Z0hNgS371MdLlcTSRcWC+rwnuZ30GU E49SZgiagxQ8heYMBTQq1dfegOoqR8Pi/xI3P19fPgJ8j5247qqdGbw6XLh+kMrMMC6C qAdl7QWoAf0dkLeSoAi1SvlgtpVfc0Ey3UFnE/c9GA6yLGCukNqtDZSOA8tK5YPkakVW lv5UtuDx6LfpWQ3PhqvJp8me+PF2Bm53mi33x1xSP5UWf2IwphNBTseD7eg2YUtBmqUR t5P8yC9xwdTKhP7OBk9FbQdvbK3kndfkNi+GR7YjEH4OxZhqBN0uvPdvc9L1RcRzEYlo HCcQ== X-Gm-Message-State: AMCzsaVU5l2KFH6m0ATQjPFFFKMqgJGjX0UNu5j+d4mJPsFQu14x++aJ QVWEVD/65xvs+iPAJbXqzltbKA== X-Google-Smtp-Source: ABhQp+SXeqDDE8Ha2LRLPc1cM2Iud9Ev+G+SuHbc1yX6nrPLLf/pWNlr9H+bMqz88Qjd6RyNdkEkHA== X-Received: by 10.223.131.226 with SMTP id 89mr15213609wre.227.1508853356548; Tue, 24 Oct 2017 06:55:56 -0700 (PDT) Received: from localhost.localdomain ([2a02:908:1251:7981:a1d5:b1:d8b4:31e2]) by smtp.gmail.com with ESMTPSA id p23sm432951wrb.76.2017.10.24.06.55.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Oct 2017 06:55:56 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: sumit.semwal@linaro.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, zhoucm1@amd.com Subject: [PATCH 2/2] dma-buf: try to replace a signaled fence in reservation_object_add_shared_inplace Date: Tue, 24 Oct 2017 15:55:52 +0200 Message-Id: <20171024135552.2139-2-deathsimple@vodafone.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171024135552.2139-1-deathsimple@vodafone.de> References: <20171024135552.2139-1-deathsimple@vodafone.de> 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 From: Christian König 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 4ede77d1bb31..702ef03a923a 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