From: Ben Widawsky <ben@bwidawsk.net>
To: Intel GFX <intel-gfx@lists.freedesktop.org>
Cc: Ben Widawsky <ben@bwidawsk.net>
Subject: [PATCH 25/34] drm/i915: Put the mm in the parent address space
Date: Sat, 25 May 2013 12:26:59 -0700 [thread overview]
Message-ID: <1369510028-3343-26-git-send-email-ben@bwidawsk.net> (raw)
In-Reply-To: <1369510028-3343-1-git-send-email-ben@bwidawsk.net>
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 <ben@bwidawsk.net>
---
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 | 20 ++++++++++++--------
drivers/gpu/drm/i915/i915_gem_stolen.c | 4 ++--
6 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 003e4e7..b36be25 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1361,7 +1361,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:
@@ -1778,7 +1778,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 a6ef1ae..d9c9b7b 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -401,6 +401,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) */
@@ -776,8 +777,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 0e7bfe3..5d476a7 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2995,7 +2995,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, max,
DRM_MM_CREATE_DEFAULT,
@@ -4077,7 +4077,7 @@ int i915_gem_init(struct drm_device *dev)
i915_gtt_vm->total, false);
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;
}
}
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 0b08a65..a161213 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -247,6 +247,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++)
@@ -275,8 +276,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,
@@ -371,6 +372,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;
}
@@ -643,13 +648,12 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,
BUG_ON(mappable_end > end);
if (!guard_page)
- drm_mm_init(&dev_priv->mm.gtt_space, start, end - start);
+ drm_mm_init(&i915_gtt_vm->mm, start, end - start);
else
- drm_mm_init(&dev_priv->mm.gtt_space, start,
- end - start - PAGE_SIZE); /* Guard page */
+ drm_mm_init(&i915_gtt_vm->mm, start, end - start - PAGE_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, gtt_list) {
@@ -657,7 +661,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);
@@ -668,7 +672,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 1b7c604..d398333 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -357,8 +357,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) {
--
1.8.2.3
next prev parent reply other threads:[~2013-05-25 19:24 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-25 19:26 [PATCH 00/34] PPGTT prep part 2 (and unmerged part 1) Ben Widawsky
2013-05-25 19:26 ` [PATCH 01/34] drm/i915: pre-fixes for checkpatch Ben Widawsky
2013-05-25 19:26 ` [PATCH 02/34] drm/i915: use mappable size for fb kickout Ben Widawsky
2013-05-25 19:26 ` [PATCH 03/34] drm/i915: use drm_mm_takedown Ben Widawsky
2013-05-25 19:26 ` [PATCH 04/34] drm/i915: context debug messages Ben Widawsky
2013-05-25 19:26 ` [PATCH 05/34] drm/i915: Call context fini at cleanup Ben Widawsky
2013-05-26 13:27 ` Daniel Vetter
2013-05-25 19:26 ` [PATCH 06/34] drm/i915: make PDE|PTE platform specific Ben Widawsky
2013-05-25 19:26 ` [PATCH 07/34] drm: Optionally create mm blocks from top-to-bottom Ben Widawsky
2013-05-25 19:26 ` [PATCH 08/34] drm/i915: Use drm_mm for PPGTT PDEs Ben Widawsky
2013-05-25 19:26 ` [PATCH 09/34] drm/i915: Use PDEs as the guard page Ben Widawsky
2013-05-25 19:26 ` [PATCH 10/34] drm/i915: cleanup context fini Ben Widawsky
2013-05-25 19:26 ` [PATCH 11/34] drm/i915: Do a fuller init after reset Ben Widawsky
2013-05-25 19:26 ` [PATCH 12/34] drm/i915: Split context enabling from init Ben Widawsky
2013-05-26 1:41 ` [PATCH v3 " Ben Widawsky
2013-05-25 19:26 ` [PATCH 13/34] drm/i915: destroy i915_gem_init_global_gtt Ben Widawsky
2013-05-25 19:26 ` [PATCH 14/34] drm/i915: Embed PPGTT into the context Ben Widawsky
2013-05-25 19:26 ` [PATCH 15/34] drm/i915: Tie context to PPGTT Ben Widawsky
2013-05-29 5:32 ` [PATCH 14.5/34] drm/i915: Unify PPGTT codepaths on gen6+ Ben Widawsky
2013-05-25 19:26 ` [PATCH 16/34] drm/i915: Really share scratch page Ben Widawsky
2013-05-25 19:26 ` [PATCH 17/34] drm/i915: Combine scratch members into a struct Ben Widawsky
2013-05-25 19:26 ` [PATCH 18/34] drm/i915: Drop dev from pte_encode Ben Widawsky
2013-05-25 20:14 ` Kenneth Graunke
2013-05-25 19:26 ` [PATCH 19/34] drm/i915: Use gtt shortform where possible Ben Widawsky
2013-05-25 19:26 ` [PATCH 20/34] drm/i915: Move fbc members out of line Ben Widawsky
2013-05-25 19:26 ` [PATCH 21/34] drm/i915: Move gtt and ppgtt under address space umbrella Ben Widawsky
2013-05-25 19:26 ` [PATCH 22/34] drm/i915: Move gtt_mtrr to i915_gtt Ben Widawsky
2013-05-25 19:26 ` [PATCH 23/34] drm/i915: Move stolen stuff " Ben Widawsky
2013-05-25 19:26 ` [PATCH 24/34] drm/i915: Move aliasing_ppgtt Ben Widawsky
2013-05-25 19:26 ` Ben Widawsky [this message]
2013-05-25 19:27 ` [PATCH 26/34] drm/i915: Move object tracking lists to new mm Ben Widawsky
2013-05-25 19:27 ` [PATCH 27/34] drm/i915: Create a global list of vms Ben Widawsky
2013-05-26 17:19 ` Ben Widawsky
2013-05-25 19:27 ` [PATCH 28/34] drm/i915: Start using vm lists Ben Widawsky
2013-05-25 19:27 ` [PATCH 29/34] drm/i915: Remove object's gtt_offset Ben Widawsky
2013-05-25 19:27 ` [PATCH 30/34] drm: pre allocate node for create_block Ben Widawsky
2013-05-25 19:27 ` [PATCH 31/34] drm/i915: Getter/setter for object attributes Ben Widawsky
2013-05-25 19:27 ` [PATCH 32/34] drm/i915: Create VMAs (part 1) Ben Widawsky
2013-05-25 19:27 ` [PATCH 33/34] drm/i915: Create VMAs (part 2) Ben Widawsky
2013-05-25 19:27 ` [PATCH 34/34] drm/i915: Create VMAs (part 3) Ben Widawsky
2013-05-27 7:31 ` Chris Wilson
2013-05-27 8:59 ` Daniel Vetter
2013-06-04 21:49 ` [PATCH 00/34] PPGTT prep part 2 (and unmerged part 1) Ben Widawsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1369510028-3343-26-git-send-email-ben@bwidawsk.net \
--to=ben@bwidawsk.net \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).