Skip to contentSkip to conversation

drm/i915: align vlv forcewake with common lore

PATCH In review Daniel Vetter 4 participants 6 messages Aug 24, 2012 – Sep 3, 2012

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

PATCH 1/2 drm/i915: align vlv forcewake with common lore

For some odd reasons, the vlv forcewake code is rather different from all other platforms, with no clear justification. Adjust things:

- Don't check whether the gt is awake already (and bail out early), we need to grab a forcewake anyway. Otherwise the chip might go to sleep too early. And this would also screw up our forcewake accounting.
- Like all other platforms, check whether the gt has cleared the forcewake bit in the _ACK register before setting it again.
- Use _MASKED_BIT_ENABLE/DISABLE macros
- Only use bit0 of the forcewake reg, not all 16 bits.
- check the gtfifodb reg like on all other platforms in _put.
- Drop the POSTING_READs for consistency.

v2: Failure to git add ... again.

v3: Fixup the spelling fail a bit.

---
 drivers/gpu/drm/i915/intel_pm.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +6 -8
index c0721ff..1a197da 100644
@@ -4075,12 +4075,10 @@ int __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv)
 
 static void vlv_force_wake_get(struct drm_i915_private *dev_priv)
 {
-	/* Already awake? */
-	if ((I915_READ(0x130094) & 0xa1) == 0xa1)
-		return;
+	if (wait_for_atomic_us((I915_READ_NOTRACE(FORCEWAKE_ACK_VLV) & 1) == 0, 500))
+		DRM_ERROR("Force wake wait timed out\n");
 
-	I915_WRITE_NOTRACE(FORCEWAKE_VLV, 0xffffffff);
-	POSTING_READ(FORCEWAKE_VLV);
+	I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_ENABLE(1));
 
 	if (wait_for_atomic_us((I915_READ_NOTRACE(FORCEWAKE_ACK_VLV) & 1), 500))
 		DRM_ERROR("Force wake wait timed out\n");
@@ -4090,9 +4088,9 @@ static void vlv_force_wake_get(struct drm_i915_private *dev_priv)
 
 static void vlv_force_wake_put(struct drm_i915_private *dev_priv)
 {
-	I915_WRITE_NOTRACE(FORCEWAKE_VLV, 0xffff0000);
-	/* FIXME: confirm VLV behavior with Punit folks */
-	POSTING_READ(FORCEWAKE_VLV);
+	I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_DISABLE(1));
+	/* The below doubles as a POSTING_READ */
+	gen6_gt_check_fifodbg(dev_priv);
 }
 
 void intel_gt_init(struct drm_device *dev)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 2/2 drm/i915: differe error message between forcwake timeouts

<ickle> danvet: in the force wake, both DRM_ERRORs have the same string. <ickle> useful for .txt shrinkage, horrible for debugging

---
 drivers/gpu/drm/i915/intel_pm.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +6 -6
index 1a197da..1e4d25e 100644
@@ -3969,13 +3969,13 @@ static void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv)
 		forcewake_ack = FORCEWAKE_ACK;
 
 	if (wait_for_atomic_us((I915_READ_NOTRACE(forcewake_ack) & 1) == 0, 500))
-		DRM_ERROR("Force wake wait timed out\n");
+		DRM_ERROR("Timed out waiting for forcewake old ack to clear.\n");
 
 	I915_WRITE_NOTRACE(FORCEWAKE, 1);
 	POSTING_READ(FORCEWAKE);
 
 	if (wait_for_atomic_us((I915_READ_NOTRACE(forcewake_ack) & 1), 500))
-		DRM_ERROR("Force wake wait timed out\n");
+		DRM_ERROR("Timed out waiting for forcewake to ack request.\n");
 
 	__gen6_gt_wait_for_thread_c0(dev_priv);
 }
@@ -3990,13 +3990,13 @@ static void __gen6_gt_force_wake_mt_get(struct drm_i915_private *dev_priv)
 		forcewake_ack = FORCEWAKE_MT_ACK;
 
 	if (wait_for_atomic_us((I915_READ_NOTRACE(forcewake_ack) & 1) == 0, 500))
