aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_gem.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-04-24 10:47:30 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2012-05-03 05:18:11 -0400
commit1b50247a8ddde4af5aaa0e6bc125615372ce6c16 (patch)
tree98f5a6a590242476b863e1a3caffa6ea8fcdba58 /drivers/gpu/drm/i915/i915_gem.c
parenta39d7efc6200d05b9ca3cfeec5dd82f6dd03f4e8 (diff)
drm/i915: Remove the list of pinned inactive objects
Simplify object tracking by removing the inactive but pinned list. The only place where this was used is for counting the available memory, which is just as easy performed by checking all objects on the rare occasions it is required (application startup). For ease of debugging, we keep the reporting of pinned objects through the error-state and debugfs. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c38
1 files changed, 8 insertions, 30 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 2fc7c55e0e05..bf4683c9aed8 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -132,7 +132,7 @@ int i915_mutex_lock_interruptible(struct drm_device *dev)
132static inline bool 132static inline bool
133i915_gem_object_is_inactive(struct drm_i915_gem_object *obj) 133i915_gem_object_is_inactive(struct drm_i915_gem_object *obj)
134{ 134{
135 return !obj->active && obj->pin_count == 0; 135 return !obj->active;
136} 136}
137 137
138int 138int
@@ -171,8 +171,9 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
171 171
172 pinned = 0; 172 pinned = 0;
173 mutex_lock(&dev->struct_mutex); 173 mutex_lock(&dev->struct_mutex);
174 list_for_each_entry(obj, &dev_priv->mm.pinned_list, mm_list) 174 list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list)
175 pinned += obj->gtt_space->size; 175 if (obj->pin_count)
176 pinned += obj->gtt_space->size;
176 mutex_unlock(&dev->struct_mutex); 177 mutex_unlock(&dev->struct_mutex);
177 178
178 args->aper_size = dev_priv->mm.gtt_total; 179 args->aper_size = dev_priv->mm.gtt_total;
@@ -1455,10 +1456,7 @@ i915_gem_object_move_to_inactive(struct drm_i915_gem_object *obj)
1455 struct drm_device *dev = obj->base.dev; 1456 struct drm_device *dev = obj->base.dev;
1456 struct drm_i915_private *dev_priv = dev->dev_private; 1457 struct drm_i915_private *dev_priv = dev->dev_private;
1457 1458
1458 if (obj->pin_count != 0) 1459 list_move_tail(&obj->mm_list, &dev_priv->mm.inactive_list);
1459 list_move_tail(&obj->mm_list, &dev_priv->mm.pinned_list);
1460 else
1461 list_move_tail(&obj->mm_list, &dev_priv->mm.inactive_list);
1462 1460
1463 BUG_ON(!list_empty(&obj->gpu_write_list)); 1461 BUG_ON(!list_empty(&obj->gpu_write_list));
1464 BUG_ON(!obj->active); 1462 BUG_ON(!obj->active);
@@ -3063,12 +3061,9 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj,
3063 uint32_t alignment, 3061 uint32_t alignment,
3064 bool map_and_fenceable) 3062 bool map_and_fenceable)
3065{ 3063{
3066 struct drm_device *dev = obj->base.dev;
3067 struct drm_i915_private *dev_priv = dev->dev_private;
3068 int ret; 3064 int ret;
3069 3065
3070 BUG_ON(obj->pin_count == DRM_I915_GEM_OBJECT_MAX_PIN_COUNT); 3066 BUG_ON(obj->pin_count == DRM_I915_GEM_OBJECT_MAX_PIN_COUNT);
3071 WARN_ON(i915_verify_lists(dev));
3072 3067
3073 if (obj->gtt_space != NULL) { 3068 if (obj->gtt_space != NULL) {
3074 if ((alignment && obj->gtt_offset & (alignment - 1)) || 3069 if ((alignment && obj->gtt_offset & (alignment - 1)) ||
@@ -3096,34 +3091,20 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj,
3096 if (!obj->has_global_gtt_mapping && map_and_fenceable) 3091 if (!obj->has_global_gtt_mapping && map_and_fenceable)
3097 i915_gem_gtt_bind_object(obj, obj->cache_level); 3092 i915_gem_gtt_bind_object(obj, obj->cache_level);
3098 3093
3099 if (obj->pin_count++ == 0) { 3094 obj->pin_count++;
3100 if (!obj->active)
3101 list_move_tail(&obj->mm_list,
3102 &dev_priv->mm.pinned_list);
3103 }
3104 obj->pin_mappable |= map_and_fenceable; 3095 obj->pin_mappable |= map_and_fenceable;
3105 3096
3106 WARN_ON(i915_verify_lists(dev));
3107 return 0; 3097 return 0;
3108} 3098}
3109 3099
3110void 3100void
3111i915_gem_object_unpin(struct drm_i915_gem_object *obj) 3101i915_gem_object_unpin(struct drm_i915_gem_object *obj)
3112{ 3102{
3113 struct drm_device *dev = obj->base.dev;
3114 drm_i915_private_t *dev_priv = dev->dev_private;
3115
3116 WARN_ON(i915_verify_lists(dev));
3117 BUG_ON(obj->pin_count == 0); 3103 BUG_ON(obj->pin_count == 0);
3118 BUG_ON(obj->gtt_space == NULL); 3104 BUG_ON(obj->gtt_space == NULL);
3119 3105
3120 if (--obj->pin_count == 0) { 3106 if (--obj->pin_count == 0)
3121 if (!obj->active)
3122 list_move_tail(&obj->mm_list,
3123 &dev_priv->mm.inactive_list);
3124 obj->pin_mappable = false; 3107 obj->pin_mappable = false;
3125 }
3126 WARN_ON(i915_verify_lists(dev));
3127} 3108}
3128 3109
3129int 3110int
@@ -3426,12 +3407,10 @@ void i915_gem_free_object(struct drm_gem_object *gem_obj)
3426 struct drm_i915_gem_object *obj = to_intel_bo(gem_obj); 3407 struct drm_i915_gem_object *obj = to_intel_bo(gem_obj);
3427 struct drm_device *dev = obj->base.dev; 3408 struct drm_device *dev = obj->base.dev;
3428 3409
3429 while (obj->pin_count > 0)
3430 i915_gem_object_unpin(obj);
3431
3432 if (obj->phys_obj) 3410 if (obj->phys_obj)
3433 i915_gem_detach_phys_object(dev, obj); 3411 i915_gem_detach_phys_object(dev, obj);
3434 3412
3413 obj->pin_count = 0;
3435 i915_gem_free_object_tail(obj); 3414 i915_gem_free_object_tail(obj);
3436} 3415}
3437 3416
@@ -3699,7 +3678,6 @@ i915_gem_load(struct drm_device *dev)
3699 INIT_LIST_HEAD(&dev_priv->mm.active_list); 3678 INIT_LIST_HEAD(&dev_priv->mm.active_list);
3700 INIT_LIST_HEAD(&dev_priv->mm.flushing_list); 3679 INIT_LIST_HEAD(&dev_priv->mm.flushing_list);
3701 INIT_LIST_HEAD(&dev_priv->mm.inactive_list); 3680 INIT_LIST_HEAD(&dev_priv->mm.inactive_list);
3702 INIT_LIST_HEAD(&dev_priv->mm.pinned_list);
3703 INIT_LIST_HEAD(&dev_priv->mm.fence_list); 3681 INIT_LIST_HEAD(&dev_priv->mm.fence_list);
3704 INIT_LIST_HEAD(&dev_priv->mm.deferred_free_list); 3682 INIT_LIST_HEAD(&dev_priv->mm.deferred_free_list);
3705 INIT_LIST_HEAD(&dev_priv->mm.gtt_list); 3683 INIT_LIST_HEAD(&dev_priv->mm.gtt_list);