From patchwork Mon Aug 5 15:45:50 2019 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: 11085871 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 9EFB814F7 for ; Fri, 9 Aug 2019 09:17:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DE5028BBC for ; Fri, 9 Aug 2019 09:17:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8216728C3E; Fri, 9 Aug 2019 09:17:28 +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 4521528BBC for ; Fri, 9 Aug 2019 09:17:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C04F6EDBC; Fri, 9 Aug 2019 09:16:24 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id D08FD6E492; Mon, 5 Aug 2019 15:45:57 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id f9so5985422wre.12; Mon, 05 Aug 2019 08:45:57 -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:mime-version :content-transfer-encoding; bh=r9iyE3YOKUeG5ZizxulW4D4UK5rsERFOEpq/DiuLZko=; b=W4OH4rrWHtt8VnJ/1hWHz0MAt+P/xZ87cwMuevsXSfVZbSAhNpFPAWIHfbt4dc6UW4 eKTigP7KUkHOxJ7jtWqUGI5djxwZUwLtiTaMIIcNc/ywRNtNIOiVAZI1YHpmsbI95lh4 pETgB8dkaT3ZbtsNUDSZc+d8SNheUyeKdb6N5B5QZzh74ncaaKdqChuybFayWdGi82Ct qOwkSH0JGKtQemjp+sA5e5x/oC7bHUuBEANuwcrENWJeLE08/fnNFSUPYFE4RCav8R5q eBkvkN4+F3MquIoYSppwQFjeUow4JPXjFWttuQXjZPthASVWdpmZCrUnFV9ssAqpS7vf JUmg== X-Gm-Message-State: APjAAAVPnrjRbDXpG0W5S4nau+IF2NyKIX7T2Dlt8J7Qp0F6sTVEdTUC Q9FQED3lzHx+Px6UuokBMwStGNiH X-Google-Smtp-Source: APXvYqwCfN2jELpOVXfZqazfG5tJI+AkZ8uPPiqhfPSXd+Hfql7qg3WBGsEluL6UnV4wSsPytaVFDA== X-Received: by 2002:a05:6000:14b:: with SMTP id r11mr11212622wrx.196.1565019956350; Mon, 05 Aug 2019 08:45:56 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:fdbd:6233:4990:5a8d]) by smtp.gmail.com with ESMTPSA id 91sm171836865wrp.3.2019.08.05.08.45.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Aug 2019 08:45:55 -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, linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, chris@chris-wilson.co.uk Date: Mon, 5 Aug 2019 17:45:50 +0200 Message-Id: <20190805154554.3476-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 09 Aug 2019 09:15:44 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=r9iyE3YOKUeG5ZizxulW4D4UK5rsERFOEpq/DiuLZko=; b=r9V02blzsn/6sU9/5govctOIYa39rlzhhnCWUYpMiBr5RPzdlvmSKgAYjBwfpWrye3 GIK3Z0ZsnMO+mIW7sB6C9vQSUBjvGPMf9zOz9aEj6gdIUn3pcZ/tQ0qooolgGvNZepz8 FaPAT4RqE1dpCNs8ZzPAtC773iHBIz96czJ0t6bBJzOnt4p+Q+2D2+ZnCttlZ6+jO4Pa 8aPnXDJe/Z0fJtACdcGBKFxrlejBuusaM+n5JrCM4ta2LG/MSd9uho9HFVxSEJa9JkTj yFCpY3TQfzmD8E024Pzjk7wIcO7LSPBYD8jj6yKYumTylx2nIs0rWabchkJmVBZDT81z 1mvw== Subject: [Intel-gfx] [PATCH 1/5] drm/i915: stop pruning reservation object after wait 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 The reservation object should be capable of handling its internal memory management itself. And since we search for a free slot to add the fence from the beginning this is actually a waste of time and only minimal helpful. Drop it to allow removal of the seqno handling in the reservation object. This essentially reverts commit "drm/i915: Remove completed fences after a wait". Signed-off-by: Christian König --- drivers/gpu/drm/i915/gem/i915_gem_wait.c | 27 ------------------------ 1 file changed, 27 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_wait.c b/drivers/gpu/drm/i915/gem/i915_gem_wait.c index 26ec6579b7cd..bb64ec6bef8e 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_wait.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_wait.c @@ -35,9 +35,7 @@ i915_gem_object_wait_reservation(struct reservation_object *resv, unsigned int flags, long timeout) { - unsigned int seq = __read_seqcount_begin(&resv->seq); struct dma_fence *excl; - bool prune_fences = false; if (flags & I915_WAIT_ALL) { struct dma_fence **shared; @@ -61,17 +59,6 @@ i915_gem_object_wait_reservation(struct reservation_object *resv, for (; i < count; i++) dma_fence_put(shared[i]); kfree(shared); - - /* - * If both shared fences and an exclusive fence exist, - * then by construction the shared fences must be later - * than the exclusive fence. If we successfully wait for - * all the shared fences, we know that the exclusive fence - * must all be signaled. If all the shared fences are - * signaled, we can prune the array and recover the - * floating references on the fences/requests. - */ - prune_fences = count && timeout >= 0; } else { excl = reservation_object_get_excl_rcu(resv); } @@ -80,20 +67,6 @@ i915_gem_object_wait_reservation(struct reservation_object *resv, timeout = i915_gem_object_wait_fence(excl, flags, timeout); dma_fence_put(excl); - - /* - * Opportunistically prune the fences iff we know they have *all* been - * signaled and that the reservation object has not been changed (i.e. - * no new fences have been added). - */ - if (prune_fences && !__read_seqcount_retry(&resv->seq, seq)) { - if (reservation_object_trylock(resv)) { - if (!__read_seqcount_retry(&resv->seq, seq)) - reservation_object_add_excl_fence(resv, NULL); - reservation_object_unlock(resv); - } - } - return timeout; } From patchwork Mon Aug 5 15:45:51 2019 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: 11085925 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 8B3A61395 for ; Fri, 9 Aug 2019 09:18:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C8ED28BBC for ; Fri, 9 Aug 2019 09:18:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7079228C3E; Fri, 9 Aug 2019 09:18:46 +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 3CC0628BBC for ; Fri, 9 Aug 2019 09:18:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AA5E46EDA9; Fri, 9 Aug 2019 09:18:38 +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 A71A36E492; Mon, 5 Aug 2019 15:45:58 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id z1so84901484wru.13; Mon, 05 Aug 2019 08:45:58 -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=rLPPYENgOoc631NZg5ylujQ9Ww/Oy03mgWH9mA4Vfho=; b=G3r+uNp3UXbOBg16c6BrFDfmkoILuRLt2+xE7QsRAr5iLU1ZY9bgSZVb/G9/mzzubD 1zNL7cUhRULsnWA9dg7CfydDIDalnsL6VXK+Fdud7emujva7LDhizIh59xZvovfZRKgx hRsXbJtB1hiqqO7Zs5JASQtYn7ma2cXbq8cszSn4sJDuEvxtWKTvLzJ1EIbe13A54aMR d66cgtc0lpM+gX836qhkpJJ+1v0e3RIWSbzSPgcyYeGo1+sdfCP0u0ddd6H92M4mVRWX nQylhCndBLftm4jb1j3xVfdhHWbJ0FUO8XSM2wNYQANJniRWklMi5DZyRaq/iM6Y2Dcu fEXA== X-Gm-Message-State: APjAAAU08nvNOPZX5CCJIRhSf91rKXFudC/UYPzDwUBOkGcmhUenkFlC XPHhx8d7oshbAs4omgmwH/hux5wr X-Google-Smtp-Source: APXvYqzBprTtDw6edlmqIDiUmJARW7G/OtGF/lCyUR20zOiLqI+2QZmZi/Tqpnx0vU3E2ILqGfvMww== X-Received: by 2002:a5d:564e:: with SMTP id j14mr1799712wrw.1.1565019957178; Mon, 05 Aug 2019 08:45:57 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:fdbd:6233:4990:5a8d]) by smtp.gmail.com with ESMTPSA id 91sm171836865wrp.3.2019.08.05.08.45.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Aug 2019 08:45:56 -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, linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, chris@chris-wilson.co.uk Date: Mon, 5 Aug 2019 17:45:51 +0200 Message-Id: <20190805154554.3476-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805154554.3476-1-christian.koenig@amd.com> References: <20190805154554.3476-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 09 Aug 2019 09:15:44 +0000 X-Mailman-Original-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=rLPPYENgOoc631NZg5ylujQ9Ww/Oy03mgWH9mA4Vfho=; b=uUMttogETRTbgFeSAW6AxRt+C/hSaMGFvi3mp332QoCPwvz8IWurSQBJyJZOR7bOeh t3ZG8sKWLHmomyK1KkW6laa+1rkPlb2s6S7QLjGuLHIGU6mFCWzgKyX03MYFGac/PX3f 3FnoVZBhJNwniqasz7bjYzRcYHCGc7RShvCwvYl0KzWBYFpbx0kyIORqWht2191zBDHz Y3CTXzhkS44iwXBeQLT+vO4Z5kzpL6G5vo9DrLaozfCFZvMs+Wn9RBp8yQaEa0EJxXMd qPMg93CgzwNyEG7odpHdapiM1CXQ7Ke1wCd5xjdaY8/jfeVjVAiB9Ij2vv4o2WHx0ycg FPkQ== Subject: [Intel-gfx] [PATCH 2/5] dma-buf: fix busy wait for new shared fences 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 When reservation_object_add_shared_fence is replacing an old fence with a new one we should not drop the old one before the new one is in place. Otherwise other cores can busy wait for the new one to appear. Signed-off-by: Christian König --- drivers/dma-buf/reservation.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index c71b85c8c159..d59207ca72d2 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -196,6 +196,7 @@ void reservation_object_add_shared_fence(struct reservation_object *obj, struct dma_fence *fence) { struct reservation_object_list *fobj; + struct dma_fence *old; unsigned int i, count; dma_fence_get(fence); @@ -209,18 +210,16 @@ void reservation_object_add_shared_fence(struct reservation_object *obj, write_seqcount_begin(&obj->seq); for (i = 0; i < count; ++i) { - struct dma_fence *old_fence; - old_fence = rcu_dereference_protected(fobj->shared[i], - reservation_object_held(obj)); - if (old_fence->context == fence->context || - dma_fence_is_signaled(old_fence)) { - dma_fence_put(old_fence); + old = rcu_dereference_protected(fobj->shared[i], + reservation_object_held(obj)); + if (old->context == fence->context || + dma_fence_is_signaled(old)) goto replace; - } } BUG_ON(fobj->shared_count >= fobj->shared_max); + old = NULL; count++; replace: @@ -230,6 +229,7 @@ void reservation_object_add_shared_fence(struct reservation_object *obj, write_seqcount_end(&obj->seq); preempt_enable(); + dma_fence_put(old); } EXPORT_SYMBOL(reservation_object_add_shared_fence); From patchwork Mon Aug 5 15:45:52 2019 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: 11085703 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 66AA91398 for ; Fri, 9 Aug 2019 09:15:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B3C428B8E for ; Fri, 9 Aug 2019 09:15:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F15728BB9; Fri, 9 Aug 2019 09:15:59 +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 F34DE28B8E for ; Fri, 9 Aug 2019 09:15:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E1D86ED3E; Fri, 9 Aug 2019 09:15:46 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 905506E4A5; Mon, 5 Aug 2019 15:45:59 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id x1so35006012wrr.9; Mon, 05 Aug 2019 08:45:59 -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=v306sfwUGIVnriTquF2KCh9r0qG80xENrZcYr3yv41A=; b=p3QdSqp/IZB3BssJZRJDeiseUIkbyEbmHVTChgu8eWbkqg131THLOU5N1osGb4cufE H+B9+t2BnfDCCA2prODnZdBe8C/6MPweeiVcTaMr0wmnBOFiK4XJN9YusWhViUIIbXvM 3i1aMIWDdViu15fONie0+A0QmWi2RG8za6XSkMgLXlr6PJdsa4AxQUunmWSD/B7ESUPn Jk5K3tKoqpqN1tlXBvre3Wol4NvMmVCapBxV24cS2g5jM5JD5+W2zoMmElMZCImz2kld Q0+QgXsBJNnnnk19S9SlLSTZZOphx52Vz9zv4zD2Zfcu/p9JXAK9dIRUhjRvjhXV2Sal S08Q== X-Gm-Message-State: APjAAAUp+7Vj6Me+dbGXQBZcdoG9hEcJrjiAur8dcJES1Yg3oexsNFNI xxcexLxHpjJbN5y3KHN0n4TcYUua X-Google-Smtp-Source: APXvYqyiVh4JW9BAxeQmV7Ga2Y/xwkIkFOdeQDansqXZR5hzlhxtXw4izgVGV95M9bxc9zQCbGMijQ== X-Received: by 2002:a5d:4090:: with SMTP id o16mr6149082wrp.292.1565019958047; Mon, 05 Aug 2019 08:45:58 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:fdbd:6233:4990:5a8d]) by smtp.gmail.com with ESMTPSA id 91sm171836865wrp.3.2019.08.05.08.45.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Aug 2019 08:45:57 -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, linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, chris@chris-wilson.co.uk Date: Mon, 5 Aug 2019 17:45:52 +0200 Message-Id: <20190805154554.3476-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805154554.3476-1-christian.koenig@amd.com> References: <20190805154554.3476-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 09 Aug 2019 09:15:44 +0000 X-Mailman-Original-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=v306sfwUGIVnriTquF2KCh9r0qG80xENrZcYr3yv41A=; b=RPl/cWr4ICJ1bdX1iZkG7X25CTPpq5Ar/WW0HcJ9gh5rqtkdD6q+0gjm3pYy80LHB7 ELw9Df1MB3ZM5DzXGQtjdAMPwyex8IiqdGKjuXDxFrQJJiog8knuUUCzGlQJkSJcylCN f6E625dTHPgYBXlqgrWGSayMZAOiXy9+KK4OP95Z7YdHJOXPvABdeursdLsGzp/xy5xx GN51bL/l/g3eajCja5cX2Mxp5mshzDQhFo/u1rKNq67lnuK0zeaPUW0EHObGBXr90fte cM1CkFfovDVjZ9WVP3wjmAgeQQhpPI9AXl0WHYSzW8KxOqc2Gwi+OhPu7VHmdfjfoovC YuMQ== Subject: [Intel-gfx] [PATCH 3/5] dma-buf: further relax reservation_object_add_shared_fence 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 Other cores don't busy wait any more and we removed the last user of checking the seqno for changes. Drop updating the number for shared fences altogether. Signed-off-by: Christian König --- drivers/dma-buf/reservation.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index d59207ca72d2..6eaca469005f 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -206,9 +206,6 @@ void reservation_object_add_shared_fence(struct reservation_object *obj, fobj = reservation_object_get_list(obj); count = fobj->shared_count; - preempt_disable(); - write_seqcount_begin(&obj->seq); - for (i = 0; i < count; ++i) { old = rcu_dereference_protected(fobj->shared[i], @@ -226,9 +223,6 @@ void reservation_object_add_shared_fence(struct reservation_object *obj, RCU_INIT_POINTER(fobj->shared[i], fence); /* pointer update must be visible before we extend the shared_count */ smp_store_mb(fobj->shared_count, count); - - write_seqcount_end(&obj->seq); - preempt_enable(); dma_fence_put(old); } EXPORT_SYMBOL(reservation_object_add_shared_fence); From patchwork Mon Aug 5 15:45:53 2019 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: 11085725 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 04EA5912 for ; Fri, 9 Aug 2019 09:16:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA49028B38 for ; Fri, 9 Aug 2019 09:16:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF21E28C3E; Fri, 9 Aug 2019 09:16:12 +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 A406128B38 for ; Fri, 9 Aug 2019 09:16:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F32786ED49; Fri, 9 Aug 2019 09:15:46 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 883946E4A5; Mon, 5 Aug 2019 15:46:00 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id f9so5985566wre.12; Mon, 05 Aug 2019 08:46:00 -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=a4ZZo1KUS4v5eA927ZZztm7GQeLvgm0C/yGY+IBScNk=; b=HgHKz0ky44AVh2fiF8KDNj4qxdbRxE6lK55M9xRUtlm/jAT8JjJdYxeFXB2G/7+v4Q ph9lqFD2uwdG65UhNjOFRsX96TQCbBC886ks9nRJxmeZwoYZW1v5dbkgfg3BYpTazj4R gwPwcS/FPgo5KkAgIqA63G9ClD5eFIvGi2XRzo1BlJN4izSBl30DtekpLpvE+LhCwIAG ng4syeAGlSR03Lt/fVx6Kg4Lwrrb6UJv4UrXgmDdFX1vTl2mcwJnWcp3FyQwdLKNrjkz HeDXMA2NM1HHOBDU1KEUISxxPhQa19IAziJ53cm9RLYQ8t+qDmJdkND7draGItHfZ/te UuTw== X-Gm-Message-State: APjAAAXxU0KsNHbV+/SM5Mn5sOw4l9/gAvzLtUkpHkb6KN8xpJaEfAHC 6+SBATfCY+m1D3JrGq1fhgq7PxV5 X-Google-Smtp-Source: APXvYqyKtWz2oAW1/rv7hSkrkd2h3z7inIhLfCt8NJpgwvZgCZQvI+8ki0rdQlhG46LV+7qztvPF4w== X-Received: by 2002:a5d:6389:: with SMTP id p9mr1126311wru.297.1565019958875; Mon, 05 Aug 2019 08:45:58 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:fdbd:6233:4990:5a8d]) by smtp.gmail.com with ESMTPSA id 91sm171836865wrp.3.2019.08.05.08.45.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Aug 2019 08:45:58 -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, linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, chris@chris-wilson.co.uk Date: Mon, 5 Aug 2019 17:45:53 +0200 Message-Id: <20190805154554.3476-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805154554.3476-1-christian.koenig@amd.com> References: <20190805154554.3476-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 09 Aug 2019 09:15:44 +0000 X-Mailman-Original-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=a4ZZo1KUS4v5eA927ZZztm7GQeLvgm0C/yGY+IBScNk=; b=c8lKjumQ802qAfCvsp5WXfL6BHjFMbZ03rSET63kgSVQxwL/Si4kP11+H9pHt9SeC8 NBKpD0r8ULstE6FSP+fQdLCvtGGyH/qMhQUScICPY7e3ZLr8bDXUj4R1Scn6dYI4pOyn eL+OWq0smywS6iFlWZQnphIY48FUqJ1Iv4D+S0hk/xSnywiDLWApC4PmPVswHUxzp2Dt AdA6MQwxUQquKYm66Vcv4+HKNz6Bcw1v1VndIYGPs7OEDiryqfcp8AaS+qzZQQWKhyD4 SI4xZu/j0j7DktO6fvtfDA9+/bdcwg5kx5ZXqeP2JEQpJHyjvFJGoA1i9OUPXvDWBwmr UhNw== Subject: [Intel-gfx] [PATCH 4/5] dma-buf: simplify reservation_object_get_fences_rcu a bit 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 We can add the exclusive fence to the list after making sure we got a consistent state. Signed-off-by: Christian König --- drivers/dma-buf/reservation.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index 6eaca469005f..69c826553c72 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -426,13 +426,6 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, if (!dma_fence_get_rcu(shared[i])) break; } - - if (!pfence_excl && fence_excl) { - shared[i] = fence_excl; - fence_excl = NULL; - ++i; - ++shared_count; - } } if (i != shared_count || read_seqcount_retry(&obj->seq, seq)) { @@ -447,6 +440,11 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, rcu_read_unlock(); } while (ret); + if (pfence_excl) + *pfence_excl = fence_excl; + else if (fence_excl) + shared[++shared_count] = fence_excl; + if (!shared_count) { kfree(shared); shared = NULL; @@ -454,9 +452,6 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, *pshared_count = shared_count; *pshared = shared; - if (pfence_excl) - *pfence_excl = fence_excl; - return ret; } EXPORT_SYMBOL_GPL(reservation_object_get_fences_rcu); From patchwork Mon Aug 5 15:45:54 2019 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: 11085951 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 C9E721395 for ; Fri, 9 Aug 2019 09:19:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA4C828BBC for ; Fri, 9 Aug 2019 09:19:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE7A228C55; Fri, 9 Aug 2019 09:19:27 +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 263C928BBC for ; Fri, 9 Aug 2019 09:19:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DAF476EDCF; Fri, 9 Aug 2019 09:19:21 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 84C416E4A5; Mon, 5 Aug 2019 15:46:01 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id p17so84895901wrf.11; Mon, 05 Aug 2019 08:46:01 -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=XU22kvabM0UAeUTon64K6xj93zNYGy477hyrLlnkqqs=; b=bQXLbo7DJjHTfXiezL/KpfUeGVUf6vI0Q74nXO5CF+h8MQsM2OtvmtwDdN+LyZIC7l /hpM3EXQn0rMLF9+HgoFfyEs8UFOKD2oPqfrQaoXP/FmVbbG1jDp+AgmZkhQIcXQATG9 YsgOVt8HRwv+aZNp1+VvEg6kpOU/8cZ3l6P/pBIyBRgoQ/jv5AKwVNKT1HiBol8nTHtf V1TMoXxdHKqElVAqkfEBdvTtQv346chXqrz0D2gSx1kP7qumIVXJ+E2ISjDNa1aQq2F5 F6WfkS3xRM/ASDBEDV2avvbaOFWUiSqPnMbonItgdVYJKaMRh10uS7vf1zmg5C7P3mKl RPew== X-Gm-Message-State: APjAAAWbtDTxfLGvoV26s9E4ZqMyVcrNsw9TqWlhjxms+HOdL6tY9kzq vEpvIPtsgym0IH8Prc6ZhkCgxYgu X-Google-Smtp-Source: APXvYqzHdYFy9XMLdFXHPaQajeeRSYmmHeXb+ImtY7dbzuQuBVRElYCX9hzmLr8fW66jkiqAFEWqKA== X-Received: by 2002:adf:dfc5:: with SMTP id q5mr18757753wrn.142.1565019959731; Mon, 05 Aug 2019 08:45:59 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:fdbd:6233:4990:5a8d]) by smtp.gmail.com with ESMTPSA id 91sm171836865wrp.3.2019.08.05.08.45.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Aug 2019 08:45:59 -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, linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, chris@chris-wilson.co.uk Date: Mon, 5 Aug 2019 17:45:54 +0200 Message-Id: <20190805154554.3476-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805154554.3476-1-christian.koenig@amd.com> References: <20190805154554.3476-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 09 Aug 2019 09:15:44 +0000 X-Mailman-Original-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=XU22kvabM0UAeUTon64K6xj93zNYGy477hyrLlnkqqs=; b=tEGanAP7V+39A/ck+Ix+YYs2iIz2rRrLG3XU2C8x50EPhssYveTxIH5YLXv1iO8NLP Lz439rOUOqi8fXqe4wfoWU2uGi9eXaUfCcF2bVNF3EATqzeUy6KBWm6gt78IINvpszPt qyztvbL0349xAwgCDsqhK8Ixv51qLMO7qDYQBNWVCQAvUxWW2iba0f/Zu/xMMyXl8sRn BBrYi5gfunSpGZ8dBDo2QlyRO/sBtG31jV9VvfbYOhAAq0m7eb6a9LzjtQvXwudBmNT+ voSa/3e+xAeaoMeVdUEotFwLUZnZj+Lgt+n1BoOEt3B44baXnBKBbSlhu/kjU1nK2CMJ ktew== Subject: [Intel-gfx] [PATCH 5/5] dma-buf: nuke reservation_object seq number 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 The only remaining use for this is to protect against setting a new exclusive fence while we grab both exclusive and shared. That can also be archived by looking if the exclusive fence has changed or not after completing the operation. Signed-off-by: Christian König --- drivers/dma-buf/dma-buf.c | 14 ++--- drivers/dma-buf/reservation.c | 58 +++++++------------ .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 8 +-- drivers/gpu/drm/i915/gem/i915_gem_busy.c | 11 ++-- include/linux/reservation.h | 3 - 5 files changed, 33 insertions(+), 61 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index f45bfb29ef96..c4ee4ccbfc40 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -199,7 +199,7 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll) struct reservation_object_list *fobj; struct dma_fence *fence_excl; __poll_t events; - unsigned shared_count, seq; + unsigned shared_count; dmabuf = file->private_data; if (!dmabuf || !dmabuf->resv) @@ -214,16 +214,16 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll) return 0; retry: - seq = read_seqcount_begin(&resv->seq); rcu_read_lock(); + fence_excl = rcu_dereference(resv->fence_excl); fobj = rcu_dereference(resv->fence); if (fobj) shared_count = fobj->shared_count; else shared_count = 0; - fence_excl = rcu_dereference(resv->fence_excl); - if (read_seqcount_retry(&resv->seq, seq)) { + + if (rcu_dereference(resv->fence_excl) != fence_excl) { rcu_read_unlock(); goto retry; } @@ -1157,7 +1157,6 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) struct reservation_object *robj; struct reservation_object_list *fobj; struct dma_fence *fence; - unsigned seq; int count = 0, attach_count, shared_count, i; size_t size = 0; @@ -1189,12 +1188,11 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) robj = buf_obj->resv; while (true) { - seq = read_seqcount_begin(&robj->seq); rcu_read_lock(); + fence = rcu_dereference(robj->fence_excl); fobj = rcu_dereference(robj->fence); shared_count = fobj ? fobj->shared_count : 0; - fence = rcu_dereference(robj->fence_excl); - if (!read_seqcount_retry(&robj->seq, seq)) + if (rcu_dereference(robj->fence_excl) != fence) break; rcu_read_unlock(); } diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index 69c826553c72..d8ed6235a3eb 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -49,12 +49,6 @@ DEFINE_WD_CLASS(reservation_ww_class); EXPORT_SYMBOL(reservation_ww_class); -struct lock_class_key reservation_seqcount_class; -EXPORT_SYMBOL(reservation_seqcount_class); - -const char reservation_seqcount_string[] = "reservation_seqcount"; -EXPORT_SYMBOL(reservation_seqcount_string); - /** * reservation_object_init - initialize a reservation object * @obj: the reservation object @@ -62,9 +56,6 @@ EXPORT_SYMBOL(reservation_seqcount_string); void reservation_object_init(struct reservation_object *obj) { ww_mutex_init(&obj->lock, &reservation_ww_class); - - __seqcount_init(&obj->seq, reservation_seqcount_string, - &reservation_seqcount_class); RCU_INIT_POINTER(obj->fence, NULL); RCU_INIT_POINTER(obj->fence_excl, NULL); } @@ -251,12 +242,10 @@ void reservation_object_add_excl_fence(struct reservation_object *obj, dma_fence_get(fence); preempt_disable(); - write_seqcount_begin(&obj->seq); - /* write_seqcount_begin provides the necessary memory barrier */ RCU_INIT_POINTER(obj->fence_excl, fence); + /* pointer update must be visible before we modify the shared_count */ if (old) - old->shared_count = 0; - write_seqcount_end(&obj->seq); + smp_store_mb(old->shared_count, 0); preempt_enable(); /* inplace update, no shared fences */ @@ -340,11 +329,8 @@ int reservation_object_copy_fences(struct reservation_object *dst, old = reservation_object_get_excl(dst); preempt_disable(); - write_seqcount_begin(&dst->seq); - /* write_seqcount_begin provides the necessary memory barrier */ RCU_INIT_POINTER(dst->fence_excl, new); - RCU_INIT_POINTER(dst->fence, dst_list); - write_seqcount_end(&dst->seq); + rcu_assign_pointer(dst->fence, dst_list); preempt_enable(); if (src_list) @@ -380,18 +366,14 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, do { struct reservation_object_list *fobj; - unsigned int i, seq; + unsigned int i; size_t sz = 0; shared_count = i = 0; rcu_read_lock(); - seq = read_seqcount_begin(&obj->seq); - - fence_excl = rcu_dereference(obj->fence_excl); - if (fence_excl && !dma_fence_get_rcu(fence_excl)) - goto unlock; + fence_excl = dma_fence_get_rcu_safe(&obj->fence_excl); fobj = rcu_dereference(obj->fence); if (fobj) sz += sizeof(*shared) * fobj->shared_max; @@ -428,7 +410,8 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, } } - if (i != shared_count || read_seqcount_retry(&obj->seq, seq)) { + if (i != shared_count || + rcu_dereference(obj->fence_excl) != fence_excl) { while (i--) dma_fence_put(shared[i]); dma_fence_put(fence_excl); @@ -472,18 +455,17 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, bool wait_all, bool intr, unsigned long timeout) { - struct dma_fence *fence; - unsigned seq, shared_count; + struct dma_fence *fence, *fence_excl; long ret = timeout ? timeout : 1; + unsigned shared_count; int i; retry: shared_count = 0; - seq = read_seqcount_begin(&obj->seq); rcu_read_lock(); i = -1; - fence = rcu_dereference(obj->fence_excl); + fence = fence_excl = rcu_dereference(obj->fence_excl); if (fence && !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) { if (!dma_fence_get_rcu(fence)) goto unlock_retry; @@ -524,13 +506,13 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, } } + if (rcu_dereference(obj->fence_excl) != fence_excl) { + dma_fence_put(fence); + goto unlock_retry; + } + rcu_read_unlock(); if (fence) { - if (read_seqcount_retry(&obj->seq, seq)) { - dma_fence_put(fence); - goto retry; - } - ret = dma_fence_wait_timeout(fence, intr, ret); dma_fence_put(fence); if (ret > 0 && wait_all && (i + 1 < shared_count)) @@ -575,14 +557,15 @@ reservation_object_test_signaled_single(struct dma_fence *passed_fence) bool reservation_object_test_signaled_rcu(struct reservation_object *obj, bool test_all) { - unsigned seq, shared_count; + struct dma_fence *fence_excl; + unsigned shared_count; int ret; rcu_read_lock(); retry: + fence_excl = rcu_dereference(obj->fence_excl); ret = true; shared_count = 0; - seq = read_seqcount_begin(&obj->seq); if (test_all) { unsigned i; @@ -603,12 +586,11 @@ bool reservation_object_test_signaled_rcu(struct reservation_object *obj, break; } - if (read_seqcount_retry(&obj->seq, seq)) + if (rcu_dereference(obj->fence_excl) != fence_excl) goto retry; } if (!shared_count) { - struct dma_fence *fence_excl = rcu_dereference(obj->fence_excl); if (fence_excl) { ret = reservation_object_test_signaled_single( @@ -616,7 +598,7 @@ bool reservation_object_test_signaled_rcu(struct reservation_object *obj, if (ret < 0) goto retry; - if (read_seqcount_retry(&obj->seq, seq)) + if (rcu_dereference(obj->fence_excl) != fence_excl) goto retry; } } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 1d3ee9c42f7e..a2a2ae592f20 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -251,12 +251,8 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo, new->shared_max = old->shared_max; new->shared_count = k; - /* Install the new fence list, seqcount provides the barriers */ - preempt_disable(); - write_seqcount_begin(&resv->seq); - RCU_INIT_POINTER(resv->fence, new); - write_seqcount_end(&resv->seq); - preempt_enable(); + /* Install the new fence list */ + rcu_assign_pointer(resv->fence, new); /* Drop the references to the removed fences or move them to ef_list */ for (i = j, k = 0; i < old->shared_count; ++i) { diff --git a/drivers/gpu/drm/i915/gem/i915_gem_busy.c b/drivers/gpu/drm/i915/gem/i915_gem_busy.c index 6ad93a09968c..6e8a6e4f39ff 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_busy.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_busy.c @@ -83,7 +83,7 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data, struct drm_i915_gem_busy *args = data; struct drm_i915_gem_object *obj; struct reservation_object_list *list; - unsigned int seq; + struct dma_fence *fence_excl; int err; err = -ENOENT; @@ -110,11 +110,9 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data, * */ retry: - seq = raw_read_seqcount(&obj->base.resv->seq); - /* Translate the exclusive fence to the READ *and* WRITE engine */ - args->busy = - busy_check_writer(rcu_dereference(obj->base.resv->fence_excl)); + fence_excl = rcu_dereference(obj->base.resv->fence_excl); + args->busy = busy_check_writer(fence_excl); /* Translate shared fences to READ set of engines */ list = rcu_dereference(obj->base.resv->fence); @@ -129,7 +127,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data, } } - if (args->busy && read_seqcount_retry(&obj->base.resv->seq, seq)) + if (args->busy && + rcu_dereference(obj->base.resv->fence_excl) != fence_excl) goto retry; err = 0; diff --git a/include/linux/reservation.h b/include/linux/reservation.h index 56b782fec49b..2b0b2a1aeae2 100644 --- a/include/linux/reservation.h +++ b/include/linux/reservation.h @@ -46,8 +46,6 @@ #include extern struct ww_class reservation_ww_class; -extern struct lock_class_key reservation_seqcount_class; -extern const char reservation_seqcount_string[]; /** * struct reservation_object_list - a list of shared fences @@ -71,7 +69,6 @@ struct reservation_object_list { */ struct reservation_object { struct ww_mutex lock; - seqcount_t seq; struct dma_fence __rcu *fence_excl; struct reservation_object_list __rcu *fence;