From patchwork Tue Oct 31 08:41:37 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: 10033735 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 25E98602B9 for ; Tue, 31 Oct 2017 08:41:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12EC9289D7 for ; Tue, 31 Oct 2017 08:41:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06FBB289DA; Tue, 31 Oct 2017 08:41: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 C0B69289D7 for ; Tue, 31 Oct 2017 08:41:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F00076E522; Tue, 31 Oct 2017 08:41:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id D89476E1A1; Tue, 31 Oct 2017 08:41:42 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id n74so12117260wmi.1; Tue, 31 Oct 2017 01:41:42 -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=LqnfEFmz6tcGVMFHBtvjEc4VyX1pHaOtWnz51h7SsSM=; b=htMfD7JvkcbMO+w3DkH/KpFCj0Cph/DsoYD9qNRdyfPUuHRX1nUiJ0YDs/DEWejzRc f3Z/IOaCXTCXP4x1B9BJHwg6cq+xC9NtgppvuS+tNXf5tKrO9bfmBmyE4RyUif+7HrqP G1puNlN6/IbADu4e9xoYrpv8O7nB6HpTKv71+vHbAAF8+KUDhZkkeOj06MvDWNA6evAE JqCRmSZtPtr7DnP6mZUWuwIMkP1J0i/CqMdCwuzT/GAlGt6v0GIk+jSeI21NK9xbg3qJ SDUHor+qhpBwJQmoYLve9bIB7/ib70SN+DpP8rx+KSzrFrEQERUXQXIjM/FZsNfRwmfY I6Mg== 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=LqnfEFmz6tcGVMFHBtvjEc4VyX1pHaOtWnz51h7SsSM=; b=HJ1LZWOTubfzk6FbwxE00vaAXlG3sd5y92DxbAJJFKcPbjnPR2KIGLl3CKr4g1nF1H ltY3qtkKWum6Dto9Jbiv0bx9jEW2S2doXUGuiS3OIhUzf7trcdF2vD4kTRbynYJgHlbL WVtTdk4FULjgmKTbImGCM2KMrYud0xVOQVH2g7m0mkczZ73c0L0jawbG1ipc+9D+xDRy lyS2aLsVVJzZzCFb0Wn07CN12gIDHsKX3d68WqECZmWwJ4m20yeboD33oVVuUUZNRgGw SX7kpvic/2OE3UCV8BvU3K+cTa2RLzwjC5TNSwRUiJyM3/ZIgI7mrnXYC4AYngJHJuVN GaRg== X-Gm-Message-State: AMCzsaXAToDGOq2QhniAzCPpKAIOYYhu/2BoPml5+dFkylsVFKAeQ6xJ Hejwyeonic/fg41twfc/+/J6Lg== X-Google-Smtp-Source: ABhQp+Q/gWlma7y/UB6fA920etU6qjP08oVttFK3BYPy5o6WngnfmG69b/02g7I7lPC8QutT2laLcA== X-Received: by 10.28.0.65 with SMTP id 62mr1255290wma.58.1509439301163; Tue, 31 Oct 2017 01:41:41 -0700 (PDT) Received: from localhost.localdomain ([2a02:908:1251:7981:c0f4:45e6:8be5:ed97]) by smtp.gmail.com with ESMTPSA id v35sm2690908wrc.13.2017.10.31.01.41.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Oct 2017 01:41:40 -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:41:37 +0100 Message-Id: <20171031084137.1925-2-deathsimple@vodafone.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171031084137.1925-1-deathsimple@vodafone.de> References: <20171031084137.1925-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 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