From patchwork Tue Nov 14 14:24:36 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: 10057721 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 E6B746056E for ; Tue, 14 Nov 2017 14:24:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D23AE2976C for ; Tue, 14 Nov 2017 14:24:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0D5F2976F; Tue, 14 Nov 2017 14:24:45 +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 9005F2976C for ; Tue, 14 Nov 2017 14:24:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D7616E03F; Tue, 14 Nov 2017 14:24:43 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9EB366E02E; Tue, 14 Nov 2017 14:24:42 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id y80so21631391wmd.0; Tue, 14 Nov 2017 06:24:42 -0800 (PST) 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=k+BGTfAEPU1uVllxXc5gcJEY7q12fHcuZBmp/+3bEfk=; b=VSum03m2fa0qcEr1PbxRyOfSckGmeIZM77B8xshrGiaovTSYeoWg2Oe8VkPzP8SZqB 2fPuxBABUr7cWQ3kTy5amt9rA6+AXrB5B8iIYguo4wH3PLBHpffGPabzS7b+2XM5210T tX2nX7+T2Zs25FLabEmcq9mb4qRjCt1Ts7J8bteU2xB7P2q3L//cf4A0cSt7pYXrJBXQ 4zqEpkgy/wH/mJhfbqTThY7AuBzXzQi17tlaRtcnokiXEYafMDpdYhiWgQBWH5xBkVPE lPtjAVOMvg86LV7hjgsOccWnYwN79dgohRP2DgVTXeOHChRkQKrWcWPXGW8ARvskyqPH WNqw== 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=k+BGTfAEPU1uVllxXc5gcJEY7q12fHcuZBmp/+3bEfk=; b=nzRkmos3HQzUdT8p1gL5q9RzPOrGLtmpGuAoK0eAj4/fXGcgd48H4YqV+emNKi+o1s AkMk41c9ZnNYs/9qthoIdU+bC51r2U7Ryez/KtveMFW0vKP4FGXeqBazQ3K2UZjjYIkp 3luL6tbK0i8a5NOAjFM/6vou/gPKtlRTd5po9zoksLCL9jA3UG03EB9Rx3RDT9BdoeDR ptYvApSWe8338tD5GrhaS8ktUfXUVB3cIhsAkor7JgZygNyL9Xgyddv2ef2zJcpdsi9b G0Sp8P/L3Po9qXaBeb83h/Y7x0czcuCy3S3o651BNanWz06UPXqnRrG3EZyXmpf3ynO0 q7Ug== X-Gm-Message-State: AJaThX7Ir206Qc4rn82phZvBsraZVg8m0Y1u8HCEEc6U8DPitxpF3ctJ RzWJ5g5edXyZLZNGxtQXIsk= X-Google-Smtp-Source: AGs4zMb5L3MxlYjPmWNBySladZOp4QZlmp+CfgJA1weU+OSskxUNKYZjE9F/E/7QhD1kg/OwPGkKyw== X-Received: by 10.28.8.145 with SMTP id 139mr9757394wmi.115.1510669480996; Tue, 14 Nov 2017 06:24:40 -0800 (PST) Received: from localhost.localdomain ([2a02:908:1251:7981:50c0:8c4d:16f4:878b]) by smtp.gmail.com with ESMTPSA id 185sm11246938wmj.33.2017.11.14.06.24.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Nov 2017 06:24:40 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: chris@chris-wilson.co.uk, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 2/2] dma-buf: try to replace a signaled fence in reservation_object_add_shared_inplace Date: Tue, 14 Nov 2017 15:24:36 +0100 Message-Id: <20171114142436.1360-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171114142436.1360-1-christian.koenig@amd.com> References: <20171114142436.1360-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 Reviewed-by: Chris Wilson --- 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 6d7a53dadf77..d72079742ca9 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