From patchwork Fri Apr 15 18:57:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 711151 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 p3FI61XU004989 for ; Fri, 15 Apr 2011 18:06:27 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56B579E79C for ; Fri, 15 Apr 2011 11:06:01 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ww0-f43.google.com (mail-ww0-f43.google.com [74.125.82.43]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B44B9E77A for ; Fri, 15 Apr 2011 11:03:26 -0700 (PDT) Received: by wwb17 with SMTP id 17so2950835wwb.12 for ; Fri, 15 Apr 2011 11:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=pa4k5pDoNwg4iM2PiXRuXbsVu7DPhAjMck40qZlLqUA=; b=BtXtMQNGrkVFuLmDe64Eq0bfyACoUL6TjCaYodGktb/mZj1owx4h9KZu+oFieQv+n6 pZwDTO5NT8UGaZcl0ZFs8GzZumiF7dSfxCtMfZlV2q0WrqPmEDis/hVQrfOusXmw9zmk TK6XIJPUuaG5uqO3xDt/dZB7Y7dC0JqhqHP/c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=Xso3ChFolAUdG4rhu4c42+GxaqDoszH20EjcZsLuR+dkII2mIucJcn2Bl9j8RIXlT+ R3iiOtVKg2UBXKzdWDyaRvSHHxCr7jYSEb2o6j4vg3EfuAHbHtJZ9hGouA5vvzxUFYg/ L7n5D+VUEr49SbcStt5eZTcN+HPh9byQlEBio= Received: by 10.216.254.39 with SMTP id g39mr1121036wes.108.1302890605448; Fri, 15 Apr 2011 11:03:25 -0700 (PDT) Received: from localhost.localdomain (cable-static-216-94.intergga.ch [87.102.216.94]) by mx.google.com with ESMTPS id s40sm1433457weq.4.2011.04.15.11.03.24 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Apr 2011 11:03:24 -0700 (PDT) From: Daniel Vetter To: intel-gfx@lists.freedesktop.org Date: Fri, 15 Apr 2011 20:57:38 +0200 Message-Id: <1302893858-8234-5-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1302893858-8234-1-git-send-email-daniel.vetter@ffwll.ch> References: <1302893858-8234-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 4/4] drm/i915: use drm_mm_for_each_scanned_node_reverse helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 15 Apr 2011 18:06:27 +0000 (UTC) Doesn't really buy much, but looks nicer. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_gem_evict.c | 34 ++++++++++++++------------------ 1 files changed, 15 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c index 1a9c96b..7d3ea89 100644 --- a/drivers/gpu/drm/i915/i915_gem_evict.c +++ b/drivers/gpu/drm/i915/i915_gem_evict.c @@ -33,9 +33,8 @@ #include "i915_trace.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->exec_list, unwind); drm_gem_object_reference(&obj->base); return drm_mm_scan_add_block(&obj->gtt_space); } @@ -45,8 +44,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); @@ -89,7 +89,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, @@ -99,7 +98,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; } @@ -109,7 +108,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; } @@ -118,27 +117,25 @@ 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! */ - while (!list_empty(&unwind_list)) { - obj = list_first_entry(&unwind_list, - struct drm_i915_gem_object, - exec_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); - list_del_init(&obj->exec_list); drm_gem_object_unreference(&obj->base); } @@ -152,15 +149,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, - exec_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->exec_list, &eviction_list); + list_add(&obj->exec_list, &eviction_list); continue; } - list_del_init(&obj->exec_list); drm_gem_object_unreference(&obj->base); }