Skip to contentSkip to conversation

drm/i915/vlv: save/restore the power context base reg

PATCH In review Jesse Barnes 5 participants 9 messages Apr 1, 2015 – Apr 7, 2015

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

PATCH 1/2 drm/i915/vlv: save/restore the power context base reg

Some BIOSes (e.g. the one on the Minnowboard) don't save/restore this reg. If it's unlocked, we can just restore the previous value, and if it's locked (in case the BIOS re-programmed it for us) the write will be ignored and we'll still have "did it move" sanity check in the PM code to warn us if something is still amiss.

References: https://bugs.freedesktop.org/show_bug.cgi?id=89611

---
 drivers/gpu/drm/i915/i915_drv.c | 2 ++
 drivers/gpu/drm/i915/i915_drv.h | 1 +
 2 files changed, 3 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index c1a3cdb5..4d6d6f0 100644
@@ -1104,6 +1104,7 @@ static void vlv_save_gunit_s0ix_state(struct drm_i915_private *dev_priv)
 	/* Gunit-Display CZ domain, 0x182028-0x1821CF */
 	s->gu_ctl0		= I915_READ(VLV_GU_CTL0);
 	s->gu_ctl1		= I915_READ(VLV_GU_CTL1);
+	s->pcbr			= I915_READ(VLV_PCBR);
 	s->clock_gate_dis2	= I915_READ(VLV_GUNIT_CLOCK_GATE2);
 
 	/*
@@ -1198,6 +1199,7 @@ static void vlv_restore_gunit_s0ix_state(struct drm_i915_private *dev_priv)
 	/* Gunit-Display CZ domain, 0x182028-0x1821CF */
 	I915_WRITE(VLV_GU_CTL0,			s->gu_ctl0);
 	I915_WRITE(VLV_GU_CTL1,			s->gu_ctl1);
+	I915_WRITE(VLV_PCBR,			s->pcbr);
 	I915_WRITE(VLV_GUNIT_CLOCK_GATE2,	s->clock_gate_dis2);
 }
 
drivers/gpu/drm/i915/i915_drv.h +1 -0
index b13c552..f3ac683 100644
@@ -994,6 +994,7 @@ struct vlv_s0ix_state {
 	/* Display 2 CZ domain */
 	u32 gu_ctl0;
 	u32 gu_ctl1;
+	u32 pcbr;
 	u32 clock_gate_dis2;
 };
 
Signature · 6 lines
1.9.1

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

PATCH 2/2 drm/i915/vlv: remove wait for previous GFX clk disable request

Looks like it was introduced in:

commit 650ad970a39f8b6164fe8613edc150f585315289

Author: Imre Deak <[email protected]>
Date:   Fri Apr 18 16:35:02 2014 +0300

drm/i915: vlv: factor out vlv_force_gfx_clock and check for pending force-of

but I'm not sure why. It has caused problems for us in the past (see 85250ddff7a603dfe0ec0503a9e6395f79424f61 and 8d4eee9cd7a170342dc6fbc2ee19ae77031a8cd5) and doesn't seem to be required, so let's just drop it.

References: https://bugs.freedesktop.org/show_bug.cgi?id=89611

---
 drivers/gpu/drm/i915/i915_drv.c | 14 --------------
 1 file changed, 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +0 -14
index 4d6d6f0..c3fdbb0 100644
@@ -1208,21 +1208,7 @@ int vlv_force_gfx_clock(struct drm_i915_private *dev_priv, bool force_on)
 	u32 val;
 	int err;
 
-	val = I915_READ(VLV_GTLC_SURVIVABILITY_REG);
-
 #define COND (I915_READ(VLV_GTLC_SURVIVABILITY_REG) & VLV_GFX_CLK_STATUS_BIT)
