Skip to contentSkip to conversation

drm/i915: HSW: allow PCH clock gating for suspend

PATCH Superseded Imre Deak 4 participants 9 messages Apr 16, 2013 – May 9, 2013

Subsystems (2)
lore
Share & tools
lore

Imre Deak

author
#0 lore raw

PATCH 1/1 drm/i915: HSW: allow PCH clock gating for suspend

For the device to enter D3 we should enable PCH clock gating.

---
 drivers/gpu/drm/i915/i915_drv.c      |    2 ++
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    5 +++++
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 drivers/gpu/drm/i915/intel_pm.c      |   18 ++++++++++++++++++
 5 files changed, 27 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index bddb9a5..e9a82f1 100644
@@ -521,6 +521,8 @@ static int i915_drm_freeze(struct drm_device *dev)
 		 */
 		list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
 			dev_priv->display.crtc_disable(crtc);
+
+		intel_modeset_suspend_hw(dev);
 	}
 
 	i915_save_state(dev);
drivers/gpu/drm/i915/i915_drv.h +1 -0
index b5a495a..e549e6c 100644
@@ -1831,6 +1831,7 @@ static inline void intel_unregister_dsm_handler(void) { return; }
 
 /* modesetting */
 extern void intel_modeset_init_hw(struct drm_device *dev);
+extern void intel_modeset_suspend_hw(struct drm_device *dev);
 extern void intel_modeset_init(struct drm_device *dev);
 extern void intel_modeset_gem_init(struct drm_device *dev);
 extern void intel_modeset_cleanup(struct drm_device *dev);
drivers/gpu/drm/i915/intel_display.c +5 -0
index 457a0a0..e9192bf 100644
@@ -8984,6 +8984,11 @@ void intel_modeset_init_hw(struct drm_device *dev)
 	mutex_unlock(&dev->struct_mutex);
 }
 
+void intel_modeset_suspend_hw(struct drm_device *dev)
+{
+	intel_suspend_hw(dev);
+}
+
 void intel_modeset_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
drivers/gpu/drm/i915/intel_drv.h +1 -0
index d7bd031..8b29897 100644
@@ -652,6 +652,7 @@ extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
 #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
 
 extern void intel_init_clock_gating(struct drm_device *dev);
+extern void intel_suspend_hw(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
 			    struct drm_display_mode *mode);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
drivers/gpu/drm/i915/intel_pm.c +18 -0
index baea4fc..3567881 100644
@@ -3735,6 +3735,18 @@ static void lpt_init_clock_gating(struct drm_device *dev)
 			   PCH_LP_PARTITION_LEVEL_DISABLE);
 }
 
+static void lpt_allow_clock_gating(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	if (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
+		uint32_t val = I915_READ(SOUTH_DSPCLK_GATE_D);
+
+		val &= ~PCH_LP_PARTITION_LEVEL_DISABLE;
+		I915_WRITE(SOUTH_DSPCLK_GATE_D, val);
+	}
+}
+
 static void haswell_init_clock_gating(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -4085,6 +4097,12 @@ void intel_init_clock_gating(struct drm_device *dev)
 	dev_priv->display.init_clock_gating(dev);
 }
 
+void intel_suspend_hw(struct drm_device *dev)
+{
+	if (IS_HASWELL(dev))
+		lpt_allow_clock_gating(dev);
+}
+
 void intel_set_power_well(struct drm_device *dev, bool enable)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 41 lines · Imre Deak

For the device to enter D3 we should enable PCH clock gating.

---
 drivers/gpu/drm/i915/i915_drv.c      |    2 ++
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    5 +++++
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 drivers/gpu/drm/i915/intel_pm.c      |   18 ++++++++++++++++++
 5 files changed, 27 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index bddb9a5..e9a82f1 100644
@@ -521,6 +521,8 @@ static int i915_drm_freeze(struct drm_device *dev)
 		 */
 		list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
 			dev_priv->display.crtc_disable(crtc);
+
+		intel_modeset_suspend_hw(dev);
 	}
 
 	i915_save_state(dev);
