[Intel-gfx] [PATCH 10/15] drm/i915: track objects in the gtt

Daniel Vetter daniel.vetter at ffwll.ch
Sat Nov 6 15:22:03 CET 2010


This is required to restore gtt mappings on resume when agp is gone.

The right way to do this would be to make sturct drm_mm_node embeddable
and use the allocation list maintained by the drm memory manager. But
that's a bigger project. Getting rid of the per bo agp_mem will save
more memory than this wastes, anyway.

Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 drivers/gpu/drm/i915/i915_drv.h |    4 ++++
 drivers/gpu/drm/i915/i915_gem.c |    4 ++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 6212342..e77963d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -544,6 +544,9 @@ typedef struct drm_i915_private {
 		struct drm_mm vram;
 		/** Memory allocator for GTT */
 		struct drm_mm gtt_space;
+		/** List of all objects in gtt_space. Used to restore gtt
+		 * mappings on resume */
+		struct list_head gtt_list;
 		/** End of mappable part of GTT */
 		unsigned long gtt_mappable_end;
 
@@ -711,6 +714,7 @@ struct drm_i915_gem_object {
 
 	/** Current space allocated to this object in the GTT, if any. */
 	struct drm_mm_node *gtt_space;
+	struct list_head gtt_list;
 
 	/** This object's place on the active/flushing/inactive lists */
 	struct list_head ring_list;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 49e38ff..feb1b4f 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -95,6 +95,7 @@ static void i915_gem_info_add_gtt(struct drm_i915_private *dev_priv,
 			min_t(size_t, obj->gtt_space->size,
 			      dev_priv->mm.gtt_mappable_end - obj->gtt_offset);
 	}
+	list_add_tail(&obj->gtt_list, &dev_priv->mm.gtt_list);
 }
 
 static void i915_gem_info_remove_gtt(struct drm_i915_private *dev_priv,
@@ -107,6 +108,7 @@ static void i915_gem_info_remove_gtt(struct drm_i915_private *dev_priv,
 			min_t(size_t, obj->gtt_space->size,
 			      dev_priv->mm.gtt_mappable_end - obj->gtt_offset);
 	}
+	list_del_init(&obj->gtt_list);
 }
 
 /**
@@ -4432,6 +4434,7 @@ struct drm_gem_object * i915_gem_alloc_object(struct drm_device *dev,
 	obj->base.driver_private = NULL;
 	obj->fence_reg = I915_FENCE_REG_NONE;
 	INIT_LIST_HEAD(&obj->mm_list);
+	INIT_LIST_HEAD(&obj->gtt_list);
 	INIT_LIST_HEAD(&obj->ring_list);
 	INIT_LIST_HEAD(&obj->gpu_write_list);
 	obj->madv = I915_MADV_WILLNEED;
@@ -4744,6 +4747,7 @@ i915_gem_load(struct drm_device *dev)
 	INIT_LIST_HEAD(&dev_priv->mm.pinned_list);
 	INIT_LIST_HEAD(&dev_priv->mm.fence_list);
 	INIT_LIST_HEAD(&dev_priv->mm.deferred_free_list);
+	INIT_LIST_HEAD(&dev_priv->mm.gtt_list);
 	init_ring_lists(&dev_priv->render_ring);
 	init_ring_lists(&dev_priv->bsd_ring);
 	init_ring_lists(&dev_priv->blt_ring);
-- 
1.7.1




More information about the Intel-gfx mailing list