-	/* Wait for a previous force-off to settle */
-	if (force_on && !IS_CHERRYVIEW(dev_priv->dev)) {
-		/* WARN_ON only for the Valleyview */
-		WARN_ON(!!(val & VLV_GFX_CLK_FORCE_ON_BIT) == force_on);
-
-		err = wait_for(!COND, 20);
-		if (err) {
-			DRM_ERROR("timeout waiting for GFX clock force-off (%08x)\n",
-				  I915_READ(VLV_GTLC_SURVIVABILITY_REG));
-			return err;
-		}
-	}
 
 	val = I915_READ(VLV_GTLC_SURVIVABILITY_REG);
 	val &= ~VLV_GFX_CLK_FORCE_ON_BIT;
Signature · 6 lines
1.9.1

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

Re: [PATCH 2/2] drm/i915/vlv: remove wait for previous GFX clk disable request

Quoted 32 lines · Jesse Barnes

Looks like it was introduced in:

commit 650ad970a39f8b6164fe8613edc150f585315289

Author: Imre Deak <[email protected]>
Date:   Fri Apr 18 16:35:02 2014 +0300

drm/i915: vlv: factor out vlv_force_gfx_clock and check for pending force-of

but I'm not sure why. It has caused problems for us in the past (see 85250ddff7a603dfe0ec0503a9e6395f79424f61 and 8d4eee9cd7a170342dc6fbc2ee19ae77031a8cd5) and doesn't seem to be required, so let's just drop it.

References: https://bugs.freedesktop.org/show_bug.cgi?id=89611

---
 drivers/gpu/drm/i915/i915_drv.c | 14 --------------
 1 file changed, 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +0 -4
index 4d6d6f0..c3fdbb0 100644
@@ -1208,21 +1208,7 @@ int vlv_force_gfx_clock(struct drm_i915_private *dev_priv, bool force_on)
 	u32 val;
 	int err;
 
-	val = I915_READ(VLV_GTLC_SURVIVABILITY_REG);
-
 #define COND (I915_READ(VLV_GTLC_SURVIVABILITY_REG) & VLV_GFX_CLK_STATUS_BIT)
-	/* Wait for a previous force-off to settle */
-	if (force_on && !IS_CHERRYVIEW(dev_priv->dev)) {

drivers/gpu/drm/i915/i915_drv.c int vlv_force_gfx_clock(struct drm_i915_private *dev_priv, bool force_on) · line 1225

Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.c +0 -10
-		/* WARN_ON only for the Valleyview */
-		WARN_ON(!!(val & VLV_GFX_CLK_FORCE_ON_BIT) == force_on);
-
-		err = wait_for(!COND, 20);
-		if (err) {
-			DRM_ERROR("timeout waiting for GFX clock force-off (%08x)\n",
-				  I915_READ(VLV_GTLC_SURVIVABILITY_REG));
-			return err;
-		}
-	}

The reason I added this is that it's not clear what happens if you try to force the clock on while the previous force-off operation is still pending. That is if Punit will correctly cancel turning off the clock in this case. Since the docs don't clarify this either I thought the above is safer. Is it the WARN that triggers and only during resume (we also call the function from vlv_set_rps_idle)? If so, then it's not a real timeout but BIOS has left the force-on flag set and we could just skip calling vlv_force_gfx_clock(true) in that case.

If the HW people can confirm that the above isn't needed then I'm also ok to remove it.

drivers/gpu/drm/i915/i915_drv.c int vlv_force_gfx_clock(struct drm_i915_private *dev_priv, bool force_on) · line 1214

Quoted 3 lines
drivers/gpu/drm/i915/i915_drv.c +0 -0
 	val = I915_READ(VLV_GTLC_SURVIVABILITY_REG);
 	val &= ~VLV_GFX_CLK_FORCE_ON_BIT;

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

Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] drm/i915/vlv: remove wait for previous GFX clk disable request

In reply to Jesse Barnes
Quoted 33 lines · Jesse Barnes

Looks like it was introduced in:

commit 650ad970a39f8b6164fe8613edc150f585315289

Author: Imre Deak <[email protected]>
Date:   Fri Apr 18 16:35:02 2014 +0300

drm/i915: vlv: factor out vlv_force_gfx_clock and check for pending force-of

