Skip to contentSkip to conversation

drm/i915/bdw: Enable full PPGTT

PATCH In review Ben Widawsky 2 participants 7 messages Apr 1, 2014 – Apr 2, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/bdw: Enable full PPGTT

Broadwell is perfectly capable of full PPGTT. I've been using it for some time, and seen no especially ill effects.

---
 drivers/gpu/drm/i915/i915_drv.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -2
index ab7a75e..95477f7 100644
@@ -1830,8 +1830,7 @@ struct drm_i915_cmd_table {
 
 #define HAS_HW_CONTEXTS(dev)	(INTEL_INFO(dev)->gen >= 6)
 #define HAS_ALIASING_PPGTT(dev)	(INTEL_INFO(dev)->gen >= 6 && !IS_VALLEYVIEW(dev))
-#define HAS_PPGTT(dev)		(INTEL_INFO(dev)->gen >= 7 && !IS_VALLEYVIEW(dev) \
-				 && !IS_BROADWELL(dev))
+#define HAS_PPGTT(dev)		(INTEL_INFO(dev)->gen >= 7 && !IS_VALLEYVIEW(dev))
 #define USES_PPGTT(dev)		intel_enable_ppgtt(dev, false)
 #define USES_FULL_PPGTT(dev)	intel_enable_ppgtt(dev, true)
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 4 lines · Ben Widawsky

Broadwell is perfectly capable of full PPGTT. I've been using it for some time, and seen no especially ill effects.

Nak. I spoke too soon. 1 context + default works fine. More than that gets ugly.

Quoted 25 lines
---
 drivers/gpu/drm/i915/i915_drv.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -2
index ab7a75e..95477f7 100644
@@ -1830,8 +1830,7 @@ struct drm_i915_cmd_table {
 
 #define HAS_HW_CONTEXTS(dev)	(INTEL_INFO(dev)->gen >= 6)
 #define HAS_ALIASING_PPGTT(dev)	(INTEL_INFO(dev)->gen >= 6 && !IS_VALLEYVIEW(dev))
-#define HAS_PPGTT(dev)		(INTEL_INFO(dev)->gen >= 7 && !IS_VALLEYVIEW(dev) \
-				 && !IS_BROADWELL(dev))
+#define HAS_PPGTT(dev)		(INTEL_INFO(dev)->gen >= 7 && !IS_VALLEYVIEW(dev))
 #define USES_PPGTT(dev)		intel_enable_ppgtt(dev, false)
 #define USES_FULL_PPGTT(dev)	intel_enable_ppgtt(dev, true)
 
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#2 lore raw

PATCH 1/3 drm/i915/ppgtt: Load address space after mi_set_context

On GEN8 the PDPs are saved and restored with context, which means we must set them after the context switch has occurred. If we do not do this, we end up saving the new PDPs for the old context.

The next patch will go one step further and actually only load the PDPs once.

Example of a problem
LRI PDPs 1
MI_SET_CONTEXT bar
LRI_PDPs 2
MI_SET_CONTEXT foo // save PDPs 2 to bar's context

		  //  load foos PDPs

LRI PDPs 1
MI_SET_CONTEXT bar // save PDPs 1 to foo's context

It's all wacky. This should allow full PPGTT on Broadwell to work.

---
 drivers/gpu/drm/i915/i915_gem_context.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +18 -6
