diff mbox

[4/7] drm/i915: PCH_NOP suspend/resume

Message ID 1365192765-3485-4-git-send-email-ben@bwidawsk.net (mailing list archive)
State New, archived
Headers show

Commit Message

Ben Widawsky April 5, 2013, 8:12 p.m. UTC
More registers we can't write.

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_suspend.c | 58 +++++++++++++++++++++++++++----------
 1 file changed, 42 insertions(+), 16 deletions(-)

Comments

Daniel Vetter April 6, 2013, 5:41 p.m. UTC | #1
On Fri, Apr 05, 2013 at 01:12:42PM -0700, Ben Widawsky wrote:
> More registers we can't write.
> 
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>

Fixed up a minor bug (at least I think it's one) in the irq uninstall
code. Note that this is also run on gpu hangs and resume, so relevant.

Also there's been a little conflict with Paulo's SDE irq handling fix in
-fixes. I recommend to base all feature work on top of -nightly to avoid
such issues. If there'll be a conflict when the patch applies only to
-nightly, but not dinq, I can fix this up when applying.

Can you please check whether I didn't break the PCH_NOP support?

Thanks, Daniel
> ---
>  drivers/gpu/drm/i915/i915_suspend.c | 58 +++++++++++++++++++++++++++----------
>  1 file changed, 42 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c
> index 41f0fde..7f58c82 100644
> --- a/drivers/gpu/drm/i915/i915_suspend.c
> +++ b/drivers/gpu/drm/i915/i915_suspend.c
> @@ -334,11 +334,19 @@ int i915_save_state(struct drm_device *dev)
>  
>  	mutex_lock(&dev->struct_mutex);
>  
> -	i915_save_display(dev);
> +	if (!HAS_PCH_NOP(dev))
> +		i915_save_display(dev);
>  
>  	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
>  		/* Interrupt state */
> -		if (HAS_PCH_SPLIT(dev)) {
> +		if (HAS_PCH_NOP(dev)) {
> +			dev_priv->regfile.saveDEIER = I915_READ(DEIER);
> +			dev_priv->regfile.saveDEIMR = I915_READ(DEIMR);
> +			dev_priv->regfile.saveGTIER = I915_READ(GTIER);
> +			dev_priv->regfile.saveGTIMR = I915_READ(GTIMR);
> +			dev_priv->regfile.saveMCHBAR_RENDER_STANDBY =
> +				I915_READ(RSTDBYCTL);
> +		} else if (HAS_PCH_SPLIT(dev)) {
>  			dev_priv->regfile.saveDEIER = I915_READ(DEIER);
>  			dev_priv->regfile.saveDEIMR = I915_READ(DEIMR);
>  			dev_priv->regfile.saveGTIER = I915_READ(GTIER);
> @@ -362,13 +370,19 @@ int i915_save_state(struct drm_device *dev)
>  	/* Memory Arbitration state */
>  	dev_priv->regfile.saveMI_ARB_STATE = I915_READ(MI_ARB_STATE);
>  
> -	/* Scratch space */
> -	for (i = 0; i < 16; i++) {
> -		dev_priv->regfile.saveSWF0[i] = I915_READ(SWF00 + (i << 2));
> -		dev_priv->regfile.saveSWF1[i] = I915_READ(SWF10 + (i << 2));
> +	if (!HAS_PCH_NOP(dev)) {
> +		/* Scratch space
> +		 * XXX: Do we really need this for kms? */
> +		for (i = 0; i < 16; i++) {
> +			dev_priv->regfile.saveSWF0[i] =
> +				I915_READ(SWF00 + (i << 2));
> +			dev_priv->regfile.saveSWF1[i] =
> +				I915_READ(SWF10 + (i << 2));
> +		}
> +		for (i = 0; i < 3; i++)
> +			dev_priv->regfile.saveSWF2[i] =
> +				I915_READ(SWF30 + (i << 2));
>  	}
> -	for (i = 0; i < 3; i++)
> -		dev_priv->regfile.saveSWF2[i] = I915_READ(SWF30 + (i << 2));
>  
>  	mutex_unlock(&dev->struct_mutex);
>  
> @@ -384,11 +398,17 @@ int i915_restore_state(struct drm_device *dev)
>  
>  	mutex_lock(&dev->struct_mutex);
>  
> -	i915_restore_display(dev);
> +	if (!HAS_PCH_NOP(dev))
> +		i915_restore_display(dev);
>  
>  	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
>  		/* Interrupt state */
> -		if (HAS_PCH_SPLIT(dev)) {
> +		if (HAS_PCH_NOP(dev)) {
> +			I915_WRITE(DEIER, dev_priv->regfile.saveDEIER);
> +			I915_WRITE(DEIMR, dev_priv->regfile.saveDEIMR);
> +			I915_WRITE(GTIER, dev_priv->regfile.saveGTIER);
> +			I915_WRITE(GTIMR, dev_priv->regfile.saveGTIMR);
> +		} else if (HAS_PCH_SPLIT(dev)) {
>  			I915_WRITE(DEIER, dev_priv->regfile.saveDEIER);
>  			I915_WRITE(DEIMR, dev_priv->regfile.saveDEIMR);
>  			I915_WRITE(GTIER, dev_priv->regfile.saveGTIER);
> @@ -408,16 +428,22 @@ int i915_restore_state(struct drm_device *dev)
>  	/* Memory arbitration state */
>  	I915_WRITE(MI_ARB_STATE, dev_priv->regfile.saveMI_ARB_STATE | 0xffff0000);
>  
> -	for (i = 0; i < 16; i++) {
> -		I915_WRITE(SWF00 + (i << 2), dev_priv->regfile.saveSWF0[i]);
> -		I915_WRITE(SWF10 + (i << 2), dev_priv->regfile.saveSWF1[i]);
> +	if (!HAS_PCH_NOP(dev)) {
> +		for (i = 0; i < 16; i++) {
> +			I915_WRITE(SWF00 + (i << 2),
> +				   dev_priv->regfile.saveSWF0[i]);
> +			I915_WRITE(SWF10 + (i << 2),
> +				   dev_priv->regfile.saveSWF1[i]);
> +		}
> +		for (i = 0; i < 3; i++)
> +			I915_WRITE(SWF30 + (i << 2),
> +				   dev_priv->regfile.saveSWF2[i]);
>  	}
> -	for (i = 0; i < 3; i++)
> -		I915_WRITE(SWF30 + (i << 2), dev_priv->regfile.saveSWF2[i]);
>  
>  	mutex_unlock(&dev->struct_mutex);
>  
> -	intel_i2c_reset(dev);
> +	if (!HAS_PCH_NOP(dev))
> +		intel_i2c_reset(dev);
>  
>  	return 0;
>  }
> -- 
> 1.8.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter April 8, 2013, 6:57 p.m. UTC | #2
On Sat, Apr 06, 2013 at 07:41:44PM +0200, Daniel Vetter wrote:
> On Fri, Apr 05, 2013 at 01:12:42PM -0700, Ben Widawsky wrote:
> > More registers we can't write.
> > 
> > Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
> 
> Fixed up a minor bug (at least I think it's one) in the irq uninstall
> code. Note that this is also run on gpu hangs and resume, so relevant.
> 
> Also there's been a little conflict with Paulo's SDE irq handling fix in
> -fixes. I recommend to base all feature work on top of -nightly to avoid
> such issues. If there'll be a conflict when the patch applies only to
> -nightly, but not dinq, I can fix this up when applying.

Ok, I've embarassed myself here a bit and fixed up the ilk irq handler,
which isn't run at all on ivb. I've rectified that again.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c
index 41f0fde..7f58c82 100644
--- a/drivers/gpu/drm/i915/i915_suspend.c
+++ b/drivers/gpu/drm/i915/i915_suspend.c
@@ -334,11 +334,19 @@  int i915_save_state(struct drm_device *dev)
 
 	mutex_lock(&dev->struct_mutex);
 
-	i915_save_display(dev);
+	if (!HAS_PCH_NOP(dev))
+		i915_save_display(dev);
 
 	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
 		/* Interrupt state */
-		if (HAS_PCH_SPLIT(dev)) {
+		if (HAS_PCH_NOP(dev)) {
+			dev_priv->regfile.saveDEIER = I915_READ(DEIER);
+			dev_priv->regfile.saveDEIMR = I915_READ(DEIMR);
+			dev_priv->regfile.saveGTIER = I915_READ(GTIER);
+			dev_priv->regfile.saveGTIMR = I915_READ(GTIMR);
+			dev_priv->regfile.saveMCHBAR_RENDER_STANDBY =
+				I915_READ(RSTDBYCTL);
+		} else if (HAS_PCH_SPLIT(dev)) {
 			dev_priv->regfile.saveDEIER = I915_READ(DEIER);
 			dev_priv->regfile.saveDEIMR = I915_READ(DEIMR);
 			dev_priv->regfile.saveGTIER = I915_READ(GTIER);
@@ -362,13 +370,19 @@  int i915_save_state(struct drm_device *dev)
 	/* Memory Arbitration state */
 	dev_priv->regfile.saveMI_ARB_STATE = I915_READ(MI_ARB_STATE);
 
-	/* Scratch space */
-	for (i = 0; i < 16; i++) {
-		dev_priv->regfile.saveSWF0[i] = I915_READ(SWF00 + (i << 2));
-		dev_priv->regfile.saveSWF1[i] = I915_READ(SWF10 + (i << 2));
+	if (!HAS_PCH_NOP(dev)) {
+		/* Scratch space
+		 * XXX: Do we really need this for kms? */
+		for (i = 0; i < 16; i++) {
+			dev_priv->regfile.saveSWF0[i] =
+				I915_READ(SWF00 + (i << 2));
+			dev_priv->regfile.saveSWF1[i] =
+				I915_READ(SWF10 + (i << 2));
+		}
+		for (i = 0; i < 3; i++)
+			dev_priv->regfile.saveSWF2[i] =
+				I915_READ(SWF30 + (i << 2));
 	}
-	for (i = 0; i < 3; i++)
-		dev_priv->regfile.saveSWF2[i] = I915_READ(SWF30 + (i << 2));
 
 	mutex_unlock(&dev->struct_mutex);
 
@@ -384,11 +398,17 @@  int i915_restore_state(struct drm_device *dev)
 
 	mutex_lock(&dev->struct_mutex);
 
-	i915_restore_display(dev);
+	if (!HAS_PCH_NOP(dev))
+		i915_restore_display(dev);
 
 	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
 		/* Interrupt state */
-		if (HAS_PCH_SPLIT(dev)) {
+		if (HAS_PCH_NOP(dev)) {
+			I915_WRITE(DEIER, dev_priv->regfile.saveDEIER);
+			I915_WRITE(DEIMR, dev_priv->regfile.saveDEIMR);
+			I915_WRITE(GTIER, dev_priv->regfile.saveGTIER);
+			I915_WRITE(GTIMR, dev_priv->regfile.saveGTIMR);
+		} else if (HAS_PCH_SPLIT(dev)) {
 			I915_WRITE(DEIER, dev_priv->regfile.saveDEIER);
 			I915_WRITE(DEIMR, dev_priv->regfile.saveDEIMR);
 			I915_WRITE(GTIER, dev_priv->regfile.saveGTIER);
@@ -408,16 +428,22 @@  int i915_restore_state(struct drm_device *dev)
 	/* Memory arbitration state */
 	I915_WRITE(MI_ARB_STATE, dev_priv->regfile.saveMI_ARB_STATE | 0xffff0000);
 
-	for (i = 0; i < 16; i++) {
-		I915_WRITE(SWF00 + (i << 2), dev_priv->regfile.saveSWF0[i]);
-		I915_WRITE(SWF10 + (i << 2), dev_priv->regfile.saveSWF1[i]);
+	if (!HAS_PCH_NOP(dev)) {
+		for (i = 0; i < 16; i++) {
+			I915_WRITE(SWF00 + (i << 2),
+				   dev_priv->regfile.saveSWF0[i]);
+			I915_WRITE(SWF10 + (i << 2),
+				   dev_priv->regfile.saveSWF1[i]);
+		}
+		for (i = 0; i < 3; i++)
+			I915_WRITE(SWF30 + (i << 2),
+				   dev_priv->regfile.saveSWF2[i]);
 	}
-	for (i = 0; i < 3; i++)
-		I915_WRITE(SWF30 + (i << 2), dev_priv->regfile.saveSWF2[i]);
 
 	mutex_unlock(&dev->struct_mutex);
 
-	intel_i2c_reset(dev);
+	if (!HAS_PCH_NOP(dev))
+		intel_i2c_reset(dev);
 
 	return 0;
 }