drivers/gpu/drm/i915/i915_drv.h +1 -0
index b5a495a..e549e6c 100644
@@ -1831,6 +1831,7 @@ static inline void intel_unregister_dsm_handler(void) { return; }
 
 /* modesetting */
 extern void intel_modeset_init_hw(struct drm_device *dev);
+extern void intel_modeset_suspend_hw(struct drm_device *dev);
 extern void intel_modeset_init(struct drm_device *dev);
 extern void intel_modeset_gem_init(struct drm_device *dev);
 extern void intel_modeset_cleanup(struct drm_device *dev);
drivers/gpu/drm/i915/intel_display.c +0 -0
index 457a0a0..e9192bf 100644

drivers/gpu/drm/i915/intel_display.c void intel_modeset_init_hw(struct drm_device *dev) · line 8991

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +5 -0
@@ -8984,6 +8984,11 @@ void intel_modeset_init_hw(struct drm_device *dev)
 	mutex_unlock(&dev->struct_mutex);
 }
 
+void intel_modeset_suspend_hw(struct drm_device *dev)
+{
+	intel_suspend_hw(dev);
+}
+

Why this extra level of indirection?

Quoted 23 lines
drivers/gpu/drm/i915/intel_display.c +0 -0
 void intel_modeset_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
drivers/gpu/drm/i915/intel_drv.h +1 -0
index d7bd031..8b29897 100644
@@ -652,6 +652,7 @@ extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
 #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
 
 extern void intel_init_clock_gating(struct drm_device *dev);
+extern void intel_suspend_hw(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
 			    struct drm_display_mode *mode);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
drivers/gpu/drm/i915/intel_pm.c +0 -0
index baea4fc..3567881 100644
@@ -3735,6 +3735,18 @@ static void lpt_init_clock_gating(struct drm_device *dev)
 			   PCH_LP_PARTITION_LEVEL_DISABLE);
 }
 

drivers/gpu/drm/i915/intel_pm.c static void lpt_init_clock_gating(struct drm_device *dev) · line 3747

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+static void lpt_allow_clock_gating(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	if (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
+		uint32_t val = I915_READ(SOUTH_DSPCLK_GATE_D);
+
+		val &= ~PCH_LP_PARTITION_LEVEL_DISABLE;
+		I915_WRITE(SOUTH_DSPCLK_GATE_D, val);
+	}

So who sets it back when we resume?

drivers/gpu/drm/i915/intel_pm.c void intel_init_clock_gating(struct drm_device *dev) · line 4103

Quoted 13 lines
drivers/gpu/drm/i915/intel_pm.c +6 -0
+}
+
 static void haswell_init_clock_gating(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -4085,6 +4097,12 @@ void intel_init_clock_gating(struct drm_device *dev)
 	dev_priv->display.init_clock_gating(dev);
 }
 
+void intel_suspend_hw(struct drm_device *dev)
+{
+	if (IS_HASWELL(dev))
+		lpt_allow_clock_gating(dev);

Do you need the HSW check? Isn't the LPT LP check enough?

Quoted 12 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
+}
+
 void intel_set_power_well(struct drm_device *dev, bool enable)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
Signature · 6 lines
1.7.10.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC
author
#2 lore raw
Quoted 45 lines · Ville Syrjälä
Quoted 44 lines · Imre Deak

For the device to enter D3 we should enable PCH clock gating.

---
 drivers/gpu/drm/i915/i915_drv.c      |    2 ++
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    5 +++++
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 drivers/gpu/drm/i915/intel_pm.c      |   18 ++++++++++++++++++
 5 files changed, 27 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index bddb9a5..e9a82f1 100644
@@ -521,6 +521,8 @@ static int i915_drm_freeze(struct drm_device *dev)
 		 */
 		list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
 			dev_priv->display.crtc_disable(crtc);
+
+		intel_modeset_suspend_hw(dev);
 	}
 
 	i915_save_state(dev);
drivers/gpu/drm/i915/i915_drv.h +1 -0
index b5a495a..e549e6c 100644
@@ -1831,6 +1831,7 @@ static inline void intel_unregister_dsm_handler(void) { return; }
 
 /* modesetting */
 extern void intel_modeset_init_hw(struct drm_device *dev);
