From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v2 3/4] drm/i915: Mark all non-vma being inserted into the address spaces
Date: Thu, 17 Nov 2016 12:08:43 +0000 [thread overview]
Message-ID: <20161117120844.27340-3-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20161117120844.27340-1-chris@chris-wilson.co.uk>
We need to distinguish between full i915_vma structs and simple
drm_mm_nodes when considering eviction (i.e. we must be careful not to
treat a mere drm_mm_node as a much larger i915_vma causing memory
corruption, if we are lucky). To do this, color these not-a-vma with -1
(UNCOLORED).
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/gpu/drm/i915/gvt/aperture_gm.c | 5 +++--
drivers/gpu/drm/i915/i915_drv.h | 1 +
drivers/gpu/drm/i915/i915_gem.c | 2 +-
drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +-
drivers/gpu/drm/i915/i915_gem_gtt.c | 10 +++++-----
5 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/aperture_gm.c b/drivers/gpu/drm/i915/gvt/aperture_gm.c
index 0d41ebc4aea6..e7b8674dea76 100644
--- a/drivers/gpu/drm/i915/gvt/aperture_gm.c
+++ b/drivers/gpu/drm/i915/gvt/aperture_gm.c
@@ -73,12 +73,13 @@ static int alloc_gm(struct intel_vgpu *vgpu, bool high_gm)
mutex_lock(&dev_priv->drm.struct_mutex);
search_again:
ret = drm_mm_insert_node_in_range_generic(&dev_priv->ggtt.base.mm,
- node, size, 4096, 0,
+ node, size, 4096, UNCOLORED,
start, end, search_flag,
alloc_flag);
if (ret) {
ret = i915_gem_evict_something(&dev_priv->ggtt.base,
- size, 4096, 0, start, end, 0);
+ size, 4096, UNCOLORED,
+ start, end, 0);
if (ret == 0 && ++retried < 3)
goto search_again;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 5192206c62e2..32a77ee489c8 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -895,6 +895,7 @@ enum i915_cache_level {
the CPU, but L3 is only visible to the GPU. */
I915_CACHE_WT, /* hsw:gt3e WriteThrough for scanouts */
};
+#define UNCOLORED (-1)
struct i915_ctx_hang_stats {
/* This context had batch pending when hang was declared */
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 3fb5e66e4d65..ca89751c0c22 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -69,7 +69,7 @@ insert_mappable_node(struct i915_ggtt *ggtt,
{
memset(node, 0, sizeof(*node));
return drm_mm_insert_node_in_range_generic(&ggtt->base.mm, node,
- size, 0, -1,
+ size, 0, UNCOLORED,
0, ggtt->mappable_end,
DRM_MM_SEARCH_DEFAULT,
DRM_MM_CREATE_DEFAULT);
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index e804cb2fa57e..109f99f22e7c 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -437,7 +437,7 @@ static void *reloc_iomap(struct drm_i915_gem_object *obj,
memset(&cache->node, 0, sizeof(cache->node));
ret = drm_mm_insert_node_in_range_generic
(&ggtt->base.mm, &cache->node,
- 4096, 0, 0,
+ 4096, 0, UNCOLORED,
0, ggtt->mappable_end,
DRM_MM_SEARCH_DEFAULT,
DRM_MM_CREATE_DEFAULT);
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 01f238adfb67..65d1845d2bd8 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -2072,15 +2072,15 @@ static int gen6_ppgtt_allocate_page_directories(struct i915_hw_ppgtt *ppgtt)
return ret;
alloc:
- ret = drm_mm_insert_node_in_range_generic(&ggtt->base.mm,
- &ppgtt->node, GEN6_PD_SIZE,
- GEN6_PD_ALIGN, 0,
+ ret = drm_mm_insert_node_in_range_generic(&ggtt->base.mm, &ppgtt->node,
+ GEN6_PD_SIZE, GEN6_PD_ALIGN,
+ UNCOLORED,
0, ggtt->base.total,
DRM_MM_TOPDOWN);
if (ret == -ENOSPC && !retried) {
ret = i915_gem_evict_something(&ggtt->base,
GEN6_PD_SIZE, GEN6_PD_ALIGN,
- I915_CACHE_NONE,
+ UNCOLORED,
0, ggtt->base.total,
0);
if (ret)
@@ -2757,7 +2757,7 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv)
/* Reserve a mappable slot for our lockless error capture */
ret = drm_mm_insert_node_in_range_generic(&ggtt->base.mm,
&ggtt->error_capture,
- 4096, 0, -1,
+ 4096, 0, UNCOLORED,
0, ggtt->mappable_end,
0, 0);
if (ret)
--
2.10.2
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-11-17 12:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-17 12:08 [PATCH v2 1/4] drm: Define drm_mm_for_each_node_in_range() Chris Wilson
2016-11-17 12:08 ` [PATCH v2 2/4] drm: Check against color expansion in drm_mm_reserve_node() Chris Wilson
2016-11-17 13:20 ` Joonas Lahtinen
2016-11-17 12:08 ` Chris Wilson [this message]
2016-11-17 13:31 ` [PATCH v2 3/4] drm/i915: Mark all non-vma being inserted into the address spaces Joonas Lahtinen
2016-11-17 14:12 ` Chris Wilson
2016-11-18 9:05 ` Chris Wilson
2016-11-18 9:55 ` Joonas Lahtinen
2016-11-17 12:08 ` [PATCH v2 4/4] drm/i915: Fix i915_gem_evict_for_vma (soft-pinning) Chris Wilson
2016-11-18 9:18 ` Joonas Lahtinen
2016-11-18 10:14 ` Chris Wilson
2016-11-18 11:31 ` Joonas Lahtinen
2016-11-18 12:06 ` Chris Wilson
2016-11-18 12:14 ` Chris Wilson
2016-11-17 12:46 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/4] drm: Define drm_mm_for_each_node_in_range() Patchwork
2016-11-17 13:56 ` [PATCH v2 1/4] " Joonas Lahtinen
2016-11-17 14:49 ` [PATCH] " Chris Wilson
2016-11-18 8:43 ` Joonas Lahtinen
2016-11-17 16:53 ` ✗ Fi.CI.BAT: failure for series starting with drm: Define drm_mm_for_each_node_in_range() (rev2) Patchwork
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=20161117120844.27340-3-chris@chris-wilson.co.uk \
--to=chris@chris-wilson.co.uk \
--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).