Use an atomic_t for the count (since that is useful for leak detection in tests) and just rip out the object memory check. Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxx> --- drivers/gpu/drm/i915/i915_debugfs.c | 5 ++--- drivers/gpu/drm/i915/i915_drv.h | 5 ++--- drivers/gpu/drm/i915/i915_gem.c | 24 ++++++------------------ 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 9d871c7..67d6699 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -228,9 +228,8 @@ static int i915_gem_object_info(struct seq_file *m, void *data) if (ret) return ret; - seq_printf(m, "%u objects, %zu bytes\n", - dev_priv->mm.object_count, - dev_priv->mm.object_memory); + seq_printf(m, "%u objects\n", + atomic_read(&dev_priv->mm.object_count)); size = count = mappable_size = mappable_count = 0; count_objects(&dev_priv->mm.bound_list, global_list); diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index c9dd0cb..9e49f79 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -925,9 +925,8 @@ struct i915_gem_mm { /* storage for physical objects */ struct drm_i915_gem_phys_object *phys_objs[I915_MAX_PHYS_OBJECT]; - /* accounting, useful for userland debugging */ - size_t object_memory; - u32 object_count; + /* accounting, useful for leak detection in tests */ + atomic_t object_count; }; struct drm_i915_error_state_buf { diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 8e6ff52..8020154 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -71,21 +71,6 @@ static inline void i915_gem_object_fence_lost(struct drm_i915_gem_object *obj) obj->fence_reg = I915_FENCE_REG_NONE; } -/* some bookkeeping */ -static void i915_gem_info_add_obj(struct drm_i915_private *dev_priv, - size_t size) -{ - dev_priv->mm.object_count++; - dev_priv->mm.object_memory += size; -} - -static void i915_gem_info_remove_obj(struct drm_i915_private *dev_priv, - size_t size) -{ - dev_priv->mm.object_count--; - dev_priv->mm.object_memory -= size; -} - static int i915_gem_wait_for_error(struct i915_gpu_error *error) { @@ -206,6 +191,7 @@ i915_gem_create(struct drm_file *file, uint32_t *handle_p) { struct drm_i915_gem_object *obj; + struct drm_i915_private *dev_priv = dev->dev_private; int ret; u32 handle; @@ -221,7 +207,7 @@ i915_gem_create(struct drm_file *file, ret = drm_gem_handle_create(file, &obj->base, &handle); if (ret) { drm_gem_object_release(&obj->base); - i915_gem_info_remove_obj(dev->dev_private, obj->base.size); + atomic_dec(&dev_priv->mm.object_count); i915_gem_object_free(obj); return ret; } @@ -3864,6 +3850,8 @@ unlock: void i915_gem_object_init(struct drm_i915_gem_object *obj, const struct drm_i915_gem_object_ops *ops) { + struct drm_i915_private *dev_priv = obj->base.dev->dev_private; + INIT_LIST_HEAD(&obj->mm_list); INIT_LIST_HEAD(&obj->global_list); INIT_LIST_HEAD(&obj->ring_list); @@ -3877,7 +3865,7 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj, /* Avoid an unnecessary call to unbind on the first bind. */ obj->map_and_fenceable = true; - i915_gem_info_add_obj(obj->base.dev->dev_private, obj->base.size); + atomic_inc(&dev_priv->mm.object_count); } static const struct drm_i915_gem_object_ops i915_gem_object_ops = { @@ -3983,7 +3971,7 @@ void i915_gem_free_object(struct drm_gem_object *gem_obj) drm_prime_gem_destroy(&obj->base, NULL); drm_gem_object_release(&obj->base); - i915_gem_info_remove_obj(dev_priv, obj->base.size); + atomic_dec(&dev_priv->mm.object_count); kfree(obj->bit_17); i915_gem_object_free(obj); -- 1.8.1.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx