From patchwork Thu Jun 27 23:30:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 2796231 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 447EC9F245 for ; Thu, 27 Jun 2013 23:41:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C433200EE for ; Thu, 27 Jun 2013 23:41:21 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F0D2E200ED for ; Thu, 27 Jun 2013 23:41:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C334EE64A4 for ; Thu, 27 Jun 2013 16:41:19 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from shiva.localdomain (unknown [209.20.75.48]) by gabe.freedesktop.org (Postfix) with ESMTP id BB051E5D11 for ; Thu, 27 Jun 2013 16:28:24 -0700 (PDT) Received: by shiva.localdomain (Postfix, from userid 99) id B70C28864E; Thu, 27 Jun 2013 23:28:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lundgren.jf.intel.com (jfdmzpr02-ext.jf.intel.com [134.134.137.71]) by shiva.localdomain (Postfix) with ESMTPSA id 8220D886A3; Thu, 27 Jun 2013 23:28:23 +0000 (UTC) From: Ben Widawsky To: Intel GFX Date: Thu, 27 Jun 2013 16:30:26 -0700 Message-Id: <1372375867-1003-26-git-send-email-ben@bwidawsk.net> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1372375867-1003-1-git-send-email-ben@bwidawsk.net> References: <1372375867-1003-1-git-send-email-ben@bwidawsk.net> Cc: Ben Widawsky Subject: [Intel-gfx] [PATCH 25/66] drm/i915: Put the mm in the parent address space X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 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-Virus-Scanned: ClamAV using ClamSMTP Every address space should support object allocation. It therefore makes sense to have the allocator be part of the "superclass" which GGTT and PPGTT will derive. Since our maximum address space size is only 2GB we're not yet able to avoid doing allocation/eviction; but we'd hope one day this becomes almost irrelvant. Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_dma.c | 4 ++-- drivers/gpu/drm/i915/i915_drv.h | 3 +-- drivers/gpu/drm/i915/i915_gem.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_evict.c | 10 +++++----- drivers/gpu/drm/i915/i915_gem_gtt.c | 18 +++++++++++------- drivers/gpu/drm/i915/i915_gem_stolen.c | 4 ++-- 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index ef00847..7d6d4b0 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1363,7 +1363,7 @@ cleanup_gem: i915_gem_cleanup_ringbuffer(dev); i915_gem_context_fini(dev); mutex_unlock(&dev->struct_mutex); - drm_mm_takedown(&dev_priv->mm.gtt_space); + drm_mm_takedown(&i915_gtt_vm->mm); cleanup_irq: drm_irq_uninstall(dev); cleanup_gem_stolen: @@ -1753,7 +1753,7 @@ int i915_driver_unload(struct drm_device *dev) i915_free_hws(dev); } - drm_mm_takedown(&dev_priv->mm.gtt_space); + drm_mm_takedown(&i915_gtt_vm->mm); if (dev_priv->regs != NULL) pci_iounmap(dev->pdev, dev_priv->regs); diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 0fa7a21..e65cf57 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -443,6 +443,7 @@ enum i915_cache_level { typedef uint32_t gen6_gtt_pte_t; struct i915_address_space { + struct drm_mm mm; struct drm_device *dev; unsigned long start; /* Start offset always 0 for dri2 */ size_t total; /* size addr space maps (ex. 2GB for ggtt) */ @@ -834,8 +835,6 @@ struct intel_l3_parity { }; struct i915_gem_mm { - /** 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 bound_list; diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index eb78c5b..608b6b5 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -3131,7 +3131,7 @@ i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj, } search_free: - ret = drm_mm_insert_node_in_range_generic(&dev_priv->mm.gtt_space, node, + ret = drm_mm_insert_node_in_range_generic(&i915_gtt_vm->mm, node, size, alignment, obj->cache_level, 0, gtt_max, DRM_MM_CREATE_DEFAULT, @@ -4229,7 +4229,7 @@ int i915_gem_init(struct drm_device *dev) i915_gtt_vm->total, 0); i915_gem_context_init(dev); if (dev_priv->hw_contexts_disabled) { - drm_mm_takedown(&dev_priv->mm.gtt_space); + drm_mm_takedown(&i915_gtt_vm->mm); goto ggtt_only; } } else diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c index c86d5d9..6e620f86 100644 --- a/drivers/gpu/drm/i915/i915_gem_evict.c +++ b/drivers/gpu/drm/i915/i915_gem_evict.c @@ -78,12 +78,12 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, INIT_LIST_HEAD(&unwind_list); if (mappable) - drm_mm_init_scan_with_range(&dev_priv->mm.gtt_space, - min_size, alignment, cache_level, - 0, dev_priv->gtt.mappable_end); + drm_mm_init_scan_with_range(&i915_gtt_vm->mm, min_size, + alignment, cache_level, 0, + dev_priv->gtt.mappable_end); else - drm_mm_init_scan(&dev_priv->mm.gtt_space, - min_size, alignment, cache_level); + drm_mm_init_scan(&i915_gtt_vm->mm, min_size, alignment, + cache_level); /* First see if there is a large enough contiguous idle region... */ list_for_each_entry(obj, &dev_priv->mm.inactive_list, mm_list) { diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 18820cb..4131c22 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -249,6 +249,7 @@ static void gen6_ppgtt_cleanup(struct i915_hw_ppgtt *ppgtt) int i; drm_mm_remove_node(&ppgtt->node); + drm_mm_takedown(&ppgtt->base.mm); if (ppgtt->pt_dma_addr) { for (i = 0; i < ppgtt->num_pd_entries; i++) @@ -277,8 +278,8 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) * multiplied by page size. We allocate at the top of the GTT to avoid * fragmentation. */ - BUG_ON(!drm_mm_initialized(&dev_priv->mm.gtt_space)); - ret = drm_mm_insert_node_in_range_generic(&dev_priv->mm.gtt_space, + BUG_ON(!drm_mm_initialized(&i915_gtt_vm->mm)); + ret = drm_mm_insert_node_in_range_generic(&i915_gtt_vm->mm, &ppgtt->node, GEN6_PD_SIZE, GEN6_PD_ALIGN, 0, dev_priv->gtt.mappable_end, @@ -377,6 +378,10 @@ int i915_gem_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt) else BUG(); + if (!ret) + drm_mm_init(&ppgtt->base.mm, ppgtt->base.start, + ppgtt->base.total); + return ret; } @@ -668,10 +673,9 @@ void i915_gem_setup_global_gtt(struct drm_device *dev, if (WARN_ON(guard_size & ~PAGE_MASK)) guard_size = round_up(guard_size, PAGE_SIZE); - /* Subtract the guard page ... */ - drm_mm_init(&dev_priv->mm.gtt_space, start, end - start - guard_size); + drm_mm_init(&i915_gtt_vm->mm, start, end - start - guard_size); if (!HAS_LLC(dev)) - dev_priv->mm.gtt_space.color_adjust = i915_gtt_color_adjust; + i915_gtt_vm->mm.color_adjust = i915_gtt_color_adjust; /* Mark any preallocated objects as occupied */ list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { @@ -679,7 +683,7 @@ void i915_gem_setup_global_gtt(struct drm_device *dev, obj->gtt_offset, obj->base.size); BUG_ON(obj->gtt_space != I915_GTT_RESERVED); - obj->gtt_space = drm_mm_create_block(&dev_priv->mm.gtt_space, + obj->gtt_space = drm_mm_create_block(&i915_gtt_vm->mm, obj->gtt_offset, obj->base.size, false); @@ -690,7 +694,7 @@ void i915_gem_setup_global_gtt(struct drm_device *dev, i915_gtt_vm->total = end - start; /* Clear any non-preallocated blocks */ - drm_mm_for_each_hole(entry, &dev_priv->mm.gtt_space, + drm_mm_for_each_hole(entry, &i915_gtt_vm->mm, hole_start, hole_end) { DRM_DEBUG_KMS("clearing unused GTT space: [%lx, %lx]\n", hole_start, hole_end); diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c index fd812d5..49e8be7 100644 --- a/drivers/gpu/drm/i915/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c @@ -368,8 +368,8 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, * setting up the GTT space. The actual reservation will occur * later. */ - if (drm_mm_initialized(&dev_priv->mm.gtt_space)) { - obj->gtt_space = drm_mm_create_block(&dev_priv->mm.gtt_space, + if (drm_mm_initialized(&i915_gtt_vm->mm)) { + obj->gtt_space = drm_mm_create_block(&i915_gtt_vm->mm, gtt_offset, size, false); if (obj->gtt_space == NULL) {