+extern void intel_modeset_suspend_hw(struct drm_device *dev);
 extern void intel_modeset_init(struct drm_device *dev);
 extern void intel_modeset_gem_init(struct drm_device *dev);
 extern void intel_modeset_cleanup(struct drm_device *dev);
drivers/gpu/drm/i915/intel_display.c +0 -0
index 457a0a0..e9192bf 100644
@@ -8984,6 +8984,11 @@ void intel_modeset_init_hw(struct drm_device *dev)
 	mutex_unlock(&dev->struct_mutex);
 }
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_display.c void intel_modeset_init_hw(struct drm_device *dev) · line 8991

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5 -0
+void intel_modeset_suspend_hw(struct drm_device *dev)
+{
+	intel_suspend_hw(dev);
+}
+

Why this extra level of indirection?

I thought it'd be more symmetric w.r.t.

__i915_drm_thaw->intel_modeset_init_hw().

Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/i915/intel_display.c +0 -0
 void intel_modeset_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
drivers/gpu/drm/i915/intel_drv.h +1 -0
index d7bd031..8b29897 100644
@@ -652,6 +652,7 @@ extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
 #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
 
 extern void intel_init_clock_gating(struct drm_device *dev);
+extern void intel_suspend_hw(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
 			    struct drm_display_mode *mode);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
drivers/gpu/drm/i915/intel_pm.c +0 -0
index baea4fc..3567881 100644
@@ -3735,6 +3735,18 @@ static void lpt_init_clock_gating(struct drm_device *dev)
 			   PCH_LP_PARTITION_LEVEL_DISABLE);
 }
 
Quoted 12 lines

drivers/gpu/drm/i915/intel_pm.c static void lpt_init_clock_gating(struct drm_device *dev) · line 3747

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+static void lpt_allow_clock_gating(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	if (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
+		uint32_t val = I915_READ(SOUTH_DSPCLK_GATE_D);
+
+		val &= ~PCH_LP_PARTITION_LEVEL_DISABLE;
+		I915_WRITE(SOUTH_DSPCLK_GATE_D, val);
+	}

So who sets it back when we resume?

intel_modeset_init_hw()->intel_init_clock_gating()

Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
+}
+
 static void haswell_init_clock_gating(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -4085,6 +4097,12 @@ void intel_init_clock_gating(struct drm_device *dev)
 	dev_priv->display.init_clock_gating(dev);
 }
 
Quoted 6 lines

drivers/gpu/drm/i915/intel_pm.c void intel_init_clock_gating(struct drm_device *dev) · line 4103

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +4 -0
+void intel_suspend_hw(struct drm_device *dev)
+{
+	if (IS_HASWELL(dev))
+		lpt_allow_clock_gating(dev);

Do you need the HSW check? Isn't the LPT LP check enough?

Not sure. According to the spec this is a workaround for HSW/LPT.

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
+}
+
 void intel_set_power_well(struct drm_device *dev, bool enable)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
Signature · 1 line
1.7.10.4
Quoted 5 lines
Quoted 4 lines

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

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

#3 lore raw

2013/4/16 Imre Deak <[email protected]>:

Quoted 106 lines · Ville Syrjälä
Quoted 45 lines · Imre Deak
Quoted 44 lines

For the device to enter D3 we should enable PCH clock gating.

---
 drivers/gpu/drm/i915/i915_drv.c      |    2 ++
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    5 +++++
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 drivers/gpu/drm/i915/intel_pm.c      |   18 ++++++++++++++++++
 5 files changed, 27 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index bddb9a5..e9a82f1 100644
@@ -521,6 +521,8 @@ static int i915_drm_freeze(struct drm_device *dev)
             */
            list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
                    dev_priv->display.crtc_disable(crtc);
+
+           intel_modeset_suspend_hw(dev);
    }
 
    i915_save_state(dev);
drivers/gpu/drm/i915/i915_drv.h +1 -0
index b5a495a..e549e6c 100644
@@ -1831,6 +1831,7 @@ static inline void intel_unregister_dsm_handler(void) { return; }
 
 /* modesetting */
 extern void intel_modeset_init_hw(struct drm_device *dev);
