Intel-GFX Archive on lore.kernel.org
 help / color / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: intel-gfx@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 4/4] drm/i915: use drm_mm_for_each_scanned_node_reverse helper
Date: Fri, 15 Apr 2011 20:57:38 +0200
Message-ID: <1302893858-8234-5-git-send-email-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <1302893858-8234-1-git-send-email-daniel.vetter@ffwll.ch>

Doesn't really buy much, but looks nicer.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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);
 	}
 
-- 
1.7.4.1

      parent reply index

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-15 18:57 [PATCH 0/4] embed drm_mm_node Daniel Vetter
2011-04-15 18:57 ` [PATCH 1/4] drm/i915: embed struct drm_mm_node into struct drm_i915_gem_object Daniel Vetter
2011-04-15 23:01   ` Dave Airlie
2011-04-16 10:59     ` Daniel Vetter
2011-04-15 18:57 ` [PATCH 2/4] drm/i915: kill obj->gtt_offset Daniel Vetter
2011-04-15 18:56   ` Chris Wilson
2011-04-15 19:19     ` Daniel Vetter
2011-04-15 20:04       ` Chris Wilson
2011-04-15 18:57 ` [PATCH 3/4] drm/i915: kill gtt_list Daniel Vetter
2011-04-15 18:57 ` Daniel Vetter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302893858-8234-5-git-send-email-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Intel-GFX Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/intel-gfx/0 intel-gfx/git/0.git
	git clone --mirror https://lore.kernel.org/intel-gfx/1 intel-gfx/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 intel-gfx intel-gfx/ https://lore.kernel.org/intel-gfx \
		intel-gfx@lists.freedesktop.org
	public-inbox-index intel-gfx

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.freedesktop.lists.intel-gfx


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git