diff mbox series

drm/i915: Only discard simple GGTT vma

Message ID 20200611174704.18430-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series drm/i915: Only discard simple GGTT vma | expand

Commit Message

Chris Wilson June 11, 2020, 5:47 p.m. UTC
Be careful that we do not discard the irregular information used for
remapping the planes, and when discarding preserve the partial offset so
that the existing users can continue to interpret the old vma correctly.

An underlying issue here is that we opting to discard a vma while it is
in the process of being bound, because at the time it is not known
whether it will be bound suitable for our use. If we didn't discard, we
would then try to unbind it even if it were suitable after serialising
with the binder.

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/2012
Fixes: 9bdcaa5e3a2f ("drm/i915: Discard a misplaced GGTT vma")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 41553e9e57a9..cd5aeeb96ca4 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -938,9 +938,13 @@  discard_ggtt_vma(struct i915_vma *vma, const struct i915_ggtt_view *view)
 {
 	const struct i915_ggtt_view discard = {
 		.type = I915_GGTT_VIEW_PARTIAL,
+		.partial.offset = view->partial.offset,
 	};
 	struct drm_i915_gem_object *obj = vma->obj;
 
+	if (view->type > I915_GGTT_VIEW_PARTIAL)
+		return false;
+
 	spin_lock(&obj->vma.lock);
 	if (i915_vma_compare(vma, vma->vm, &discard)) {
 		struct rb_node *rb, **p;