+extern void intel_modeset_suspend_hw(struct drm_device *dev);
 extern void intel_modeset_init(struct drm_device *dev);
 extern void intel_modeset_gem_init(struct drm_device *dev);
 extern void intel_modeset_cleanup(struct drm_device *dev);
drivers/gpu/drm/i915/intel_display.c +0 -0
index 457a0a0..e9192bf 100644
@@ -8984,6 +8984,11 @@ void intel_modeset_init_hw(struct drm_device *dev)
    mutex_unlock(&dev->struct_mutex);
 }
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_display.c void intel_modeset_init_hw(struct drm_device *dev) · line 8991

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5 -0
+void intel_modeset_suspend_hw(struct drm_device *dev)
+{
+   intel_suspend_hw(dev);
+}
+

Why this extra level of indirection?

I thought it'd be more symmetric w.r.t.

__i915_drm_thaw->intel_modeset_init_hw().

Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/i915/intel_display.c +0 -0
 void intel_modeset_init(struct drm_device *dev)
 {
    struct drm_i915_private *dev_priv = dev->dev_private;
drivers/gpu/drm/i915/intel_drv.h +1 -0
index d7bd031..8b29897 100644
@@ -652,6 +652,7 @@ extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
 #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
 
 extern void intel_init_clock_gating(struct drm_device *dev);
+extern void intel_suspend_hw(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
                        struct drm_display_mode *mode);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
drivers/gpu/drm/i915/intel_pm.c +0 -0
index baea4fc..3567881 100644
@@ -3735,6 +3735,18 @@ static void lpt_init_clock_gating(struct drm_device *dev)
                       PCH_LP_PARTITION_LEVEL_DISABLE);
 }
 
Quoted 12 lines

drivers/gpu/drm/i915/intel_pm.c static void lpt_init_clock_gating(struct drm_device *dev) · line 3747

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+static void lpt_allow_clock_gating(struct drm_device *dev)
+{
+   struct drm_i915_private *dev_priv = dev->dev_private;
+
+   if (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
+           uint32_t val = I915_READ(SOUTH_DSPCLK_GATE_D);
+
+           val &= ~PCH_LP_PARTITION_LEVEL_DISABLE;
+           I915_WRITE(SOUTH_DSPCLK_GATE_D, val);
+   }

So who sets it back when we resume?

intel_modeset_init_hw()->intel_init_clock_gating()

Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
+}
+
 static void haswell_init_clock_gating(struct drm_device *dev)
 {
    struct drm_i915_private *dev_priv = dev->dev_private;
@@ -4085,6 +4097,12 @@ void intel_init_clock_gating(struct drm_device *dev)
    dev_priv->display.init_clock_gating(dev);
 }
 
Quoted 8 lines
Quoted 6 lines

drivers/gpu/drm/i915/intel_pm.c void intel_init_clock_gating(struct drm_device *dev) · line 4103

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +4 -0
+void intel_suspend_hw(struct drm_device *dev)
+{
+   if (IS_HASWELL(dev))
+           lpt_allow_clock_gating(dev);

Do you need the HSW check? Isn't the LPT LP check enough?

Not sure. According to the spec this is a workaround for HSW/LPT.

I'd check for HAS_PCH_LPT before calling lpt_allow_clock_gating. Let's not forget that, for example, PPT is considered the same as CPT, so any code that's inside a "HAS_PCH_CPT" runs for both SNB and IVB.

Optional bikeshed: maybe rename "lpt_allow_clock_gating" to "lpt_suspend_hw"?

Quoted 16 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_pm.c +2 -1
+}
+
 void intel_set_power_well(struct drm_device *dev, bool enable)
 {
    struct drm_i915_private *dev_priv = dev->dev_private;
--

1.7.10.4

Quoted 5 lines
Quoted 4 lines

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

Quoted 4 lines

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

--
Paulo Zanoni

author
#4 lore raw
Quoted 114 lines · Paulo Zanoni

2013/4/16 Imre Deak <[email protected]>:

Quoted 113 lines · Ville Syrjälä
Quoted 45 lines · Imre Deak
Quoted 44 lines

For the device to enter D3 we should enable PCH clock gating.

---
 drivers/gpu/drm/i915/i915_drv.c      |    2 ++
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    5 +++++
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 drivers/gpu/drm/i915/intel_pm.c      |   18 ++++++++++++++++++
 5 files changed, 27 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index bddb9a5..e9a82f1 100644
@@ -521,6 +521,8 @@ static int i915_drm_freeze(struct drm_device *dev)
             */
            list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
                    dev_priv->display.crtc_disable(crtc);
+
+           intel_modeset_suspend_hw(dev);
    }
 
    i915_save_state(dev);
