From patchwork Thu Feb 23 16:18:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9588487 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 87E6A60578 for ; Thu, 23 Feb 2017 16:18:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 787AF2833C for ; Thu, 23 Feb 2017 16:18:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C9E2283E8; Thu, 23 Feb 2017 16:18:41 +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 7F9102833C for ; Thu, 23 Feb 2017 16:18:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DF26E6EA57; Thu, 23 Feb 2017 16:18:39 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@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 EED446EA57 for ; Thu, 23 Feb 2017 16:18:36 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id z61so4431691wrc.3 for ; Thu, 23 Feb 2017 08:18:36 -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=tc5bw2yHZcKzzDeod8LKb8MfEe7u/WCEUezLQODmRMQ=; b=uWggQLNFyt29dtkeZE6FpbMwIpatI/7OegLCxgq5WefUqDkPms8rv+oLQ/Caw1Qbp7 Ykzdgc9CqNDi/vT1DO4gdZZEHHBgc10GFHpKv+Y0EtbWALoMBainDQFioCxFuzIdpK40 xe0qRFo0Eq1Wv+SiwETHVC3q744kjvNlEB3yIl4ebjOKw2OOqvfGOxWreJuL0UibLnBM C/ekmUZXFAMgOooLRoTa/nmkgmKlQplFHXgUyh+ctHO9I7wynN35xR9rssfTn856LCbP FuCeiZ3ejGu03JOpApSQXXBrIWkZcGe2XedDHjqKQqk+Wo2PAJrIbgafuu+5CCbMGbtK 9hSw== 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=tc5bw2yHZcKzzDeod8LKb8MfEe7u/WCEUezLQODmRMQ=; b=syHDy/TqyFBB6iZN97x4llRdOXcRgLkWJXKSgwOy2DuZb8yZPpD1z98vQxYy99Yqno +Z6w3K9ChnAfpWuai2m37cNx7X7ePhOBN3DWpIVDOndaDczOOnpxvi5xLEHfJb/xQGpD XHHqY8mIlUW7ypRVpnmP7PQRf/qEwbqm0gca+Esw1tv07tYAEiDL7j0UCvVMGPVS6kWj oYFVO4O7VKy5oUppedziW1oFFsBu7nst4Hy606uoXJqiVftDxiesXezCZ01vadV6GDxz LbwgWxGY4IR0JhrIlPeyj3snTRCvT59Olh/qPgLOtwgKmuudRwP+d+kp8RwLD0h7pC7S J8qw== X-Gm-Message-State: AMke39lIIkcySNQumTlsa2K4/WkHZUZwD02Te2nMG6nDaaCwsvcK/V7ZOJM/EqGOO/BBOQ== X-Received: by 10.223.138.183 with SMTP id y52mr21326563wry.190.1487866715673; Thu, 23 Feb 2017 08:18:35 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id 65sm6587444wri.53.2017.02.23.08.18.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Feb 2017 08:18:35 -0800 (PST) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Thu, 23 Feb 2017 16:18:17 +0000 Message-Id: <20170223161830.26965-3-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170223161830.26965-1-chris@chris-wilson.co.uk> References: <20170223161830.26965-1-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [PATCH 02/15] drm/i915: Retire an active batch pool object rather than allocate new 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 Since obj->active_count is only updated upon retirement, if we see an active object in the batch pool, double check that is still active before deciding to allocate a new object. Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/i915_gem_batch_pool.c | 37 ++++++++++++++---------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_batch_pool.c b/drivers/gpu/drm/i915/i915_gem_batch_pool.c index 99ceae7855f8..41aa598c4f3b 100644 --- a/drivers/gpu/drm/i915/i915_gem_batch_pool.c +++ b/drivers/gpu/drm/i915/i915_gem_batch_pool.c @@ -96,8 +96,7 @@ struct drm_i915_gem_object * i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool, size_t size) { - struct drm_i915_gem_object *obj = NULL; - struct drm_i915_gem_object *tmp; + struct drm_i915_gem_object *obj; struct list_head *list; int n, ret; @@ -112,31 +111,29 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool, n = ARRAY_SIZE(pool->cache_list) - 1; list = &pool->cache_list[n]; - list_for_each_entry(tmp, list, batch_pool_link) { + list_for_each_entry(obj, list, batch_pool_link) { /* The batches are strictly LRU ordered */ - if (i915_gem_object_is_active(tmp)) - break; + if (i915_gem_object_is_active(obj)) { + if (!reservation_object_test_signaled_rcu(obj->resv, + true)) + break; - GEM_BUG_ON(!reservation_object_test_signaled_rcu(tmp->resv, - true)); + i915_gem_retire_requests(pool->engine->i915); + GEM_BUG_ON(i915_gem_object_is_active(obj)); + } - if (tmp->base.size >= size) { - /* Clear the set of shared fences early */ - reservation_object_lock(tmp->resv, NULL); - reservation_object_add_excl_fence(tmp->resv, NULL); - reservation_object_unlock(tmp->resv); + GEM_BUG_ON(!reservation_object_test_signaled_rcu(obj->resv, + true)); - obj = tmp; - break; - } + if (obj->base.size >= size) + goto found; } - if (obj == NULL) { - obj = i915_gem_object_create_internal(pool->engine->i915, size); - if (IS_ERR(obj)) - return obj; - } + obj = i915_gem_object_create_internal(pool->engine->i915, size); + if (IS_ERR(obj)) + return obj; +found: ret = i915_gem_object_pin_pages(obj); if (ret) return ERR_PTR(ret);