]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/i915: Mark all non-vma being inserted into the address spaces
authorChris Wilson <chris@chris-wilson.co.uk>
Mon, 5 Dec 2016 14:29:36 +0000 (14:29 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 5 Dec 2016 20:49:17 +0000 (20:49 +0000)
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
(I915_COLOR_UNEVICTABLE).

v2...v200: New name for -1.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161205142941.21965-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/gvt/aperture_gm.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_execbuffer.c
drivers/gpu/drm/i915/i915_gem_gtt.c

index 0d41ebc4aea63a6a7e101b5439739a8faad989fd..7d33b607bc89dc22ee5f530b040af69e347414d5 100644 (file)
@@ -73,12 +73,15 @@ 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,
+                                                 I915_COLOR_UNEVICTABLE,
                                                  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,
+                                              I915_COLOR_UNEVICTABLE,
+                                              start, end, 0);
                if (ret == 0 && ++retried < 3)
                        goto search_again;
 
index 74658acb307b83d9632fb1ae50d7f8ce5150ee9b..a0c67916ec20634816c6ecf0640605a306dee5a6 100644 (file)
@@ -934,6 +934,8 @@ enum i915_cache_level {
        I915_CACHE_WT, /* hsw:gt3e WriteThrough for scanouts */
 };
 
+#define I915_COLOR_UNEVICTABLE (-1) /* a non-vma sharing the address space */
+
 #define DEFAULT_CONTEXT_HANDLE 0
 
 /**
index 59065ae0b1536ec88159828ae80d2e9e5ab9e782..ca0bb837a57f8557dc440a8cc67bd19c8e32b3ee 100644 (file)
@@ -70,7 +70,8 @@ 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,
+                                                  I915_COLOR_UNEVICTABLE,
                                                   0, ggtt->mappable_end,
                                                   DRM_MM_SEARCH_DEFAULT,
                                                   DRM_MM_CREATE_DEFAULT);
index 985142cc6cc96c41a9ceb98b45e5583efeec4de3..5f164adc837cd11937e12003ae931405b6c787d7 100644 (file)
@@ -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, I915_COLOR_UNEVICTABLE,
                                 0, ggtt->mappable_end,
                                 DRM_MM_SEARCH_DEFAULT,
                                 DRM_MM_CREATE_DEFAULT);
index c0042471ad876a47dfaf80747f8e1a968cdecc0a..88ddca24afdb92b1880e32d67ed62e8cfb68a5eb 100644 (file)
@@ -2071,15 +2071,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,
+                                                 I915_COLOR_UNEVICTABLE,
                                                  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,
+                                              I915_COLOR_UNEVICTABLE,
                                               0, ggtt->base.total,
                                               0);
                if (ret)
@@ -2755,7 +2755,8 @@ 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,
+                                                 I915_COLOR_UNEVICTABLE,
                                                  0, ggtt->mappable_end,
                                                  0, 0);
        if (ret)