drivers/gpu/drm/i915/i915_drv.h +1 -0
index b5a495a..e549e6c 100644
@@ -1831,6 +1831,7 @@ static inline void intel_unregister_dsm_handler(void) { return; }
 
 /* modesetting */
 extern void intel_modeset_init_hw(struct drm_device *dev);
+extern void intel_modeset_suspend_hw(struct drm_device *dev);
 extern void intel_modeset_init(struct drm_device *dev);
 extern void intel_modeset_gem_init(struct drm_device *dev);
 extern void intel_modeset_cleanup(struct drm_device *dev);
drivers/gpu/drm/i915/intel_display.c +0 -0
index 457a0a0..e9192bf 100644
@@ -8984,6 +8984,11 @@ void intel_modeset_init_hw(struct drm_device *dev)
    mutex_unlock(&dev->struct_mutex);
 }
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_display.c void intel_modeset_init_hw(struct drm_device *dev) · line 8991

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5 -0
+void intel_modeset_suspend_hw(struct drm_device *dev)
+{
+   intel_suspend_hw(dev);
+}
+

Why this extra level of indirection?

I thought it'd be more symmetric w.r.t.

__i915_drm_thaw->intel_modeset_init_hw().

Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/i915/intel_display.c +0 -0
 void intel_modeset_init(struct drm_device *dev)
 {
    struct drm_i915_private *dev_priv = dev->dev_private;
drivers/gpu/drm/i915/intel_drv.h +1 -0
index d7bd031..8b29897 100644
@@ -652,6 +652,7 @@ extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
 #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
 
 extern void intel_init_clock_gating(struct drm_device *dev);
+extern void intel_suspend_hw(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
                        struct drm_display_mode *mode);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
drivers/gpu/drm/i915/intel_pm.c +0 -0
index baea4fc..3567881 100644
@@ -3735,6 +3735,18 @@ static void lpt_init_clock_gating(struct drm_device *dev)
                       PCH_LP_PARTITION_LEVEL_DISABLE);
 }
 
Quoted 12 lines

drivers/gpu/drm/i915/intel_pm.c static void lpt_init_clock_gating(struct drm_device *dev) · line 3747

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+static void lpt_allow_clock_gating(struct drm_device *dev)
+{
+   struct drm_i915_private *dev_priv = dev->dev_private;
+
+   if (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
+           uint32_t val = I915_READ(SOUTH_DSPCLK_GATE_D);
+
+           val &= ~PCH_LP_PARTITION_LEVEL_DISABLE;
+           I915_WRITE(SOUTH_DSPCLK_GATE_D, val);
+   }

So who sets it back when we resume?

intel_modeset_init_hw()->intel_init_clock_gating()

Quoted 16 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
+}
+
 static void haswell_init_clock_gating(struct drm_device *dev)
 {
    struct drm_i915_private *dev_priv = dev->dev_private;

drivers/gpu/drm/i915/intel_pm.c void intel_init_clock_gating(struct drm_device *dev) · line 4103

Quoted 7 lines
drivers/gpu/drm/i915/intel_pm.c +4 -0
@@ -4085,6 +4097,12 @@ void intel_init_clock_gating(struct drm_device *dev)
    dev_priv->display.init_clock_gating(dev);
 }
 
