[Intel-gfx] [PATCH 05/49] drm/i915: Extract trivial parts of ring init (early init)

oscar.mateo at intel.com oscar.mateo at intel.com
Thu Mar 27 18:59:34 CET 2014


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

It's beneficial to be able to get a name, base, and id before we've
actually initialized the rings. This ability was effectively destroyed
in the ringbuffer fire which Daniel started.

With the simple early init function, that ability is restored.

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

v2: The Full PPGTT series have moved things around a little bit.
Also, don't forget the VEBOX.

Signed-off-by: Oscar Mateo <oscar.mateo at intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c         |  2 ++
 drivers/gpu/drm/i915/intel_ringbuffer.c | 57 +++++++++++++++++++++------------
 drivers/gpu/drm/i915/intel_ringbuffer.h |  1 +
 3 files changed, 39 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 1d85dc9..f429887 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4464,6 +4464,8 @@ int i915_gem_init(struct drm_device *dev)
 
 	i915_gem_init_global_gtt(dev);
 
+	intel_init_rings_early(dev);
+
 	ret = i915_gem_context_init(dev);
 	if (ret) {
 		mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 489046a..659fed0 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1875,10 +1875,6 @@ int intel_init_render_ring_buffer(struct drm_device *dev)
 	drm_i915_private_t *dev_priv = dev->dev_private;
 	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
 
-	ring->name = "render ring";
-	ring->id = RCS;
-	ring->mmio_base = RENDER_RING_BASE;
-
 	if (INTEL_INFO(dev)->gen >= 6) {
 		ring->add_request = gen6_add_request;
 		ring->flush = gen7_render_ring_flush;
@@ -1977,10 +1973,6 @@ int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
 	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
 	int ret;
 
-	ring->name = "render ring";
-	ring->id = RCS;
-	ring->mmio_base = RENDER_RING_BASE;
-
 	if (INTEL_INFO(dev)->gen >= 6) {
 		/* non-kms not supported on gen6+ */
 		return -ENODEV;
@@ -2044,12 +2036,8 @@ int intel_init_bsd_ring_buffer(struct drm_device *dev)
 	drm_i915_private_t *dev_priv = dev->dev_private;
 	struct intel_ring_buffer *ring = &dev_priv->ring[VCS];
 
-	ring->name = "bsd ring";
-	ring->id = VCS;
-
 	ring->write_tail = ring_write_tail;
 	if (INTEL_INFO(dev)->gen >= 6) {
-		ring->mmio_base = GEN6_BSD_RING_BASE;
 		/* gen6 bsd needs a special wa for tail updates */
 		if (IS_GEN6(dev))
 			ring->write_tail = gen6_bsd_ring_write_tail;
@@ -2081,7 +2069,6 @@ int intel_init_bsd_ring_buffer(struct drm_device *dev)
 		ring->signal_mbox[BCS] = GEN6_BVSYNC;
 		ring->signal_mbox[VECS] = GEN6_VEVSYNC;
 	} else {
-		ring->mmio_base = BSD_RING_BASE;
 		ring->flush = bsd_ring_flush;
 		ring->add_request = i9xx_add_request;
 		ring->get_seqno = ring_get_seqno;
@@ -2107,10 +2094,6 @@ int intel_init_blt_ring_buffer(struct drm_device *dev)
 	drm_i915_private_t *dev_priv = dev->dev_private;
 	struct intel_ring_buffer *ring = &dev_priv->ring[BCS];
 
-	ring->name = "blitter ring";
-	ring->id = BCS;
-
-	ring->mmio_base = BLT_RING_BASE;
 	ring->write_tail = ring_write_tail;
 	ring->flush = gen6_ring_flush;
 	ring->add_request = gen6_add_request;
@@ -2147,10 +2130,6 @@ int intel_init_vebox_ring_buffer(struct drm_device *dev)
 	drm_i915_private_t *dev_priv = dev->dev_private;
 	struct intel_ring_buffer *ring = &dev_priv->ring[VECS];
 
-	ring->name = "video enhancement ring";
-	ring->id = VECS;
-
-	ring->mmio_base = VEBOX_RING_BASE;
 	ring->write_tail = ring_write_tail;
 	ring->flush = gen6_ring_flush;
 	ring->add_request = gen6_add_request;
@@ -2220,3 +2199,39 @@ intel_ring_invalidate_all_caches(struct intel_ring_buffer *ring)
 	ring->gpu_caches_dirty = false;
 	return 0;
 }
+
+void intel_init_rings_early(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	dev_priv->ring[RCS].name = "render ring";
+	dev_priv->ring[RCS].id = RCS;
+	dev_priv->ring[RCS].mmio_base = RENDER_RING_BASE;
+	dev_priv->ring[RCS].dev = dev;
+	dev_priv->ring[RCS].head = 0;
+	dev_priv->ring[RCS].tail = 0;
+
+	dev_priv->ring[BCS].name = "blitter ring";
+	dev_priv->ring[BCS].id = BCS;
+	dev_priv->ring[BCS].mmio_base = BLT_RING_BASE;
+	dev_priv->ring[BCS].dev = dev;
+	dev_priv->ring[BCS].head = 0;
+	dev_priv->ring[BCS].tail = 0;
+
+	dev_priv->ring[VCS].name = "bsd ring";
+	dev_priv->ring[VCS].id = VCS;
+	if (INTEL_INFO(dev)->gen >= 6)
+		dev_priv->ring[VCS].mmio_base = GEN6_BSD_RING_BASE;
+	else
+		dev_priv->ring[VCS].mmio_base = BSD_RING_BASE;
+	dev_priv->ring[VCS].dev = dev;
+	dev_priv->ring[VCS].head = 0;
+	dev_priv->ring[VCS].tail = 0;
+
+	dev_priv->ring[VECS].name = "video enhancement ring";
+	dev_priv->ring[VECS].id = VECS;
+	dev_priv->ring[VECS].mmio_base = VEBOX_RING_BASE;
+	dev_priv->ring[VECS].dev = dev;
+	dev_priv->ring[VECS].head = 0;
+	dev_priv->ring[VECS].tail = 0;
+}
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index f11ceb2..135bdc1 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -287,6 +287,7 @@ void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno);
 int intel_ring_flush_all_caches(struct intel_ring_buffer *ring);
 int intel_ring_invalidate_all_caches(struct intel_ring_buffer *ring);
 
+void intel_init_rings_early(struct drm_device *dev);
 int intel_init_render_ring_buffer(struct drm_device *dev);
 int intel_init_bsd_ring_buffer(struct drm_device *dev);
 int intel_init_blt_ring_buffer(struct drm_device *dev);
-- 
1.9.0




More information about the Intel-gfx mailing list