aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2015-11-20 09:16:39 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-12-17 10:59:24 -0500
commitd0710abbcd88b1ff17760e97d74a673e67b49ea1 (patch)
tree437df51effdaec0b9f164f045c5de5b3c043e2f7 /drivers/gpu/drm/i915
parent71a199bacb398ee54eeac001699257dda083a455 (diff)
drm/i915: Set the map-and-fenceable flag for preallocated objects
As we mark the preallocated objects as bound, we should also flag them correctly as being map-and-fenceable (if appropriate!) so that later users do not get confused and try and rebind the pinned vma in order to get a map-and-fenceable binding. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: "Goel, Akash" <akash.goel@intel.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Jesse Barnes <jbarnes@virtuousgeek.org> Cc: drm-intel-fixes@lists.freedesktop.org Link: http://patchwork.freedesktop.org/patch/msgid/1448029000-10616-1-git-send-email-chris@chris-wilson.co.uk Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915')
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h1
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c43
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c1
-rw-r--r--drivers/gpu/drm/i915/i915_gem_stolen.c1
4 files changed, 27 insertions, 19 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 1943b8f0e684..1d28d90ed901 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2894,6 +2894,7 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
2894 2894
2895int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level, 2895int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
2896 u32 flags); 2896 u32 flags);
2897void __i915_vma_set_map_and_fenceable(struct i915_vma *vma);
2897int __must_check i915_vma_unbind(struct i915_vma *vma); 2898int __must_check i915_vma_unbind(struct i915_vma *vma);
2898/* 2899/*
2899 * BEWARE: Do not use the function below unless you can _absolutely_ 2900 * BEWARE: Do not use the function below unless you can _absolutely_
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index e143d6ce8949..adc339a5ab09 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4110,6 +4110,29 @@ i915_vma_misplaced(struct i915_vma *vma, uint32_t alignment, uint64_t flags)
4110 return false; 4110 return false;
4111} 4111}
4112 4112
4113void __i915_vma_set_map_and_fenceable(struct i915_vma *vma)
4114{
4115 struct drm_i915_gem_object *obj = vma->obj;
4116 bool mappable, fenceable;
4117 u32 fence_size, fence_alignment;
4118
4119 fence_size = i915_gem_get_gtt_size(obj->base.dev,
4120 obj->base.size,
4121 obj->tiling_mode);
4122 fence_alignment = i915_gem_get_gtt_alignment(obj->base.dev,
4123 obj->base.size,
4124 obj->tiling_mode,
4125 true);
4126
4127 fenceable = (vma->node.size == fence_size &&
4128 (vma->node.start & (fence_alignment - 1)) == 0);
4129
4130 mappable = (vma->node.start + fence_size <=
4131 to_i915(obj->base.dev)->gtt.mappable_end);
4132
4133 obj->map_and_fenceable = mappable && fenceable;
4134}
4135
4113static int 4136static int
4114i915_gem_object_do_pin(struct drm_i915_gem_object *obj, 4137i915_gem_object_do_pin(struct drm_i915_gem_object *obj,
4115 struct i915_address_space *vm, 4138 struct i915_address_space *vm,
@@ -4177,25 +4200,7 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj,
4177 4200
4178 if (ggtt_view && ggtt_view->type == I915_GGTT_VIEW_NORMAL && 4201 if (ggtt_view && ggtt_view->type == I915_GGTT_VIEW_NORMAL &&
4179 (bound ^ vma->bound) & GLOBAL_BIND) { 4202 (bound ^ vma->bound) & GLOBAL_BIND) {
4180 bool mappable, fenceable; 4203 __i915_vma_set_map_and_fenceable(vma);
4181 u32 fence_size, fence_alignment;
4182
4183 fence_size = i915_gem_get_gtt_size(obj->base.dev,
4184 obj->base.size,
4185 obj->tiling_mode);
4186 fence_alignment = i915_gem_get_gtt_alignment(obj->base.dev,
4187 obj->base.size,
4188 obj->tiling_mode,
4189 true);
4190
4191 fenceable = (vma->node.size == fence_size &&
4192 (vma->node.start & (fence_alignment - 1)) == 0);
4193
4194 mappable = (vma->node.start + fence_size <=
4195 dev_priv->gtt.mappable_end);
4196
4197 obj->map_and_fenceable = mappable && fenceable;
4198
4199 WARN_ON(flags & PIN_MAPPABLE && !obj->map_and_fenceable); 4204 WARN_ON(flags & PIN_MAPPABLE && !obj->map_and_fenceable);
4200 } 4205 }
4201 4206
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index c14b8f8d0c87..52bc6c3dfe04 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -2728,6 +2728,7 @@ static int i915_gem_setup_global_gtt(struct drm_device *dev,
2728 return ret; 2728 return ret;
2729 } 2729 }
2730 vma->bound |= GLOBAL_BIND; 2730 vma->bound |= GLOBAL_BIND;
2731 __i915_vma_set_map_and_fenceable(vma);
2731 list_add_tail(&vma->mm_list, &ggtt_vm->inactive_list); 2732 list_add_tail(&vma->mm_list, &ggtt_vm->inactive_list);
2732 } 2733 }
2733 2734
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
index 598ed2facf85..3476877fc0d6 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -688,6 +688,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
688 } 688 }
689 689
690 vma->bound |= GLOBAL_BIND; 690 vma->bound |= GLOBAL_BIND;
691 __i915_vma_set_map_and_fenceable(vma);
691 list_add_tail(&vma->mm_list, &ggtt->inactive_list); 692 list_add_tail(&vma->mm_list, &ggtt->inactive_list);
692 } 693 }
693 694