+void intel_suspend_hw(struct drm_device *dev)
+{
+   if (IS_HASWELL(dev))
+           lpt_allow_clock_gating(dev);

Do you need the HSW check? Isn't the LPT LP check enough?

Quoted 7 lines
Quoted 1 line

Not sure. According to the spec this is a workaround for HSW/LPT.

I'd check for HAS_PCH_LPT before calling lpt_allow_clock_gating. Let's not forget that, for example, PPT is considered the same as CPT, so any code that's inside a "HAS_PCH_CPT" runs for both SNB and IVB.

Optional bikeshed: maybe rename "lpt_allow_clock_gating" to "lpt_suspend_hw"?

Ok, will change these.

--Imre

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

author
#5 lore raw

PATCH v2 1/1 drm/i915: HSW: allow PCH clock gating for suspend

In reply to Imre Deak

For the device to enter D3 we should enable PCH clock gating.

v2:
- use HAS_PCH_LPT instead of IS_HASWELL (Ville, Paolo)
- rename lpt_allow_clock_gating to lpt_suspend_hw (Paolo)

---
 drivers/gpu/drm/i915/i915_drv.c      |    2 ++
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    5 +++++
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 drivers/gpu/drm/i915/intel_pm.c      |   18 ++++++++++++++++++
 5 files changed, 27 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index 9ebe895..6902219 100644
@@ -525,6 +525,8 @@ static int i915_drm_freeze(struct drm_device *dev)
 		 */
 		list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
 			dev_priv->display.crtc_disable(crtc);
+
+		intel_modeset_suspend_hw(dev);
 	}
 
 	i915_save_state(dev);
drivers/gpu/drm/i915/i915_drv.h +1 -0
index b5a495a..e549e6c 100644
@@ -1831,6 +1831,7 @@ static inline void intel_unregister_dsm_handler(void) { return; }
 
 /* modesetting */
 extern void intel_modeset_init_hw(struct drm_device *dev);
+extern void intel_modeset_suspend_hw(struct drm_device *dev);
 extern void intel_modeset_init(struct drm_device *dev);
 extern void intel_modeset_gem_init(struct drm_device *dev);
 extern void intel_modeset_cleanup(struct drm_device *dev);
drivers/gpu/drm/i915/intel_display.c +5 -0
index dce643c..dec9019 100644
@@ -9004,6 +9004,11 @@ void intel_modeset_init_hw(struct drm_device *dev)
 	mutex_unlock(&dev->struct_mutex);
 }
 
+void intel_modeset_suspend_hw(struct drm_device *dev)
+{
+	intel_suspend_hw(dev);
+}
+
 void intel_modeset_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
drivers/gpu/drm/i915/intel_drv.h +1 -0
index a124e05..3f31b2e 100644
@@ -652,6 +652,7 @@ extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
 #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
 
 extern void intel_init_clock_gating(struct drm_device *dev);
+extern void intel_suspend_hw(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
 			    struct drm_display_mode *mode);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
drivers/gpu/drm/i915/intel_pm.c +18 -0
index f747cb0..8a163d4 100644
@@ -3750,6 +3750,18 @@ static void lpt_init_clock_gating(struct drm_device *dev)
 			   PCH_LP_PARTITION_LEVEL_DISABLE);
 }
 
+static void lpt_suspend_hw(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	if (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
+		uint32_t val = I915_READ(SOUTH_DSPCLK_GATE_D);
+
+		val &= ~PCH_LP_PARTITION_LEVEL_DISABLE;
+		I915_WRITE(SOUTH_DSPCLK_GATE_D, val);
+	}
+}
+
 static void haswell_init_clock_gating(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -4100,6 +4112,12 @@ void intel_init_clock_gating(struct drm_device *dev)
 	dev_priv->display.init_clock_gating(dev);
 }
 