but I'm not sure why. It has caused problems for us in the past (see 85250ddff7a603dfe0ec0503a9e6395f79424f61 and 8d4eee9cd7a170342dc6fbc2ee19ae77031a8cd5) and doesn't seem to be required, so let's just drop it.

References: https://bugs.freedesktop.org/show_bug.cgi?id=89611

---
  drivers/gpu/drm/i915/i915_drv.c | 14 --------------
  1 file changed, 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +0 -5
index 4d6d6f0..c3fdbb0 100644
@@ -1208,21 +1208,7 @@ int vlv_force_gfx_clock(struct drm_i915_private *dev_priv, bool force_on)
  	u32 val;
  	int err;
 
-	val = I915_READ(VLV_GTLC_SURVIVABILITY_REG);
-
  #define COND (I915_READ(VLV_GTLC_SURVIVABILITY_REG) & VLV_GFX_CLK_STATUS_BIT)
-	/* Wait for a previous force-off to settle */
-	if (force_on && !IS_CHERRYVIEW(dev_priv->dev)) {
-		/* WARN_ON only for the Valleyview */

drivers/gpu/drm/i915/i915_drv.c int vlv_force_gfx_clock(struct drm_i915_private *dev_priv, bool force_on) · line 1212

Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.c +0 -9
-		WARN_ON(!!(val & VLV_GFX_CLK_FORCE_ON_BIT) == force_on);
-
-		err = wait_for(!COND, 20);
-		if (err) {
-			DRM_ERROR("timeout waiting for GFX clock force-off (%08x)\n",
-				  I915_READ(VLV_GTLC_SURVIVABILITY_REG));
-			return err;
-		}
-	}
 

I agree, I do not think we need to wait for previous Gfx clk force-off.
Also, I do not see any race condition happening between diff Gfx force clk in driver. Lets just drop it :)

drivers/gpu/drm/i915/i915_drv.c int vlv_force_gfx_clock(struct drm_i915_private *dev_priv, bool force_on) · line 1214

Quoted 2 lines
drivers/gpu/drm/i915/i915_drv.c +0 -0
  	val = I915_READ(VLV_GTLC_SURVIVABILITY_REG);
  	val &= ~VLV_GFX_CLK_FORCE_ON_BIT;

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

Tested-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] drm/i915/vlv: remove wait for previous GFX clk disable request

In reply to Jesse Barnes
Quoted 9 lines · Jesse Barnes <jbarnes <at> virtuousgeek.org> writes:

Looks like it was introduced in:

commit 650ad970a39f8b6164fe8613edc150f585315289

Author: Imre Deak <imre.deak <at> intel.com>
Date:   Fri Apr 18 16:35:02 2014 +0300

drm/i915: vlv: factor out vlv_force_gfx_clock and check for pending force-of

Quoted 7 lines

but I'm not sure why. It has caused problems for us in the past (see 85250ddff7a603dfe0ec0503a9e6395f79424f61 and 8d4eee9cd7a170342dc6fbc2ee19ae77031a8cd5) and doesn't seem to be required, so let's just drop it.

References: https://bugs.freedesktop.org/show_bug.cgi?id=89611
Signed-off-by: Jesse Barnes <jbarnes <at> virtuousgeek.org>

Thanks Jesse,

With this and 1/2 applied I was able to suspend/resume twice in a row successfully on a MinnowBoard MAX dual-core (E3825) with the 0.78 firmware.

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

maintainer
#5 lore raw

Re: [PATCH 2/2] drm/i915/vlv: remove wait for previous GFX clk disable request

Quoted 19 lines · Darren Hart
Quoted 9 lines · Jesse Barnes <jbarnes <at> virtuousgeek.org> writes:

Looks like it was introduced in:

commit 650ad970a39f8b6164fe8613edc150f585315289

Author: Imre Deak <imre.deak <at> intel.com>
Date:   Fri Apr 18 16:35:02 2014 +0300

drm/i915: vlv: factor out vlv_force_gfx_clock and check for pending force-of

Quoted 7 lines