index 8fe7d72..0e8fd1e 100644
@@ -667,13 +667,12 @@ static int do_switch(struct intel_ring_buffer *ring,
 	 */
 	from = ring->last_context;
 
-	if (USES_FULL_PPGTT(ring->dev)) {
-		ret = ppgtt->switch_mm(ppgtt, ring, false);
-		if (ret)
-			goto unpin_out;
-	}
-
 	if (ring != &dev_priv->ring[RCS]) {
+		if (USES_FULL_PPGTT(ring->dev)) {
+			ret = ppgtt->switch_mm(ppgtt, ring, false);
+			if (ret)
+				goto unpin_out;
+		}
 		if (from)
 			i915_gem_context_unreference(from);
 		goto done;
@@ -711,6 +710,19 @@ static int do_switch(struct intel_ring_buffer *ring,
 	if (ret)
 		goto unpin_out;
 
+	if (USES_FULL_PPGTT(ring->dev)) {
+		ret = ppgtt->switch_mm(ppgtt, ring, false);
+		/* The hardware context switch is emitted, but we haven't
+		 * actually changed the state - so it's probably safe to bail
+		 * here. Still, let the user know something dangerous has
+		 * happened.
+		 */
+		if (ret) {
+			DRM_ERROR("Failed to change address space on context switch\n");
+			goto unpin_out;
+		}
+	}
+
 	for (i = 0; i < MAX_L3_SLICES; i++) {
 		if (!(to->remap_slice & (1<<i)))
 			continue;
Signature · 1 line
1.9.1
#3 lore raw

PATCH 2/3 drm/i915/bdw: Render ring PDP is restored with context

So let's not do it every time we switch.

---
 drivers/gpu/drm/i915/i915_gem_context.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
index 0e8fd1e..743fc42 100644
@@ -710,7 +710,7 @@ static int do_switch(struct intel_ring_buffer *ring,
 	if (ret)
 		goto unpin_out;
 
-	if (USES_FULL_PPGTT(ring->dev)) {
+	if (USES_FULL_PPGTT(ring->dev) && !to->is_initialized) {
 		ret = ppgtt->switch_mm(ppgtt, ring, false);
 		/* The hardware context switch is emitted, but we haven't
 		 * actually changed the state - so it's probably safe to bail
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 2/3 drm/i915/bdw: Render ring PDP is restored with context

So let's not do it every time we switch.

v2: v1 skipped the switch for all gens. We still need it pre-gen8.

---
 drivers/gpu/drm/i915/i915_gem_context.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_context.c +2 -1
index 0e8fd1e..3b5b8ab 100644
@@ -710,7 +710,8 @@ static int do_switch(struct intel_ring_buffer *ring,
 	if (ret)
 		goto unpin_out;
 
-	if (USES_FULL_PPGTT(ring->dev)) {
+	if (USES_FULL_PPGTT(ring->dev) &&
+	    (!IS_GEN8(ring->dev) || !to->is_initialized)) {
 		ret = ppgtt->switch_mm(ppgtt, ring, false);
 		/* The hardware context switch is emitted, but we haven't
 		 * actually changed the state - so it's probably safe to bail
Signature · 1 line
1.9.1
#5 lore raw

Re: [PATCH 2/3] [v2] drm/i915/bdw: Render ring PDP is restored with context

Quoted 5 lines · Ben Widawsky

So let's not do it every time we switch.

v2: v1 skipped the switch for all gens. We still need it pre-gen8.

Please ignore this patch. I actually need to rework some stuff. 1 and 3 are still good though.

Quoted 25 lines
---
 drivers/gpu/drm/i915/i915_gem_context.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_context.c +2 -1
index 0e8fd1e..3b5b8ab 100644
@@ -710,7 +710,8 @@ static int do_switch(struct intel_ring_buffer *ring,
 	if (ret)
 		goto unpin_out;
 
-	if (USES_FULL_PPGTT(ring->dev)) {
+	if (USES_FULL_PPGTT(ring->dev) &&
+	    (!IS_GEN8(ring->dev) || !to->is_initialized)) {
 		ret = ppgtt->switch_mm(ppgtt, ring, false);
 		/* The hardware context switch is emitted, but we haven't
 		 * actually changed the state - so it's probably safe to bail
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#6 lore raw

PATCH 3/3 drm/i915/bdw: Enable full PPGTT

In reply to Ben Widawsky

Broadwell is perfectly capable of full PPGTT. I've been using it for some time, and seen no especially ill effects.

---
 drivers/gpu/drm/i915/i915_drv.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -2
index 9a8cfe0..33bc85a 100644
@@ -1830,8 +1830,7 @@ struct drm_i915_cmd_table {
 
 #define HAS_HW_CONTEXTS(dev)	(INTEL_INFO(dev)->gen >= 6)
 #define HAS_ALIASING_PPGTT(dev)	(INTEL_INFO(dev)->gen >= 6 && !IS_VALLEYVIEW(dev))
-#define HAS_PPGTT(dev)		(INTEL_INFO(dev)->gen >= 7 && !IS_VALLEYVIEW(dev) \
-				 && !IS_BROADWELL(dev))
+#define HAS_PPGTT(dev)		(INTEL_INFO(dev)->gen >= 7 && !IS_VALLEYVIEW(dev))
 #define USES_PPGTT(dev)		intel_enable_ppgtt(dev, false)
 #define USES_FULL_PPGTT(dev)	intel_enable_ppgtt(dev, true)
 
Signature · 1 line
1.9.1