+void intel_suspend_hw(struct drm_device *dev)
+{
+	if (HAS_PCH_LPT(dev))
+		lpt_suspend_hw(dev);
+}
+
 /**
  * We should only use the power well if we explicitly asked the hardware to
  * enable it, so check if it's enabled and also check if we've requested it to
Signature · 1 line
1.7.10.4
Reviewed-by on v2 1/1
#6 lore raw

Hi

2013/4/17 Imre Deak <[email protected]>:

Quoted 6 lines

For the device to enter D3 we should enable PCH clock gating.

v2:
- use HAS_PCH_LPT instead of IS_HASWELL (Ville, Paolo)
- rename lpt_allow_clock_gating to lpt_suspend_hw (Paolo)

s/Paolo/Paulo/ :)
Besides this, the patch looks fine. But I can't test it right now since suspend seems to be broken on my machine, even with nomodeset.

Quoted 101 lines
---
 drivers/gpu/drm/i915/i915_drv.c      |    2 ++
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    5 +++++
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 drivers/gpu/drm/i915/intel_pm.c      |   18 ++++++++++++++++++
 5 files changed, 27 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index 9ebe895..6902219 100644
@@ -525,6 +525,8 @@ static int i915_drm_freeze(struct drm_device *dev)
                 */
                list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
                        dev_priv->display.crtc_disable(crtc);
+
+               intel_modeset_suspend_hw(dev);
        }
 
        i915_save_state(dev);
drivers/gpu/drm/i915/i915_drv.h +1 -0
index b5a495a..e549e6c 100644
@@ -1831,6 +1831,7 @@ static inline void intel_unregister_dsm_handler(void) { return; }
 
 /* modesetting */
 extern void intel_modeset_init_hw(struct drm_device *dev);
+extern void intel_modeset_suspend_hw(struct drm_device *dev);
 extern void intel_modeset_init(struct drm_device *dev);
 extern void intel_modeset_gem_init(struct drm_device *dev);
 extern void intel_modeset_cleanup(struct drm_device *dev);
drivers/gpu/drm/i915/intel_display.c +5 -0
index dce643c..dec9019 100644
@@ -9004,6 +9004,11 @@ void intel_modeset_init_hw(struct drm_device *dev)
        mutex_unlock(&dev->struct_mutex);
 }
 
+void intel_modeset_suspend_hw(struct drm_device *dev)
+{
+       intel_suspend_hw(dev);
+}
+
 void intel_modeset_init(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
drivers/gpu/drm/i915/intel_drv.h +1 -0
index a124e05..3f31b2e 100644
@@ -652,6 +652,7 @@ extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
 #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
 
 extern void intel_init_clock_gating(struct drm_device *dev);
+extern void intel_suspend_hw(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
                            struct drm_display_mode *mode);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
drivers/gpu/drm/i915/intel_pm.c +18 -1
index f747cb0..8a163d4 100644
@@ -3750,6 +3750,18 @@ static void lpt_init_clock_gating(struct drm_device *dev)
                           PCH_LP_PARTITION_LEVEL_DISABLE);
 }
 
+static void lpt_suspend_hw(struct drm_device *dev)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+
+       if (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
+               uint32_t val = I915_READ(SOUTH_DSPCLK_GATE_D);
+
+               val &= ~PCH_LP_PARTITION_LEVEL_DISABLE;
+               I915_WRITE(SOUTH_DSPCLK_GATE_D, val);
+       }
+}
+
 static void haswell_init_clock_gating(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
@@ -4100,6 +4112,12 @@ void intel_init_clock_gating(struct drm_device *dev)
        dev_priv->display.init_clock_gating(dev);
 }
 
+void intel_suspend_hw(struct drm_device *dev)
+{
+       if (HAS_PCH_LPT(dev))
+               lpt_suspend_hw(dev);
+}
+
 /**
  * We should only use the power well if we explicitly asked the hardware to
  * enable it, so check if it's enabled and also check if we've requested it to
--

1.7.10.4

Quoted 4 lines

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

--
Paulo Zanoni

author
#7 lore raw
Quoted 11 lines · Paulo Zanoni

Hi

2013/4/17 Imre Deak <[email protected]>:

Quoted 6 lines

For the device to enter D3 we should enable PCH clock gating.

v2:
- use HAS_PCH_LPT instead of IS_HASWELL (Ville, Paolo)
- rename lpt_allow_clock_gating to lpt_suspend_hw (Paolo)

s/Paolo/Paulo/ :)

Ok, sorry..

Quoted 3 lines

Besides this, the patch looks fine. But I can't test it right now since suspend seems to be broken on my machine, even with nomodeset.

Yes, same here suspend is broken even without loading i915.

Quoted 111 lines
Quoted 102 lines
---
 drivers/gpu/drm/i915/i915_drv.c      |    2 ++
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    5 +++++
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 drivers/gpu/drm/i915/intel_pm.c      |   18 ++++++++++++++++++
 5 files changed, 27 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index 9ebe895..6902219 100644
@@ -525,6 +525,8 @@ static int i915_drm_freeze(struct drm_device *dev)
                 */
                list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
                        dev_priv->display.crtc_disable(crtc);
