From patchwork Fri Nov 12 17:36:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 320262 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oACHfNM0019742 for ; Fri, 12 Nov 2010 17:41:44 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C905EA1806 for ; Fri, 12 Nov 2010 09:41:23 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.ffwll.ch (cable-static-49-187.intergga.ch [157.161.49.187]) by gabe.freedesktop.org (Postfix) with ESMTP id 138EF9F37F for ; Fri, 12 Nov 2010 09:34:18 -0800 (PST) Received: by mail.ffwll.ch (Postfix, from userid 1000) id DE78520C1D1; Fri, 12 Nov 2010 18:37:26 +0100 (CET) X-Spam-ASN: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on orange.ffwll.ch X-Spam-Level: X-Spam-Hammy: 0.000-+--HTo:U*dri-devel, 0.000-+--H*UA:git-send-email, 0.000-+--H*x:git-send-email X-Spam-Status: No, score=-4.4 required=6.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Spammy: 0.963-+--H*r:mail.ffwll.ch, 0.958-+--H*m:ffwll, 0.944-+--H*Ad:U*daniel.vetter Received: from viiv.ffwll.ch (viiv.ffwll.ch [192.168.23.128]) by mail.ffwll.ch (Postfix) with ESMTP id C560F20C348; Fri, 12 Nov 2010 18:36:57 +0100 (CET) Received: from daniel by viiv.ffwll.ch with local (Exim 4.72) (envelope-from ) id 1PGxYX-0004Lu-LL; Fri, 12 Nov 2010 18:36:57 +0100 From: Daniel Vetter To: dri-devel@lists.freedesktop.org Subject: [PATCH 9/9] drm/i915: use drm_mm_for_each_scanned_node_reverse helper Date: Fri, 12 Nov 2010 18:36:41 +0100 Message-Id: <1289583401-16605-10-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1289583401-16605-1-git-send-email-daniel.vetter@ffwll.ch> References: <1289583401-16605-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 12 Nov 2010 17:41:44 +0000 (UTC) diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c index ea252a4..845b6ad 100644 --- a/drivers/gpu/drm/i915/i915_gem_evict.c +++ b/drivers/gpu/drm/i915/i915_gem_evict.c @@ -32,9 +32,8 @@ #include "i915_drm.h" static bool -mark_free(struct drm_i915_gem_object *obj, struct list_head *unwind) +mark_free(struct drm_i915_gem_object *obj) { - list_add(&obj->evict_list, unwind); drm_gem_object_reference(&obj->base); return drm_mm_scan_add_block(&obj->gtt_space); } @@ -44,8 +43,9 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, unsigned alignment, bool mappable) { drm_i915_private_t *dev_priv = dev->dev_private; - struct list_head eviction_list, unwind_list; + struct list_head eviction_list; struct drm_i915_gem_object *obj; + struct drm_mm_node *node, *next; int ret = 0; i915_gem_retire_requests(dev); @@ -86,7 +86,6 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, * object on the TAIL. */ - INIT_LIST_HEAD(&unwind_list); if (mappable) drm_mm_init_scan_with_range(&dev_priv->mm.gtt_space, min_size, alignment, 0, @@ -96,7 +95,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, /* First see if there is a large enough contiguous idle region... */ list_for_each_entry(obj, &dev_priv->mm.inactive_list, mm_list) { - if (mark_free(obj, &unwind_list)) + if (mark_free(obj)) goto found; } @@ -106,7 +105,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, if (obj->base.write_domain || obj->pin_count) continue; - if (mark_free(obj, &unwind_list)) + if (mark_free(obj)) goto found; } @@ -115,19 +114,22 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, if (obj->pin_count) continue; - if (mark_free(obj, &unwind_list)) + if (mark_free(obj)) goto found; } list_for_each_entry(obj, &dev_priv->mm.active_list, mm_list) { if (! obj->base.write_domain || obj->pin_count) continue; - if (mark_free(obj, &unwind_list)) + if (mark_free(obj)) goto found; } /* Nothing found, clean up and bail out! */ - list_for_each_entry(obj, &unwind_list, evict_list) { + drm_mm_for_each_scanned_node_reverse(node, next, + &dev_priv->mm.gtt_space) { + obj = container_of(node, struct drm_i915_gem_object, gtt_space); + ret = drm_mm_scan_remove_block(&obj->gtt_space); BUG_ON(ret); drm_gem_object_unreference(&obj->base); @@ -143,15 +145,14 @@ found: * scanning, therefore store to be evicted objects on a * temporary list. */ INIT_LIST_HEAD(&eviction_list); - while (!list_empty(&unwind_list)) { - obj = list_first_entry(&unwind_list, - struct drm_i915_gem_object, - evict_list); + drm_mm_for_each_scanned_node_reverse(node, next, + &dev_priv->mm.gtt_space) { + obj = container_of(node, struct drm_i915_gem_object, gtt_space); + if (drm_mm_scan_remove_block(&obj->gtt_space)) { - list_move(&obj->evict_list, &eviction_list); + list_add(&obj->evict_list, &eviction_list); continue; } - list_del(&obj->evict_list); drm_gem_object_unreference(&obj->base); }