From patchwork Fri Apr 15 18:57:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 711141 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3FI5WVW004733 for ; Fri, 15 Apr 2011 18:05:53 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E01C49E848 for ; Fri, 15 Apr 2011 11:05:32 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wy0-f177.google.com (mail-wy0-f177.google.com [74.125.82.177]) by gabe.freedesktop.org (Postfix) with ESMTP id AF2529E7BA for ; Fri, 15 Apr 2011 11:03:24 -0700 (PDT) Received: by mail-wy0-f177.google.com with SMTP id 28so3140772wyb.36 for ; Fri, 15 Apr 2011 11:03:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=jiUpwGId6uv0NYKCiJO2pGERd6Q6Jq+SKEGu4/bElnk=; b=f2dAjM20+Juucg+G4bp8F7As7u1Bcq+k7q8jqTiZXd7Pxl/kvJi893XMmdeBRirjvz +OkLyzZ1bCvFdu47CGYdvVzeuIzecAOEltgr8f2Q4ojDGztUW37MLzEfKZtg9HvIndlV EY7KDnWP7Lk4kaDK+Kyu4akjUmLbZMOnbAA/k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=gEYzBx+/BsduGeqWIObgMRY3IX7VQfCVT8VRJiAhJ1STHHaCNaGdr8oYbh2hzx2UDM rhn4LN15Zqhcihdyh/hI9T7svYEDs4Gn0dIVB5zQpPVlakQAtKm1ITIOZV3LKFDBzOYo 5wzaOu52iL+9rMU4O+bwdHgcl7BbvXuaXBmnA= Received: by 10.216.241.66 with SMTP id f44mr34553wer.37.1302890604201; Fri, 15 Apr 2011 11:03:24 -0700 (PDT) Received: from localhost.localdomain (cable-static-216-94.intergga.ch [87.102.216.94]) by mx.google.com with ESMTPS id s40sm1433457weq.4.2011.04.15.11.03.22 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Apr 2011 11:03:23 -0700 (PDT) From: Daniel Vetter To: intel-gfx@lists.freedesktop.org Date: Fri, 15 Apr 2011 20:57:37 +0200 Message-Id: <1302893858-8234-4-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1302893858-8234-1-git-send-email-daniel.vetter@ffwll.ch> References: <1302893858-8234-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 3/4] drm/i915: kill gtt_list X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 15 Apr 2011 18:05:53 +0000 (UTC) Use the list iterator provided by drm_mm instead. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_debugfs.c | 29 ++++++++++++++++++++--------- drivers/gpu/drm/i915/i915_drv.h | 4 ---- drivers/gpu/drm/i915/i915_gem.c | 4 ---- drivers/gpu/drm/i915/i915_gem_gtt.c | 4 +++- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 1a6783f..6148bdf 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -208,14 +208,18 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data) return 0; } +#define count_object(obj) do { \ + size += obj->gtt_space.size; \ + ++count; \ + if (obj->map_and_fenceable) { \ + mappable_size += obj->gtt_space.size; \ + ++mappable_count; \ + } \ +} while(0) + #define count_objects(list, member) do { \ list_for_each_entry(obj, list, member) { \ - size += obj->gtt_space.size; \ - ++count; \ - if (obj->map_and_fenceable) { \ - mappable_size += obj->gtt_space.size; \ - ++mappable_count; \ - } \ + count_object(obj); \ } \ } while(0) @@ -226,6 +230,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data) struct drm_i915_private *dev_priv = dev->dev_private; u32 count, mappable_count; size_t size, mappable_size; + struct drm_mm_node *mm_node; struct drm_i915_gem_object *obj; int ret; @@ -238,7 +243,10 @@ static int i915_gem_object_info(struct seq_file *m, void* data) dev_priv->mm.object_memory); size = count = mappable_size = mappable_count = 0; - count_objects(&dev_priv->mm.gtt_list, gtt_list); + drm_mm_for_each_node(mm_node, &dev_priv->mm.gtt_space) { + obj = container_of(mm_node, struct drm_i915_gem_object, gtt_space); + count_object(obj); + } seq_printf(m, "%u [%u] objects, %zu [%zu] bytes in gtt\n", count, mappable_count, size, mappable_size); @@ -264,7 +272,8 @@ static int i915_gem_object_info(struct seq_file *m, void* data) count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count = 0; - list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) { + drm_mm_for_each_node(mm_node, &dev_priv->mm.gtt_space) { + obj = container_of(mm_node, struct drm_i915_gem_object, gtt_space); if (obj->fault_mappable) { size += obj->gtt_space.size; ++count; @@ -292,6 +301,7 @@ static int i915_gem_gtt_info(struct seq_file *m, void* data) struct drm_info_node *node = (struct drm_info_node *) m->private; struct drm_device *dev = node->minor->dev; struct drm_i915_private *dev_priv = dev->dev_private; + struct drm_mm_node *mm_node; struct drm_i915_gem_object *obj; size_t total_obj_size, total_gtt_size; int count, ret; @@ -301,7 +311,8 @@ static int i915_gem_gtt_info(struct seq_file *m, void* data) return ret; total_obj_size = total_gtt_size = count = 0; - list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) { + drm_mm_for_each_node(mm_node, &dev_priv->mm.gtt_space) { + obj = container_of(mm_node, struct drm_i915_gem_object, gtt_space); seq_printf(m, " "); describe_obj(m, obj); seq_printf(m, "\n"); diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 2301a6a..5186429 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -542,9 +542,6 @@ typedef struct drm_i915_private { struct drm_mm stolen; /** 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; /** Usable portion of the GTT for GEM */ unsigned long gtt_start; @@ -722,7 +719,6 @@ 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 d08ad01..d9984e3 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2239,7 +2239,6 @@ i915_gem_object_unbind(struct drm_i915_gem_object *obj) i915_gem_gtt_unbind_object(obj); i915_gem_object_put_pages_gtt(obj); - list_del_init(&obj->gtt_list); list_del_init(&obj->mm_list); /* Avoid an unnecessary call to unbind on rebind. */ obj->map_and_fenceable = true; @@ -2870,7 +2869,6 @@ i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj, goto search_free; } - list_add_tail(&obj->gtt_list, &dev_priv->mm.gtt_list); list_add_tail(&obj->mm_list, &dev_priv->mm.inactive_list); /* Assert that the object is not currently in any GPU domain. As it @@ -3705,7 +3703,6 @@ struct drm_i915_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->exec_list); INIT_LIST_HEAD(&obj->gpu_write_list); @@ -3946,7 +3943,6 @@ 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); for (i = 0; i < I915_NUM_RINGS; i++) init_ring_lists(&dev_priv->ring[i]); for (i = 0; i < 16; i++) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index bca5a97..bb627bf 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -53,12 +53,14 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_gem_object *obj; + struct drm_mm_node *node; /* First fill our portion of the GTT with scratch pages */ intel_gtt_clear_range(dev_priv->mm.gtt_start / PAGE_SIZE, (dev_priv->mm.gtt_end - dev_priv->mm.gtt_start) / PAGE_SIZE); - list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) { + drm_mm_for_each_node(node, &dev_priv->mm.gtt_space) { + obj = container_of(node, struct drm_i915_gem_object, gtt_space); i915_gem_clflush_object(obj); i915_gem_gtt_rebind_object(obj, obj->cache_level); }