but I'm not sure why. It has caused problems for us in the past (see 85250ddff7a603dfe0ec0503a9e6395f79424f61 and 8d4eee9cd7a170342dc6fbc2ee19ae77031a8cd5) and doesn't seem to be required, so let's just drop it.

References: https://bugs.freedesktop.org/show_bug.cgi?id=89611
Signed-off-by: Jesse Barnes <jbarnes <at> virtuousgeek.org>

Quoted 7 lines

Thanks Jesse,

With this and 1/2 applied I was able to suspend/resume twice in a row successfully on a MinnowBoard MAX dual-core (E3825) with the 0.78 firmware.

Both patches pushed to drm-intel-fixes, along with a cherry-pick of 85250ddff7a6 ("drm/i915/chv: Remove Wait for a previous gfx force-off") from drm-next to avoid conflicts, all cc: stable. Thanks for the patches, review, and testing.

BR,
Jani.

Quoted 5 lines

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

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer Tested-by Darren Hart on v1 1/2
#6 lore raw
In reply to Jesse Barnes
Quoted 7 lines · Jesse Barnes

Some BIOSes (e.g. the one on the Minnowboard) don't save/restore this reg. If it's unlocked, we can just restore the previous value, and if it's locked (in case the BIOS re-programmed it for us) the write will be ignored and we'll still have "did it move" sanity check in the PM code to warn us if something is still amiss.

References: https://bugs.freedesktop.org/show_bug.cgi?id=89611

Both patches

Quoted 45 lines
---
 drivers/gpu/drm/i915/i915_drv.c | 2 ++
 drivers/gpu/drm/i915/i915_drv.h | 1 +
 2 files changed, 3 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index c1a3cdb5..4d6d6f0 100644
@@ -1104,6 +1104,7 @@ static void vlv_save_gunit_s0ix_state(struct drm_i915_private *dev_priv)
 	/* Gunit-Display CZ domain, 0x182028-0x1821CF */
 	s->gu_ctl0		= I915_READ(VLV_GU_CTL0);
 	s->gu_ctl1		= I915_READ(VLV_GU_CTL1);
+	s->pcbr			= I915_READ(VLV_PCBR);
 	s->clock_gate_dis2	= I915_READ(VLV_GUNIT_CLOCK_GATE2);
 
 	/*
@@ -1198,6 +1199,7 @@ static void vlv_restore_gunit_s0ix_state(struct drm_i915_private *dev_priv)
 	/* Gunit-Display CZ domain, 0x182028-0x1821CF */
 	I915_WRITE(VLV_GU_CTL0,			s->gu_ctl0);
 	I915_WRITE(VLV_GU_CTL1,			s->gu_ctl1);
+	I915_WRITE(VLV_PCBR,			s->pcbr);
 	I915_WRITE(VLV_GUNIT_CLOCK_GATE2,	s->clock_gate_dis2);
 }
 
drivers/gpu/drm/i915/i915_drv.h +1 -0
index b13c552..f3ac683 100644
@@ -994,6 +994,7 @@ struct vlv_s0ix_state {
 	/* Display 2 CZ domain */
 	u32 gu_ctl0;
 	u32 gu_ctl1;
+	u32 pcbr;
 	u32 clock_gate_dis2;
 };
 
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/2
#7 lore raw
In reply to Jesse Barnes
Quoted 8 lines · Jesse Barnes

Some BIOSes (e.g. the one on the Minnowboard) don't save/restore this reg. If it's unlocked, we can just restore the previous value, and if it's locked (in case the BIOS re-programmed it for us) the write will be ignored and we'll still have "did it move" sanity check in the PM code to warn us if something is still amiss.

References: https://bugs.freedesktop.org/show_bug.cgi?id=89611

Yea, the BIOS is supposed to program this reg according to the Gunit doc, but we can't have any guarantee anyway.. I guess this is a problem only for S3, but I can't see any problem saving/restoring it also during s0ix, so:

Quoted 30 lines
---
 drivers/gpu/drm/i915/i915_drv.c | 2 ++
 drivers/gpu/drm/i915/i915_drv.h | 1 +
 2 files changed, 3 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index c1a3cdb5..4d6d6f0 100644
