[Intel-gfx] [RFC 2/2] drm/i915: Use i915_vma_iomap from the ringbuffer
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Tue Apr 12 15:56:52 UTC 2016
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Similarly to i915_gem_object_pin_map on LLC platforms, we can
use the new VMA based io mapping on !LLC to decrease the cost
of ringbuf pinning and unpinning.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
drivers/gpu/drm/i915/i915_gem_gtt.h | 2 ++
drivers/gpu/drm/i915/intel_ringbuffer.c | 20 ++++++++++++--------
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
index 526fdbc71ace..5dd0ddba5488 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
@@ -560,6 +560,8 @@ size_t
i915_ggtt_view_size(struct drm_i915_gem_object *obj,
const struct i915_ggtt_view *view);
+struct drm_i915_private;
+
/**
* i915_vma_iomap - calls ioremap_wc to map the GGTT VMA via the aperture
* @dev_priv: i915 private pointer
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 41b604e69db7..8ac3342b4bdd 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2084,8 +2084,6 @@ void intel_unpin_ringbuffer_obj(struct intel_ringbuffer *ringbuf)
{
if (HAS_LLC(ringbuf->obj->base.dev) && !ringbuf->obj->stolen)
i915_gem_object_unpin_map(ringbuf->obj);
- else
- iounmap(ringbuf->virtual_start);
ringbuf->vma = NULL;
i915_gem_object_ggtt_unpin(ringbuf->obj);
}
@@ -2094,8 +2092,9 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev,
struct intel_ringbuffer *ringbuf)
{
struct drm_i915_private *dev_priv = to_i915(dev);
- struct i915_ggtt *ggtt = &dev_priv->ggtt;
struct drm_i915_gem_object *obj = ringbuf->obj;
+ struct i915_vma *vma;
+ void *addr;
int ret;
if (HAS_LLC(dev_priv) && !obj->stolen) {
@@ -2112,6 +2111,8 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev,
ret = -ENOMEM;
goto err_unpin;
}
+
+ vma = i915_gem_obj_to_ggtt(obj);
} else {
ret = i915_gem_obj_ggtt_pin(obj, PAGE_SIZE, PIN_MAPPABLE);
if (ret)
@@ -2124,15 +2125,18 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev,
/* Access through the GTT requires the device to be awake. */
assert_rpm_wakelock_held(dev_priv);
- ringbuf->virtual_start = ioremap_wc(ggtt->mappable_base +
- i915_gem_obj_ggtt_offset(obj), ringbuf->size);
- if (ringbuf->virtual_start == NULL) {
- ret = -ENOMEM;
+ vma = i915_gem_obj_to_ggtt(obj);
+
+ addr = i915_vma_iomap(dev_priv, vma);
+ if (IS_ERR(addr)) {
+ ret = PTR_ERR(ringbuf->virtual_start);
goto err_unpin;
}
+
+ ringbuf->virtual_start = addr;
}
- ringbuf->vma = i915_gem_obj_to_ggtt(obj);
+ ringbuf->vma = vma;
return 0;
err_unpin:
--
1.9.1
More information about the Intel-gfx
mailing list