From patchwork Sun Feb 12 21:53:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9568585 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 263F660572 for ; Sun, 12 Feb 2017 21:53:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1861927F8C for ; Sun, 12 Feb 2017 21:53:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D36B27FBB; Sun, 12 Feb 2017 21:53:53 +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_SIGNED, 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 C6ADF27F8C for ; Sun, 12 Feb 2017 21:53:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D27806E039; Sun, 12 Feb 2017 21:53:51 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@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 C771C6E06A for ; Sun, 12 Feb 2017 21:53:49 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id 89so21645349wrr.1 for ; Sun, 12 Feb 2017 13:53:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Aufz4BiGT8pHQgDz4uMu3HLSCxVNB6p/OKGOwnxHcRo=; b=KxIW9LaXytDNVSDM8dn/WxgxGCAeQOq++XSz6xJ8KBxX2baSYRVy5BhnXJTh7Gippq h33HucfiWuXiGNyUa33GBupOvHVT6tVh1z+6JGrxvn0zuFlW0EKlkeVqaoKxtZeGMTBP uBmYNzL/0Qgeob/cMU05Fe40hBcxcRBuR0Q9xHjBq8c7zcLc3/KYXALoEz/GC4n5Of8C zmwd9j5FelPyXBjI+GO2ThxxUGFujtb1eGKDjliUQHjxT3mhax4zmGilf2a09Jhno0fp +/hbqYCKFvicGQ9e4ow+IORHcJItM+wP/SW/+NtPrNL2XVVKDXh0r6hGNZCadd4MJ7RQ zRBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Aufz4BiGT8pHQgDz4uMu3HLSCxVNB6p/OKGOwnxHcRo=; b=ORvA53H8lp6UNBjcYCXiDntc0PHbSnNw35t8u9+hm2IRMPMtOWf6FpbAR8o+IKCEDG aCqDueAPPzgWH16X/niQWJl2k4tT3xB50phAA8UkGglkSsJxIp/eIbQxOJ+AzV+xQ6X0 H88rqjpGFpuO2pA8dIl2qaWhiqpIbM0iYAwzDLA7vECe6N1oW1RJey77+/0Av6K7RQqu qo64Oc3a5fRetwsjpgqt34O74SeVQerrAHe6shgKJZbMiYDKrBVKdVzncOZlp3AVJK5F 2b+psU5EjDuJz7t2IlOVsImqWAhQehUrHdgsTSGOfH2txgZWFDNx/BGJPmiDcpebfcOo TVUg== X-Gm-Message-State: AMke39m/abnZHb1yRl89GxdwPNzaAMwCHnfb85erPCvGsab7y4vUyAr7fql2ueA8G9vEUA== X-Received: by 10.223.164.151 with SMTP id g23mr17305540wrb.86.1486936428192; Sun, 12 Feb 2017 13:53:48 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id i203sm2817266wmf.12.2017.02.12.13.53.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Feb 2017 13:53:47 -0800 (PST) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Sun, 12 Feb 2017 21:53:44 +0000 Message-Id: <20170212215344.16600-2-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170212215344.16600-1-chris@chris-wilson.co.uk> References: <20170212215344.16600-1-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [PATCH 2/2] drm/i915: Remove completed fences after a wait X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP If we wait up on the full (i.e. all shared fences, or upon an exclusive fence) reservation object successfully, we know that all fences beneath it have been signaled, so long as no new fences were added whilst we slept. If the reservation_object remains the same, as detected by its seqcount, we can then reap all the fences upon completion. Signed-off-by: Chris Wilson Cc: Joonas Lahtinen Reviewed-by: Matthew Auld --- drivers/gpu/drm/i915/i915_gem.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index cf8132c49600..e55a60c1afce 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -424,7 +424,9 @@ i915_gem_object_wait_reservation(struct reservation_object *resv, long timeout, struct intel_rps_client *rps) { + 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; @@ -449,15 +451,26 @@ i915_gem_object_wait_reservation(struct reservation_object *resv, for (; i < count; i++) dma_fence_put(shared[i]); kfree(shared); + + prune_fences = timeout >= 0; } else { excl = reservation_object_get_excl_rcu(resv); } - if (excl && timeout >= 0) + if (excl && timeout >= 0) { timeout = i915_gem_object_wait_fence(excl, flags, timeout, rps); + prune_fences = timeout >= 0; + } dma_fence_put(excl); + if (prune_fences && !__read_seqcount_retry(&resv->seq, seq)) { + reservation_object_lock(resv, NULL); + if (!__read_seqcount_retry(&resv->seq, seq)) + reservation_object_add_excl_fence(resv, NULL); + reservation_object_unlock(resv); + } + return timeout; }