+
+               intel_modeset_suspend_hw(dev);
        }
 
        i915_save_state(dev);
drivers/gpu/drm/i915/i915_drv.h +1 -0
index b5a495a..e549e6c 100644
@@ -1831,6 +1831,7 @@ static inline void intel_unregister_dsm_handler(void) { return; }
 
 /* modesetting */
 extern void intel_modeset_init_hw(struct drm_device *dev);
+extern void intel_modeset_suspend_hw(struct drm_device *dev);
 extern void intel_modeset_init(struct drm_device *dev);
 extern void intel_modeset_gem_init(struct drm_device *dev);
 extern void intel_modeset_cleanup(struct drm_device *dev);
drivers/gpu/drm/i915/intel_display.c +5 -0
index dce643c..dec9019 100644
@@ -9004,6 +9004,11 @@ void intel_modeset_init_hw(struct drm_device *dev)
        mutex_unlock(&dev->struct_mutex);
 }
 
+void intel_modeset_suspend_hw(struct drm_device *dev)
+{
+       intel_suspend_hw(dev);
+}
+
 void intel_modeset_init(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
drivers/gpu/drm/i915/intel_drv.h +1 -0
index a124e05..3f31b2e 100644
@@ -652,6 +652,7 @@ extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
 #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
 
 extern void intel_init_clock_gating(struct drm_device *dev);
+extern void intel_suspend_hw(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
                            struct drm_display_mode *mode);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
drivers/gpu/drm/i915/intel_pm.c +18 -1
index f747cb0..8a163d4 100644
@@ -3750,6 +3750,18 @@ static void lpt_init_clock_gating(struct drm_device *dev)
                           PCH_LP_PARTITION_LEVEL_DISABLE);
 }
 
+static void lpt_suspend_hw(struct drm_device *dev)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+
+       if (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
+               uint32_t val = I915_READ(SOUTH_DSPCLK_GATE_D);
+
+               val &= ~PCH_LP_PARTITION_LEVEL_DISABLE;
+               I915_WRITE(SOUTH_DSPCLK_GATE_D, val);
+       }
+}
+
 static void haswell_init_clock_gating(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
@@ -4100,6 +4112,12 @@ void intel_init_clock_gating(struct drm_device *dev)
        dev_priv->display.init_clock_gating(dev);
 }
 
+void intel_suspend_hw(struct drm_device *dev)
+{
+       if (HAS_PCH_LPT(dev))
+               lpt_suspend_hw(dev);
+}
+
 /**
  * We should only use the power well if we explicitly asked the hardware to
  * enable it, so check if it's enabled and also check if we've requested it to
--

1.7.10.4

Quoted 4 lines

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

--
Paulo Zanoni

#8 lore raw
In reply to Paulo Zanoni
Quoted 10 lines · Paulo Zanoni

Hi

2013/4/17 Imre Deak <[email protected]>:

Quoted 6 lines

For the device to enter D3 we should enable PCH clock gating.

v2:
- use HAS_PCH_LPT instead of IS_HASWELL (Ville, Paolo)
- rename lpt_allow_clock_gating to lpt_suspend_hw (Paolo)

Quoted 4 lines

s/Paolo/Paulo/ :)
Besides this, the patch looks fine. But I can't test it right now since suspend seems to be broken on my machine, even with nomodeset.

Paulo poked me about this on irc, so queued for -next, thanks for the patch.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch