Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d36caeea authored by Chris Wilson's avatar Chris Wilson
Browse files

drm/i915: Assert vma->flags are updated correctly during binding



As we bind, and unbind on error, we want to be sure that the vma->flags
are updated to reflect the binding state so that on the next invocation
all is well.

v2: Take two.
v3: Take three; vma-misplaced is checking map-and-fenceable so keep it
last!

Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Matthew Auld <matthew.william.auld@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171105124550.32715-1-chris@chris-wilson.co.uk


Reviewed-by: default avatarMatthew Auld <matthew.william.auld@gmail.com>
parent 136109c6
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -633,15 +633,17 @@ int __i915_vma_do_pin(struct i915_vma *vma,
		if (ret)
		if (ret)
			goto err_unpin;
			goto err_unpin;
	}
	}
	GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));


	ret = i915_vma_bind(vma, vma->obj->cache_level, flags);
	ret = i915_vma_bind(vma, vma->obj->cache_level, flags);
	if (ret)
	if (ret)
		goto err_remove;
		goto err_remove;


	GEM_BUG_ON((vma->flags & I915_VMA_BIND_MASK) == 0);

	if ((bound ^ vma->flags) & I915_VMA_GLOBAL_BIND)
	if ((bound ^ vma->flags) & I915_VMA_GLOBAL_BIND)
		__i915_vma_set_map_and_fenceable(vma);
		__i915_vma_set_map_and_fenceable(vma);


	GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
	GEM_BUG_ON(i915_vma_misplaced(vma, size, alignment, flags));
	GEM_BUG_ON(i915_vma_misplaced(vma, size, alignment, flags));
	return 0;
	return 0;


@@ -649,6 +651,7 @@ int __i915_vma_do_pin(struct i915_vma *vma,
	if ((bound & I915_VMA_BIND_MASK) == 0) {
	if ((bound & I915_VMA_BIND_MASK) == 0) {
		i915_vma_remove(vma);
		i915_vma_remove(vma);
		GEM_BUG_ON(vma->pages);
		GEM_BUG_ON(vma->pages);
		GEM_BUG_ON(vma->flags & I915_VMA_BIND_MASK);
	}
	}
err_unpin:
err_unpin:
	__i915_vma_unpin(vma);
	__i915_vma_unpin(vma);