-		DRM_ERROR("Force wake wait timed out\n");
+		DRM_ERROR("Timed out waiting for forcewake old ack to clear.\n");
 
 	I915_WRITE_NOTRACE(FORCEWAKE_MT, _MASKED_BIT_ENABLE(1));
 	POSTING_READ(FORCEWAKE_MT);
 
 	if (wait_for_atomic_us((I915_READ_NOTRACE(forcewake_ack) & 1), 500))
-		DRM_ERROR("Force wake wait timed out\n");
+		DRM_ERROR("Timed out waiting for forcewake to ack request.\n");
 
 	__gen6_gt_wait_for_thread_c0(dev_priv);
 }
@@ -4076,12 +4076,12 @@ int __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv)
 static void vlv_force_wake_get(struct drm_i915_private *dev_priv)
 {
 	if (wait_for_atomic_us((I915_READ_NOTRACE(FORCEWAKE_ACK_VLV) & 1) == 0, 500))
-		DRM_ERROR("Force wake wait timed out\n");
+		DRM_ERROR("Timed out waiting for forcewake old ack to clear.\n");
 
 	I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_ENABLE(1));
 
 	if (wait_for_atomic_us((I915_READ_NOTRACE(FORCEWAKE_ACK_VLV) & 1), 500))
-		DRM_ERROR("Force wake wait timed out\n");
+		DRM_ERROR("Timed out waiting for forcewake to ack request.\n");
 
 	__gen6_gt_wait_for_thread_c0(dev_priv);
 }
Signature · 1 line
1.7.10.4
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/i915: differe error message between forcwake timeouts

Am Freitag, den 24.08.2012, 17:26 +0200 schrieb Daniel Vetter:

In the commit summary: s,differe,different,

Quoted 8 lines

<ickle> danvet: in the force wake, both DRM_ERRORs have the same string. <ickle> useful for .txt shrinkage, horrible for debugging

---
 drivers/gpu/drm/i915/intel_pm.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

[…]

Thanks,

Paul

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Tested-by on v1 1/2
#4 lore raw
In reply to Daniel Vetter
Quoted 14 lines · On Fri, 24 Aug 2012 17:26:20 +0200 Daniel Vetter <[email protected]> wrote:

For some odd reasons, the vlv forcewake code is rather different from all other platforms, with no clear justification. Adjust things:

- Don't check whether the gt is awake already (and bail out early), we need to grab a forcewake anyway. Otherwise the chip might go to sleep too early. And this would also screw up our forcewake accounting.
- Like all other platforms, check whether the gt has cleared the forcewake bit in the _ACK register before setting it again.
- Use _MASKED_BIT_ENABLE/DISABLE macros
- Only use bit0 of the forcewake reg, not all 16 bits.
- check the gtfifodb reg like on all other platforms in _put.
- Drop the POSTING_READs for consistency.

Quoted 6 lines

v2: Failure to git add ... again.

v3: Fixup the spelling fail a bit.

I'd like to see the FORCEWAKE patches I've recently submitted get merged, and the same magic in those get applied here.

Regarding docs, I can't find the right ones to verify any of the forcewake stuff, so no r-b. Maybe Jesse can help. For an a-b I'd like you to take the forcewake fixes, and considering squashing the vlv specific functions into the main functions, since you've removed most of the differences anyway.

In any case, it is:

Quoted 9 lines
---
 drivers/gpu/drm/i915/intel_pm.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +0 -0
index c0721ff..1a197da 100644

drivers/gpu/drm/i915/intel_pm.c int __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv) · line 4079

Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +2 -3
@@ -4075,12 +4075,10 @@ int __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv)
 
 static void vlv_force_wake_get(struct drm_i915_private *dev_priv)
 {
-	/* Already awake? */
-	if ((I915_READ(0x130094) & 0xa1) == 0xa1)
-		return;
+	if (wait_for_atomic_us((I915_READ_NOTRACE(FORCEWAKE_ACK_VLV) & 1) == 0, 500))
+		DRM_ERROR("Force wake wait timed out\n");

WTF?

Quoted 20 lines
drivers/gpu/drm/i915/intel_pm.c +4 -5
-	I915_WRITE_NOTRACE(FORCEWAKE_VLV, 0xffffffff);
-	POSTING_READ(FORCEWAKE_VLV);
+	I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_ENABLE(1));
 
 	if (wait_for_atomic_us((I915_READ_NOTRACE(FORCEWAKE_ACK_VLV) & 1), 500))
 		DRM_ERROR("Force wake wait timed out\n");
