diff options
Diffstat (limited to 'linux-core')
-rw-r--r-- | linux-core/drmP.h | 5 | ||||
-rw-r--r-- | linux-core/drm_gem.c | 7 | ||||
-rw-r--r-- | linux-core/drm_proc.c | 4 | ||||
-rw-r--r-- | linux-core/i915_gem.c | 26 |
4 files changed, 35 insertions, 7 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 02826c8d..ba25f3a8 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -965,6 +965,11 @@ struct drm_device { spinlock_t object_name_lock; struct idr object_name_idr; atomic_t object_count; + atomic_t object_memory; + atomic_t pin_count; + atomic_t pin_memory; + atomic_t gtt_count; + atomic_t gtt_memory; uint32_t invalidate_domains; /* domains pending invalidation */ uint32_t flush_domains; /* domains pending flush */ /*@} */ diff --git a/linux-core/drm_gem.c b/linux-core/drm_gem.c index 47b55434..434155b3 100644 --- a/linux-core/drm_gem.c +++ b/linux-core/drm_gem.c @@ -74,6 +74,11 @@ drm_gem_init(struct drm_device *dev) spin_lock_init(&dev->object_name_lock); idr_init(&dev->object_name_idr); atomic_set(&dev->object_count, 0); + atomic_set(&dev->object_memory, 0); + atomic_set(&dev->pin_count, 0); + atomic_set(&dev->pin_memory, 0); + atomic_set(&dev->gtt_count, 0); + atomic_set(&dev->gtt_memory, 0); return 0; } @@ -106,6 +111,7 @@ drm_gem_object_alloc(struct drm_device *dev, size_t size) return NULL; } atomic_inc(&dev->object_count); + atomic_add(obj->size, &dev->object_memory); return obj; } EXPORT_SYMBOL(drm_gem_object_alloc); @@ -376,6 +382,7 @@ drm_gem_object_free(struct kref *kref) fput(obj->filp); atomic_dec(&dev->object_count); + atomic_sub(obj->size, &dev->object_memory); kfree(obj); } EXPORT_SYMBOL(drm_gem_object_free); diff --git a/linux-core/drm_proc.c b/linux-core/drm_proc.c index b1b976b2..71d55274 100644 --- a/linux-core/drm_proc.c +++ b/linux-core/drm_proc.c @@ -655,6 +655,10 @@ static int drm_gem_object_info(char *buf, char **start, off_t offset, *start = &buf[offset]; *eof = 0; DRM_PROC_PRINT ("%d objects\n", atomic_read (&dev->object_count)); + DRM_PROC_PRINT ("%d object bytes\n", atomic_read (&dev->object_memory)); + DRM_PROC_PRINT ("%d pinned\n", atomic_read (&dev->pin_count)); + DRM_PROC_PRINT ("%d pin bytes\n", atomic_read (&dev->pin_memory)); + DRM_PROC_PRINT ("%d gtt bytes\n", atomic_read (&dev->gtt_memory)); if (len > request + offset) return request; *eof = 1; diff --git a/linux-core/i915_gem.c b/linux-core/i915_gem.c index 210ae9d9..cb5d663e 100644 --- a/linux-core/i915_gem.c +++ b/linux-core/i915_gem.c @@ -677,6 +677,7 @@ i915_gem_object_wait_rendering(struct drm_gem_object *obj) static int i915_gem_object_unbind(struct drm_gem_object *obj) { + struct drm_device *dev = obj->dev; struct drm_i915_gem_object *obj_priv = obj->driver_private; int ret = 0; @@ -706,6 +707,9 @@ i915_gem_object_unbind(struct drm_gem_object *obj) i915_gem_object_free_page_list(obj); + atomic_dec(&dev->gtt_count); + atomic_sub(obj->size, &dev->gtt_memory); + drm_memrange_put_block(obj_priv->gtt_space); obj_priv->gtt_space = NULL; @@ -995,6 +999,8 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment) obj_priv->gtt_space = NULL; return -ENOMEM; } + atomic_inc(&dev->gtt_count); + atomic_add(obj->size, &dev->gtt_memory); /* Assert that the object is not currently in any GPU domain. As it * wasn't in the GTT, there shouldn't be any way it could have been in @@ -1764,6 +1770,7 @@ pre_mutex_err: int i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment) { + struct drm_device *dev = obj->dev; struct drm_i915_gem_object *obj_priv = obj->driver_private; int ret; @@ -1779,10 +1786,12 @@ i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment) /* If the object is not active and not pending a flush, * remove it from the inactive list */ - if (obj_priv->pin_count == 1 && - !obj_priv->active && - obj->write_domain == 0) - list_del_init(&obj_priv->list); + if (obj_priv->pin_count == 1) { + atomic_inc(&dev->pin_count); + atomic_add(obj->size, &dev->pin_memory); + if (!obj_priv->active && obj->write_domain == 0) + list_del_init(&obj_priv->list); + } return 0; } @@ -1802,9 +1811,12 @@ i915_gem_object_unpin(struct drm_gem_object *obj) * neither active nor being flushed, then stick it on * the inactive list */ - if (obj_priv->pin_count == 0 && - !obj_priv->active && obj->write_domain == 0) - list_move_tail(&obj_priv->list, &dev_priv->mm.inactive_list); + if (obj_priv->pin_count == 0) { + if (!obj_priv->active && obj->write_domain == 0) + list_move_tail(&obj_priv->list, &dev_priv->mm.inactive_list); + atomic_dec(&dev->pin_count); + atomic_sub(obj->size, &dev->pin_memory); + } } int |