[Intel-gfx] [PATCH 4/4] drm/i915: use drm_mm_for_each_scanned_node_reverse helper
Daniel Vetter
daniel.vetter at ffwll.ch
Fri Apr 15 20:57:38 CEST 2011
Doesn't really buy much, but looks nicer.
Signed-off-by: Daniel Vetter <daniel.vetter at 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
More information about the Intel-gfx
mailing list