[RFC,2/2] drm/i915: Use i915_vma_iomap from the ringbuffer

Submitted by Tvrtko Ursulin on April 12, 2016, 3:56 p.m.

Details

Message ID 1460476612-10427-2-git-send-email-tvrtko.ursulin@linux.intel.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Intel GFX

Not browsing as part of any series.

Commit Message

Tvrtko Ursulin April 12, 2016, 3:56 p.m.
From: Tvrtko Ursulin <tvrtko.ursulin@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@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(-)

Patch hide | download patch | download mbox

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:

Comments

On Tue, Apr 12, 2016 at 04:56:52PM +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@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.

If you are going to mention pin_map, you open up the discussion that we
can avoid the mappable apertures requirement on !llc if we use pin_map
with a pgprot_writecombine. That's my preferred solution, caching the
ioremap is just a stopgap, or fallback for when we can't use direct CPU
access.
-Chris