| From 6db784ea1b660252a389617787720b851f047f97 Mon Sep 17 00:00:00 2001 |
| From: Ben Widawsky <benjamin.widawsky@intel.com> |
| Date: Tue, 13 Aug 2013 18:09:06 -0700 |
| Subject: drm/i915: Remove node only when allocated |
| |
| VMAs can be created and not bound. One may think of it as lazy cleanup, |
| and safely gloss over the conditions which manufacture it. In either |
| case, when the object backing the i915 vma is destroyed, we must cleanup |
| the vma without stumbling into a bunch of pitfalls that assume the vma |
| is bound. |
| |
| NOTE: I was pretty certain the above condition could only happen when we |
| introduced the use of VMAs being looked up at execbuf, and already |
| existing. Paulo has hit this though, so I must be missing something. As |
| I believe the patch is correct anyway, therefore I won't scratch my head |
| too hard. |
| |
| v2: use goto destroy as a compromise (Chris) |
| |
| Cc: Chris Wilson <chris@chris-wilson.co.uk> |
| Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> |
| Signed-off-by: Ben Widawsky <ben@bwidawsk.net> |
| Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> |
| Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> |
| (cherry picked from commit 433544bd25b06cb6dcdb79b6da8d748a0220898e) |
| Signed-off-by: Darren Hart <dvhart@linux.intel.com> |
| --- |
| drivers/gpu/drm/i915/i915_gem.c | 5 +++++ |
| 1 file changed, 5 insertions(+) |
| |
| diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c |
| index 3d9e248bf422..4a58ead0ba76 100644 |
| --- a/drivers/gpu/drm/i915/i915_gem.c |
| +++ b/drivers/gpu/drm/i915/i915_gem.c |
| @@ -2606,6 +2606,9 @@ int i915_vma_unbind(struct i915_vma *vma) |
| if (list_empty(&vma->vma_link)) |
| return 0; |
| |
| + if (!drm_mm_node_allocated(&vma->node)) |
| + goto destroy; |
| + |
| if (obj->pin_count) |
| return -EBUSY; |
| |
| @@ -2643,6 +2646,8 @@ int i915_vma_unbind(struct i915_vma *vma) |
| obj->map_and_fenceable = true; |
| |
| drm_mm_remove_node(&vma->node); |
| + |
| +destroy: |
| i915_gem_vma_destroy(vma); |
| |
| /* Since the unbound list is global, only move to that list if |
| -- |
| 1.8.5.rc3 |
| |