[Intel-gfx] [PATCH 1/3] drm/i915: Cleanup i915_gem_restore_gtt_mappings()
David Weinehall
david.weinehall at linux.intel.com
Fri Nov 18 10:06:01 UTC 2016
On resume we unbind+bind our VMA-mappings. This patch simplifies
this a bit by introducing a rebind() helper. As a nice side-effect
this also makes the resume callgraph self-documenting.
Patch by Chris.
Signed-off-by: David Weinehall <david.weinehall at linux.intel.com>
CC: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_gem_gtt.c | 7 +------
drivers/gpu/drm/i915/i915_vma.c | 10 ++++++++++
drivers/gpu/drm/i915/i915_vma.h | 6 ++++--
3 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index b4bde1452f2a..76af33443fcd 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -3299,12 +3299,7 @@ void i915_gem_restore_gtt_mappings(struct drm_i915_private *dev_priv)
if (vma->vm != &ggtt->base)
continue;
- if (!i915_vma_unbind(vma))
- continue;
-
- WARN_ON(i915_vma_bind(vma, obj->cache_level,
- PIN_UPDATE));
- ggtt_bound = true;
+ ggtt_bound |= i915_vma_rebind(vma);
}
if (ggtt_bound)
diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index 738ff3a5cd6e..1fc54686c2c3 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -648,3 +648,13 @@ int i915_vma_unbind(struct i915_vma *vma)
return 0;
}
+bool i915_vma_rebind(struct i915_vma *vma)
+{
+ if (i915_vma_is_pinned(vma)) {
+ WARN_ON(i915_vma_bind(vma, vma->obj->cache_level, PIN_UPDATE));
+ return true;
+ } else {
+ WARN_ON(i915_vma_unbind(vma));
+ return false;
+ }
+}
diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
index 2e49f5dd6107..16fa9cdc0dd2 100644
--- a/drivers/gpu/drm/i915/i915_vma.h
+++ b/drivers/gpu/drm/i915/i915_vma.h
@@ -200,8 +200,11 @@ i915_vma_compare(struct i915_vma *vma,
sizeof(view->params));
}
-int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
+int i915_vma_bind(struct i915_vma *vma,
+ enum i915_cache_level cache_level,
u32 flags);
+bool i915_vma_rebind(struct i915_vma *vma);
+
bool i915_gem_valid_gtt_space(struct i915_vma *vma, unsigned long cache_level);
bool
i915_vma_misplaced(struct i915_vma *vma, u64 size, u64 alignment, u64 flags);
@@ -339,4 +342,3 @@ i915_vma_unpin_fence(struct i915_vma *vma)
}
#endif
-
--
2.10.2
More information about the Intel-gfx
mailing list