[Intel-gfx] [PATCH 20/50] drm/i915/bdw: Rework init code for Logical Ring Contexts

oscar.mateo at intel.com oscar.mateo at intel.com
Fri May 9 14:08:50 CEST 2014


From: Ben Widawsky <benjamin.widawsky at intel.com>

This modifies the init code to try to start logical ring contexts when
possible, and fall back to legacy ringbuffers when not.

Most importantly, things make things easy if we do the context creation
before ringbuffer initialization. Upcoming patches will make it clearer
why that is. For the initial enabling of execlists, the ringbuffer code
will be reused a decent amount. As such this code will have to change,
but it helps with enabling to be able to run through a bunch of the
context init, and still have a system boot.

Finally, for the bikeshedders out there: I've tried merging the legacy
hw context init functionality, ie. one init function, and this logic was
in the context creation. The resulting code was much uglier and for no
real gain.

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>

v2: Rebased on top of the Full PPGTT series.

Signed-off-by: Oscar Mateo <oscar.mateo at intel.com>

v3: Factor out a enable_execlists() function so it's clear what the
condition is. Use module parameter to enable.

Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h  |  3 +++
 drivers/gpu/drm/i915/i915_gem.c  | 24 +++++++++++++++++++-----
 drivers/gpu/drm/i915/intel_lrc.c |  5 +++++
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index bd93dc2..41d3f95 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2425,6 +2425,9 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
 int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
 				   struct drm_file *file);
 
+/* intel_lrc.c */
+int gen8_gem_context_init(struct drm_device *dev);
+
 /* i915_gem_evict.c */
 int __must_check i915_gem_evict_something(struct drm_device *dev,
 					  struct i915_address_space *vm,
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 4a22560..f8acf3d 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4490,10 +4490,18 @@ i915_gem_init_hw(struct drm_device *dev)
 	return ret;
 }
 
+static bool enable_execlists(struct drm_device *dev)
+{
+	if (!i915.enable_execlists)
+		return false;
+
+	return HAS_LOGICAL_RING_CONTEXTS(dev) && USES_PPGTT(dev);
+}
+
 int i915_gem_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	int ret;
+	int ret = -1;
 
 	mutex_lock(&dev->struct_mutex);
 
@@ -4509,11 +4517,17 @@ int i915_gem_init(struct drm_device *dev)
 
 	intel_init_rings_early(dev);
 
-	ret = i915_gem_context_init(dev);
+	if (enable_execlists(dev))
+		ret = gen8_gem_context_init(dev);
+
 	if (ret) {
-		mutex_unlock(&dev->struct_mutex);
-		return ret;
-	}
+		ret = i915_gem_context_init(dev);
+		if (ret) {
+			mutex_unlock(&dev->struct_mutex);
+			return ret;
+		}
+	} else
+		dev_priv->lrc_enabled = true;
 
 	ret = i915_gem_init_hw(dev);
 	if (ret == -EIO) {
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 49bb6fc..3a93e99 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -40,3 +40,8 @@
 #include <drm/drmP.h>
 #include <drm/i915_drm.h>
 #include "i915_drv.h"
+
+int gen8_gem_context_init(struct drm_device *dev)
+{
+	return -ENOSYS;
+}
-- 
1.9.0




More information about the Intel-gfx mailing list