From 217beb9c8de01417ac6219b54bd25046da6d4c7a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 13 Jun 2008 15:43:02 -0700 Subject: [intel-gem] add gtt and pin counts to /proc/dri/*/gem_objects Not quite portable, but these are useful for intel. Some more general mechanism could be done... --- linux-core/i915_gem.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'linux-core/i915_gem.c') 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 -- cgit v1.2.3