@@ -4090,9 +4088,9 @@ static void vlv_force_wake_get(struct drm_i915_private *dev_priv)
 
 static void vlv_force_wake_put(struct drm_i915_private *dev_priv)
 {
-	I915_WRITE_NOTRACE(FORCEWAKE_VLV, 0xffff0000);
-	/* FIXME: confirm VLV behavior with Punit folks */
-	POSTING_READ(FORCEWAKE_VLV);
+	I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_DISABLE(1));
+	/* The below doubles as a POSTING_READ */
+	gen6_gt_check_fifodbg(dev_priv);
 }
 
 void intel_gt_init(struct drm_device *dev)
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#5 lore raw
Quoted 23 lines · Ben Widawsky
Quoted 14 lines · On Fri, 24 Aug 2012 17:26:20 +0200 Daniel Vetter <[email protected]> wrote:

For some odd reasons, the vlv forcewake code is rather different from all other platforms, with no clear justification. Adjust things:

- Don't check whether the gt is awake already (and bail out early), we need to grab a forcewake anyway. Otherwise the chip might go to sleep too early. And this would also screw up our forcewake accounting.
- Like all other platforms, check whether the gt has cleared the forcewake bit in the _ACK register before setting it again.
- Use _MASKED_BIT_ENABLE/DISABLE macros
- Only use bit0 of the forcewake reg, not all 16 bits.
- check the gtfifodb reg like on all other platforms in _put.
- Drop the POSTING_READs for consistency.

Quoted 6 lines

v2: Failure to git add ... again.

v3: Fixup the spelling fail a bit.

Quoted 8 lines

I'd like to see the FORCEWAKE patches I've recently submitted get merged, and the same magic in those get applied here.

Regarding docs, I can't find the right ones to verify any of the forcewake stuff, so no r-b. Maybe Jesse can help. For an a-b I'd like you to take the forcewake fixes, and considering squashing the vlv specific functions into the main functions, since you've removed most of the differences anyway.

I've figured I'll just apply it and let Jesse yell it at me ;-) After all, this patch has been floating for a few weeks already in some form or another, and seems to no break 2 of the 3 vlv machines we have access too
...

Quoted 2 lines

In any case, it is:

Thanks, I've merged both patches for -next.
-Daniel

Quoted 13 lines
Quoted 13 lines


---
 drivers/gpu/drm/i915/intel_pm.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +0 -0
index c0721ff..1a197da 100644
@@ -4075,12 +4075,10 @@ int __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv)
 
Quoted 9 lines

drivers/gpu/drm/i915/intel_pm.c int __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv) · line 4079

Quoted 7 lines
drivers/gpu/drm/i915/intel_pm.c +2 -3
 static void vlv_force_wake_get(struct drm_i915_private *dev_priv)
 {
-	/* Already awake? */
-	if ((I915_READ(0x130094) & 0xa1) == 0xa1)
-		return;
+	if (wait_for_atomic_us((I915_READ_NOTRACE(FORCEWAKE_ACK_VLV) & 1) == 0, 500))
+		DRM_ERROR("Force wake wait timed out\n");

WTF?

I hope that wtf is for the old code, not the new ...

Quoted 26 lines
Quoted 21 lines
drivers/gpu/drm/i915/intel_pm.c +4 -5
-	I915_WRITE_NOTRACE(FORCEWAKE_VLV, 0xffffffff);
-	POSTING_READ(FORCEWAKE_VLV);
+	I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_ENABLE(1));
 
 	if (wait_for_atomic_us((I915_READ_NOTRACE(FORCEWAKE_ACK_VLV) & 1), 500))
 		DRM_ERROR("Force wake wait timed out\n");
@@ -4090,9 +4088,9 @@ static void vlv_force_wake_get(struct drm_i915_private *dev_priv)
 
 static void vlv_force_wake_put(struct drm_i915_private *dev_priv)
 {
-	I915_WRITE_NOTRACE(FORCEWAKE_VLV, 0xffff0000);
-	/* FIXME: confirm VLV behavior with Punit folks */
-	POSTING_READ(FORCEWAKE_VLV);
+	I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_DISABLE(1));
+	/* The below doubles as a POSTING_READ */
+	gen6_gt_check_fifodbg(dev_priv);
 }
 
 void intel_gt_init(struct drm_device *dev)
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48