@@ -1104,6 +1104,7 @@ static void vlv_save_gunit_s0ix_state(struct drm_i915_private *dev_priv)
 	/* Gunit-Display CZ domain, 0x182028-0x1821CF */
 	s->gu_ctl0		= I915_READ(VLV_GU_CTL0);
 	s->gu_ctl1		= I915_READ(VLV_GU_CTL1);
+	s->pcbr			= I915_READ(VLV_PCBR);
 	s->clock_gate_dis2	= I915_READ(VLV_GUNIT_CLOCK_GATE2);
 
 	/*
@@ -1198,6 +1199,7 @@ static void vlv_restore_gunit_s0ix_state(struct drm_i915_private *dev_priv)
 	/* Gunit-Display CZ domain, 0x182028-0x1821CF */
 	I915_WRITE(VLV_GU_CTL0,			s->gu_ctl0);
 	I915_WRITE(VLV_GU_CTL1,			s->gu_ctl1);
+	I915_WRITE(VLV_PCBR,			s->pcbr);
 	I915_WRITE(VLV_GUNIT_CLOCK_GATE2,	s->clock_gate_dis2);
 }
 
drivers/gpu/drm/i915/i915_drv.h +0 -0
index b13c552..f3ac683 100644

drivers/gpu/drm/i915/i915_drv.h struct vlv_s0ix_state { · line 1000

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -994,6 +994,7 @@ struct vlv_s0ix_state {
 	/* Display 2 CZ domain */
 	u32 gu_ctl0;
 	u32 gu_ctl1;
+	u32 pcbr;
 	u32 clock_gate_dis2;
 };
 

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

Reviewed-by on v1 1/2
#8 lore raw
In reply to Jesse Barnes
Quoted 5 lines · Jesse Barnes

Some BIOSes (e.g. the one on the Minnowboard) don't save/restore this reg. If it's unlocked, we can just restore the previous value, and if it's locked (in case the BIOS re-programmed it for us) the write will be ignored and we'll still have "did it move" sanity check in the PM code to warn us if something is still amiss.

Looks fine to me

Quoted 32 lines

References: https://bugs.freedesktop.org/show_bug.cgi?id=89611

---
  drivers/gpu/drm/i915/i915_drv.c | 2 ++
  drivers/gpu/drm/i915/i915_drv.h | 1 +
  2 files changed, 3 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index c1a3cdb5..4d6d6f0 100644
@@ -1104,6 +1104,7 @@ static void vlv_save_gunit_s0ix_state(struct drm_i915_private *dev_priv)
  	/* Gunit-Display CZ domain, 0x182028-0x1821CF */
  	s->gu_ctl0		= I915_READ(VLV_GU_CTL0);
  	s->gu_ctl1		= I915_READ(VLV_GU_CTL1);
+	s->pcbr			= I915_READ(VLV_PCBR);
  	s->clock_gate_dis2	= I915_READ(VLV_GUNIT_CLOCK_GATE2);
 
  	/*
@@ -1198,6 +1199,7 @@ static void vlv_restore_gunit_s0ix_state(struct drm_i915_private *dev_priv)
  	/* Gunit-Display CZ domain, 0x182028-0x1821CF */
  	I915_WRITE(VLV_GU_CTL0,			s->gu_ctl0);
  	I915_WRITE(VLV_GU_CTL1,			s->gu_ctl1);
+	I915_WRITE(VLV_PCBR,			s->pcbr);
  	I915_WRITE(VLV_GUNIT_CLOCK_GATE2,	s->clock_gate_dis2);
  }
 
drivers/gpu/drm/i915/i915_drv.h +0 -0
index b13c552..f3ac683 100644

drivers/gpu/drm/i915/i915_drv.h struct vlv_s0ix_state { · line 1000

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -994,6 +994,7 @@ struct vlv_s0ix_state {
  	/* Display 2 CZ domain */
  	u32 gu_ctl0;
  	u32 gu_ctl1;
+	u32 pcbr;
  	u32 clock_gate_dis2;
  };
 

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