Skip to contentSkip to conversation

Basic Skylake enabling

PATCH Applied Damien Lespiau 14 participants 286 messages Sep 4, 2014 – May 13, 2015 Page 2 of 3

Subsystems (4)
lore
Share & tools
lore
#148 lore raw

Re: [PATCH 55/89] drm/i915/skl: Gen9 multi-engine forcewake

In reply to Damien Lespiau
Quoted 33 lines · Damien Lespiau

From: Zhe Wang <[email protected]>

Enable multi-engine forcewake for Gen9.

v2: Rebase on top of nightly
Move the register range definitions to intel_uncore.c Whitespace fixes
(Damien)

---
 drivers/gpu/drm/i915/intel_uncore.c | 120 ++++++++++++++++++++++++++++++++++++
 1 file changed, 120 insertions(+)
drivers/gpu/drm/i915/intel_uncore.c +10 -0
index 7b7fc9e..f289f4f 100644
@@ -674,6 +674,34 @@ void assert_force_wake_inactive(struct drm_i915_private *dev_priv)
 	 REG_RANGE((reg), 0x14000, 0x14400) || \
 	 REG_RANGE((reg), 0x22000, 0x24000))
 
+#define FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) \
+	((reg) >= 0xC00 && (reg) < 0x2000)
+
+#define FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg) \
+	(((reg) >= 0x2000 && (reg) < 0x4000) || \
+	((reg) >= 0x5200 && (reg) < 0x8000) || \
+	((reg) >= 0x8300 && (reg) < 0x8500) || \
+	((reg) >= 0x8C00 && (reg) < 0x8D00) || \
+	((reg) >= 0xB000 && (reg) < 0xB480) || \
+	((reg) >= 0xE000 && (reg) < 0xE800))

drivers/gpu/drm/i915/intel_uncore.c void assert_force_wake_inactive(struct drm_i915_private *dev_priv) · line 696

Quoted 10 lines
drivers/gpu/drm/i915/intel_uncore.c +10 -0
+
+#define FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg) \
+	(((reg) >= 0x8800 && (reg) < 0x8A00) || \
+	((reg) >= 0xD000 && (reg) < 0xD800) || \
+	((reg) >= 0x12000 && (reg) < 0x14000) || \
+	((reg) >= 0x1A000 && (reg) < 0x1EA00) || \
+	((reg) >= 0x30000 && (reg) < 0x40000))
+
+#define FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg) \
+	((reg) >= 0x9400 && (reg) < 0x9800)

Please use REG_RANGE for all above.

Quoted 11 lines
drivers/gpu/drm/i915/intel_uncore.c +7 -0
+#define FORCEWAKE_GEN9_BLITTER_RANGE_OFFSET(reg) \
+	((reg) < 0x40000 &&\
+	!FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) && \
+	!FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg) && \
+	!FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg) && \
+	!FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg))
+
 static void
 ilk_dummy_write(struct drm_i915_private *dev_priv)
 {

drivers/gpu/drm/i915/intel_uncore.c chv_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \ · line 839

Quoted 8 lines
drivers/gpu/drm/i915/intel_uncore.c +5 -0
@@ -804,6 +832,43 @@ chv_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \
 	REG_READ_FOOTER; \
 }
 
+#define __gen9_read(x) \
+static u##x \
+gen9_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \
+	REG_READ_HEADER(x); \
+	if (!NEEDS_FORCE_WAKE((dev_priv), (reg)) || \

As gen9 doesn't have FORCEWAKE register, you can save one comparison here if you discard the macro and opencode.

Quoted 44 lines
drivers/gpu/drm/i915/intel_uncore.c +33 -0
+			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg)) { \
+		val = __raw_i915_read##x(dev_priv, reg); \
+	} else { \
+		unsigned fwengine = 0; \
+		if (FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine = FORCEWAKE_RENDER; \
+		} else if (FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine = FORCEWAKE_MEDIA; \
+		} else if (FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine |= FORCEWAKE_RENDER; \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine |= FORCEWAKE_MEDIA; \
+		} else { \
+			if (dev_priv->uncore.fw_blittercount == 0) \
+				fwengine = FORCEWAKE_BLITTER; \
+		} \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_get(dev_priv, fwengine); \
+		val = __raw_i915_read##x(dev_priv, reg); \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_put(dev_priv, fwengine); \
+	} \
+	REG_READ_FOOTER; \
+}
+
+__gen9_read(8)
+__gen9_read(16)
+__gen9_read(32)
+__gen9_read(64)
 __chv_read(8)
 __chv_read(16)
 __chv_read(32)
@@ -825,6 +890,7 @@ __gen4_read(16)
 __gen4_read(32)
 __gen4_read(64)
 
+#undef __gen9_read
 #undef __chv_read
 #undef __vlv_read
 #undef __gen6_read

drivers/gpu/drm/i915/intel_uncore.c chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace) · line 1036

Quoted 9 lines
drivers/gpu/drm/i915/intel_uncore.c +6 -0
@@ -962,6 +1028,46 @@ chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace)
 	REG_WRITE_FOOTER; \
 }
 
+#define __gen9_write(x) \
+static void \
+gen9_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, \
+		bool trace) { \
+	REG_WRITE_HEADER; \
+	if (!NEEDS_FORCE_WAKE((dev_priv), (reg)) || \

ditto

-Mika

Quoted 72 lines
drivers/gpu/drm/i915/intel_uncore.c +48 -0
+			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg)) { \
+		__raw_i915_write##x(dev_priv, reg, val); \
+	} else { \
+		unsigned fwengine = 0; \
+		if (FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine = FORCEWAKE_RENDER; \
+		} else if (FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine = FORCEWAKE_MEDIA; \
+		} else if (FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine |= FORCEWAKE_RENDER; \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine |= FORCEWAKE_MEDIA; \
+		} else { \
+			if (dev_priv->uncore.fw_blittercount == 0) \
+				fwengine = FORCEWAKE_BLITTER; \
+		} \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_get(dev_priv, \
+					fwengine); \
+		__raw_i915_write##x(dev_priv, reg, val); \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_put(dev_priv, \
+					fwengine); \
+	} \
+	REG_WRITE_FOOTER; \
+}
+
+__gen9_write(8)
+__gen9_write(16)
+__gen9_write(32)
+__gen9_write(64)
 __chv_write(8)
 __chv_write(16)
 __chv_write(32)
@@ -987,6 +1093,7 @@ __gen4_write(16)
 __gen4_write(32)
 __gen4_write(64)
 
+#undef __gen9_write
 #undef __chv_write
 #undef __gen8_write
 #undef __hsw_write
@@ -1054,6 +1161,19 @@ void intel_uncore_init(struct drm_device *dev)
 
 	switch (INTEL_INFO(dev)->gen) {
 	default:
+		WARN_ON(1);
+		return;
+	case 9:
+		dev_priv->uncore.funcs.mmio_writeb  = gen9_write8;
+		dev_priv->uncore.funcs.mmio_writew  = gen9_write16;
+		dev_priv->uncore.funcs.mmio_writel  = gen9_write32;
+		dev_priv->uncore.funcs.mmio_writeq  = gen9_write64;
+		dev_priv->uncore.funcs.mmio_readb  = gen9_read8;
+		dev_priv->uncore.funcs.mmio_readw  = gen9_read16;
+		dev_priv->uncore.funcs.mmio_readl  = gen9_read32;
+		dev_priv->uncore.funcs.mmio_readq  = gen9_read64;
+		break;
+	case 8:
 		if (IS_CHERRYVIEW(dev)) {
 			dev_priv->uncore.funcs.mmio_writeb  = chv_write8;
 			dev_priv->uncore.funcs.mmio_writew  = chv_write16;
Signature · 6 lines
1.8.3.1

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

Re: [PATCH 55/89] drm/i915/skl: Gen9 multi-engine forcewake

Quoted 38 lines · Mika Kuoppala
Quoted 36 lines · Damien Lespiau

From: Zhe Wang <[email protected]>

Enable multi-engine forcewake for Gen9.

v2: Rebase on top of nightly
Move the register range definitions to intel_uncore.c Whitespace fixes
(Damien)

---
  drivers/gpu/drm/i915/intel_uncore.c | 120 ++++++++++++++++++++++++++++++++++++
  1 file changed, 120 insertions(+)
drivers/gpu/drm/i915/intel_uncore.c +13 -0
index 7b7fc9e..f289f4f 100644
@@ -674,6 +674,34 @@ void assert_force_wake_inactive(struct drm_i915_private *dev_priv)
  	 REG_RANGE((reg), 0x14000, 0x14400) || \
  	 REG_RANGE((reg), 0x22000, 0x24000))
 
+#define FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) \
+	((reg) >= 0xC00 && (reg) < 0x2000)
+
+#define FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg) \
+	(((reg) >= 0x2000 && (reg) < 0x4000) || \
+	((reg) >= 0x5200 && (reg) < 0x8000) || \
+	((reg) >= 0x8300 && (reg) < 0x8500) || \
+	((reg) >= 0x8C00 && (reg) < 0x8D00) || \
+	((reg) >= 0xB000 && (reg) < 0xB480) || \
+	((reg) >= 0xE000 && (reg) < 0xE800))
+
+#define FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg) \
+	(((reg) >= 0x8800 && (reg) < 0x8A00) || \
Quoted 8 lines

drivers/gpu/drm/i915/intel_uncore.c void assert_force_wake_inactive(struct drm_i915_private *dev_priv) · line 696

Quoted 7 lines
drivers/gpu/drm/i915/intel_uncore.c +7 -0
+	((reg) >= 0xD000 && (reg) < 0xD800) || \
+	((reg) >= 0x12000 && (reg) < 0x14000) || \
+	((reg) >= 0x1A000 && (reg) < 0x1EA00) || \
+	((reg) >= 0x30000 && (reg) < 0x40000))
+
+#define FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg) \
+	((reg) >= 0x9400 && (reg) < 0x9800)

Please use REG_RANGE for all above.

ok, we can change this for these macros.

Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/i915/intel_uncore.c +7 -0
+#define FORCEWAKE_GEN9_BLITTER_RANGE_OFFSET(reg) \
+	((reg) < 0x40000 &&\
+	!FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) && \
+	!FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg) && \
+	!FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg) && \
+	!FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg))
+
  static void
  ilk_dummy_write(struct drm_i915_private *dev_priv)
  {
@@ -804,6 +832,43 @@ chv_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \
  	REG_READ_FOOTER; \
  }
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_uncore.c chv_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \ · line 839

Quoted 5 lines
drivers/gpu/drm/i915/intel_uncore.c +5 -0
+#define __gen9_read(x) \
+static u##x \
+gen9_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \
+	REG_READ_HEADER(x); \
+	if (!NEEDS_FORCE_WAKE((dev_priv), (reg)) || \

As gen9 doesn't have FORCEWAKE register, you can save one comparison here if you discard the macro and opencode.

Hi Mika,
Excuse me, I didn't really get this. can you explain more on it?

Gen9 has 3 separate forcewake registers.
we still have to check for 2 ranges to ensure forcewake is not required
1. >= 0x40000
2. 0xC00-0x1FFF (this range is new and always accessible)

Thanks,
Bob

Quoted 133 lines
Quoted 44 lines
drivers/gpu/drm/i915/intel_uncore.c +33 -0
+			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg)) { \
+		val = __raw_i915_read##x(dev_priv, reg); \
+	} else { \
+		unsigned fwengine = 0; \
+		if (FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine = FORCEWAKE_RENDER; \
+		} else if (FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine = FORCEWAKE_MEDIA; \
+		} else if (FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine |= FORCEWAKE_RENDER; \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine |= FORCEWAKE_MEDIA; \
+		} else { \
+			if (dev_priv->uncore.fw_blittercount == 0) \
+				fwengine = FORCEWAKE_BLITTER; \
+		} \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_get(dev_priv, fwengine); \
+		val = __raw_i915_read##x(dev_priv, reg); \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_put(dev_priv, fwengine); \
+	} \
+	REG_READ_FOOTER; \
+}
+
+__gen9_read(8)
+__gen9_read(16)
+__gen9_read(32)
+__gen9_read(64)
  __chv_read(8)
  __chv_read(16)
  __chv_read(32)
@@ -825,6 +890,7 @@ __gen4_read(16)
  __gen4_read(32)
  __gen4_read(64)
 
+#undef __gen9_read
  #undef __chv_read
  #undef __vlv_read
  #undef __gen6_read

drivers/gpu/drm/i915/intel_uncore.c chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace) · line 1036

Quoted 9 lines
drivers/gpu/drm/i915/intel_uncore.c +6 -0
@@ -962,6 +1028,46 @@ chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace)
  	REG_WRITE_FOOTER; \
  }
 
+#define __gen9_write(x) \
+static void \
+gen9_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, \
+		bool trace) { \
+	REG_WRITE_HEADER; \
+	if (!NEEDS_FORCE_WAKE((dev_priv), (reg)) || \

ditto

-Mika

Quoted 72 lines
drivers/gpu/drm/i915/intel_uncore.c +48 -0
+			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg)) { \
+		__raw_i915_write##x(dev_priv, reg, val); \
+	} else { \
+		unsigned fwengine = 0; \
+		if (FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine = FORCEWAKE_RENDER; \
+		} else if (FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine = FORCEWAKE_MEDIA; \
+		} else if (FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine |= FORCEWAKE_RENDER; \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine |= FORCEWAKE_MEDIA; \
+		} else { \
+			if (dev_priv->uncore.fw_blittercount == 0) \
+				fwengine = FORCEWAKE_BLITTER; \
+		} \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_get(dev_priv, \
+					fwengine); \
+		__raw_i915_write##x(dev_priv, reg, val); \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_put(dev_priv, \
+					fwengine); \
+	} \
+	REG_WRITE_FOOTER; \
+}
+
+__gen9_write(8)
+__gen9_write(16)
+__gen9_write(32)
+__gen9_write(64)
  __chv_write(8)
  __chv_write(16)
  __chv_write(32)
@@ -987,6 +1093,7 @@ __gen4_write(16)
  __gen4_write(32)
  __gen4_write(64)
 
+#undef __gen9_write
  #undef __chv_write
  #undef __gen8_write
  #undef __hsw_write
@@ -1054,6 +1161,19 @@ void intel_uncore_init(struct drm_device *dev)
 
  	switch (INTEL_INFO(dev)->gen) {
  	default:
+		WARN_ON(1);
+		return;
+	case 9:
+		dev_priv->uncore.funcs.mmio_writeb  = gen9_write8;
+		dev_priv->uncore.funcs.mmio_writew  = gen9_write16;
+		dev_priv->uncore.funcs.mmio_writel  = gen9_write32;
+		dev_priv->uncore.funcs.mmio_writeq  = gen9_write64;
+		dev_priv->uncore.funcs.mmio_readb  = gen9_read8;
+		dev_priv->uncore.funcs.mmio_readw  = gen9_read16;
+		dev_priv->uncore.funcs.mmio_readl  = gen9_read32;
+		dev_priv->uncore.funcs.mmio_readq  = gen9_read64;
+		break;
+	case 8:
  		if (IS_CHERRYVIEW(dev)) {
  			dev_priv->uncore.funcs.mmio_writeb  = chv_write8;
  			dev_priv->uncore.funcs.mmio_writew  = chv_write16;
Signature · 6 lines
1.8.3.1

_______________________________________________
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

#150 lore raw

Re: [PATCH 55/89] drm/i915/skl: Gen9 multi-engine forcewake

Quoted 69 lines · Bob Wang
Quoted 38 lines · Mika Kuoppala
Quoted 36 lines · Damien Lespiau

From: Zhe Wang <[email protected]>

Enable multi-engine forcewake for Gen9.

v2: Rebase on top of nightly
Move the register range definitions to intel_uncore.c Whitespace fixes
(Damien)

---
  drivers/gpu/drm/i915/intel_uncore.c | 120 ++++++++++++++++++++++++++++++++++++
  1 file changed, 120 insertions(+)
drivers/gpu/drm/i915/intel_uncore.c +13 -0
index 7b7fc9e..f289f4f 100644
@@ -674,6 +674,34 @@ void assert_force_wake_inactive(struct drm_i915_private *dev_priv)
  	 REG_RANGE((reg), 0x14000, 0x14400) || \
  	 REG_RANGE((reg), 0x22000, 0x24000))
 
+#define FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) \
+	((reg) >= 0xC00 && (reg) < 0x2000)
+
+#define FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg) \
+	(((reg) >= 0x2000 && (reg) < 0x4000) || \
+	((reg) >= 0x5200 && (reg) < 0x8000) || \
+	((reg) >= 0x8300 && (reg) < 0x8500) || \
+	((reg) >= 0x8C00 && (reg) < 0x8D00) || \
+	((reg) >= 0xB000 && (reg) < 0xB480) || \
+	((reg) >= 0xE000 && (reg) < 0xE800))
+
+#define FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg) \
+	(((reg) >= 0x8800 && (reg) < 0x8A00) || \
Quoted 8 lines

drivers/gpu/drm/i915/intel_uncore.c void assert_force_wake_inactive(struct drm_i915_private *dev_priv) · line 696

Quoted 7 lines
drivers/gpu/drm/i915/intel_uncore.c +7 -0
+	((reg) >= 0xD000 && (reg) < 0xD800) || \
+	((reg) >= 0x12000 && (reg) < 0x14000) || \
+	((reg) >= 0x1A000 && (reg) < 0x1EA00) || \
+	((reg) >= 0x30000 && (reg) < 0x40000))
+
+#define FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg) \
+	((reg) >= 0x9400 && (reg) < 0x9800)

Please use REG_RANGE for all above.

ok, we can change this for these macros.

Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/i915/intel_uncore.c +7 -0
+#define FORCEWAKE_GEN9_BLITTER_RANGE_OFFSET(reg) \
+	((reg) < 0x40000 &&\
+	!FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) && \
+	!FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg) && \
+	!FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg) && \
+	!FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg))
+
  static void
  ilk_dummy_write(struct drm_i915_private *dev_priv)
  {
@@ -804,6 +832,43 @@ chv_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \
  	REG_READ_FOOTER; \
  }
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_uncore.c chv_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \ · line 839

Quoted 5 lines
drivers/gpu/drm/i915/intel_uncore.c +5 -0
+#define __gen9_read(x) \
+static u##x \
+gen9_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \
+	REG_READ_HEADER(x); \
+	if (!NEEDS_FORCE_WAKE((dev_priv), (reg)) || \

As gen9 doesn't have FORCEWAKE register, you can save one comparison here if you discard the macro and opencode.

Quoted 7 lines

Hi Mika,
Excuse me, I didn't really get this. can you explain more on it?

Gen9 has 3 separate forcewake registers.
we still have to check for 2 ranges to ensure forcewake is not required
1. >= 0x40000
2. 0xC00-0x1FFF (this range is new and always accessible)

I was a little bit vague on what macro I was talking about.

The macro in question is:

/* We give fast paths for the really cool registers */

#define NEEDS_FORCE_WAKE(dev_priv, reg) \
         ((reg) < 0x40000 && (reg) != FORCEWAKE)

and as we dont have generic FORCEWAKE (0xA18C) on gen9, we end up doing one needless != for each register access.

-Mika

Quoted 135 lines

Thanks,
Bob

Quoted 133 lines
Quoted 44 lines
drivers/gpu/drm/i915/intel_uncore.c +33 -0
+			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg)) { \
+		val = __raw_i915_read##x(dev_priv, reg); \
+	} else { \
+		unsigned fwengine = 0; \
+		if (FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine = FORCEWAKE_RENDER; \
+		} else if (FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine = FORCEWAKE_MEDIA; \
+		} else if (FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine |= FORCEWAKE_RENDER; \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine |= FORCEWAKE_MEDIA; \
+		} else { \
+			if (dev_priv->uncore.fw_blittercount == 0) \
+				fwengine = FORCEWAKE_BLITTER; \
+		} \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_get(dev_priv, fwengine); \
+		val = __raw_i915_read##x(dev_priv, reg); \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_put(dev_priv, fwengine); \
+	} \
+	REG_READ_FOOTER; \
+}
+
+__gen9_read(8)
+__gen9_read(16)
+__gen9_read(32)
+__gen9_read(64)
  __chv_read(8)
  __chv_read(16)
  __chv_read(32)
@@ -825,6 +890,7 @@ __gen4_read(16)
  __gen4_read(32)
  __gen4_read(64)
 
+#undef __gen9_read
  #undef __chv_read
  #undef __vlv_read
  #undef __gen6_read

drivers/gpu/drm/i915/intel_uncore.c chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace) · line 1036

Quoted 9 lines
drivers/gpu/drm/i915/intel_uncore.c +6 -0
@@ -962,6 +1028,46 @@ chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace)
  	REG_WRITE_FOOTER; \
  }
 
+#define __gen9_write(x) \
+static void \
+gen9_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, \
+		bool trace) { \
+	REG_WRITE_HEADER; \
+	if (!NEEDS_FORCE_WAKE((dev_priv), (reg)) || \

ditto

-Mika

Quoted 72 lines
drivers/gpu/drm/i915/intel_uncore.c +48 -0
+			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg)) { \
+		__raw_i915_write##x(dev_priv, reg, val); \
+	} else { \
+		unsigned fwengine = 0; \
+		if (FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine = FORCEWAKE_RENDER; \
+		} else if (FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine = FORCEWAKE_MEDIA; \
+		} else if (FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine |= FORCEWAKE_RENDER; \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine |= FORCEWAKE_MEDIA; \
+		} else { \
+			if (dev_priv->uncore.fw_blittercount == 0) \
+				fwengine = FORCEWAKE_BLITTER; \
+		} \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_get(dev_priv, \
+					fwengine); \
+		__raw_i915_write##x(dev_priv, reg, val); \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_put(dev_priv, \
+					fwengine); \
+	} \
+	REG_WRITE_FOOTER; \
+}
+
+__gen9_write(8)
+__gen9_write(16)
+__gen9_write(32)
+__gen9_write(64)
  __chv_write(8)
  __chv_write(16)
  __chv_write(32)
@@ -987,6 +1093,7 @@ __gen4_write(16)
  __gen4_write(32)
  __gen4_write(64)
 
+#undef __gen9_write
  #undef __chv_write
  #undef __gen8_write
  #undef __hsw_write
@@ -1054,6 +1161,19 @@ void intel_uncore_init(struct drm_device *dev)
 
  	switch (INTEL_INFO(dev)->gen) {
  	default:
+		WARN_ON(1);
+		return;
+	case 9:
+		dev_priv->uncore.funcs.mmio_writeb  = gen9_write8;
+		dev_priv->uncore.funcs.mmio_writew  = gen9_write16;
+		dev_priv->uncore.funcs.mmio_writel  = gen9_write32;
+		dev_priv->uncore.funcs.mmio_writeq  = gen9_write64;
+		dev_priv->uncore.funcs.mmio_readb  = gen9_read8;
+		dev_priv->uncore.funcs.mmio_readw  = gen9_read16;
+		dev_priv->uncore.funcs.mmio_readl  = gen9_read32;
+		dev_priv->uncore.funcs.mmio_readq  = gen9_read64;
+		break;
+	case 8:
  		if (IS_CHERRYVIEW(dev)) {
  			dev_priv->uncore.funcs.mmio_writeb  = chv_write8;
  			dev_priv->uncore.funcs.mmio_writew  = chv_write16;
Signature · 6 lines
1.8.3.1

_______________________________________________
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

#151 lore raw

PATCH v4 55/59 drm/i915/skl: Gen9 multi-engine forcewake

From: Zhe Wang <[email protected]>

Enable multi-engine forcewake for Gen9.

v2: (Damien)
- Rebase on top of nightly
- Move the register range definitions to intel_uncore.c
- Whitespace fixes

v3: (Addressing Mika's comment, done by Damien)
- Use REG_RANGE() (introduced after the patch was written)
- Add a SKL_NEEDS_FORCE_WAKE() macro that gets rid of a useless comparison to FORCEWAKE (reg 0xa18c is not used on SKL)

v4: (Damien)
- Use newly introduced ASSIGN_READ/WRITE_MMIO_VFUNCS() macros

---
 drivers/gpu/drm/i915/intel_uncore.c | 115 ++++++++++++++++++++++++++++++++++++
 1 file changed, 115 insertions(+)
drivers/gpu/drm/i915/intel_uncore.c +115 -0
index 68e722b..8ce56f6 100644
@@ -678,6 +678,34 @@ void assert_force_wake_inactive(struct drm_i915_private *dev_priv)
 	 REG_RANGE((reg), 0x14000, 0x14400) || \
 	 REG_RANGE((reg), 0x22000, 0x24000))
 
+#define FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) \
+	REG_RANGE((reg), 0xC00,  0x2000)
+
+#define FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg) \
+	(REG_RANGE((reg), 0x2000, 0x4000) || \
+	 REG_RANGE((reg), 0x5200, 0x8000) || \
+	 REG_RANGE((reg), 0x8300, 0x8500) || \
+	 REG_RANGE((reg), 0x8C00, 0x8D00) || \
+	 REG_RANGE((reg), 0xB000, 0xB480) || \
+	 REG_RANGE((reg), 0xE000, 0xE800))
+
+#define FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg) \
+	(REG_RANGE((reg), 0x8800, 0x8A00) || \
+	 REG_RANGE((reg), 0xD000, 0xD800) || \
+	 REG_RANGE((reg), 0x12000, 0x14000) || \
+	 REG_RANGE((reg), 0x1A000, 0x1EA00) || \
+	 REG_RANGE((reg), 0x30000, 0x40000))
+
+#define FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg) \
+	REG_RANGE((reg), 0x9400, 0x9800)
+
+#define FORCEWAKE_GEN9_BLITTER_RANGE_OFFSET(reg) \
+	((reg) < 0x40000 &&\
+	 !FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) && \
+	 !FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg) && \
+	 !FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg) && \
+	 !FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg))
+
 static void
 ilk_dummy_write(struct drm_i915_private *dev_priv)
 {
@@ -808,6 +836,45 @@ chv_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \
 	REG_READ_FOOTER; \
 }
 
+#define SKL_NEEDS_FORCE_WAKE(dev_priv, reg)	\
+	 ((reg) < 0x40000 && !FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg))
+
+#define __gen9_read(x) \
+static u##x \
+gen9_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \
+	REG_READ_HEADER(x); \
+	if (!SKL_NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
+		val = __raw_i915_read##x(dev_priv, reg); \
+	} else { \
+		unsigned fwengine = 0; \
+		if (FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine = FORCEWAKE_RENDER; \
+		} else if (FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine = FORCEWAKE_MEDIA; \
+		} else if (FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine |= FORCEWAKE_RENDER; \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine |= FORCEWAKE_MEDIA; \
+		} else { \
+			if (dev_priv->uncore.fw_blittercount == 0) \
+				fwengine = FORCEWAKE_BLITTER; \
+		} \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_get(dev_priv, fwengine); \
+		val = __raw_i915_read##x(dev_priv, reg); \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_put(dev_priv, fwengine); \
+	} \
+	REG_READ_FOOTER; \
+}
+
+__gen9_read(8)
+__gen9_read(16)
+__gen9_read(32)
+__gen9_read(64)
 __chv_read(8)
 __chv_read(16)
 __chv_read(32)
@@ -829,6 +896,7 @@ __gen4_read(16)
 __gen4_read(32)
 __gen4_read(64)
 
+#undef __gen9_read
 #undef __chv_read
 #undef __vlv_read
 #undef __gen6_read
@@ -966,6 +1034,45 @@ chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace)
 	REG_WRITE_FOOTER; \
 }
 
+#define __gen9_write(x) \
+static void \
+gen9_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, \
+		bool trace) { \
+	REG_WRITE_HEADER; \
+	if (!SKL_NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
+		__raw_i915_write##x(dev_priv, reg, val); \
+	} else { \
+		unsigned fwengine = 0; \
+		if (FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine = FORCEWAKE_RENDER; \
+		} else if (FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine = FORCEWAKE_MEDIA; \
+		} else if (FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine |= FORCEWAKE_RENDER; \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine |= FORCEWAKE_MEDIA; \
+		} else { \
+			if (dev_priv->uncore.fw_blittercount == 0) \
+				fwengine = FORCEWAKE_BLITTER; \
+		} \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_get(dev_priv, \
+					fwengine); \
+		__raw_i915_write##x(dev_priv, reg, val); \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_put(dev_priv, \
+					fwengine); \
+	} \
+	REG_WRITE_FOOTER; \
+}
+
+__gen9_write(8)
+__gen9_write(16)
+__gen9_write(32)
+__gen9_write(64)
 __chv_write(8)
 __chv_write(16)
 __chv_write(32)
@@ -991,6 +1098,7 @@ __gen4_write(16)
 __gen4_write(32)
 __gen4_write(64)
 
+#undef __gen9_write
 #undef __chv_write
 #undef __gen8_write
 #undef __hsw_write
@@ -1074,6 +1182,13 @@ void intel_uncore_init(struct drm_device *dev)
 
 	switch (INTEL_INFO(dev)->gen) {
 	default:
+		WARN_ON(1);
+		return;
+	case 9:
+		ASSIGN_WRITE_MMIO_VFUNCS(gen9);
+		ASSIGN_READ_MMIO_VFUNCS(gen9);
+		break;
+	case 8:
 		if (IS_CHERRYVIEW(dev)) {
 			ASSIGN_WRITE_MMIO_VFUNCS(chv);
 			ASSIGN_READ_MMIO_VFUNCS(chv);
Signature · 6 lines
1.8.3.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v4 55/59
#152 lore raw

Re: [PATCH 55/59 v4] drm/i915/skl: Gen9 multi-engine forcewake

Quoted 14 lines · Damien Lespiau

From: Zhe Wang <[email protected]>

Enable multi-engine forcewake for Gen9.

v2: (Damien)
- Rebase on top of nightly
- Move the register range definitions to intel_uncore.c
- Whitespace fixes

v3: (Addressing Mika's comment, done by Damien)
- Use REG_RANGE() (introduced after the patch was written)
- Add a SKL_NEEDS_FORCE_WAKE() macro that gets rid of a useless comparison to FORCEWAKE (reg 0xa18c is not used on SKL)

Quoted 5 lines

v4: (Damien)
- Use newly introduced ASSIGN_READ/WRITE_MMIO_VFUNCS() macros

Quoted 167 lines
---
 drivers/gpu/drm/i915/intel_uncore.c | 115 ++++++++++++++++++++++++++++++++++++
 1 file changed, 115 insertions(+)
drivers/gpu/drm/i915/intel_uncore.c +115 -0
index 68e722b..8ce56f6 100644
@@ -678,6 +678,34 @@ void assert_force_wake_inactive(struct drm_i915_private *dev_priv)
 	 REG_RANGE((reg), 0x14000, 0x14400) || \
 	 REG_RANGE((reg), 0x22000, 0x24000))
 
+#define FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) \
+	REG_RANGE((reg), 0xC00,  0x2000)
+
+#define FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg) \
+	(REG_RANGE((reg), 0x2000, 0x4000) || \
+	 REG_RANGE((reg), 0x5200, 0x8000) || \
+	 REG_RANGE((reg), 0x8300, 0x8500) || \
+	 REG_RANGE((reg), 0x8C00, 0x8D00) || \
+	 REG_RANGE((reg), 0xB000, 0xB480) || \
+	 REG_RANGE((reg), 0xE000, 0xE800))
+
+#define FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg) \
+	(REG_RANGE((reg), 0x8800, 0x8A00) || \
+	 REG_RANGE((reg), 0xD000, 0xD800) || \
+	 REG_RANGE((reg), 0x12000, 0x14000) || \
+	 REG_RANGE((reg), 0x1A000, 0x1EA00) || \
+	 REG_RANGE((reg), 0x30000, 0x40000))
+
+#define FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg) \
+	REG_RANGE((reg), 0x9400, 0x9800)
+
+#define FORCEWAKE_GEN9_BLITTER_RANGE_OFFSET(reg) \
+	((reg) < 0x40000 &&\
+	 !FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) && \
+	 !FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg) && \
+	 !FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg) && \
+	 !FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg))
+
 static void
 ilk_dummy_write(struct drm_i915_private *dev_priv)
 {
@@ -808,6 +836,45 @@ chv_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \
 	REG_READ_FOOTER; \
 }
 
+#define SKL_NEEDS_FORCE_WAKE(dev_priv, reg)	\
+	 ((reg) < 0x40000 && !FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg))
+
+#define __gen9_read(x) \
+static u##x \
+gen9_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \
+	REG_READ_HEADER(x); \
+	if (!SKL_NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
+		val = __raw_i915_read##x(dev_priv, reg); \
+	} else { \
+		unsigned fwengine = 0; \
+		if (FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine = FORCEWAKE_RENDER; \
+		} else if (FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine = FORCEWAKE_MEDIA; \
+		} else if (FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine |= FORCEWAKE_RENDER; \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine |= FORCEWAKE_MEDIA; \
+		} else { \
+			if (dev_priv->uncore.fw_blittercount == 0) \
+				fwengine = FORCEWAKE_BLITTER; \
+		} \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_get(dev_priv, fwengine); \
+		val = __raw_i915_read##x(dev_priv, reg); \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_put(dev_priv, fwengine); \
+	} \
+	REG_READ_FOOTER; \
+}
+
+__gen9_read(8)
+__gen9_read(16)
+__gen9_read(32)
+__gen9_read(64)
 __chv_read(8)
 __chv_read(16)
 __chv_read(32)
@@ -829,6 +896,7 @@ __gen4_read(16)
 __gen4_read(32)
 __gen4_read(64)
 
+#undef __gen9_read
 #undef __chv_read
 #undef __vlv_read
 #undef __gen6_read
@@ -966,6 +1034,45 @@ chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace)
 	REG_WRITE_FOOTER; \
 }
 
+#define __gen9_write(x) \
+static void \
+gen9_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, \
+		bool trace) { \
+	REG_WRITE_HEADER; \
+	if (!SKL_NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
+		__raw_i915_write##x(dev_priv, reg, val); \
+	} else { \
+		unsigned fwengine = 0; \
+		if (FORCEWAKE_GEN9_RENDER_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine = FORCEWAKE_RENDER; \
+		} else if (FORCEWAKE_GEN9_MEDIA_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine = FORCEWAKE_MEDIA; \
+		} else if (FORCEWAKE_GEN9_COMMON_RANGE_OFFSET(reg)) { \
+			if (dev_priv->uncore.fw_rendercount == 0) \
+				fwengine |= FORCEWAKE_RENDER; \
+			if (dev_priv->uncore.fw_mediacount == 0) \
+				fwengine |= FORCEWAKE_MEDIA; \
+		} else { \
+			if (dev_priv->uncore.fw_blittercount == 0) \
+				fwengine = FORCEWAKE_BLITTER; \
+		} \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_get(dev_priv, \
+					fwengine); \
+		__raw_i915_write##x(dev_priv, reg, val); \
+		if (fwengine) \
+			dev_priv->uncore.funcs.force_wake_put(dev_priv, \
+					fwengine); \
+	} \
+	REG_WRITE_FOOTER; \
+}
+
+__gen9_write(8)
+__gen9_write(16)
+__gen9_write(32)
+__gen9_write(64)
 __chv_write(8)
 __chv_write(16)
 __chv_write(32)
@@ -991,6 +1098,7 @@ __gen4_write(16)
 __gen4_write(32)
 __gen4_write(64)
 
+#undef __gen9_write
 #undef __chv_write
 #undef __gen8_write
 #undef __hsw_write
@@ -1074,6 +1182,13 @@ void intel_uncore_init(struct drm_device *dev)
 
 	switch (INTEL_INFO(dev)->gen) {
 	default:
+		WARN_ON(1);
+		return;
+	case 9:
+		ASSIGN_WRITE_MMIO_VFUNCS(gen9);
+		ASSIGN_READ_MMIO_VFUNCS(gen9);
+		break;
+	case 8:
 		if (IS_CHERRYVIEW(dev)) {
 			ASSIGN_WRITE_MMIO_VFUNCS(chv);
 			ASSIGN_READ_MMIO_VFUNCS(chv);
Signature · 1 line
1.8.3.1

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

#153 lore raw

PATCH 56/89 drm/i915: Gen9 shadowed registers

In reply to Damien Lespiau

From: Zhe Wang <[email protected]>

For MMIO registers which are shadowed, force wake is not needed to write to these registers.

v2: Rebase on top of nightly (Damien)

---
 drivers/gpu/drm/i915/intel_uncore.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_uncore.c +25 -1
index f289f4f..ce1214b 100644
@@ -1028,13 +1028,37 @@ chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace)
 	REG_WRITE_FOOTER; \
 }
 
+static const u32 gen9_shadowed_regs[] = {
+	FORCEWAKE_MEDIA_GEN9,
+	FORCEWAKE_RENDER_GEN9,
+	FORCEWAKE_BLITTER_GEN9,
+	GEN6_RPNSWREQ,
+	GEN6_RC_VIDEO_FREQ,
+	RING_TAIL(RENDER_RING_BASE),
+	RING_TAIL(GEN6_BSD_RING_BASE),
+	RING_TAIL(VEBOX_RING_BASE),
+	RING_TAIL(BLT_RING_BASE),
+	/* TODO: Other registers are not yet used */
+};
+
+static bool is_gen9_shadowed(struct drm_i915_private *dev_priv, u32 reg)
+{
+	int i;
+	for (i = 0; i < ARRAY_SIZE(gen9_shadowed_regs); i++)
+		if (reg == gen9_shadowed_regs[i])
+			return true;
+
+	return false;
+}
+
 #define __gen9_write(x) \
 static void \
 gen9_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, \
 		bool trace) { \
 	REG_WRITE_HEADER; \
 	if (!NEEDS_FORCE_WAKE((dev_priv), (reg)) || \
-			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg)) { \
+			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) || \
+			is_gen9_shadowed(dev_priv, reg)) { \
 		__raw_i915_write##x(dev_priv, reg, val); \
 	} else { \
 		unsigned fwengine = 0; \
Signature · 1 line
1.8.3.1
#154 lore raw

Re: [PATCH 56/89] drm/i915: Gen9 shadowed registers

Quoted 18 lines · Damien Lespiau

From: Zhe Wang <[email protected]>

For MMIO registers which are shadowed, force wake is not needed to write to these registers.

v2: Rebase on top of nightly (Damien)

---
 drivers/gpu/drm/i915/intel_uncore.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_uncore.c +0 -0
index f289f4f..ce1214b 100644

drivers/gpu/drm/i915/intel_uncore.c chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace) · line 1034

Quoted 7 lines
drivers/gpu/drm/i915/intel_uncore.c +4 -0
@@ -1028,13 +1028,37 @@ chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace)
 	REG_WRITE_FOOTER; \
 }
 
+static const u32 gen9_shadowed_regs[] = {
+	FORCEWAKE_MEDIA_GEN9,
+	FORCEWAKE_RENDER_GEN9,
+	FORCEWAKE_BLITTER_GEN9,

You might want to move the ring tails first on the list and forcewake regs to bottom, to reflect the popularity of access.

drivers/gpu/drm/i915/intel_uncore.c chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace) · line 1041

Quoted 7 lines
drivers/gpu/drm/i915/intel_uncore.c +7 -0
+	GEN6_RPNSWREQ,
+	GEN6_RC_VIDEO_FREQ,
+	RING_TAIL(RENDER_RING_BASE),
+	RING_TAIL(GEN6_BSD_RING_BASE),
+	RING_TAIL(VEBOX_RING_BASE),
+	RING_TAIL(BLT_RING_BASE),
+	/* TODO: Other registers are not yet used */

I think we need exec list ones here also, but couldn't find certain proof. Atleast with bdw we are missing them.

-Mika

Quoted 31 lines
drivers/gpu/drm/i915/intel_uncore.c +14 -1
+};
+
+static bool is_gen9_shadowed(struct drm_i915_private *dev_priv, u32 reg)
+{
+	int i;
+	for (i = 0; i < ARRAY_SIZE(gen9_shadowed_regs); i++)
+		if (reg == gen9_shadowed_regs[i])
+			return true;
+
+	return false;
+}
+
 #define __gen9_write(x) \
 static void \
 gen9_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, \
 		bool trace) { \
 	REG_WRITE_HEADER; \
 	if (!NEEDS_FORCE_WAKE((dev_priv), (reg)) || \
-			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg)) { \
+			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) || \
+			is_gen9_shadowed(dev_priv, reg)) { \
 		__raw_i915_write##x(dev_priv, reg, val); \
 	} else { \
 		unsigned fwengine = 0; \
Signature · 6 lines
1.8.3.1

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

Re: [PATCH 56/89] drm/i915: Gen9 shadowed registers

Quoted 23 lines · Mika Kuoppala
Quoted 21 lines · Damien Lespiau

From: Zhe Wang <[email protected]>

For MMIO registers which are shadowed, force wake is not needed to write to these registers.

v2: Rebase on top of nightly (Damien)

---
  drivers/gpu/drm/i915/intel_uncore.c | 26 +++++++++++++++++++++++++-
  1 file changed, 25 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_uncore.c +0 -0
index f289f4f..ce1214b 100644
@@ -1028,13 +1028,37 @@ chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace)
  	REG_WRITE_FOOTER; \
  }
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_uncore.c chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace) · line 1034

Quoted 4 lines
drivers/gpu/drm/i915/intel_uncore.c +4 -0
+static const u32 gen9_shadowed_regs[] = {
+	FORCEWAKE_MEDIA_GEN9,
+	FORCEWAKE_RENDER_GEN9,
+	FORCEWAKE_BLITTER_GEN9,

You might want to move the ring tails first on the list and forcewake regs to bottom, to reflect the popularity of access.

good suggestion. a better order I can think of. comments welcomed.

RING_TAIL(RENDER_RING_BASE),
RING_TAIL(GEN6_BSD_RING_BASE),
RING_TAIL(VEBOX_RING_BASE),
RING_TAIL(BLT_RING_BASE),
FORCEWAKE_BLITTER_GEN9,
FORCEWAKE_RENDER_GEN9,
FORCEWAKE_MEDIA_GEN9,
GEN6_RPNSWREQ,
GEN6_RC_VIDEO_FREQ,

Quoted 11 lines

drivers/gpu/drm/i915/intel_uncore.c chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace) · line 1041

Quoted 7 lines
drivers/gpu/drm/i915/intel_uncore.c +7 -0
+	GEN6_RPNSWREQ,
+	GEN6_RC_VIDEO_FREQ,
+	RING_TAIL(RENDER_RING_BASE),
+	RING_TAIL(GEN6_BSD_RING_BASE),
+	RING_TAIL(VEBOX_RING_BASE),
+	RING_TAIL(BLT_RING_BASE),
+	/* TODO: Other registers are not yet used */

I think we need exec list ones here also, but couldn't find certain proof. Atleast with bdw we are missing them.

-Mika

Good catch. Execlist ones are on the list. We need to add those since execlist is enabled.

Quoted 35 lines
Quoted 31 lines
drivers/gpu/drm/i915/intel_uncore.c +14 -1
+};
+
+static bool is_gen9_shadowed(struct drm_i915_private *dev_priv, u32 reg)
+{
+	int i;
+	for (i = 0; i < ARRAY_SIZE(gen9_shadowed_regs); i++)
+		if (reg == gen9_shadowed_regs[i])
+			return true;
+
+	return false;
+}
+
  #define __gen9_write(x) \
  static void \
  gen9_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, \
  		bool trace) { \
  	REG_WRITE_HEADER; \
  	if (!NEEDS_FORCE_WAKE((dev_priv), (reg)) || \
-			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg)) { \
+			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) || \
+			is_gen9_shadowed(dev_priv, reg)) { \
  		__raw_i915_write##x(dev_priv, reg, val); \
  	} else { \
  		unsigned fwengine = 0; \
Signature · 6 lines
1.8.3.1

_______________________________________________
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

#156 lore raw

Re: [PATCH 56/89] drm/i915: Gen9 shadowed registers

Quoted 54 lines · Bob Wang
Quoted 23 lines · Mika Kuoppala
Quoted 21 lines · Damien Lespiau

From: Zhe Wang <[email protected]>

For MMIO registers which are shadowed, force wake is not needed to write to these registers.

v2: Rebase on top of nightly (Damien)

---
  drivers/gpu/drm/i915/intel_uncore.c | 26 +++++++++++++++++++++++++-
  1 file changed, 25 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_uncore.c +0 -0
index f289f4f..ce1214b 100644
@@ -1028,13 +1028,37 @@ chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace)
  	REG_WRITE_FOOTER; \
  }
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_uncore.c chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace) · line 1034

Quoted 4 lines
drivers/gpu/drm/i915/intel_uncore.c +4 -0
+static const u32 gen9_shadowed_regs[] = {
+	FORCEWAKE_MEDIA_GEN9,
+	FORCEWAKE_RENDER_GEN9,
+	FORCEWAKE_BLITTER_GEN9,

You might want to move the ring tails first on the list and forcewake regs to bottom, to reflect the popularity of access.

good suggestion. a better order I can think of. comments welcomed.

RING_TAIL(RENDER_RING_BASE),
RING_TAIL(GEN6_BSD_RING_BASE),
RING_TAIL(VEBOX_RING_BASE),
RING_TAIL(BLT_RING_BASE),
FORCEWAKE_BLITTER_GEN9,
FORCEWAKE_RENDER_GEN9,
FORCEWAKE_MEDIA_GEN9,
GEN6_RPNSWREQ,
GEN6_RC_VIDEO_FREQ,

Quoted 10 lines

drivers/gpu/drm/i915/intel_uncore.c chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace) · line 1041

Quoted 7 lines
drivers/gpu/drm/i915/intel_uncore.c +7 -0
+	GEN6_RPNSWREQ,
+	GEN6_RC_VIDEO_FREQ,
+	RING_TAIL(RENDER_RING_BASE),
+	RING_TAIL(GEN6_BSD_RING_BASE),
+	RING_TAIL(VEBOX_RING_BASE),
+	RING_TAIL(BLT_RING_BASE),
+	/* TODO: Other registers are not yet used */

I think we need exec list ones here also, but couldn't find certain proof. Atleast with bdw we are missing them.

Quoted 3 lines
Quoted 1 line

-Mika

Good catch. Execlist ones are on the list. We need to add those since execlist is enabled.

On closer look, it seems that the exec lists do their own forcewake handling.

-Mika

Quoted 35 lines
Quoted 35 lines
Quoted 31 lines
drivers/gpu/drm/i915/intel_uncore.c +14 -1
+};
+
+static bool is_gen9_shadowed(struct drm_i915_private *dev_priv, u32 reg)
+{
+	int i;
+	for (i = 0; i < ARRAY_SIZE(gen9_shadowed_regs); i++)
+		if (reg == gen9_shadowed_regs[i])
+			return true;
+
+	return false;
+}
+
  #define __gen9_write(x) \
  static void \
  gen9_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, \
  		bool trace) { \
  	REG_WRITE_HEADER; \
  	if (!NEEDS_FORCE_WAKE((dev_priv), (reg)) || \
-			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg)) { \
+			FORCEWAKE_GEN9_UNCORE_RANGE_OFFSET(reg) || \
+			is_gen9_shadowed(dev_priv, reg)) { \
  		__raw_i915_write##x(dev_priv, reg, val); \
  	} else { \
  		unsigned fwengine = 0; \
Signature · 6 lines
1.8.3.1

_______________________________________________
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

#157 lore raw

PATCH v4 56/89 drm/i915: Gen9 shadowed registers

From: Zhe Wang <[email protected]>

For MMIO registers which are shadowed, force wake is not needed to write to these registers.

v2: Rebase on top of nightly (Damien)

v3: Rebase on top of "Gen9 multiple-engine forcewake" changes

v4: (Mika, Bob, done by Damien)
- Reorder the shadowed registers by popularity

---
 drivers/gpu/drm/i915/intel_uncore.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_uncore.c +25 -1
index 8ce56f6..4b46976 100644
@@ -1034,12 +1034,36 @@ chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace)
 	REG_WRITE_FOOTER; \
 }
 
+static const u32 gen9_shadowed_regs[] = {
+	RING_TAIL(RENDER_RING_BASE),
+	RING_TAIL(GEN6_BSD_RING_BASE),
+	RING_TAIL(VEBOX_RING_BASE),
+	RING_TAIL(BLT_RING_BASE),
+	FORCEWAKE_BLITTER_GEN9,
+	FORCEWAKE_RENDER_GEN9,
+	FORCEWAKE_MEDIA_GEN9,
+	GEN6_RPNSWREQ,
+	GEN6_RC_VIDEO_FREQ,
+	/* TODO: Other registers are not yet used */
+};
+
+static bool is_gen9_shadowed(struct drm_i915_private *dev_priv, u32 reg)
+{
+	int i;
+	for (i = 0; i < ARRAY_SIZE(gen9_shadowed_regs); i++)
+		if (reg == gen9_shadowed_regs[i])
+			return true;
+
+	return false;
+}
+
 #define __gen9_write(x) \
 static void \
 gen9_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, \
 		bool trace) { \
 	REG_WRITE_HEADER; \
-	if (!SKL_NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
+	if (!SKL_NEEDS_FORCE_WAKE((dev_priv), (reg)) || \
+			is_gen9_shadowed(dev_priv, reg)) { \
 		__raw_i915_write##x(dev_priv, reg, val); \
 	} else { \
 		unsigned fwengine = 0; \
Signature · 6 lines
1.8.3.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v4 56/89
#158 lore raw

Re: [PATCH 56/89 v4] drm/i915: Gen9 shadowed registers

Quoted 7 lines · Damien Lespiau

From: Zhe Wang <[email protected]>

For MMIO registers which are shadowed, force wake is not needed to write to these registers.

v2: Rebase on top of nightly (Damien)

Quoted 7 lines

v3: Rebase on top of "Gen9 multiple-engine forcewake" changes

v4: (Mika, Bob, done by Damien)
- Reorder the shadowed registers by popularity

Quoted 48 lines
---
 drivers/gpu/drm/i915/intel_uncore.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_uncore.c +25 -1
index 8ce56f6..4b46976 100644
@@ -1034,12 +1034,36 @@ chv_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace)
 	REG_WRITE_FOOTER; \
 }
 
+static const u32 gen9_shadowed_regs[] = {
+	RING_TAIL(RENDER_RING_BASE),
+	RING_TAIL(GEN6_BSD_RING_BASE),
+	RING_TAIL(VEBOX_RING_BASE),
+	RING_TAIL(BLT_RING_BASE),
+	FORCEWAKE_BLITTER_GEN9,
+	FORCEWAKE_RENDER_GEN9,
+	FORCEWAKE_MEDIA_GEN9,
+	GEN6_RPNSWREQ,
+	GEN6_RC_VIDEO_FREQ,
+	/* TODO: Other registers are not yet used */
+};
+
+static bool is_gen9_shadowed(struct drm_i915_private *dev_priv, u32 reg)
+{
+	int i;
+	for (i = 0; i < ARRAY_SIZE(gen9_shadowed_regs); i++)
+		if (reg == gen9_shadowed_regs[i])
+			return true;
+
+	return false;
+}
+
 #define __gen9_write(x) \
 static void \
 gen9_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, \
 		bool trace) { \
 	REG_WRITE_HEADER; \
-	if (!SKL_NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
+	if (!SKL_NEEDS_FORCE_WAKE((dev_priv), (reg)) || \
+			is_gen9_shadowed(dev_priv, reg)) { \
 		__raw_i915_write##x(dev_priv, reg, val); \
 	} else { \
 		unsigned fwengine = 0; \
Signature · 1 line
1.8.3.1

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

#159 lore raw

PATCH 57/89 drm/i915: Rewrite ABS_DIFF() in a safer manner

In reply to Damien Lespiau

The new version of the macro does a few things better:
- protect the arguments,
- only evaluate the arguments once,
- check that the arguments are of the same type,

Change LC_FREQ_2K to be a unsigned 64bit constant and removed the '()' from the caller as a result.

---
 drivers/gpu/drm/i915/intel_ddi.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +9 -5
index 64eda53..ba1103f 100644
@@ -460,7 +460,7 @@ intel_ddi_get_crtc_encoder(struct drm_crtc *crtc)
 }
 
 #define LC_FREQ 2700
-#define LC_FREQ_2K (LC_FREQ * 2000)
+#define LC_FREQ_2K U64_C(LC_FREQ * 2000)
 
 #define P_MIN 2
 #define P_MAX 64
@@ -472,7 +472,11 @@ intel_ddi_get_crtc_encoder(struct drm_crtc *crtc)
 #define VCO_MIN 2400
 #define VCO_MAX 4800
 
-#define ABS_DIFF(a, b) ((a > b) ? (a - b) : (b - a))
+#define abs_diff(a, b) ({			\
+	typeof(a) __a = (a);			\
+	typeof(b) __b = (b);			\
+	(void) (&__a == &__b);			\
+	__a > __b ? (__a - __b) : (__b - __a); })
 
 struct wrpll_rnp {
 	unsigned p, n2, r2;
@@ -582,9 +586,9 @@ static void wrpll_update_rnp(uint64_t freq2k, unsigned budget,
 	 */
 	a = freq2k * budget * p * r2;
 	b = freq2k * budget * best->p * best->r2;
-	diff = ABS_DIFF((freq2k * p * r2), (LC_FREQ_2K * n2));
-	diff_best = ABS_DIFF((freq2k * best->p * best->r2),
-			     (LC_FREQ_2K * best->n2));
+	diff = abs_diff(freq2k * p * r2, LC_FREQ_2K * n2);
+	diff_best = abs_diff(freq2k * best->p * best->r2,
+			     LC_FREQ_2K * best->n2);
 	c = 1000000 * diff;
 	d = 1000000 * diff_best;
 
Signature · 1 line
1.8.3.1
maintainer Reviewed-by on v1 57/89
#160 lore raw

Re: [PATCH 57/89] drm/i915: Rewrite ABS_DIFF() in a safer manner

Quoted 9 lines · Damien Lespiau

The new version of the macro does a few things better:
- protect the arguments,
- only evaluate the arguments once,
- check that the arguments are of the same type,

Change LC_FREQ_2K to be a unsigned 64bit constant and removed the '()' from the caller as a result.

Can be picked up for dinq separate from this series, right?

Quoted 50 lines
---
 drivers/gpu/drm/i915/intel_ddi.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +9 -5
index 64eda53..ba1103f 100644
@@ -460,7 +460,7 @@ intel_ddi_get_crtc_encoder(struct drm_crtc *crtc)
 }
 
 #define LC_FREQ 2700
-#define LC_FREQ_2K (LC_FREQ * 2000)
+#define LC_FREQ_2K U64_C(LC_FREQ * 2000)
 
 #define P_MIN 2
 #define P_MAX 64
@@ -472,7 +472,11 @@ intel_ddi_get_crtc_encoder(struct drm_crtc *crtc)
 #define VCO_MIN 2400
 #define VCO_MAX 4800
 
-#define ABS_DIFF(a, b) ((a > b) ? (a - b) : (b - a))
+#define abs_diff(a, b) ({			\
+	typeof(a) __a = (a);			\
+	typeof(b) __b = (b);			\
+	(void) (&__a == &__b);			\
+	__a > __b ? (__a - __b) : (__b - __a); })
 
 struct wrpll_rnp {
 	unsigned p, n2, r2;
@@ -582,9 +586,9 @@ static void wrpll_update_rnp(uint64_t freq2k, unsigned budget,
 	 */
 	a = freq2k * budget * p * r2;
 	b = freq2k * budget * best->p * best->r2;
-	diff = ABS_DIFF((freq2k * p * r2), (LC_FREQ_2K * n2));
-	diff_best = ABS_DIFF((freq2k * best->p * best->r2),
-			     (LC_FREQ_2K * best->n2));
+	diff = abs_diff(freq2k * p * r2, LC_FREQ_2K * n2);
+	diff_best = abs_diff(freq2k * best->p * best->r2,
+			     LC_FREQ_2K * best->n2);
 	c = 1000000 * diff;
 	d = 1000000 * diff_best;
 
Signature · 6 lines
1.8.3.1

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

Re: [PATCH 57/89] drm/i915: Rewrite ABS_DIFF() in a safer manner

Quoted 6 lines · Jani Nikula
Quoted 5 lines · Damien Lespiau

The new version of the macro does a few things better:
- protect the arguments,
- only evaluate the arguments once,
- check that the arguments are of the same type,

Quoted 8 lines
Quoted 4 lines

Change LC_FREQ_2K to be a unsigned 64bit constant and removed the '()' from the caller as a result.

Can be picked up for dinq separate from this series, right?

Yes, it can indeed.

Signature · 1 line
Damien
#162 lore raw

Re: [PATCH 57/89] drm/i915: Rewrite ABS_DIFF() in a safer manner

Quoted 10 lines · Damien Lespiau
Quoted 9 lines · Jani Nikula
Quoted 8 lines · Damien Lespiau

The new version of the macro does a few things better:
- protect the arguments,
- only evaluate the arguments once,
- check that the arguments are of the same type,

Change LC_FREQ_2K to be a unsigned 64bit constant and removed the '()' from the caller as a result.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Can be picked up for dinq separate from this series, right?

Yes, it can indeed.

s/can/must/ If the platform enabling changes shared code, that part must go in through the normal merge process and has the same merge window cutoff deadlines like everything else.

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
#163 lore raw

PATCH 58/89 drm/i915/skl: Register definitions for SKL Clocks

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

This patch defines the necessary SKL registers for implementing the new clocking mechanism.

v2: Addressed review comments by Damien
- Added code comment
- Introduced enum for WRPLL values

v3: Rebase on top of nightly (minor conflict in i915_reg.h)

v4: Use 0x, not 0X (Ville)

---
 drivers/gpu/drm/i915/i915_reg.h | 84 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +84 -0
index 417075d..2364ece 100644
@@ -6336,6 +6336,90 @@ enum punit_power_well {
 #define  LCPLL_CD_SOURCE_FCLK		(1<<21)
 #define  LCPLL_CD_SOURCE_FCLK_DONE	(1<<19)
 
+/*
+ * SKL Clocks
+ */
+
+/* CDCLK_CTL */
+#define CDCLK_CTL			0x46000
+#define  CDCLK_FREQ_SEL_MASK		(3<<26)
+#define  CDCLK_FREQ_450_432		(0<<26)
+#define  CDCLK_FREQ_540			(1<<26)
+#define  CDCLK_FREQ_337_308		(2<<26)
+#define  CDCLK_FREQ_675_617		(3<<26)
+#define	 CDCLK_FREQ_DECIMAL_MASK	(0x7ff)
+
+/* LCPLL_CTL */
+#define LCPLL1_CTL		0x46010
+#define LCPLL2_CTL		0x46014
+#define  LCPLL_PLL_ENABLE	(1<<31)
+
+/* DPLL control1 */
+#define DPLL_CTRL1		0x6C058
+#define  DPLL_CTRL1_HDMI_MODE(id)		(1<<((id)*6+5))
+#define  DPLL_CTRL1_SSC(id)			(1<<((id)*6+4))
+#define  DPLL_CRTL1_LINK_RATE_MASK(id)		(7<<((id)*6+1))
+#define  DPLL_CRTL1_LINK_RATE(linkrate, id)	((linkrate)<<((id)*6+1))
+#define  DPLL_CTRL1_OVERRIDE(id)		(1<<((id)*6))
+#define  DPLL_CRTL1_LINK_RATE_2700		0
+#define  DPLL_CRTL1_LINK_RATE_1350		1
+#define  DPLL_CRTL1_LINK_RATE_810		2
+#define  DPLL_CRTL1_LINK_RATE_1620		3
+#define  DPLL_CRTL1_LINK_RATE_1080		4
+#define  DPLL_CRTL1_LINK_RATE_2160		5
+
+/* DPLL control2 */
+#define DPLL_CTRL2				0x6C05C
+#define  DPLL_CTRL2_DDI_CLK_OFF(port)		(1<<(port+15))
+#define  DPLL_CTRL2_DDI_CLK_SEL_MASK(port)	(3<<((port)*3+1))
+#define  DPLL_CTRL2_DDI_CLK_SEL(clk, port)	(clk<<((port)*3+1))
+#define  DPLL_CTRL2_DDI_SEL_OVERRIDE(port)	(1<<(port*3))
+
+/* DPLL Status */
+#define DPLL_STATUS	0x6C060
+#define	 DPLL_LOCK(id)	(1<<((id)*8))
+
+/* DPLL cfg */
+#define DPLL1_CFGCR1	0x6C040
+#define DPLL2_CFGCR1	0x6C048
+#define DPLL3_CFGCR1	0x6C050
+#define  DPLL_CFGCR1_FREQ_ENABLE	(1<<31)
+#define  DPLL_CFGCR1_DCO_FRACTION_MASK	(0x7fff<<9)
+#define  DPLL_CFGCR1_DCO_FRACTION(x)	(x<<9)
+#define  DPLL_CFGCR1_DCO_INTEGER_MASK	(0x1ff)
+
+#define DPLL1_CFGCR2	0x6C044
+#define DPLL2_CFGCR2	0x6C04C
+#define DPLL3_CFGCR2	0x6C054
+#define  DPLL_CFGCR2_QDIV_RATIO_MASK	(0xff<<8)
+#define  DPLL_CFGCR2_QDIV_RATIO(x)	(x<<8)
+#define  DPLL_CFGCR2_QDIV_MODE(x)	(x<<7)
+#define  DPLL_CFGCR2_KDIV_MASK		(3<<5)
+#define  DPLL_CFGCR2_KDIV(x)		(x<<5)
+#define  DPLL_CFGCR2_PDIV_MASK		(7<<2)
+#define  DPLL_CFGCR2_PDIV(x)		(x<<2)
+#define  DPLL_CFGCR2_CENTRAL_FREQ_MASK	(3)
+
+enum central_freq {
+	freq_9600 = 0,
+	freq_9000 = 1,
+	freq_8400 = 3,
+};
+
+enum pdiv {
+	pdiv_1 = 0,
+	pdiv_2 = 1,
+	pdiv_3 = 2,
+	pdiv_7 = 4,
+};
+
+enum kdiv {
+	kdiv_5 = 0,
+	kdiv_2 = 1,
+	kdiv_3 = 2,
+	kdiv_1 = 3,
+};
+
 /* Please see hsw_read_dcomp() and hsw_write_dcomp() before using this register,
  * since on HSW we can't write to it using I915_WRITE. */
 #define D_COMP_HSW			(MCHBAR_MIRROR_BASE_SNB + 0x5F0C)
Signature · 1 line
1.8.3.1
Reviewed-by on v1 58/89
#164 lore raw

Re: [PATCH 58/89] drm/i915/skl: Register definitions for SKL Clocks

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 5 lines

From: Satheeshakrishna M <[email protected]>

This patch defines the necessary SKL registers for implementing the new clocking mechanism.

Quoted 7 lines

v2: Addressed review comments by Damien
- Added code comment
- Introduced enum for WRPLL values

v3: Rebase on top of nightly (minor conflict in i915_reg.h)

v4: Use 0x, not 0X (Ville)

Bikeshed: One of my worries with this patch is that names like CDCLK_CTL and DPLL_CTRL1 are too generic. Basically every platform has a CDCLK and DPLLs... Maybe adding _SKL in their names would help a little. Or maybe we don't need it, since the functions using these defines will already be surrounded by IS_SKL+ checks...

Quoted 17 lines
---
 drivers/gpu/drm/i915/i915_reg.h | 84 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 417075d..2364ece 100644
@@ -6336,6 +6336,90 @@ enum punit_power_well {
 #define  LCPLL_CD_SOURCE_FCLK          (1<<21)
 #define  LCPLL_CD_SOURCE_FCLK_DONE     (1<<19)
 
+/*
+ * SKL Clocks

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6350

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +10 -0
+ */
+
+/* CDCLK_CTL */
+#define CDCLK_CTL                      0x46000
+#define  CDCLK_FREQ_SEL_MASK           (3<<26)
+#define  CDCLK_FREQ_450_432            (0<<26)
+#define  CDCLK_FREQ_540                        (1<<26)
+#define  CDCLK_FREQ_337_308            (2<<26)
+#define  CDCLK_FREQ_675_617            (3<<26)
+#define         CDCLK_FREQ_DECIMAL_MASK        (0x7ff)

<ocd> Please replace the tab for a space on the line above. </ocd>

Quoted 20 lines
drivers/gpu/drm/i915/i915_reg.h +20 -0
+
+/* LCPLL_CTL */
+#define LCPLL1_CTL             0x46010
+#define LCPLL2_CTL             0x46014
+#define  LCPLL_PLL_ENABLE      (1<<31)
+
+/* DPLL control1 */
+#define DPLL_CTRL1             0x6C058
+#define  DPLL_CTRL1_HDMI_MODE(id)              (1<<((id)*6+5))
+#define  DPLL_CTRL1_SSC(id)                    (1<<((id)*6+4))
+#define  DPLL_CRTL1_LINK_RATE_MASK(id)         (7<<((id)*6+1))
+#define  DPLL_CRTL1_LINK_RATE(linkrate, id)    ((linkrate)<<((id)*6+1))
+#define  DPLL_CTRL1_OVERRIDE(id)               (1<<((id)*6))
+#define  DPLL_CRTL1_LINK_RATE_2700             0
+#define  DPLL_CRTL1_LINK_RATE_1350             1
+#define  DPLL_CRTL1_LINK_RATE_810              2
+#define  DPLL_CRTL1_LINK_RATE_1620             3
+#define  DPLL_CRTL1_LINK_RATE_1080             4
+#define  DPLL_CRTL1_LINK_RATE_2160             5
+

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6380

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +10 -0
+/* DPLL control2 */
+#define DPLL_CTRL2                             0x6C05C
+#define  DPLL_CTRL2_DDI_CLK_OFF(port)          (1<<(port+15))
+#define  DPLL_CTRL2_DDI_CLK_SEL_MASK(port)     (3<<((port)*3+1))
+#define  DPLL_CTRL2_DDI_CLK_SEL(clk, port)     (clk<<((port)*3+1))
+#define  DPLL_CTRL2_DDI_SEL_OVERRIDE(port)     (1<<(port*3))
+
+/* DPLL Status */
+#define DPLL_STATUS    0x6C060
+#define         DPLL_LOCK(id)  (1<<((id)*8))

Bad tab here too.

Quoted 32 lines
drivers/gpu/drm/i915/i915_reg.h +32 -0
+
+/* DPLL cfg */
+#define DPLL1_CFGCR1   0x6C040
+#define DPLL2_CFGCR1   0x6C048
+#define DPLL3_CFGCR1   0x6C050
+#define  DPLL_CFGCR1_FREQ_ENABLE       (1<<31)
+#define  DPLL_CFGCR1_DCO_FRACTION_MASK (0x7fff<<9)
+#define  DPLL_CFGCR1_DCO_FRACTION(x)   (x<<9)
+#define  DPLL_CFGCR1_DCO_INTEGER_MASK  (0x1ff)
+
+#define DPLL1_CFGCR2   0x6C044
+#define DPLL2_CFGCR2   0x6C04C
+#define DPLL3_CFGCR2   0x6C054
+#define  DPLL_CFGCR2_QDIV_RATIO_MASK   (0xff<<8)
+#define  DPLL_CFGCR2_QDIV_RATIO(x)     (x<<8)
+#define  DPLL_CFGCR2_QDIV_MODE(x)      (x<<7)
+#define  DPLL_CFGCR2_KDIV_MASK         (3<<5)
+#define  DPLL_CFGCR2_KDIV(x)           (x<<5)
+#define  DPLL_CFGCR2_PDIV_MASK         (7<<2)
+#define  DPLL_CFGCR2_PDIV(x)           (x<<2)
+#define  DPLL_CFGCR2_CENTRAL_FREQ_MASK (3)
+
+enum central_freq {
+       freq_9600 = 0,
+       freq_9000 = 1,
+       freq_8400 = 3,
+};
+
+enum pdiv {
+       pdiv_1 = 0,
+       pdiv_2 = 1,
+       pdiv_3 = 2,

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6422

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +10 -0
+       pdiv_7 = 4,
+};
+
+enum kdiv {
+       kdiv_5 = 0,
+       kdiv_2 = 1,
+       kdiv_3 = 2,
+       kdiv_1 = 3,
+};
+

I find it weird that we're using enums here. We don't have the tradition to do this, so it's a deviation from the usual coding style.

With or without changes:

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +0 -1
 /* Please see hsw_read_dcomp() and hsw_write_dcomp() before using this register,
  * since on HSW we can't write to it using I915_WRITE. */
 #define D_COMP_HSW                     (MCHBAR_MIRROR_BASE_SNB + 0x5F0C)
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#165 lore raw

Re: [PATCH 58/89] drm/i915/skl: Register definitions for SKL Clocks

Quoted 10 lines · Paulo Zanoni

2014-09-04 8:27 GMT-03:00 Damien Lespiau<[email protected]>:

Quoted 9 lines

From: Satheeshakrishna M<[email protected]>

This patch defines the necessary SKL registers for implementing the new clocking mechanism.

v2: Addressed review comments by Damien
- Added code comment
- Introduced enum for WRPLL values

Quoted 8 lines
Quoted 3 lines

v3: Rebase on top of nightly (minor conflict in i915_reg.h)

v4: Use 0x, not 0X (Ville)

Bikeshed: One of my worries with this patch is that names like CDCLK_CTL and DPLL_CTRL1 are too generic. Basically every platform has a CDCLK and DPLLs... Maybe adding _SKL in their names would help a little. Or maybe we don't need it, since the functions using these defines will already be surrounded by IS_SKL+ checks...

Tried to keep the names to match bspec. I haven't any instance where register name remains same and offset changes from one platform to another.

Quoted 14 lines
Quoted 14 lines
---
  drivers/gpu/drm/i915/i915_reg.h | 84 +++++++++++++++++++++++++++++++++++++++++
  1 file changed, 84 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +0 -0
index 417075d..2364ece 100644
@@ -6336,6 +6336,90 @@ enum punit_power_well {
  #define  LCPLL_CD_SOURCE_FCLK          (1<<21)
  #define  LCPLL_CD_SOURCE_FCLK_DONE     (1<<19)
 
Quoted 13 lines

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6350

Quoted 12 lines
drivers/gpu/drm/i915/i915_reg.h +12 -0
+/*
+ * SKL Clocks
+ */
+
+/* CDCLK_CTL */
+#define CDCLK_CTL                      0x46000
+#define  CDCLK_FREQ_SEL_MASK           (3<<26)
+#define  CDCLK_FREQ_450_432            (0<<26)
+#define  CDCLK_FREQ_540                        (1<<26)
+#define  CDCLK_FREQ_337_308            (2<<26)
+#define  CDCLK_FREQ_675_617            (3<<26)
+#define         CDCLK_FREQ_DECIMAL_MASK        (0x7ff)

<ocd> Please replace the tab for a space on the line above. </ocd>

ok

Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/i915/i915_reg.h +23 -0
+
+/* LCPLL_CTL */
+#define LCPLL1_CTL             0x46010
+#define LCPLL2_CTL             0x46014
+#define  LCPLL_PLL_ENABLE      (1<<31)
+
+/* DPLL control1 */
+#define DPLL_CTRL1             0x6C058
+#define  DPLL_CTRL1_HDMI_MODE(id)              (1<<((id)*6+5))
+#define  DPLL_CTRL1_SSC(id)                    (1<<((id)*6+4))
+#define  DPLL_CRTL1_LINK_RATE_MASK(id)         (7<<((id)*6+1))
+#define  DPLL_CRTL1_LINK_RATE(linkrate, id)    ((linkrate)<<((id)*6+1))
+#define  DPLL_CTRL1_OVERRIDE(id)               (1<<((id)*6))
+#define  DPLL_CRTL1_LINK_RATE_2700             0
+#define  DPLL_CRTL1_LINK_RATE_1350             1
+#define  DPLL_CRTL1_LINK_RATE_810              2
+#define  DPLL_CRTL1_LINK_RATE_1620             3
+#define  DPLL_CRTL1_LINK_RATE_1080             4
+#define  DPLL_CRTL1_LINK_RATE_2160             5
+
+/* DPLL control2 */
+#define DPLL_CTRL2                             0x6C05C
+#define  DPLL_CTRL2_DDI_CLK_OFF(port)          (1<<(port+15))
Quoted 8 lines

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6380

Quoted 7 lines
drivers/gpu/drm/i915/i915_reg.h +7 -0
+#define  DPLL_CTRL2_DDI_CLK_SEL_MASK(port)     (3<<((port)*3+1))
+#define  DPLL_CTRL2_DDI_CLK_SEL(clk, port)     (clk<<((port)*3+1))
+#define  DPLL_CTRL2_DDI_SEL_OVERRIDE(port)     (1<<(port*3))
+
+/* DPLL Status */
+#define DPLL_STATUS    0x6C060
+#define         DPLL_LOCK(id)  (1<<((id)*8))

Bad tab here too.

ok, will take care of this.

Quoted 37 lines
Quoted 37 lines
drivers/gpu/drm/i915/i915_reg.h +36 -0
+
+/* DPLL cfg */
+#define DPLL1_CFGCR1   0x6C040
+#define DPLL2_CFGCR1   0x6C048
+#define DPLL3_CFGCR1   0x6C050
+#define  DPLL_CFGCR1_FREQ_ENABLE       (1<<31)
+#define  DPLL_CFGCR1_DCO_FRACTION_MASK (0x7fff<<9)
+#define  DPLL_CFGCR1_DCO_FRACTION(x)   (x<<9)
+#define  DPLL_CFGCR1_DCO_INTEGER_MASK  (0x1ff)
+
+#define DPLL1_CFGCR2   0x6C044
+#define DPLL2_CFGCR2   0x6C04C
+#define DPLL3_CFGCR2   0x6C054
+#define  DPLL_CFGCR2_QDIV_RATIO_MASK   (0xff<<8)
+#define  DPLL_CFGCR2_QDIV_RATIO(x)     (x<<8)
+#define  DPLL_CFGCR2_QDIV_MODE(x)      (x<<7)
+#define  DPLL_CFGCR2_KDIV_MASK         (3<<5)
+#define  DPLL_CFGCR2_KDIV(x)           (x<<5)
+#define  DPLL_CFGCR2_PDIV_MASK         (7<<2)
+#define  DPLL_CFGCR2_PDIV(x)           (x<<2)
+#define  DPLL_CFGCR2_CENTRAL_FREQ_MASK (3)
+
+enum central_freq {
+       freq_9600 = 0,
+       freq_9000 = 1,
+       freq_8400 = 3,
+};
+
+enum pdiv {
+       pdiv_1 = 0,
+       pdiv_2 = 1,
+       pdiv_3 = 2,
+       pdiv_7 = 4,
+};
+
+enum kdiv {
Quoted 8 lines

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6422

Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +6 -0
+       kdiv_5 = 0,
+       kdiv_2 = 1,
+       kdiv_3 = 2,
+       kdiv_1 = 3,
+};
+

I find it weird that we're using enums here. We don't have the tradition to do this, so it's a deviation from the usual coding style.

ok, will change this to #define

Quoted 14 lines

With or without changes:

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +0 -1
  /* Please see hsw_read_dcomp() and hsw_write_dcomp() before using this register,
   * since on HSW we can't write to it using I915_WRITE. */
  #define D_COMP_HSW                     (MCHBAR_MIRROR_BASE_SNB + 0x5F0C)
--

1.8.3.1

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

#166 lore raw

PATCH v5 58/89 drm/i915/skl: Register definitions for SKL Clocks

In reply to Paulo Zanoni

From: Satheeshakrishna M <[email protected]>

This patch defines the necessary SKL registers for implementing the new clocking mechanism.

v2: Addressed review comments by Damien
- Added code comment
- Introduced enum for WRPLL values

v3: Rebase on top of nightly (minor conflict in i915_reg.h)

v4: Use 0x, not 0X (Ville)

v5: Modified as per review comments from Paulo

---
 drivers/gpu/drm/i915/i915_reg.h | 72 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +72 -0
index 15f227b..eb35d05 100644
@@ -6434,6 +6434,78 @@ enum punit_power_well {
 #define  LCPLL_CD_SOURCE_FCLK		(1<<21)
 #define  LCPLL_CD_SOURCE_FCLK_DONE	(1<<19)
 
+/*
+ * SKL Clocks
+ */
+
+/* CDCLK_CTL */
+#define CDCLK_CTL			0x46000
+#define  CDCLK_FREQ_SEL_MASK		(3<<26)
+#define  CDCLK_FREQ_450_432		(0<<26)
+#define  CDCLK_FREQ_540			(1<<26)
+#define  CDCLK_FREQ_337_308		(2<<26)
+#define  CDCLK_FREQ_675_617		(3<<26)
+#define  CDCLK_FREQ_DECIMAL_MASK	(0x7ff)
+
+/* LCPLL_CTL */
+#define LCPLL1_CTL		0x46010
+#define LCPLL2_CTL		0x46014
+#define  LCPLL_PLL_ENABLE	(1<<31)
+
+/* DPLL control1 */
+#define DPLL_CTRL1		0x6C058
+#define  DPLL_CTRL1_HDMI_MODE(id)		(1<<((id)*6+5))
+#define  DPLL_CTRL1_SSC(id)			(1<<((id)*6+4))
+#define  DPLL_CRTL1_LINK_RATE_MASK(id)		(7<<((id)*6+1))
+#define  DPLL_CRTL1_LINK_RATE(linkrate, id)	((linkrate)<<((id)*6+1))
+#define  DPLL_CTRL1_OVERRIDE(id)		(1<<((id)*6))
+#define  DPLL_CRTL1_LINK_RATE_2700		0
+#define  DPLL_CRTL1_LINK_RATE_1350		1
+#define  DPLL_CRTL1_LINK_RATE_810		2
+#define  DPLL_CRTL1_LINK_RATE_1620		3
+#define  DPLL_CRTL1_LINK_RATE_1080		4
+#define  DPLL_CRTL1_LINK_RATE_2160		5
+
+/* DPLL control2 */
+#define DPLL_CTRL2				0x6C05C
+#define  DPLL_CTRL2_DDI_CLK_OFF(port)		(1<<(port+15))
+#define  DPLL_CTRL2_DDI_CLK_SEL_MASK(port)	(3<<((port)*3+1))
+#define  DPLL_CTRL2_DDI_CLK_SEL(clk, port)	(clk<<((port)*3+1))
+#define  DPLL_CTRL2_DDI_SEL_OVERRIDE(port)     (1<<((port)*3))
+
+/* DPLL Status */
+#define DPLL_STATUS	0x6C060
+#define  DPLL_LOCK(id) (1<<((id)*8))
+
+/* DPLL cfg */
+#define DPLL1_CFGCR1	0x6C040
+#define DPLL2_CFGCR1	0x6C048
+#define DPLL3_CFGCR1	0x6C050
+#define  DPLL_CFGCR1_FREQ_ENABLE	(1<<31)
+#define  DPLL_CFGCR1_DCO_FRACTION_MASK	(0x7fff<<9)
+#define  DPLL_CFGCR1_DCO_FRACTION(x)	(x<<9)
+#define  DPLL_CFGCR1_DCO_INTEGER_MASK	(0x1ff)
+
+#define DPLL1_CFGCR2	0x6C044
+#define DPLL2_CFGCR2	0x6C04C
+#define DPLL3_CFGCR2	0x6C054
+#define  DPLL_CFGCR2_QDIV_RATIO_MASK	(0xff<<8)
+#define  DPLL_CFGCR2_QDIV_RATIO(x)	(x<<8)
+#define  DPLL_CFGCR2_QDIV_MODE(x)	(x<<7)
+#define  DPLL_CFGCR2_KDIV_MASK		(3<<5)
+#define  DPLL_CFGCR2_KDIV(x)		(x<<5)
+#define  DPLL_CFGCR2_KDIV_5 (0<<5)
+#define  DPLL_CFGCR2_KDIV_2 (1<<5)
+#define  DPLL_CFGCR2_KDIV_3 (2<<5)
+#define  DPLL_CFGCR2_KDIV_1 (3<<5)
+#define  DPLL_CFGCR2_PDIV_MASK		(7<<2)
+#define  DPLL_CFGCR2_PDIV(x)		(x<<2)
+#define  DPLL_CFGCR2_PDIV_1 (0<<2)
+#define  DPLL_CFGCR2_PDIV_2 (1<<2)
+#define  DPLL_CFGCR2_PDIV_3 (2<<2)
+#define  DPLL_CFGCR2_PDIV_7 (4<<2)
+#define  DPLL_CFGCR2_CENTRAL_FREQ_MASK	(3)
+
 /* Please see hsw_read_dcomp() and hsw_write_dcomp() before using this register,
  * since on HSW we can't write to it using I915_WRITE. */
 #define D_COMP_HSW			(MCHBAR_MIRROR_BASE_SNB + 0x5F0C)
Signature · 6 lines
1.8.3.1

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

PATCH 59/89 drm/i915/skl: Structure/enum definitions for SKL clocks

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

Adding structure/enum for SKL clocking implementation.

v2: Addressed Damien's comment
- Removed internal structure from this header file

v3: Stove this into the generic intel_dpll_id enum and give them the established DPLL_ID_ prefixes. (Daniel)

v4: - We'll only try to share DPLL1/2/3, leaving DPLL0 to eDP
- Use SKL in the skylake shared DPLL names
- Re-add the skl_dpll enum
(Damien)

v5: Remove SKL_DPLL_NONE (Daniel)

---
 drivers/gpu/drm/i915/i915_drv.h | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +13 -1
index 84defa4..65e5ffb 100644
@@ -206,10 +206,15 @@ enum intel_dpll_id {
 	/* real shared dpll ids must be >= 0 */
 	DPLL_ID_PCH_PLL_A = 0,
 	DPLL_ID_PCH_PLL_B = 1,
+	/* hsw/bdw */
 	DPLL_ID_WRPLL1 = 0,
 	DPLL_ID_WRPLL2 = 1,
+	/* skl */
+	DPLL_ID_SKL_DPLL1 = 0,
+	DPLL_ID_SKL_DPLL2 = 1,
+	DPLL_ID_SKL_DPLL3 = 2,
 };
-#define I915_NUM_PLLS 2
+#define I915_NUM_PLLS 3
 
 struct intel_dpll_hw_state {
 	/* i9xx, pch plls */
@@ -243,6 +248,13 @@ struct intel_shared_dpll {
 			     struct intel_dpll_hw_state *hw_state);
 };
 
+enum skl_dpll {
+	SKL_DPLL0,
+	SKL_DPLL1,
+	SKL_DPLL2,
+	SKL_DPLL3,
+};
+
 /* Used by dp and fdi links */
 struct intel_link_m_n {
 	uint32_t	tu;
Signature · 1 line
1.8.3.1
#168 lore raw

Re: [PATCH 59/89] drm/i915/skl: Structure/enum definitions for SKL clocks

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 15 lines

From: Satheeshakrishna M <[email protected]>

Adding structure/enum for SKL clocking implementation.

v2: Addressed Damien's comment
- Removed internal structure from this header file

v3: Stove this into the generic intel_dpll_id enum and give them the established DPLL_ID_ prefixes. (Daniel)

v4: - We'll only try to share DPLL1/2/3, leaving DPLL0 to eDP
- Use SKL in the skylake shared DPLL names
- Re-add the skl_dpll enum
(Damien)

Quoted 5 lines

v5: Remove SKL_DPLL_NONE (Daniel)

The changes contained on this patch should be part of another patch. I can't really review this if I don't know how those things, especially enum skl_dpll are going to be used. And it also makes the lives of backporters harder.

Also, I guess that a patch with 3 signed-off-by stamps shouldn't really need an additional reviewed-by stamp, right? So maybe this should just be merged.

Quoted 46 lines
---
 drivers/gpu/drm/i915/i915_drv.h | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +13 -2
index 84defa4..65e5ffb 100644
@@ -206,10 +206,15 @@ enum intel_dpll_id {
        /* real shared dpll ids must be >= 0 */
        DPLL_ID_PCH_PLL_A = 0,
        DPLL_ID_PCH_PLL_B = 1,
+       /* hsw/bdw */
        DPLL_ID_WRPLL1 = 0,
        DPLL_ID_WRPLL2 = 1,
+       /* skl */
+       DPLL_ID_SKL_DPLL1 = 0,
+       DPLL_ID_SKL_DPLL2 = 1,
+       DPLL_ID_SKL_DPLL3 = 2,
 };
-#define I915_NUM_PLLS 2
+#define I915_NUM_PLLS 3
 
 struct intel_dpll_hw_state {
        /* i9xx, pch plls */
@@ -243,6 +248,13 @@ struct intel_shared_dpll {
                             struct intel_dpll_hw_state *hw_state);
 };
 
+enum skl_dpll {
+       SKL_DPLL0,
+       SKL_DPLL1,
+       SKL_DPLL2,
+       SKL_DPLL3,
+};
+
 /* Used by dp and fdi links */
 struct intel_link_m_n {
        uint32_t        tu;
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
author Reviewed-by
#169 lore raw

Re: [PATCH 59/89] drm/i915/skl: Structure/enum definitions for SKL clocks

Quoted 22 lines · Paulo Zanoni

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 15 lines

From: Satheeshakrishna M <[email protected]>

Adding structure/enum for SKL clocking implementation.

v2: Addressed Damien's comment
- Removed internal structure from this header file

v3: Stove this into the generic intel_dpll_id enum and give them the established DPLL_ID_ prefixes. (Daniel)

v4: - We'll only try to share DPLL1/2/3, leaving DPLL0 to eDP
- Use SKL in the skylake shared DPLL names
- Re-add the skl_dpll enum
(Damien)

Quoted 5 lines

v5: Remove SKL_DPLL_NONE (Daniel)

Quoted 8 lines

The changes contained on this patch should be part of another patch. I can't really review this if I don't know how those things, especially enum skl_dpll are going to be used. And it also makes the lives of backporters harder.

Also, I guess that a patch with 3 signed-off-by stamps shouldn't really need an additional reviewed-by stamp, right? So maybe this should just be merged.

Well, I can add my r-b tag here, why not.

Signature · 5 lines
Damien
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#170 lore raw

Re: [PATCH 59/89] drm/i915/skl: Structure/enum definitions for SKL clocks

Quoted 4 lines · Damien Lespiau
Quoted 3 lines · Paulo Zanoni

Also, I guess that a patch with 3 signed-off-by stamps shouldn't really need an additional reviewed-by stamp, right? So maybe this should just be merged.

The sob stamps are because of the rebases in -internal. I've made it practice to not just augment the patch revision log, but also add my name somewhere so that blame can be assigned. But that doesn't mean I've actually reviewed the beast at all complete, just that I've made some adaptions to make it work again on upstream.

For this case here where Damien completely rewrote the patch the self-r-b is kinda pointless. So yeah even when the patch has been passed around a lot (and for a long time) and don't think that's a good reason not to throw review at it. Ofc this patch here is really simple ;-)

Cheers, Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#171 lore raw

PATCH 60/89 drm/i915/skl: CD clock back calculation for SKL

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

Determine programmed cd clock for SKL.

v2: Fix the LCPLL1 enable warning logic

v3: Rebase over the hsw pll rework.

v4: Rebase on top of the per-platform split (Damien)

---
 drivers/gpu/drm/i915/intel_ddi.c | 76 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 67 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +67 -9
index ba1103f..e7a5428 100644
@@ -1260,6 +1260,55 @@ static void intel_disable_ddi(struct intel_encoder *intel_encoder)
 	}
 }
 
+static int skl_get_cdclk_freq(struct drm_i915_private *dev_priv)
+{
+	uint32_t lcpll1 = I915_READ(LCPLL1_CTL);
+	uint32_t cdctl = I915_READ(CDCLK_CTL);
+	uint32_t linkrate;
+
+	if (!(lcpll1 & LCPLL_PLL_ENABLE)) {
+		WARN(1, "LCPLL1 not enabled\n");
+		return 24000; /* 24MHz is the cd freq with NSSC ref */
+	}
+
+	if ((cdctl & CDCLK_FREQ_SEL_MASK) == CDCLK_FREQ_540)
+		return 540000;
+
+	linkrate = (I915_READ(DPLL_CTRL1) &
+		    DPLL_CRTL1_LINK_RATE_MASK(SKL_DPLL0)) >> 1;
+
+	if (linkrate == DPLL_CRTL1_LINK_RATE_2160 ||
+	    linkrate == DPLL_CRTL1_LINK_RATE_1080) {
+		/* vco 8640 */
+		switch (cdctl & CDCLK_FREQ_SEL_MASK) {
+		case CDCLK_FREQ_450_432:
+			return 432000;
+		case CDCLK_FREQ_337_308:
+			return 308570;
+		case CDCLK_FREQ_675_617:
+			return 617140;
+			break;
+		default:
+			WARN(1, "Unknown cd freq selection\n");
+		}
+	} else {
+		/* vco 8100 */
+		switch (cdctl & CDCLK_FREQ_SEL_MASK) {
+		case CDCLK_FREQ_450_432:
+			return 450000;
+		case CDCLK_FREQ_337_308:
+			return 337500;
+		case CDCLK_FREQ_675_617:
+			return 675000;
+		default:
+			WARN(1, "Unknown cd freq selection\n");
+		}
+	}
+
+	/* error case, do as if DPLL0 isn't enabled */
+	return 24000;
+}
+
 static int bdw_get_cdclk_freq(struct drm_i915_private *dev_priv)
 {
 	uint32_t lcpll = I915_READ(LCPLL_CTL);
@@ -1301,6 +1350,9 @@ int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv)
 {
 	struct drm_device *dev = dev_priv->dev;
 
+	if (IS_SKYLAKE(dev))
+		return skl_get_cdclk_freq(dev_priv);
+
 	if (IS_BROADWELL(dev))
 		return bdw_get_cdclk_freq(dev_priv);
 
@@ -1369,19 +1421,25 @@ void intel_ddi_pll_init(struct drm_device *dev)
 
 	hsw_shared_dplls_init(dev_priv);
 
-	/* The LCPLL register should be turned on by the BIOS. For now let's
-	 * just check its state and print errors in case something is wrong.
-	 * Don't even try to turn it on.
-	 */
-
 	DRM_DEBUG_KMS("CDCLK running at %dKHz\n",
 		      intel_ddi_get_cdclk_freq(dev_priv));
 
-	if (val & LCPLL_CD_SOURCE_FCLK)
-		DRM_ERROR("CDCLK source is not LCPLL\n");
+	if (IS_SKYLAKE(dev)) {
+		if (!(I915_READ(LCPLL1_CTL) & LCPLL_PLL_ENABLE))
+			DRM_ERROR("LCPLL1 is disabled\n");
+	} else {
+		/*
+		 * The LCPLL register should be turned on by the BIOS. For now
+		 * let's just check its state and print errors in case
+		 * something is wrong.  Don't even try to turn it on.
+		 */
+
+		if (val & LCPLL_CD_SOURCE_FCLK)
+			DRM_ERROR("CDCLK source is not LCPLL\n");
 
-	if (val & LCPLL_PLL_DISABLE)
-		DRM_ERROR("LCPLL is disabled\n");
+		if (val & LCPLL_PLL_DISABLE)
+			DRM_ERROR("LCPLL is disabled\n");
+	}
 }
 
 void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder)
Signature · 1 line
1.8.3.1
#172 lore raw

Re: [PATCH 60/89] drm/i915/skl: CD clock back calculation for SKL

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 42 lines

From: Satheeshakrishna M <[email protected]>

Determine programmed cd clock for SKL.

v2: Fix the LCPLL1 enable warning logic

v3: Rebase over the hsw pll rework.

v4: Rebase on top of the per-platform split (Damien)

---
 drivers/gpu/drm/i915/intel_ddi.c | 76 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 67 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +18 -0
index ba1103f..e7a5428 100644
@@ -1260,6 +1260,55 @@ static void intel_disable_ddi(struct intel_encoder *intel_encoder)
        }
 }
 
+static int skl_get_cdclk_freq(struct drm_i915_private *dev_priv)
+{
+       uint32_t lcpll1 = I915_READ(LCPLL1_CTL);
+       uint32_t cdctl = I915_READ(CDCLK_CTL);
+       uint32_t linkrate;
+
+       if (!(lcpll1 & LCPLL_PLL_ENABLE)) {
+               WARN(1, "LCPLL1 not enabled\n");
+               return 24000; /* 24MHz is the cd freq with NSSC ref */
+       }
+
+       if ((cdctl & CDCLK_FREQ_SEL_MASK) == CDCLK_FREQ_540)
+               return 540000;
+
+       linkrate = (I915_READ(DPLL_CTRL1) &
+                   DPLL_CRTL1_LINK_RATE_MASK(SKL_DPLL0)) >> 1;
+
+       if (linkrate == DPLL_CRTL1_LINK_RATE_2160 ||

drivers/gpu/drm/i915/intel_ddi.c static void intel_disable_ddi(struct intel_encoder *intel_encoder) · line 1290

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +10 -0
+           linkrate == DPLL_CRTL1_LINK_RATE_1080) {
+               /* vco 8640 */
+               switch (cdctl & CDCLK_FREQ_SEL_MASK) {
+               case CDCLK_FREQ_450_432:
+                       return 432000;
+               case CDCLK_FREQ_337_308:
+                       return 308570;
+               case CDCLK_FREQ_675_617:
+                       return 617140;
+                       break;

This is the only line with a "break" after a return :)

Quoted 25 lines
drivers/gpu/drm/i915/intel_ddi.c +21 -0
+               default:
+                       WARN(1, "Unknown cd freq selection\n");
+               }
+       } else {
+               /* vco 8100 */
+               switch (cdctl & CDCLK_FREQ_SEL_MASK) {
+               case CDCLK_FREQ_450_432:
+                       return 450000;
+               case CDCLK_FREQ_337_308:
+                       return 337500;
+               case CDCLK_FREQ_675_617:
+                       return 675000;
+               default:
+                       WARN(1, "Unknown cd freq selection\n");
+               }
+       }
+
+       /* error case, do as if DPLL0 isn't enabled */
+       return 24000;
+}
+
 static int bdw_get_cdclk_freq(struct drm_i915_private *dev_priv)
 {
        uint32_t lcpll = I915_READ(LCPLL_CTL);

drivers/gpu/drm/i915/intel_ddi.c int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv) · line 1355

Quoted 6 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
@@ -1301,6 +1350,9 @@ int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv)
 {
        struct drm_device *dev = dev_priv->dev;
 
+       if (IS_SKYLAKE(dev))
+               return skl_get_cdclk_freq(dev_priv);
+

I hope someone will replace this with a "switch (INTEL_INFO(gen))" before Gen 15 :)

With or without changes: Reviewed-by: Paulo Zanoni <[email protected]>

Quoted 45 lines
drivers/gpu/drm/i915/intel_ddi.c +15 -10
        if (IS_BROADWELL(dev))
                return bdw_get_cdclk_freq(dev_priv);
 
@@ -1369,19 +1421,25 @@ void intel_ddi_pll_init(struct drm_device *dev)
 
        hsw_shared_dplls_init(dev_priv);
 
-       /* The LCPLL register should be turned on by the BIOS. For now let's
-        * just check its state and print errors in case something is wrong.
-        * Don't even try to turn it on.
-        */
-
        DRM_DEBUG_KMS("CDCLK running at %dKHz\n",
                      intel_ddi_get_cdclk_freq(dev_priv));
 
-       if (val & LCPLL_CD_SOURCE_FCLK)
-               DRM_ERROR("CDCLK source is not LCPLL\n");
+       if (IS_SKYLAKE(dev)) {
+               if (!(I915_READ(LCPLL1_CTL) & LCPLL_PLL_ENABLE))
+                       DRM_ERROR("LCPLL1 is disabled\n");
+       } else {
+               /*
+                * The LCPLL register should be turned on by the BIOS. For now
+                * let's just check its state and print errors in case
+                * something is wrong.  Don't even try to turn it on.
+                */
+
+               if (val & LCPLL_CD_SOURCE_FCLK)
+                       DRM_ERROR("CDCLK source is not LCPLL\n");
 
-       if (val & LCPLL_PLL_DISABLE)
-               DRM_ERROR("LCPLL is disabled\n");
+               if (val & LCPLL_PLL_DISABLE)
+                       DRM_ERROR("LCPLL is disabled\n");
+       }
 }
 
 void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder)
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#173 lore raw

Re: [PATCH 60/89] drm/i915/skl: CD clock back calculation for SKL

Quoted 46 lines · Paulo Zanoni

2014-09-04 8:27 GMT-03:00 Damien Lespiau<[email protected]>:

Quoted 45 lines

From: Satheeshakrishna M<[email protected]>

Determine programmed cd clock for SKL.

v2: Fix the LCPLL1 enable warning logic

v3: Rebase over the hsw pll rework.

v4: Rebase on top of the per-platform split (Damien)

---
  drivers/gpu/drm/i915/intel_ddi.c | 76 +++++++++++++++++++++++++++++++++++-----
  1 file changed, 67 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +21 -0
index ba1103f..e7a5428 100644
@@ -1260,6 +1260,55 @@ static void intel_disable_ddi(struct intel_encoder *intel_encoder)
         }
  }
 
+static int skl_get_cdclk_freq(struct drm_i915_private *dev_priv)
+{
+       uint32_t lcpll1 = I915_READ(LCPLL1_CTL);
+       uint32_t cdctl = I915_READ(CDCLK_CTL);
+       uint32_t linkrate;
+
+       if (!(lcpll1 & LCPLL_PLL_ENABLE)) {
+               WARN(1, "LCPLL1 not enabled\n");
+               return 24000; /* 24MHz is the cd freq with NSSC ref */
+       }
+
+       if ((cdctl & CDCLK_FREQ_SEL_MASK) == CDCLK_FREQ_540)
+               return 540000;
+
+       linkrate = (I915_READ(DPLL_CTRL1) &
+                   DPLL_CRTL1_LINK_RATE_MASK(SKL_DPLL0)) >> 1;
+
+       if (linkrate == DPLL_CRTL1_LINK_RATE_2160 ||
+           linkrate == DPLL_CRTL1_LINK_RATE_1080) {
+               /* vco 8640 */
+               switch (cdctl & CDCLK_FREQ_SEL_MASK) {
Quoted 8 lines

drivers/gpu/drm/i915/intel_ddi.c static void intel_disable_ddi(struct intel_encoder *intel_encoder) · line 1290

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +7 -0
+               case CDCLK_FREQ_450_432:
+                       return 432000;
+               case CDCLK_FREQ_337_308:
+                       return 308570;
+               case CDCLK_FREQ_675_617:
+                       return 617140;
+                       break;

This is the only line with a "break" after a return :)

oops.. will remove it

Quoted 84 lines
Quoted 26 lines
drivers/gpu/drm/i915/intel_ddi.c +21 -0
+               default:
+                       WARN(1, "Unknown cd freq selection\n");
+               }
+       } else {
+               /* vco 8100 */
+               switch (cdctl & CDCLK_FREQ_SEL_MASK) {
+               case CDCLK_FREQ_450_432:
+                       return 450000;
+               case CDCLK_FREQ_337_308:
+                       return 337500;
+               case CDCLK_FREQ_675_617:
+                       return 675000;
+               default:
+                       WARN(1, "Unknown cd freq selection\n");
+               }
+       }
+
+       /* error case, do as if DPLL0 isn't enabled */
+       return 24000;
+}
+
  static int bdw_get_cdclk_freq(struct drm_i915_private *dev_priv)
  {
         uint32_t lcpll = I915_READ(LCPLL_CTL);

drivers/gpu/drm/i915/intel_ddi.c int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv) · line 1355

Quoted 6 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
@@ -1301,6 +1350,9 @@ int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv)
  {
         struct drm_device *dev = dev_priv->dev;
 
+       if (IS_SKYLAKE(dev))
+               return skl_get_cdclk_freq(dev_priv);
+

I hope someone will replace this with a "switch (INTEL_INFO(gen))" before Gen 15 :)

With or without changes: Reviewed-by: Paulo Zanoni<[email protected]>

Quoted 45 lines
drivers/gpu/drm/i915/intel_ddi.c +15 -10
         if (IS_BROADWELL(dev))
                 return bdw_get_cdclk_freq(dev_priv);
 
@@ -1369,19 +1421,25 @@ void intel_ddi_pll_init(struct drm_device *dev)
 
         hsw_shared_dplls_init(dev_priv);
 
-       /* The LCPLL register should be turned on by the BIOS. For now let's
-        * just check its state and print errors in case something is wrong.
-        * Don't even try to turn it on.
-        */
-
         DRM_DEBUG_KMS("CDCLK running at %dKHz\n",
                       intel_ddi_get_cdclk_freq(dev_priv));
 
-       if (val & LCPLL_CD_SOURCE_FCLK)
-               DRM_ERROR("CDCLK source is not LCPLL\n");
+       if (IS_SKYLAKE(dev)) {
+               if (!(I915_READ(LCPLL1_CTL) & LCPLL_PLL_ENABLE))
+                       DRM_ERROR("LCPLL1 is disabled\n");
+       } else {
+               /*
+                * The LCPLL register should be turned on by the BIOS. For now
+                * let's just check its state and print errors in case
+                * something is wrong.  Don't even try to turn it on.
+                */
+
+               if (val & LCPLL_CD_SOURCE_FCLK)
+                       DRM_ERROR("CDCLK source is not LCPLL\n");
 
-       if (val & LCPLL_PLL_DISABLE)
-               DRM_ERROR("LCPLL is disabled\n");
+               if (val & LCPLL_PLL_DISABLE)
+                       DRM_ERROR("LCPLL is disabled\n");
+       }
  }
 
  void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder)
--

1.8.3.1

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

#174 lore raw

PATCH v5 60/89 drm/i915/skl: CD clock back calculation for SKL

In reply to Paulo Zanoni

From: Satheeshakrishna M <[email protected]>

Determine programmed cd clock for SKL.

v2: Fix the LCPLL1 enable warning logic

v3: Rebase over the hsw pll rework.

v4: Rebase on top of the per-platform split (Damien)

v5: Modified as per review comments from Paulo

---
 drivers/gpu/drm/i915/intel_ddi.c | 75 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 66 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +66 -9
index a49f454..72691ec 100644
@@ -1276,6 +1276,54 @@ static void intel_disable_ddi(struct intel_encoder *intel_encoder)
 	}
 }
 
+static int skl_get_cdclk_freq(struct drm_i915_private *dev_priv)
+{
+	uint32_t lcpll1 = I915_READ(LCPLL1_CTL);
+	uint32_t cdctl = I915_READ(CDCLK_CTL);
+	uint32_t linkrate;
+
+	if (!(lcpll1 & LCPLL_PLL_ENABLE)) {
+		WARN(1, "LCPLL1 not enabled\n");
+		return 24000; /* 24MHz is the cd freq with NSSC ref */
+	}
+
+	if ((cdctl & CDCLK_FREQ_SEL_MASK) == CDCLK_FREQ_540)
+		return 540000;
+
+	linkrate = (I915_READ(DPLL_CTRL1) &
+		    DPLL_CRTL1_LINK_RATE_MASK(SKL_DPLL0)) >> 1;
+
+	if (linkrate == DPLL_CRTL1_LINK_RATE_2160 ||
+	    linkrate == DPLL_CRTL1_LINK_RATE_1080) {
+		/* vco 8640 */
+		switch (cdctl & CDCLK_FREQ_SEL_MASK) {
+		case CDCLK_FREQ_450_432:
+			return 432000;
+		case CDCLK_FREQ_337_308:
+			return 308570;
+		case CDCLK_FREQ_675_617:
+			return 617140;
+		default:
+			WARN(1, "Unknown cd freq selection\n");
+		}
+	} else {
+		/* vco 8100 */
+		switch (cdctl & CDCLK_FREQ_SEL_MASK) {
+		case CDCLK_FREQ_450_432:
+			return 450000;
+		case CDCLK_FREQ_337_308:
+			return 337500;
+		case CDCLK_FREQ_675_617:
+			return 675000;
+		default:
+			WARN(1, "Unknown cd freq selection\n");
+		}
+	}
+
+	/* error case, do as if DPLL0 isn't enabled */
+	return 24000;
+}
+
 static int bdw_get_cdclk_freq(struct drm_i915_private *dev_priv)
 {
 	uint32_t lcpll = I915_READ(LCPLL_CTL);
@@ -1317,6 +1365,9 @@ int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv)
 {
 	struct drm_device *dev = dev_priv->dev;
 
+	if (IS_SKYLAKE(dev))
+		return skl_get_cdclk_freq(dev_priv);
+
 	if (IS_BROADWELL(dev))
 		return bdw_get_cdclk_freq(dev_priv);
 
@@ -1385,19 +1436,25 @@ void intel_ddi_pll_init(struct drm_device *dev)
 
 	hsw_shared_dplls_init(dev_priv);
 
-	/* The LCPLL register should be turned on by the BIOS. For now let's
-	 * just check its state and print errors in case something is wrong.
-	 * Don't even try to turn it on.
-	 */
-
 	DRM_DEBUG_KMS("CDCLK running at %dKHz\n",
 		      intel_ddi_get_cdclk_freq(dev_priv));
 
-	if (val & LCPLL_CD_SOURCE_FCLK)
-		DRM_ERROR("CDCLK source is not LCPLL\n");
+	if (IS_SKYLAKE(dev)) {
+		if (!(I915_READ(LCPLL1_CTL) & LCPLL_PLL_ENABLE))
+			DRM_ERROR("LCPLL1 is disabled\n");
+	} else {
+		/*
+		 * The LCPLL register should be turned on by the BIOS. For now
+		 * let's just check its state and print errors in case
+		 * something is wrong.  Don't even try to turn it on.
+		 */
+
+		if (val & LCPLL_CD_SOURCE_FCLK)
+			DRM_ERROR("CDCLK source is not LCPLL\n");
 
-	if (val & LCPLL_PLL_DISABLE)
-		DRM_ERROR("LCPLL is disabled\n");
+		if (val & LCPLL_PLL_DISABLE)
+			DRM_ERROR("LCPLL is disabled\n");
+	}
 }
 
 void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder)
Signature · 6 lines
1.8.3.1

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

PATCH 61/89 drm/i915/skl: Determine enabled PLL and its linkrate/pixel clock

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

v2: Fixup compilation due to the removal of the intel_ddi_dpll_id enum. And add a fixme about the abuse of pipe_config here.

v3: Rebase on top of the hsw_ddi_clock_get() rename (Damien)

---
 drivers/gpu/drm/i915/i915_reg.h  |   5 ++
 drivers/gpu/drm/i915/intel_ddi.c | 114 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 118 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_reg.h +5 -0
index 2364ece..794d0ba 100644
@@ -6367,6 +6367,7 @@ enum punit_power_well {
 #define  DPLL_CRTL1_LINK_RATE_1620		3
 #define  DPLL_CRTL1_LINK_RATE_1080		4
 #define  DPLL_CRTL1_LINK_RATE_2160		5
+#define  DPLL_CRTL1_LINK_RATE_SHIFT(id)		((id)*6+1)
 
 /* DPLL control2 */
 #define DPLL_CTRL2				0x6C05C
@@ -6374,6 +6375,7 @@ enum punit_power_well {
 #define  DPLL_CTRL2_DDI_CLK_SEL_MASK(port)	(3<<((port)*3+1))
 #define  DPLL_CTRL2_DDI_CLK_SEL(clk, port)	(clk<<((port)*3+1))
 #define  DPLL_CTRL2_DDI_SEL_OVERRIDE(port)	(1<<(port*3))
+#define  DPLL_CTRL2_DDI_CLK_SEL_SHIFT(port)	(port*3+1)
 
 /* DPLL Status */
 #define DPLL_STATUS	0x6C060
@@ -6400,6 +6402,9 @@ enum punit_power_well {
 #define  DPLL_CFGCR2_PDIV(x)		(x<<2)
 #define  DPLL_CFGCR2_CENTRAL_FREQ_MASK	(3)
 
+#define GET_CFG_CR1_REG(id) (DPLL1_CFGCR1 + (id - 1) * 8)
+#define GET_CFG_CR2_REG(id) (DPLL1_CFGCR2 + (id - 1) * 8)
+
 enum central_freq {
 	freq_9600 = 0,
 	freq_9000 = 1,
drivers/gpu/drm/i915/intel_ddi.c +113 -1

132 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#176 lore raw

Re: [PATCH 61/89] drm/i915/skl: Determine enabled PLL and its linkrate/pixel clock

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 20 lines

From: Satheeshakrishna M <[email protected]>

v2: Fixup compilation due to the removal of the intel_ddi_dpll_id enum. And add a fixme about the abuse of pipe_config here.

v3: Rebase on top of the hsw_ddi_clock_get() rename (Damien)

---
 drivers/gpu/drm/i915/i915_reg.h  |   5 ++
 drivers/gpu/drm/i915/intel_ddi.c | 114 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 118 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_reg.h +0 -0
index 2364ece..794d0ba 100644

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6370

Quoted 4 lines
drivers/gpu/drm/i915/i915_reg.h +1 -0
@@ -6367,6 +6367,7 @@ enum punit_power_well {
 #define  DPLL_CRTL1_LINK_RATE_1620             3
 #define  DPLL_CRTL1_LINK_RATE_1080             4
 #define  DPLL_CRTL1_LINK_RATE_2160             5
+#define  DPLL_CRTL1_LINK_RATE_SHIFT(id)                ((id)*6+1)

I'd move this to a few lines above, where the MASK and RATE definitions are. Possibly reimplement the other macros using the new one (if the lines don't look to big/ugly).

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6378

Quoted 8 lines
drivers/gpu/drm/i915/i915_reg.h +1 -0
 /* DPLL control2 */
 #define DPLL_CTRL2                             0x6C05C
@@ -6374,6 +6375,7 @@ enum punit_power_well {
 #define  DPLL_CTRL2_DDI_CLK_SEL_MASK(port)     (3<<((port)*3+1))
 #define  DPLL_CTRL2_DDI_CLK_SEL(clk, port)     (clk<<((port)*3+1))
 #define  DPLL_CTRL2_DDI_SEL_OVERRIDE(port)     (1<<(port*3))
+#define  DPLL_CTRL2_DDI_CLK_SEL_SHIFT(port)    (port*3+1)

Same here: move a few lines above, and possibly reimplement the others using the new one. Also, use "(port)" instead of "port", since we don't want to risk really-hard-to-debug bugs due to operator precedence on those "*" and "+" operations.

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6406

Quoted 9 lines
drivers/gpu/drm/i915/i915_reg.h +2 -0
 /* DPLL Status */
 #define DPLL_STATUS    0x6C060
@@ -6400,6 +6402,9 @@ enum punit_power_well {
 #define  DPLL_CFGCR2_PDIV(x)           (x<<2)
 #define  DPLL_CFGCR2_CENTRAL_FREQ_MASK (3)
 
+#define GET_CFG_CR1_REG(id) (DPLL1_CFGCR1 + (id - 1) * 8)
+#define GET_CFG_CR2_REG(id) (DPLL1_CFGCR2 + (id - 1) * 8)

The macros above are not really trivial due to the fact that the "id" is undefined and confusing. Please convert this to an inline function, since what we're actually expecting here is "enum intel_dpll_id", which has ID 0 for DPLL 1, which can be super confusing (imagine someone passing ID 1 for DPLL 1, not realizing it should be using the correct enum...). If we use a function we can specify the correct expected enum for the ID type, which helps the programmer find out what is the expected thing to pass to the function.

Quoted 14 lines
drivers/gpu/drm/i915/i915_reg.h +1 -0
+
 enum central_freq {
        freq_9600 = 0,
        freq_9000 = 1,
drivers/gpu/drm/i915/intel_ddi.c +2 -0
index e7a5428..b5cfb07 100644
@@ -649,6 +649,114 @@ static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv,
        return (refclk * n * 100) / (p * r);
 }
 
+static int skl_calc_wrpll_link(struct drm_i915_private *dev_priv,
+                              enum intel_dpll_id dpll)

drivers/gpu/drm/i915/intel_ddi.c static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv, · line 663

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +10 -0
+{
+       uint32_t cfgcr1_reg, cfgcr2_reg;
+       uint32_t cfgcr1, cfgcr2;
+       uint32_t p0, p1, p2, dco_freq;
+
+       cfgcr1_reg = GET_CFG_CR1_REG(dpll);
+       cfgcr2_reg = GET_CFG_CR2_REG(dpll);
+
+       cfgcr1 = I915_READ(cfgcr1_reg);
+       cfgcr2 = I915_READ(cfgcr2_reg);

Bikeshed: I'd probably call these cfgcr{1,2}_val to avoid confusion.

Quoted 29 lines
drivers/gpu/drm/i915/intel_ddi.c +29 -0
+
+       p0 = (cfgcr2 & DPLL_CFGCR2_PDIV_MASK) >> 2;
+       p2 = (cfgcr2 & DPLL_CFGCR2_KDIV_MASK) >> 5;
+
+       if (cfgcr2 &  DPLL_CFGCR2_QDIV_MODE(1))
+               p1 = (cfgcr2 & DPLL_CFGCR2_QDIV_RATIO_MASK) >> 8;
+       else
+               p1 = 1;
+
+
+       switch (p0) {
+       case pdiv_1:
+               p0 = 1;
+               break;
+       case pdiv_2:
+               p0 = 2;
+               break;
+       case pdiv_3:
+               p0 = 3;
+               break;
+       case pdiv_7:
+               p0 = 7;
+               break;
+       }
+
+       switch (p2) {
+       case kdiv_5:
+               p2 = 5;
+               break;

drivers/gpu/drm/i915/intel_ddi.c static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv, · line 702

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +10 -0
+       case kdiv_2:
+               p2 = 2;
+               break;
+       case kdiv_3:
+               p2 = 3;
+               break;
+       case kdiv_1:
+               p2 = 1;
+               break;
+       }

I really think that if we had something like:
#define DPLL_CFGCR2_PDIV_7 (4 << 2)
we'd be able to avoid this "convert to enum and then get the value" part, making the function much simpler...

Quoted 31 lines
drivers/gpu/drm/i915/intel_ddi.c +31 -0
+
+       dco_freq = (cfgcr1 & DPLL_CFGCR1_DCO_INTEGER_MASK) * 24 * 1000;
+
+       dco_freq += (((cfgcr1 & DPLL_CFGCR1_DCO_FRACTION_MASK) >> 9) * 24 *
+               1000) / 0x8000;
+
+       return dco_freq / (p0 * p1 * p2 * 5);
+}
+
+
+static void skl_ddi_clock_get(struct intel_encoder *encoder,
+                               struct intel_crtc_config *pipe_config)
+{
+       struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+       enum port port = intel_ddi_get_encoder_port(encoder);
+       int link_clock = 0;
+       uint32_t dpll_ctl1, dpll;
+
+       /* FIXME: This should be tracked in the pipe config. */
+       dpll = I915_READ(DPLL_CTRL2);
+       dpll &= DPLL_CTRL2_DDI_CLK_SEL_MASK(port);
+       dpll >>= DPLL_CTRL2_DDI_CLK_SEL_SHIFT(port);
+
+       dpll_ctl1 = I915_READ(DPLL_CTRL1);
+
+       if (dpll_ctl1 & DPLL_CTRL1_HDMI_MODE(dpll)) {
+               link_clock = skl_calc_wrpll_link(dev_priv, dpll);
+       } else {
+               link_clock = dpll_ctl1 & DPLL_CRTL1_LINK_RATE_MASK(dpll);
+               link_clock >>= DPLL_CRTL1_LINK_RATE_SHIFT(dpll);
+

drivers/gpu/drm/i915/intel_ddi.c static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv, · line 743

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +10 -0
+               switch (link_clock) {
+               case DPLL_CRTL1_LINK_RATE_810:
+                       link_clock = 81000;
+                       break;
+               case DPLL_CRTL1_LINK_RATE_1350:
+                       link_clock = 135000;
+                       break;
+               case DPLL_CRTL1_LINK_RATE_2700:
+                       link_clock = 270000;
+                       break;

What about 1620 and 1080?

drivers/gpu/drm/i915/intel_ddi.c static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv, · line 745

Quoted 2 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -0
+               default:
+                       break;

We're just silently failing here, which will probably result in later WARNs on the HW state readout/check code. So we should probably give a WARN() here to make debugging easier :)

Quoted 26 lines
drivers/gpu/drm/i915/intel_ddi.c +15 -0
+               }
+               link_clock *= 2;
+       }
+
+       pipe_config->port_clock = link_clock;
+
+       if (pipe_config->has_dp_encoder)
+               pipe_config->adjusted_mode.crtc_clock =
+                       intel_dotclock_calculate(pipe_config->port_clock,
+                                                &pipe_config->dp_m_n);
+       else
+               pipe_config->adjusted_mode.crtc_clock = pipe_config->port_clock;
+}
+
 static void hsw_ddi_clock_get(struct intel_encoder *encoder,
                              struct intel_crtc_config *pipe_config)
 {
@@ -1535,6 +1643,7 @@ void intel_ddi_get_config(struct intel_encoder *encoder,
        struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
        enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
        u32 temp, flags = 0;
+       struct drm_device *dev = dev_priv->dev;
 
        temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder));
        if (temp & TRANS_DDI_PHSYNC)

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_get_config(struct intel_encoder *encoder, · line 1718

Quoted 5 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -1
@@ -1606,7 +1715,10 @@ void intel_ddi_get_config(struct intel_encoder *encoder,
                dev_priv->vbt.edp_bpp = pipe_config->pipe_bpp;
        }
 
-       hsw_ddi_clock_get(encoder, pipe_config);
+       if (INTEL_INFO(dev)->gen < 9)

I'm sure Daniel would request a change to "<= 8" instead of "< 9" here :)

I should probably also complain about the fact that clock calculation is a very confusing thing, and I never know which value should be assigned where, and I also never know when to multiply by 2 or 5 or divide by 10...

Note: not everything mentioned above is a hard requirement for a R-B tag. Deciding what's a bikeshed and what's not is left as an exercise to the reader.

Quoted 13 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -1
+               hsw_ddi_clock_get(encoder, pipe_config);
+       else
+               skl_ddi_clock_get(encoder, pipe_config);
 }
 
 static void intel_ddi_destroy(struct drm_encoder *encoder)
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#177 lore raw

Re: [PATCH 61/89] drm/i915/skl: Determine enabled PLL and its linkrate/pixel clock

Quoted 16 lines · Paulo Zanoni

2014-09-04 8:27 GMT-03:00 Damien Lespiau<[email protected]>:

Quoted 15 lines

From: Satheeshakrishna M<[email protected]>

v2: Fixup compilation due to the removal of the intel_ddi_dpll_id enum. And add a fixme about the abuse of pipe_config here.

v3: Rebase on top of the hsw_ddi_clock_get() rename (Damien)

---
  drivers/gpu/drm/i915/i915_reg.h  |   5 ++
  drivers/gpu/drm/i915/intel_ddi.c | 114 ++++++++++++++++++++++++++++++++++++++-
  2 files changed, 118 insertions(+), 1 deletion(-)
Quoted 12 lines

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6370

Quoted 9 lines
drivers/gpu/drm/i915/i915_reg.h +1 -0
index 2364ece..794d0ba 100644
@@ -6367,6 +6367,7 @@ enum punit_power_well {
  #define  DPLL_CRTL1_LINK_RATE_1620             3
  #define  DPLL_CRTL1_LINK_RATE_1080             4
  #define  DPLL_CRTL1_LINK_RATE_2160             5
+#define  DPLL_CRTL1_LINK_RATE_SHIFT(id)                ((id)*6+1)

I'd move this to a few lines above, where the MASK and RATE definitions are. Possibly reimplement the other macros using the new one (if the lines don't look to big/ugly).

I will move it next to MASK and RATE definitions. I didn't really get what you meant my reimplement here :(

Quoted 11 lines

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6378

Quoted 7 lines
drivers/gpu/drm/i915/i915_reg.h +1 -0
  /* DPLL control2 */
  #define DPLL_CTRL2                             0x6C05C
@@ -6374,6 +6375,7 @@ enum punit_power_well {
  #define  DPLL_CTRL2_DDI_CLK_SEL_MASK(port)     (3<<((port)*3+1))
  #define  DPLL_CTRL2_DDI_CLK_SEL(clk, port)     (clk<<((port)*3+1))
  #define  DPLL_CTRL2_DDI_SEL_OVERRIDE(port)     (1<<(port*3))
+#define  DPLL_CTRL2_DDI_CLK_SEL_SHIFT(port)    (port*3+1)

Same here: move a few lines above, and possibly reimplement the others using the new one. Also, use "(port)" instead of "port", since we don't want to risk really-hard-to-debug bugs due to operator precedence on those "*" and "+" operations.

Will move up CLK_SEL and add parenthesis. Again didn't get the what to reimplement here.

Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
  /* DPLL Status */
  #define DPLL_STATUS    0x6C060
@@ -6400,6 +6402,9 @@ enum punit_power_well {
  #define  DPLL_CFGCR2_PDIV(x)           (x<<2)
  #define  DPLL_CFGCR2_CENTRAL_FREQ_MASK (3)
 
Quoted 10 lines

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6406

Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2 -0
+#define GET_CFG_CR1_REG(id) (DPLL1_CFGCR1 + (id - 1) * 8)
+#define GET_CFG_CR2_REG(id) (DPLL1_CFGCR2 + (id - 1) * 8)

The macros above are not really trivial due to the fact that the "id" is undefined and confusing. Please convert this to an inline function, since what we're actually expecting here is "enum intel_dpll_id", which has ID 0 for DPLL 1, which can be super confusing (imagine someone passing ID 1 for DPLL 1, not realizing it should be using the correct enum...). If we use a function we can specify the correct expected enum for the ID type, which helps the programmer find out what is the expected thing to pass to the function.

Expectation is that user of this macro should know value passed :) Anyway, let me try to have a inline function here.

Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/i915/i915_reg.h +1 -0
+
  enum central_freq {
         freq_9600 = 0,
         freq_9000 = 1,
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index e7a5428..b5cfb07 100644
@@ -649,6 +649,114 @@ static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv,
         return (refclk * n * 100) / (p * r);
  }
 
Quoted 13 lines

drivers/gpu/drm/i915/intel_ddi.c static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv, · line 663

Quoted 12 lines
drivers/gpu/drm/i915/intel_ddi.c +12 -0
+static int skl_calc_wrpll_link(struct drm_i915_private *dev_priv,
+                              enum intel_dpll_id dpll)
+{
+       uint32_t cfgcr1_reg, cfgcr2_reg;
+       uint32_t cfgcr1, cfgcr2;
+       uint32_t p0, p1, p2, dco_freq;
+
+       cfgcr1_reg = GET_CFG_CR1_REG(dpll);
+       cfgcr2_reg = GET_CFG_CR2_REG(dpll);
+
+       cfgcr1 = I915_READ(cfgcr1_reg);
+       cfgcr2 = I915_READ(cfgcr2_reg);

Bikeshed: I'd probably call these cfgcr{1,2}_val to avoid confusion.

ok

Quoted 35 lines
Quoted 35 lines
drivers/gpu/drm/i915/intel_ddi.c +35 -0
+
+       p0 = (cfgcr2 & DPLL_CFGCR2_PDIV_MASK) >> 2;
+       p2 = (cfgcr2 & DPLL_CFGCR2_KDIV_MASK) >> 5;
+
+       if (cfgcr2 &  DPLL_CFGCR2_QDIV_MODE(1))
+               p1 = (cfgcr2 & DPLL_CFGCR2_QDIV_RATIO_MASK) >> 8;
+       else
+               p1 = 1;
+
+
+       switch (p0) {
+       case pdiv_1:
+               p0 = 1;
+               break;
+       case pdiv_2:
+               p0 = 2;
+               break;
+       case pdiv_3:
+               p0 = 3;
+               break;
+       case pdiv_7:
+               p0 = 7;
+               break;
+       }
+
+       switch (p2) {
+       case kdiv_5:
+               p2 = 5;
+               break;
+       case kdiv_2:
+               p2 = 2;
+               break;
+       case kdiv_3:
+               p2 = 3;
+               break;
Quoted 8 lines

drivers/gpu/drm/i915/intel_ddi.c static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv, · line 702

Quoted 4 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -0
+       case kdiv_1:
+               p2 = 1;
+               break;
+       }

I really think that if we had something like:
#define DPLL_CFGCR2_PDIV_7 (4 << 2)
we'd be able to avoid this "convert to enum and then get the value" part, making the function much simpler...

ok

Quoted 45 lines
Quoted 32 lines
drivers/gpu/drm/i915/intel_ddi.c +31 -0
+
+       dco_freq = (cfgcr1 & DPLL_CFGCR1_DCO_INTEGER_MASK) * 24 * 1000;
+
+       dco_freq += (((cfgcr1 & DPLL_CFGCR1_DCO_FRACTION_MASK) >> 9) * 24 *
+               1000) / 0x8000;
+
+       return dco_freq / (p0 * p1 * p2 * 5);
+}
+
+
+static void skl_ddi_clock_get(struct intel_encoder *encoder,
+                               struct intel_crtc_config *pipe_config)
+{
+       struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+       enum port port = intel_ddi_get_encoder_port(encoder);
+       int link_clock = 0;
+       uint32_t dpll_ctl1, dpll;
+
+       /* FIXME: This should be tracked in the pipe config. */
+       dpll = I915_READ(DPLL_CTRL2);
+       dpll &= DPLL_CTRL2_DDI_CLK_SEL_MASK(port);
+       dpll >>= DPLL_CTRL2_DDI_CLK_SEL_SHIFT(port);
+
+       dpll_ctl1 = I915_READ(DPLL_CTRL1);
+
+       if (dpll_ctl1 & DPLL_CTRL1_HDMI_MODE(dpll)) {
+               link_clock = skl_calc_wrpll_link(dev_priv, dpll);
+       } else {
+               link_clock = dpll_ctl1 & DPLL_CRTL1_LINK_RATE_MASK(dpll);
+               link_clock >>= DPLL_CRTL1_LINK_RATE_SHIFT(dpll);
+

drivers/gpu/drm/i915/intel_ddi.c static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv, · line 743

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +10 -0
+               switch (link_clock) {
+               case DPLL_CRTL1_LINK_RATE_810:
+                       link_clock = 81000;
+                       break;
+               case DPLL_CRTL1_LINK_RATE_1350:
+                       link_clock = 135000;
+                       break;
+               case DPLL_CRTL1_LINK_RATE_2700:
+                       link_clock = 270000;
+                       break;

What about 1620 and 1080?

Quoted 5 lines

drivers/gpu/drm/i915/intel_ddi.c static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv, · line 745

Quoted 2 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -0
+               default:
+                       break;

We're just silently failing here, which will probably result in later WARNs on the HW state readout/check code. So we should probably give a WARN() here to make debugging easier :)

Since link_clock is read out from the HW, we'll never end up in default case. Anyway, I'll add a WARN()

Quoted 30 lines
Quoted 30 lines
drivers/gpu/drm/i915/intel_ddi.c +15 -0
+               }
+               link_clock *= 2;
+       }
+
+       pipe_config->port_clock = link_clock;
+
+       if (pipe_config->has_dp_encoder)
+               pipe_config->adjusted_mode.crtc_clock =
+                       intel_dotclock_calculate(pipe_config->port_clock,
+                                                &pipe_config->dp_m_n);
+       else
+               pipe_config->adjusted_mode.crtc_clock = pipe_config->port_clock;
+}
+
  static void hsw_ddi_clock_get(struct intel_encoder *encoder,
                               struct intel_crtc_config *pipe_config)
  {
@@ -1535,6 +1643,7 @@ void intel_ddi_get_config(struct intel_encoder *encoder,
         struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
         enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
         u32 temp, flags = 0;
+       struct drm_device *dev = dev_priv->dev;
 
         temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder));
         if (temp & TRANS_DDI_PHSYNC)
@@ -1606,7 +1715,10 @@ void intel_ddi_get_config(struct intel_encoder *encoder,
                 dev_priv->vbt.edp_bpp = pipe_config->pipe_bpp;
         }
 
Quoted 3 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_get_config(struct intel_encoder *encoder, · line 1718

Quoted 2 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -1
-       hsw_ddi_clock_get(encoder, pipe_config);
+       if (INTEL_INFO(dev)->gen < 9)

I'm sure Daniel would request a change to "<= 8" instead of "< 9" here :)

Couldn't figure of what the convention is. Will fix this instance :)

Quoted 23 lines

I should probably also complain about the fact that clock calculation is a very confusing thing, and I never know which value should be assigned where, and I also never know when to multiply by 2 or 5 or divide by 10...

Note: not everything mentioned above is a hard requirement for a R-B tag. Deciding what's a bikeshed and what's not is left as an exercise to the reader.

Quoted 13 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -1
+               hsw_ddi_clock_get(encoder, pipe_config);
+       else
+               skl_ddi_clock_get(encoder, pipe_config);
  }
 
  static void intel_ddi_destroy(struct drm_encoder *encoder)
--

1.8.3.1

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

#178 lore raw

Re: [PATCH 61/89] drm/i915/skl: Determine enabled PLL and its linkrate/pixel clock

2014-10-01 7:51 GMT-03:00 M, Satheeshakrishna <[email protected]>:

Quoted 51 lines · Paulo Zanoni
Quoted 19 lines

2014-09-04 8:27 GMT-03:00 Damien Lespiau<[email protected]>:

Quoted 17 lines

From: Satheeshakrishna M<[email protected]>

v2: Fixup compilation due to the removal of the intel_ddi_dpll_id enum. And add a fixme about the abuse of pipe_config here.

v3: Rebase on top of the hsw_ddi_clock_get() rename (Damien)

---
  drivers/gpu/drm/i915/i915_reg.h  |   5 ++
  drivers/gpu/drm/i915/intel_ddi.c | 114
++++++++++++++++++++++++++++++++++++++-
  2 files changed, 118 insertions(+), 1 deletion(-)
Quoted 14 lines

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6370

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +1 -0
index 2364ece..794d0ba 100644
@@ -6367,6 +6367,7 @@ enum punit_power_well {
  #define  DPLL_CRTL1_LINK_RATE_1620             3
  #define  DPLL_CRTL1_LINK_RATE_1080             4
  #define  DPLL_CRTL1_LINK_RATE_2160             5
+#define  DPLL_CRTL1_LINK_RATE_SHIFT(id)                ((id)*6+1)

I'd move this to a few lines above, where the MASK and RATE definitions are. Possibly reimplement the other macros using the new one (if the lines don't look to big/ugly).

I will move it next to MASK and RATE definitions. I didn't really get what you meant my reimplement here :(

Quoted 13 lines

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6378

Quoted 8 lines
drivers/gpu/drm/i915/i915_reg.h +1 -0
  /* DPLL control2 */
  #define DPLL_CTRL2                             0x6C05C
@@ -6374,6 +6375,7 @@ enum punit_power_well {
  #define  DPLL_CTRL2_DDI_CLK_SEL_MASK(port)     (3<<((port)*3+1))
  #define  DPLL_CTRL2_DDI_CLK_SEL(clk, port)     (clk<<((port)*3+1))
  #define  DPLL_CTRL2_DDI_SEL_OVERRIDE(port)     (1<<(port*3))
+#define  DPLL_CTRL2_DDI_CLK_SEL_SHIFT(port)    (port*3+1)

Same here: move a few lines above, and possibly reimplement the others using the new one. Also, use "(port)" instead of "port", since we don't want to risk really-hard-to-debug bugs due to operator precedence on those "*" and "+" operations.

Quoted 2 lines

Will move up CLK_SEL and add parenthesis. Again didn't get the what to reimplement here.

What I meant is: since you created a macro that expands to "(port*3+1)", you could use it in the definition of the other macros, instead of writing "(port*3+1)" again. The downside is that you'd have to type many more characters, so maybe this change is not worth it.

So we'd have something like:
#define DPLL_CTRL2_XX_SHIFT(port) (port*3+1)
#define DPLL_CTRL2_XX_SEL_MASK(port) (3 << DPLL_CTRL2_XX_SHIFT(port)) #define DPLL_CTRL2_XX_SEL(clk, port) ((clk) << DPLL_CTRL2_XX_SHIFT(port))

Etc.

Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
  /* DPLL Status */
  #define DPLL_STATUS    0x6C060
@@ -6400,6 +6402,9 @@ enum punit_power_well {
  #define  DPLL_CFGCR2_PDIV(x)           (x<<2)
  #define  DPLL_CFGCR2_CENTRAL_FREQ_MASK (3)
 
Quoted 11 lines

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6406

Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2 -0
+#define GET_CFG_CR1_REG(id) (DPLL1_CFGCR1 + (id - 1) * 8)
+#define GET_CFG_CR2_REG(id) (DPLL1_CFGCR2 + (id - 1) * 8)

The macros above are not really trivial due to the fact that the "id" is undefined and confusing. Please convert this to an inline function, since what we're actually expecting here is "enum intel_dpll_id", which has ID 0 for DPLL 1, which can be super confusing (imagine someone passing ID 1 for DPLL 1, not realizing it should be using the correct enum...). If we use a function we can specify the correct expected enum for the ID type, which helps the programmer find out what is the expected thing to pass to the function.

Quoted 2 lines

Expectation is that user of this macro should know value passed :) Anyway, let me try to have a inline function here.

But currently, he'll have to read a lot of code to know which value to
pass: this is what I did while reviewing the patch. If this were a real function, all that would be needed would be to look at the function declaration.

Quoted 131 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/i915/i915_reg.h +1 -0
+
  enum central_freq {
         freq_9600 = 0,
         freq_9000 = 1,
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index e7a5428..b5cfb07 100644
@@ -649,6 +649,114 @@ static int intel_ddi_calc_wrpll_link(struct
 drm_i915_private *dev_priv,
         return (refclk * n * 100) / (p * r);
  }
 
Quoted 14 lines

drivers/gpu/drm/i915/intel_ddi.c static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv, · line 663

Quoted 12 lines
drivers/gpu/drm/i915/intel_ddi.c +12 -0
+static int skl_calc_wrpll_link(struct drm_i915_private *dev_priv,
+                              enum intel_dpll_id dpll)
+{
+       uint32_t cfgcr1_reg, cfgcr2_reg;
+       uint32_t cfgcr1, cfgcr2;
+       uint32_t p0, p1, p2, dco_freq;
+
+       cfgcr1_reg = GET_CFG_CR1_REG(dpll);
+       cfgcr2_reg = GET_CFG_CR2_REG(dpll);
+
+       cfgcr1 = I915_READ(cfgcr1_reg);
+       cfgcr2 = I915_READ(cfgcr2_reg);

Bikeshed: I'd probably call these cfgcr{1,2}_val to avoid confusion.

ok

Quoted 36 lines
Quoted 36 lines
drivers/gpu/drm/i915/intel_ddi.c +36 -0
+
+       p0 = (cfgcr2 & DPLL_CFGCR2_PDIV_MASK) >> 2;
+       p2 = (cfgcr2 & DPLL_CFGCR2_KDIV_MASK) >> 5;
+
+       if (cfgcr2 &  DPLL_CFGCR2_QDIV_MODE(1))
+               p1 = (cfgcr2 & DPLL_CFGCR2_QDIV_RATIO_MASK) >> 8;
+       else
+               p1 = 1;
+
+
+       switch (p0) {
+       case pdiv_1:
+               p0 = 1;
+               break;
+       case pdiv_2:
+               p0 = 2;
+               break;
+       case pdiv_3:
+               p0 = 3;
+               break;
+       case pdiv_7:
+               p0 = 7;
+               break;
+       }
+
+       switch (p2) {
+       case kdiv_5:
+               p2 = 5;
+               break;
+       case kdiv_2:
+               p2 = 2;
+               break;
+       case kdiv_3:
+               p2 = 3;
+               break;
+       case kdiv_1:
Quoted 8 lines

drivers/gpu/drm/i915/intel_ddi.c static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv, · line 702

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
+               p2 = 1;
+               break;
+       }

I really think that if we had something like:
#define DPLL_CFGCR2_PDIV_7 (4 << 2)
we'd be able to avoid this "convert to enum and then get the value" part, making the function much simpler...

ok

Quoted 51 lines
Quoted 34 lines
drivers/gpu/drm/i915/intel_ddi.c +31 -0
+
+       dco_freq = (cfgcr1 & DPLL_CFGCR1_DCO_INTEGER_MASK) * 24 * 1000;
+
+       dco_freq += (((cfgcr1 & DPLL_CFGCR1_DCO_FRACTION_MASK) >> 9) * 24
 *
+               1000) / 0x8000;
+
+       return dco_freq / (p0 * p1 * p2 * 5);
+}
+
+
+static void skl_ddi_clock_get(struct intel_encoder *encoder,
+                               struct intel_crtc_config *pipe_config)
+{
+       struct drm_i915_private *dev_priv =
 encoder->base.dev->dev_private;
+       enum port port = intel_ddi_get_encoder_port(encoder);
+       int link_clock = 0;
+       uint32_t dpll_ctl1, dpll;
+
+       /* FIXME: This should be tracked in the pipe config. */
+       dpll = I915_READ(DPLL_CTRL2);
+       dpll &= DPLL_CTRL2_DDI_CLK_SEL_MASK(port);
+       dpll >>= DPLL_CTRL2_DDI_CLK_SEL_SHIFT(port);
+
+       dpll_ctl1 = I915_READ(DPLL_CTRL1);
+
+       if (dpll_ctl1 & DPLL_CTRL1_HDMI_MODE(dpll)) {
+               link_clock = skl_calc_wrpll_link(dev_priv, dpll);
+       } else {
+               link_clock = dpll_ctl1 & DPLL_CRTL1_LINK_RATE_MASK(dpll);
+               link_clock >>= DPLL_CRTL1_LINK_RATE_SHIFT(dpll);
+

drivers/gpu/drm/i915/intel_ddi.c static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv, · line 743

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +10 -0
+               switch (link_clock) {
+               case DPLL_CRTL1_LINK_RATE_810:
+                       link_clock = 81000;
+                       break;
+               case DPLL_CRTL1_LINK_RATE_1350:
+                       link_clock = 135000;
+                       break;
+               case DPLL_CRTL1_LINK_RATE_2700:
+                       link_clock = 270000;
+                       break;

What about 1620 and 1080?

Quoted 2 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -0
+               default:
+                       break;
Quoted 6 lines
Quoted 3 lines

We're just silently failing here, which will probably result in later WARNs on the HW state readout/check code. So we should probably give a WARN() here to make debugging easier :)

Since link_clock is read out from the HW, we'll never end up in default case. Anyway, I'll add a WARN()

Yeah, but maybe in some gen the register address will change, then we'll start reading garbage and silently do the wrong thing. Or maybe we have some serious memory corruption, or IDK. I know this is a little too paranoid, but we have tons of WARNs on our code and they do help us catch bugs, especially on the automated IGT tests where QA is not really looking at the screen to check if it is actually working, but there's a bot looking at new dmesg WARNs.

Quoted 68 lines
Quoted 36 lines
Quoted 36 lines
drivers/gpu/drm/i915/intel_ddi.c +12 -0
+               }
+               link_clock *= 2;
+       }
+
+       pipe_config->port_clock = link_clock;
+
+       if (pipe_config->has_dp_encoder)
+               pipe_config->adjusted_mode.crtc_clock =
+                       intel_dotclock_calculate(pipe_config->port_clock,
+                                                &pipe_config->dp_m_n);
+       else
+               pipe_config->adjusted_mode.crtc_clock =

pipe_config->port_clock;

drivers/gpu/drm/i915/intel_ddi.c +3 -0
+}
+
  static void hsw_ddi_clock_get(struct intel_encoder *encoder,
                               struct intel_crtc_config *pipe_config)
  {
@@ -1535,6 +1643,7 @@ void intel_ddi_get_config(struct intel_encoder
 *encoder,
         struct intel_crtc *intel_crtc =
 to_intel_crtc(encoder->base.crtc);
         enum transcoder cpu_transcoder =
 intel_crtc->config.cpu_transcoder;
         u32 temp, flags = 0;
+       struct drm_device *dev = dev_priv->dev;

temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder)); if (temp & TRANS_DDI_PHSYNC)

drivers/gpu/drm/i915/intel_ddi.c +0 -0
@@ -1606,7 +1715,10 @@ void intel_ddi_get_config(struct intel_encoder
 *encoder,
                 dev_priv->vbt.edp_bpp = pipe_config->pipe_bpp;
         }
 
Quoted 4 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_get_config(struct intel_encoder *encoder, · line 1718

Quoted 2 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -1
-       hsw_ddi_clock_get(encoder, pipe_config);
+       if (INTEL_INFO(dev)->gen < 9)

I'm sure Daniel would request a change to "<= 8" instead of "< 9" here :)

Couldn't figure of what the convention is. Will fix this instance :)

Quoted 24 lines

I should probably also complain about the fact that clock calculation is a very confusing thing, and I never know which value should be assigned where, and I also never know when to multiply by 2 or 5 or divide by 10...

Note: not everything mentioned above is a hard requirement for a R-B tag. Deciding what's a bikeshed and what's not is left as an exercise to the reader.

Quoted 13 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
+               hsw_ddi_clock_get(encoder, pipe_config);
+       else
+               skl_ddi_clock_get(encoder, pipe_config);
  }
 

static void intel_ddi_destroy(struct drm_encoder *encoder)
--
1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#179 lore raw

PATCH v4 61/89 drm/i915/skl: Determine enabled PLL and its linkrate/pixel clock

In reply to Paulo Zanoni

From: Satheeshakrishna M <[email protected]>

v2: Fixup compilation due to the removal of the intel_ddi_dpll_id enum. And add a fixme about the abuse of pipe_config here.

v3: Rebase on top of the hsw_ddi_clock_get() rename (Damien)

v4: Modified as per review comments from Paulo

---
 drivers/gpu/drm/i915/i915_reg.h  |   5 ++
 drivers/gpu/drm/i915/intel_ddi.c | 115 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 119 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_reg.h +5 -0
index eb35d05..3ef0312 100644
@@ -6457,6 +6457,7 @@ enum punit_power_well {
 #define  DPLL_CTRL1_HDMI_MODE(id)		(1<<((id)*6+5))
 #define  DPLL_CTRL1_SSC(id)			(1<<((id)*6+4))
 #define  DPLL_CRTL1_LINK_RATE_MASK(id)		(7<<((id)*6+1))
+#define  DPLL_CRTL1_LINK_RATE_SHIFT(id)		((id)*6+1)
 #define  DPLL_CRTL1_LINK_RATE(linkrate, id)	((linkrate)<<((id)*6+1))
 #define  DPLL_CTRL1_OVERRIDE(id)		(1<<((id)*6))
 #define  DPLL_CRTL1_LINK_RATE_2700		0
@@ -6470,6 +6471,7 @@ enum punit_power_well {
 #define DPLL_CTRL2				0x6C05C
 #define  DPLL_CTRL2_DDI_CLK_OFF(port)		(1<<(port+15))
 #define  DPLL_CTRL2_DDI_CLK_SEL_MASK(port)	(3<<((port)*3+1))
+#define  DPLL_CTRL2_DDI_CLK_SEL_SHIFT(port)    ((port)*3+1)
 #define  DPLL_CTRL2_DDI_CLK_SEL(clk, port)	(clk<<((port)*3+1))
 #define  DPLL_CTRL2_DDI_SEL_OVERRIDE(port)     (1<<((port)*3))
 
@@ -6506,6 +6508,9 @@ enum punit_power_well {
 #define  DPLL_CFGCR2_PDIV_7 (4<<2)
 #define  DPLL_CFGCR2_CENTRAL_FREQ_MASK	(3)
 
+#define GET_CFG_CR1_REG(id) (DPLL1_CFGCR1 + (id - SKL_DPLL1) * 8)
+#define GET_CFG_CR2_REG(id) (DPLL1_CFGCR2 + (id - SKL_DPLL1) * 8)
+
 /* Please see hsw_read_dcomp() and hsw_write_dcomp() before using this register,
  * since on HSW we can't write to it using I915_WRITE. */
 #define D_COMP_HSW			(MCHBAR_MIRROR_BASE_SNB + 0x5F0C)
drivers/gpu/drm/i915/intel_ddi.c +114 -1

133 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

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

PATCH 62/89 drm/i915/skl: Query DPLL attached to port on SKL

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

Modify the implementation to query DPLL attached to a SKL port.

v2: Rebase on top of the run-time PM on DPMS series (Damien)

---
 drivers/gpu/drm/i915/intel_display.c | 27 ++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_drv.h     |  5 ++++-
 2 files changed, 30 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +26 -1
index 69e023a..6e71250 100644
@@ -7789,6 +7789,28 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc,
 	return 0;
 }
 
+static void skylake_get_ddi_pll(struct drm_i915_private *dev_priv,
+				enum port port,
+				struct intel_crtc_config *pipe_config)
+{
+	u32 temp;
+
+	temp = I915_READ(DPLL_CTRL2) & DPLL_CTRL2_DDI_CLK_SEL_MASK(port);
+	pipe_config->ddi_pll_sel = temp >> (port * 3 + 1);
+
+	switch (pipe_config->ddi_pll_sel) {
+	case SKL_DPLL1:
+		pipe_config->shared_dpll = DPLL_ID_SKL_DPLL1;
+		break;
+	case SKL_DPLL2:
+		pipe_config->shared_dpll = DPLL_ID_SKL_DPLL2;
+		break;
+	case SKL_DPLL3:
+		pipe_config->shared_dpll = DPLL_ID_SKL_DPLL3;
+		break;
+	}
+}
+
 static void haswell_get_ddi_pll(struct drm_i915_private *dev_priv,
 				enum port port,
 				struct intel_crtc_config *pipe_config)
@@ -7818,7 +7840,10 @@ static void haswell_get_ddi_port_state(struct intel_crtc *crtc,
 
 	port = (tmp & TRANS_DDI_PORT_MASK) >> TRANS_DDI_PORT_SHIFT;
 
-	haswell_get_ddi_pll(dev_priv, port, pipe_config);
+	if (IS_SKYLAKE(dev))
+		skylake_get_ddi_pll(dev_priv, port, pipe_config);
+	else
+		haswell_get_ddi_pll(dev_priv, port, pipe_config);
 
 	if (pipe_config->shared_dpll >= 0) {
 		pll = &dev_priv->shared_dplls[pipe_config->shared_dpll];
drivers/gpu/drm/i915/intel_drv.h +4 -1
index 559b747..9558f07 100644
@@ -323,7 +323,10 @@ struct intel_crtc_config {
 	/* Selected dpll when shared or DPLL_ID_PRIVATE. */
 	enum intel_dpll_id shared_dpll;
 
-	/* PORT_CLK_SEL for DDI ports. */
+	/*
+	 * - PORT_CLK_SEL for DDI ports on HSW/BDW.
+	 * - enum skl_dpll on SKL
+	 */
 	uint32_t ddi_pll_sel;
 
 	/* Actual register state of the dpll, for shared dpll cross-checking. */
Signature · 1 line
1.8.3.1
#181 lore raw

Re: [PATCH 62/89] drm/i915/skl: Query DPLL attached to port on SKL

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 19 lines

From: Satheeshakrishna M <[email protected]>

Modify the implementation to query DPLL attached to a SKL port.

v2: Rebase on top of the run-time PM on DPMS series (Damien)

---
 drivers/gpu/drm/i915/intel_display.c | 27 ++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_drv.h     |  5 ++++-
 2 files changed, 30 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 69e023a..6e71250 100644
@@ -7789,6 +7789,28 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc,
        return 0;

drivers/gpu/drm/i915/intel_display.c static int haswell_crtc_mode_set(struct drm_crtc *crtc, · line 7799

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +8 -0
 }
 
+static void skylake_get_ddi_pll(struct drm_i915_private *dev_priv,
+                               enum port port,
+                               struct intel_crtc_config *pipe_config)
+{
+       u32 temp;
+
+       temp = I915_READ(DPLL_CTRL2) & DPLL_CTRL2_DDI_CLK_SEL_MASK(port);
+       pipe_config->ddi_pll_sel = temp >> (port * 3 + 1);

Since we're relying on the fact that ddi_pll_sel is actually "enum skl_dpll", I'd change the definition of the enum and explicitly declare SKL_DPLL0 to be "0", and SKL_DPLL1 to be 1, and so on.

drivers/gpu/drm/i915/intel_display.c static int haswell_crtc_mode_set(struct drm_crtc *crtc, · line 7810

Quoted 11 lines
drivers/gpu/drm/i915/intel_display.c +11 -0
+
+       switch (pipe_config->ddi_pll_sel) {
+       case SKL_DPLL1:
+               pipe_config->shared_dpll = DPLL_ID_SKL_DPLL1;
+               break;
+       case SKL_DPLL2:
+               pipe_config->shared_dpll = DPLL_ID_SKL_DPLL2;
+               break;
+       case SKL_DPLL3:
+               pipe_config->shared_dpll = DPLL_ID_SKL_DPLL3;
+               break;

Please also add a WARN() to the default case, especially since there are 4 possible values and we're just checking 3.

drivers/gpu/drm/i915/intel_display.c static void haswell_get_ddi_port_state(struct intel_crtc *crtc, · line 7843

Quoted 12 lines
drivers/gpu/drm/i915/intel_display.c +4 -1
+       }
+}
+
 static void haswell_get_ddi_pll(struct drm_i915_private *dev_priv,
                                enum port port,
                                struct intel_crtc_config *pipe_config)
@@ -7818,7 +7840,10 @@ static void haswell_get_ddi_port_state(struct intel_crtc *crtc,
 
        port = (tmp & TRANS_DDI_PORT_MASK) >> TRANS_DDI_PORT_SHIFT;
 
-       haswell_get_ddi_pll(dev_priv, port, pipe_config);
+       if (IS_SKYLAKE(dev))

If you invert the check so that SKL is on the "else" part (as you did in your previous patch), you'll make sure we're ready for the next Gens in case they happen to be same as SKL. It's more likely they will be the same as SKL instead of being the same as HSW :)

With at least the WARN added on the switch statement: Reviewed-by:
Paulo Zanoni <[email protected]>

Quoted 29 lines
drivers/gpu/drm/i915/intel_display.c +3 -0
+               skylake_get_ddi_pll(dev_priv, port, pipe_config);
+       else
+               haswell_get_ddi_pll(dev_priv, port, pipe_config);
 
        if (pipe_config->shared_dpll >= 0) {
                pll = &dev_priv->shared_dplls[pipe_config->shared_dpll];
drivers/gpu/drm/i915/intel_drv.h +4 -2
index 559b747..9558f07 100644
@@ -323,7 +323,10 @@ struct intel_crtc_config {
        /* Selected dpll when shared or DPLL_ID_PRIVATE. */
        enum intel_dpll_id shared_dpll;
 
-       /* PORT_CLK_SEL for DDI ports. */
+       /*
+        * - PORT_CLK_SEL for DDI ports on HSW/BDW.
+        * - enum skl_dpll on SKL
+        */
        uint32_t ddi_pll_sel;
 
        /* Actual register state of the dpll, for shared dpll cross-checking. */
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#182 lore raw

Re: [PATCH 62/89] drm/i915/skl: Query DPLL attached to port on SKL

Quoted 22 lines · Paulo Zanoni

2014-09-04 8:27 GMT-03:00 Damien Lespiau<[email protected]>:

Quoted 21 lines

From: Satheeshakrishna M<[email protected]>

Modify the implementation to query DPLL attached to a SKL port.

v2: Rebase on top of the run-time PM on DPMS series (Damien)

---
  drivers/gpu/drm/i915/intel_display.c | 27 ++++++++++++++++++++++++++-
  drivers/gpu/drm/i915/intel_drv.h     |  5 ++++-
  2 files changed, 30 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 69e023a..6e71250 100644
@@ -7789,6 +7789,28 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc,
         return 0;
  }
 
Quoted 11 lines

drivers/gpu/drm/i915/intel_display.c static int haswell_crtc_mode_set(struct drm_crtc *crtc, · line 7799

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +8 -0
+static void skylake_get_ddi_pll(struct drm_i915_private *dev_priv,
+                               enum port port,
+                               struct intel_crtc_config *pipe_config)
+{
+       u32 temp;
+
+       temp = I915_READ(DPLL_CTRL2) & DPLL_CTRL2_DDI_CLK_SEL_MASK(port);
+       pipe_config->ddi_pll_sel = temp >> (port * 3 + 1);

Since we're relying on the fact that ddi_pll_sel is actually "enum skl_dpll", I'd change the definition of the enum and explicitly declare SKL_DPLL0 to be "0", and SKL_DPLL1 to be 1, and so on.

Makes sense

Quoted 11 lines

drivers/gpu/drm/i915/intel_display.c static int haswell_crtc_mode_set(struct drm_crtc *crtc, · line 7810

Quoted 11 lines
drivers/gpu/drm/i915/intel_display.c +11 -0
+
+       switch (pipe_config->ddi_pll_sel) {
+       case SKL_DPLL1:
+               pipe_config->shared_dpll = DPLL_ID_SKL_DPLL1;
+               break;
+       case SKL_DPLL2:
+               pipe_config->shared_dpll = DPLL_ID_SKL_DPLL2;
+               break;
+       case SKL_DPLL3:
+               pipe_config->shared_dpll = DPLL_ID_SKL_DPLL3;
+               break;
Quoted 2 lines

Please also add a WARN() to the default case, especially since there are 4 possible values and we're just checking 3.

ok

Quoted 51 lines

drivers/gpu/drm/i915/intel_display.c static void haswell_get_ddi_port_state(struct intel_crtc *crtc, · line 7843

Quoted 12 lines
drivers/gpu/drm/i915/intel_display.c +4 -1
+       }
+}
+
  static void haswell_get_ddi_pll(struct drm_i915_private *dev_priv,
                                 enum port port,
                                 struct intel_crtc_config *pipe_config)
@@ -7818,7 +7840,10 @@ static void haswell_get_ddi_port_state(struct intel_crtc *crtc,
 
         port = (tmp & TRANS_DDI_PORT_MASK) >> TRANS_DDI_PORT_SHIFT;
 
-       haswell_get_ddi_pll(dev_priv, port, pipe_config);
+       if (IS_SKYLAKE(dev))

If you invert the check so that SKL is on the "else" part (as you did in your previous patch), you'll make sure we're ready for the next Gens in case they happen to be same as SKL. It's more likely they will be the same as SKL instead of being the same as HSW :)

With at least the WARN added on the switch statement: Reviewed-by:
Paulo Zanoni<[email protected]>

Quoted 29 lines
drivers/gpu/drm/i915/intel_display.c +3 -0
+               skylake_get_ddi_pll(dev_priv, port, pipe_config);
+       else
+               haswell_get_ddi_pll(dev_priv, port, pipe_config);
 
         if (pipe_config->shared_dpll >= 0) {
                 pll = &dev_priv->shared_dplls[pipe_config->shared_dpll];
drivers/gpu/drm/i915/intel_drv.h +4 -2
index 559b747..9558f07 100644
@@ -323,7 +323,10 @@ struct intel_crtc_config {
         /* Selected dpll when shared or DPLL_ID_PRIVATE. */
         enum intel_dpll_id shared_dpll;
 
-       /* PORT_CLK_SEL for DDI ports. */
+       /*
+        * - PORT_CLK_SEL for DDI ports on HSW/BDW.
+        * - enum skl_dpll on SKL
+        */
         uint32_t ddi_pll_sel;
 
         /* Actual register state of the dpll, for shared dpll cross-checking. */
--

1.8.3.1

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

#183 lore raw

PATCH v3 62/89 drm/i915/skl: Query DPLL attached to port on SKL

In reply to Paulo Zanoni

From: Satheeshakrishna M <[email protected]>

Modify the implementation to query DPLL attached to a SKL port.

v2: Rebase on top of the run-time PM on DPMS series (Damien)

v3: Modified as per review comments from Paulo

---
 drivers/gpu/drm/i915/intel_display.c | 29 ++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_drv.h     |  5 ++++-
 2 files changed, 32 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +28 -1
index 9ec1ab7..72ee814 100644
@@ -7968,6 +7968,30 @@ static int haswell_crtc_compute_clock(struct intel_crtc *crtc)
 	return 0;
 }
 
+static void skylake_get_ddi_pll(struct drm_i915_private *dev_priv,
+				enum port port,
+				struct intel_crtc_config *pipe_config)
+{
+	u32 temp;
+
+	temp = I915_READ(DPLL_CTRL2) & DPLL_CTRL2_DDI_CLK_SEL_MASK(port);
+	pipe_config->ddi_pll_sel = temp >> (port * 3 + 1);
+
+	switch (pipe_config->ddi_pll_sel) {
+	case SKL_DPLL1:
+		pipe_config->shared_dpll = DPLL_ID_SKL_DPLL1;
+		break;
+	case SKL_DPLL2:
+		pipe_config->shared_dpll = DPLL_ID_SKL_DPLL2;
+		break;
+	case SKL_DPLL3:
+		pipe_config->shared_dpll = DPLL_ID_SKL_DPLL3;
+		break;
+	default:
+		WARN(1, "Unknown DPLL programmed\n");
+	}
+}
+
 static void haswell_get_ddi_pll(struct drm_i915_private *dev_priv,
 				enum port port,
 				struct intel_crtc_config *pipe_config)
@@ -7997,7 +8021,10 @@ static void haswell_get_ddi_port_state(struct intel_crtc *crtc,
 
 	port = (tmp & TRANS_DDI_PORT_MASK) >> TRANS_DDI_PORT_SHIFT;
 
-	haswell_get_ddi_pll(dev_priv, port, pipe_config);
+	if (IS_SKYLAKE(dev))
+		skylake_get_ddi_pll(dev_priv, port, pipe_config);
+	else
+		haswell_get_ddi_pll(dev_priv, port, pipe_config);
 
 	if (pipe_config->shared_dpll >= 0) {
 		pll = &dev_priv->shared_dplls[pipe_config->shared_dpll];
drivers/gpu/drm/i915/intel_drv.h +4 -1
index cb0e9db..ece8b82 100644
@@ -340,7 +340,10 @@ struct intel_crtc_config {
 	/* Selected dpll when shared or DPLL_ID_PRIVATE. */
 	enum intel_dpll_id shared_dpll;
 
-	/* PORT_CLK_SEL for DDI ports. */
+	/*
+	 * - PORT_CLK_SEL for DDI ports on HSW/BDW.
+	 * - enum skl_dpll on SKL
+	 */
 	uint32_t ddi_pll_sel;
 
 	/* Actual register state of the dpll, for shared dpll cross-checking. */
Signature · 6 lines
1.8.3.1

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

PATCH 63/89 drm/i915/skl: Define shared DPLLs for Skylake

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

On skylake, DPLL 1, 2 and 3 can be used for DP and HDMI. The shared dpll framework allows us to share those DPLLs among DDIs when possible.

The most tricky part is to provide a DPLL state that can be easily compared. DPLL_CRTL1 is shared by all the DPLLs, 6 bits each. The per-dpll crtl1 field of the hw state is then normalized to be the same value if 2 DPLLs do indeed have identical values for those 6 bits.

v2: Port the code to the shared DPLL infrastructure (Damien)

XXX: This patch would benefit from a bunchf of macros for handling ctrl1 to encapsulate the masking and shifting (Daniel)

---
 drivers/gpu/drm/i915/i915_drv.h  |  11 ++++
 drivers/gpu/drm/i915/intel_ddi.c | 126 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 136 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +11 -0
index 65e5ffb..a6e14db 100644
@@ -225,6 +225,17 @@ struct intel_dpll_hw_state {
 
 	/* hsw, bdw */
 	uint32_t wrpll;
+
+	/* skl */
+	/*
+	 * DPLL_CTRL1 has 6 bits for each each this DPLL. We store those in
+	 * lower part of crtl1 and they get shifted into position when writing
+	 * the register.  This allows us to easily compare the state to share
+	 * the DPLL.
+	 */
+	uint32_t ctrl1;
+	/* HDMI only, 0 when used for DP */
+	uint32_t cfgcr1, cfgcr2;
 };
 
 struct intel_shared_dpll {
drivers/gpu/drm/i915/intel_ddi.c +125 -1

137 lines not on this page · raw message

Signature · 1 line
1.8.3.1
Reviewed-by on v1 63/89
#185 lore raw

Re: [PATCH 63/89] drm/i915/skl: Define shared DPLLs for Skylake

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 10 lines

From: Satheeshakrishna M <[email protected]>

On skylake, DPLL 1, 2 and 3 can be used for DP and HDMI. The shared dpll framework allows us to share those DPLLs among DDIs when possible.

The most tricky part is to provide a DPLL state that can be easily compared. DPLL_CRTL1 is shared by all the DPLLs, 6 bits each. The per-dpll crtl1 field of the hw state is then normalized to be the same value if 2 DPLLs do indeed have identical values for those 6 bits.

Quoted 4 lines

v2: Port the code to the shared DPLL infrastructure (Damien)

XXX: This patch would benefit from a bunchf of macros for handling ctrl1 to encapsulate the masking and shifting (Daniel)

Are you planning to do the XXX above before merging?

The only suspect thing is that the spec doesn't mention if/when/how-much we need to sleep after enabling the clocks... I hope this won't be a problem later :)

Quoted 179 lines
---
 drivers/gpu/drm/i915/i915_drv.h  |  11 ++++
 drivers/gpu/drm/i915/intel_ddi.c | 126 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 136 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +11 -0
index 65e5ffb..a6e14db 100644
@@ -225,6 +225,17 @@ struct intel_dpll_hw_state {
 
        /* hsw, bdw */
        uint32_t wrpll;
+
+       /* skl */
+       /*
+        * DPLL_CTRL1 has 6 bits for each each this DPLL. We store those in
+        * lower part of crtl1 and they get shifted into position when writing
+        * the register.  This allows us to easily compare the state to share
+        * the DPLL.
+        */
+       uint32_t ctrl1;
+       /* HDMI only, 0 when used for DP */
+       uint32_t cfgcr1, cfgcr2;
 };
 
 struct intel_shared_dpll {
drivers/gpu/drm/i915/intel_ddi.c +125 -2
index b5cfb07..53ac23d 100644
@@ -1522,12 +1522,136 @@ static void hsw_shared_dplls_init(struct drm_i915_private *dev_priv)
        }
 }
 
+static const char * const skl_ddi_pll_names[] = {
+       "DPLL 1",
+       "DPLL 2",
+       "DPLL 3",
+};
+
+struct skl_dpll_regs {
+       u32 ctl, cfgcr1, cfgcr2;
+};
+
+/* this array is indexed by the *shared* pll id */
+static const struct skl_dpll_regs skl_dpll_regs[3] = {
+       {
+               /* DPLL 1 */
+               .ctl = LCPLL2_CTL,
+               .cfgcr1 = DPLL1_CFGCR1,
+               .cfgcr2 = DPLL1_CFGCR2,
+       },
+       {
+               /* DPLL 2 */
+               .ctl = WRPLL_CTL1,
+               .cfgcr1 = DPLL2_CFGCR1,
+               .cfgcr2 = DPLL2_CFGCR2,
+       },
+       {
+               /* DPLL 3 */
+               .ctl = WRPLL_CTL2,
+               .cfgcr1 = DPLL3_CFGCR1,
+               .cfgcr2 = DPLL3_CFGCR2,
+       },
+};
+
+static void skl_ddi_pll_enable(struct drm_i915_private *dev_priv,
+                              struct intel_shared_dpll *pll)
+{
+       uint32_t val;
+       unsigned int dpll;
+       const struct skl_dpll_regs *regs = skl_dpll_regs;
+
+       /* DPLL0 is not part of the shared DPLLs, so pll->id is 0 for DPLL1 */
+       dpll = pll->id + 1;
+
+       val = I915_READ(DPLL_CTRL1);
+
+       val &= ~(DPLL_CTRL1_HDMI_MODE(dpll) | DPLL_CTRL1_SSC(dpll) |
+                DPLL_CRTL1_LINK_RATE_MASK(dpll));
+       val |= pll->hw_state.ctrl1 << (dpll * 6);
+
+       I915_WRITE(DPLL_CTRL1, val);
+       POSTING_READ(DPLL_CTRL1);
+
+       I915_WRITE(regs[pll->id].cfgcr1, pll->hw_state.cfgcr1);
+       I915_WRITE(regs[pll->id].cfgcr2, pll->hw_state.cfgcr2);
+       POSTING_READ(regs[pll->id].cfgcr1);
+       POSTING_READ(regs[pll->id].cfgcr2);
+
+       /* the enable bit is always bit 31 */
+       I915_WRITE(regs[pll->id].ctl,
+                  I915_READ(regs[pll->id].ctl) | LCPLL_PLL_ENABLE);
+
+       if (wait_for(I915_READ(DPLL_STATUS) & DPLL_LOCK(dpll), 5))
+               DRM_ERROR("DPLL %d not locked\n", dpll);
+}
+
+static void skl_ddi_pll_disable(struct drm_i915_private *dev_priv,
+                               struct intel_shared_dpll *pll)
+{
+       const struct skl_dpll_regs *regs = skl_dpll_regs;
+
+       /* the enable bit is always bit 31 */
+       I915_WRITE(regs[pll->id].ctl,
+                  I915_READ(regs[pll->id].ctl) & ~LCPLL_PLL_ENABLE);
+       POSTING_READ(regs[pll->id].ctl);
+}
+
+static bool skl_ddi_pll_get_hw_state(struct drm_i915_private *dev_priv,
+                                    struct intel_shared_dpll *pll,
+                                    struct intel_dpll_hw_state *hw_state)
+{
+       uint32_t val;
+       unsigned int dpll;
+       const struct skl_dpll_regs *regs = skl_dpll_regs;
+
+       if (!intel_display_power_enabled(dev_priv, POWER_DOMAIN_PLLS))
+               return false;
+
+       /* DPLL0 is not part of the shared DPLLs, so pll->id is 0 for DPLL1 */
+       dpll = pll->id + 1;
+
+       val = I915_READ(regs[pll->id].ctl);
+       if (!(val & LCPLL_PLL_ENABLE))
+               return false;
+
+       val = I915_READ(DPLL_CTRL1);
+       hw_state->ctrl1 = (val >> (dpll * 6)) & 0x3f;
+
+       /* avoid reading back stale values if HDMI mode is not enabled */
+       if (val & DPLL_CTRL1_HDMI_MODE(dpll)) {
+               hw_state->cfgcr1 = I915_READ(regs[pll->id].cfgcr1);
+               hw_state->cfgcr2 = I915_READ(regs[pll->id].cfgcr2);
+       }
+
+       return true;
+}
+
+static void skl_shared_dplls_init(struct drm_i915_private *dev_priv)
+{
+       int i;
+
+       dev_priv->num_shared_dpll = 3;
+
+       for (i = 0; i < dev_priv->num_shared_dpll; i++) {
+               dev_priv->shared_dplls[i].id = i;
+               dev_priv->shared_dplls[i].name = skl_ddi_pll_names[i];
+               dev_priv->shared_dplls[i].disable = skl_ddi_pll_disable;
+               dev_priv->shared_dplls[i].enable = skl_ddi_pll_enable;
+               dev_priv->shared_dplls[i].get_hw_state =
+                       skl_ddi_pll_get_hw_state;
+       }
+}
+
 void intel_ddi_pll_init(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
        uint32_t val = I915_READ(LCPLL_CTL);
 
-       hsw_shared_dplls_init(dev_priv);
+       if (IS_SKYLAKE(dev))
+               skl_shared_dplls_init(dev_priv);
+       else
+               hsw_shared_dplls_init(dev_priv);
 
        DRM_DEBUG_KMS("CDCLK running at %dKHz\n",
                      intel_ddi_get_cdclk_freq(dev_priv));
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#186 lore raw

Re: [PATCH 63/89] drm/i915/skl: Define shared DPLLs for Skylake

Quoted 13 lines · Paulo Zanoni

2014-09-04 8:27 GMT-03:00 Damien Lespiau<[email protected]>:

Quoted 12 lines

From: Satheeshakrishna M<[email protected]>

On skylake, DPLL 1, 2 and 3 can be used for DP and HDMI. The shared dpll framework allows us to share those DPLLs among DDIs when possible.

The most tricky part is to provide a DPLL state that can be easily compared. DPLL_CRTL1 is shared by all the DPLLs, 6 bits each. The per-dpll crtl1 field of the hw state is then normalized to be the same value if 2 DPLLs do indeed have identical values for those 6 bits.

v2: Port the code to the shared DPLL infrastructure (Damien)

Quoted 7 lines
Quoted 2 lines

XXX: This patch would benefit from a bunchf of macros for handling ctrl1 to encapsulate the masking and shifting (Daniel)

Are you planning to do the XXX above before merging?

The only suspect thing is that the spec doesn't mention if/when/how-much we need to sleep after enabling the clocks... I hope this won't be a problem later :)

We added a very conservative number, so shouldn't be a problem.

Quoted 181 lines
Quoted 178 lines
---
  drivers/gpu/drm/i915/i915_drv.h  |  11 ++++
  drivers/gpu/drm/i915/intel_ddi.c | 126 ++++++++++++++++++++++++++++++++++++++-
  2 files changed, 136 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +11 -0
index 65e5ffb..a6e14db 100644
@@ -225,6 +225,17 @@ struct intel_dpll_hw_state {
 
         /* hsw, bdw */
         uint32_t wrpll;
+
+       /* skl */
+       /*
+        * DPLL_CTRL1 has 6 bits for each each this DPLL. We store those in
+        * lower part of crtl1 and they get shifted into position when writing
+        * the register.  This allows us to easily compare the state to share
+        * the DPLL.
+        */
+       uint32_t ctrl1;
+       /* HDMI only, 0 when used for DP */
+       uint32_t cfgcr1, cfgcr2;
  };
 
  struct intel_shared_dpll {
drivers/gpu/drm/i915/intel_ddi.c +125 -2
index b5cfb07..53ac23d 100644
@@ -1522,12 +1522,136 @@ static void hsw_shared_dplls_init(struct drm_i915_private *dev_priv)
         }
  }
 
+static const char * const skl_ddi_pll_names[] = {
+       "DPLL 1",
+       "DPLL 2",
+       "DPLL 3",
+};
+
+struct skl_dpll_regs {
+       u32 ctl, cfgcr1, cfgcr2;
+};
+
+/* this array is indexed by the *shared* pll id */
+static const struct skl_dpll_regs skl_dpll_regs[3] = {
+       {
+               /* DPLL 1 */
+               .ctl = LCPLL2_CTL,
+               .cfgcr1 = DPLL1_CFGCR1,
+               .cfgcr2 = DPLL1_CFGCR2,
+       },
+       {
+               /* DPLL 2 */
+               .ctl = WRPLL_CTL1,
+               .cfgcr1 = DPLL2_CFGCR1,
+               .cfgcr2 = DPLL2_CFGCR2,
+       },
+       {
+               /* DPLL 3 */
+               .ctl = WRPLL_CTL2,
+               .cfgcr1 = DPLL3_CFGCR1,
+               .cfgcr2 = DPLL3_CFGCR2,
+       },
+};
+
+static void skl_ddi_pll_enable(struct drm_i915_private *dev_priv,
+                              struct intel_shared_dpll *pll)
+{
+       uint32_t val;
+       unsigned int dpll;
+       const struct skl_dpll_regs *regs = skl_dpll_regs;
+
+       /* DPLL0 is not part of the shared DPLLs, so pll->id is 0 for DPLL1 */
+       dpll = pll->id + 1;
+
+       val = I915_READ(DPLL_CTRL1);
+
+       val &= ~(DPLL_CTRL1_HDMI_MODE(dpll) | DPLL_CTRL1_SSC(dpll) |
+                DPLL_CRTL1_LINK_RATE_MASK(dpll));
+       val |= pll->hw_state.ctrl1 << (dpll * 6);
+
+       I915_WRITE(DPLL_CTRL1, val);
+       POSTING_READ(DPLL_CTRL1);
+
+       I915_WRITE(regs[pll->id].cfgcr1, pll->hw_state.cfgcr1);
+       I915_WRITE(regs[pll->id].cfgcr2, pll->hw_state.cfgcr2);
+       POSTING_READ(regs[pll->id].cfgcr1);
+       POSTING_READ(regs[pll->id].cfgcr2);
+
+       /* the enable bit is always bit 31 */
+       I915_WRITE(regs[pll->id].ctl,
+                  I915_READ(regs[pll->id].ctl) | LCPLL_PLL_ENABLE);
+
+       if (wait_for(I915_READ(DPLL_STATUS) & DPLL_LOCK(dpll), 5))
+               DRM_ERROR("DPLL %d not locked\n", dpll);
+}
+
+static void skl_ddi_pll_disable(struct drm_i915_private *dev_priv,
+                               struct intel_shared_dpll *pll)
+{
+       const struct skl_dpll_regs *regs = skl_dpll_regs;
+
+       /* the enable bit is always bit 31 */
+       I915_WRITE(regs[pll->id].ctl,
+                  I915_READ(regs[pll->id].ctl) & ~LCPLL_PLL_ENABLE);
+       POSTING_READ(regs[pll->id].ctl);
+}
+
+static bool skl_ddi_pll_get_hw_state(struct drm_i915_private *dev_priv,
+                                    struct intel_shared_dpll *pll,
+                                    struct intel_dpll_hw_state *hw_state)
+{
+       uint32_t val;
+       unsigned int dpll;
+       const struct skl_dpll_regs *regs = skl_dpll_regs;
+
+       if (!intel_display_power_enabled(dev_priv, POWER_DOMAIN_PLLS))
+               return false;
+
+       /* DPLL0 is not part of the shared DPLLs, so pll->id is 0 for DPLL1 */
+       dpll = pll->id + 1;
+
+       val = I915_READ(regs[pll->id].ctl);
+       if (!(val & LCPLL_PLL_ENABLE))
+               return false;
+
+       val = I915_READ(DPLL_CTRL1);
+       hw_state->ctrl1 = (val >> (dpll * 6)) & 0x3f;
+
+       /* avoid reading back stale values if HDMI mode is not enabled */
+       if (val & DPLL_CTRL1_HDMI_MODE(dpll)) {
+               hw_state->cfgcr1 = I915_READ(regs[pll->id].cfgcr1);
+               hw_state->cfgcr2 = I915_READ(regs[pll->id].cfgcr2);
+       }
+
+       return true;
+}
+
+static void skl_shared_dplls_init(struct drm_i915_private *dev_priv)
+{
+       int i;
+
+       dev_priv->num_shared_dpll = 3;
+
+       for (i = 0; i < dev_priv->num_shared_dpll; i++) {
+               dev_priv->shared_dplls[i].id = i;
+               dev_priv->shared_dplls[i].name = skl_ddi_pll_names[i];
+               dev_priv->shared_dplls[i].disable = skl_ddi_pll_disable;
+               dev_priv->shared_dplls[i].enable = skl_ddi_pll_enable;
+               dev_priv->shared_dplls[i].get_hw_state =
+                       skl_ddi_pll_get_hw_state;
+       }
+}
+
  void intel_ddi_pll_init(struct drm_device *dev)
  {
         struct drm_i915_private *dev_priv = dev->dev_private;
         uint32_t val = I915_READ(LCPLL_CTL);
 
-       hsw_shared_dplls_init(dev_priv);
+       if (IS_SKYLAKE(dev))
+               skl_shared_dplls_init(dev_priv);
+       else
+               hsw_shared_dplls_init(dev_priv);
 
         DRM_DEBUG_KMS("CDCLK running at %dKHz\n",
                       intel_ddi_get_cdclk_freq(dev_priv));
--

1.8.3.1

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

#187 lore raw

PATCH 64/89 drm/i915/skl: Adjust the port PLL selection code

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

Skylake deprecates the usage of PORT_CLK_SEL and we are advised to use the new DPLL_CRTL2 for the DDI->PLL mapping.

---
 drivers/gpu/drm/i915/intel_ddi.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +25 -5
index 53ac23d..439cd50 100644
@@ -1223,7 +1223,8 @@ void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc)
 static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
 {
 	struct drm_encoder *encoder = &intel_encoder->base;
-	struct drm_i915_private *dev_priv = encoder->dev->dev_private;
+	struct drm_device *dev = encoder->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *crtc = to_intel_crtc(encoder->crtc);
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	int type = intel_encoder->type;
@@ -1242,8 +1243,22 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
 		intel_edp_panel_on(intel_dp);
 	}
 
-	WARN_ON(crtc->config.ddi_pll_sel == PORT_CLK_SEL_NONE);
-	I915_WRITE(PORT_CLK_SEL(port), crtc->config.ddi_pll_sel);
+	if (IS_SKYLAKE(dev)) {
+		enum skl_dpll dpll = crtc->config.ddi_pll_sel;
+		uint32_t val;
+
+		val = I915_READ(DPLL_CTRL2);
+
+		val &= ~(DPLL_CTRL2_DDI_CLK_OFF(port) |
+			DPLL_CTRL2_DDI_CLK_SEL_MASK(port));
+		val |= (DPLL_CTRL2_DDI_CLK_SEL(dpll, port) |
+			DPLL_CTRL2_DDI_SEL_OVERRIDE(port));
+
+		I915_WRITE(DPLL_CTRL2, val);
+	} else {
+		WARN_ON(crtc->config.ddi_pll_sel == PORT_CLK_SEL_NONE);
+		I915_WRITE(PORT_CLK_SEL(port), crtc->config.ddi_pll_sel);
+	}
 
 	if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
@@ -1267,7 +1282,8 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
 static void intel_ddi_post_disable(struct intel_encoder *intel_encoder)
 {
 	struct drm_encoder *encoder = &intel_encoder->base;
-	struct drm_i915_private *dev_priv = encoder->dev->dev_private;
+	struct drm_device *dev = encoder->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	enum port port = intel_ddi_get_encoder_port(intel_encoder);
 	int type = intel_encoder->type;
 	uint32_t val;
@@ -1295,7 +1311,11 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder)
 		intel_edp_panel_off(intel_dp);
 	}
 
-	I915_WRITE(PORT_CLK_SEL(port), PORT_CLK_SEL_NONE);
+	if (IS_SKYLAKE(dev))
+		I915_WRITE(DPLL_CTRL2, (I915_READ(DPLL_CTRL2) |
+					DPLL_CTRL2_DDI_CLK_OFF(port)));
+	else
+		I915_WRITE(PORT_CLK_SEL(port), PORT_CLK_SEL_NONE);
 }
 
 static void intel_enable_ddi(struct intel_encoder *intel_encoder)
Signature · 1 line
1.8.3.1
#188 lore raw

Re: [PATCH 64/89] drm/i915/skl: Adjust the port PLL selection code

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 16 lines

From: Satheeshakrishna M <[email protected]>

Skylake deprecates the usage of PORT_CLK_SEL and we are advised to use the new DPLL_CRTL2 for the DDI->PLL mapping.

---
 drivers/gpu/drm/i915/intel_ddi.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index 53ac23d..439cd50 100644

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc) · line 1226

Quoted 5 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -1
@@ -1223,7 +1223,8 @@ void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc)
 static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
 {
        struct drm_encoder *encoder = &intel_encoder->base;
-       struct drm_i915_private *dev_priv = encoder->dev->dev_private;
+       struct drm_device *dev = encoder->dev;

Bikeshed: this could be avoided if you just used dev_priv for the IS_SKYLAKE macro, now that it accepts it :)

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder) · line 1246

Quoted 11 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -2
+       struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_crtc *crtc = to_intel_crtc(encoder->crtc);
        enum port port = intel_ddi_get_encoder_port(intel_encoder);
        int type = intel_encoder->type;
@@ -1242,8 +1243,22 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
                intel_edp_panel_on(intel_dp);
        }
 
-       WARN_ON(crtc->config.ddi_pll_sel == PORT_CLK_SEL_NONE);
-       I915_WRITE(PORT_CLK_SEL(port), crtc->config.ddi_pll_sel);
+       if (IS_SKYLAKE(dev)) {

Bikeshed: invert the check so future gens are on the "else".

Quoted 5 lines
drivers/gpu/drm/i915/intel_ddi.c +5 -0
+               enum skl_dpll dpll = crtc->config.ddi_pll_sel;
+               uint32_t val;
+
+               val = I915_READ(DPLL_CTRL2);
+

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder) · line 1261

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +10 -0
+               val &= ~(DPLL_CTRL2_DDI_CLK_OFF(port) |
+                       DPLL_CTRL2_DDI_CLK_SEL_MASK(port));
+               val |= (DPLL_CTRL2_DDI_CLK_SEL(dpll, port) |
+                       DPLL_CTRL2_DDI_SEL_OVERRIDE(port));
+
+               I915_WRITE(DPLL_CTRL2, val);
+       } else {
+               WARN_ON(crtc->config.ddi_pll_sel == PORT_CLK_SEL_NONE);
+               I915_WRITE(PORT_CLK_SEL(port), crtc->config.ddi_pll_sel);
+       }

Bikeshed: extract this chunk to intel_ddi_set_port_clock() or some other name.

Quoted 14 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -1
        if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) {
                struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
@@ -1267,7 +1282,8 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
 static void intel_ddi_post_disable(struct intel_encoder *intel_encoder)
 {
        struct drm_encoder *encoder = &intel_encoder->base;
-       struct drm_i915_private *dev_priv = encoder->dev->dev_private;
+       struct drm_device *dev = encoder->dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
        enum port port = intel_ddi_get_encoder_port(intel_encoder);
        int type = intel_encoder->type;
        uint32_t val;

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct intel_encoder *intel_encoder) · line 1314

Quoted 5 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -1
@@ -1295,7 +1311,11 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder)
                intel_edp_panel_off(intel_dp);
        }
 
-       I915_WRITE(PORT_CLK_SEL(port), PORT_CLK_SEL_NONE);
+       if (IS_SKYLAKE(dev))

Same here.

With or without any changes: Reviewed-by: Paulo Zanoni <[email protected]>

Quoted 14 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -1
+               I915_WRITE(DPLL_CTRL2, (I915_READ(DPLL_CTRL2) |
+                                       DPLL_CTRL2_DDI_CLK_OFF(port)));
+       else
+               I915_WRITE(PORT_CLK_SEL(port), PORT_CLK_SEL_NONE);
 }
 
 static void intel_enable_ddi(struct intel_encoder *intel_encoder)
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#189 lore raw

PATCH 65/89 drm/i915/skl: Always use DPLL0 for eDP

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

DPLL0 is not part of the shared PLL infrastructure. We'll use on for eDP and rely on what the BIOS does for now.

---
 drivers/gpu/drm/i915/intel_dp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp.c +4 -1
index 5755f59..93bd9bf 100644
@@ -1005,7 +1005,10 @@ found:
 				&pipe_config->dp_m2_n2);
 	}
 
-	if (IS_HASWELL(dev) || IS_BROADWELL(dev))
+	if (IS_SKYLAKE(dev)) {
+		if (is_edp(intel_dp))
+			pipe_config->ddi_pll_sel = SKL_DPLL0;
+	} else if (IS_HASWELL(dev) || IS_BROADWELL(dev))
 		hsw_dp_set_ddi_pll_sel(pipe_config, intel_dp->link_bw);
 	else
 		intel_dp_set_clock(encoder, pipe_config, intel_dp->link_bw);
Signature · 1 line
1.8.3.1
#190 lore raw

Re: [PATCH 65/89] drm/i915/skl: Always use DPLL0 for eDP

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 16 lines

From: Satheeshakrishna M <[email protected]>

DPLL0 is not part of the shared PLL infrastructure. We'll use on for eDP and rely on what the BIOS does for now.

---
 drivers/gpu/drm/i915/intel_dp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp.c +0 -0
index 5755f59..93bd9bf 100644

drivers/gpu/drm/i915/intel_dp.c found: · line 1010

Quoted 7 lines
drivers/gpu/drm/i915/intel_dp.c +3 -1
@@ -1005,7 +1005,10 @@ found:
                                &pipe_config->dp_m2_n2);
        }
 
-       if (IS_HASWELL(dev) || IS_BROADWELL(dev))
+       if (IS_SKYLAKE(dev)) {
+               if (is_edp(intel_dp))
+                       pipe_config->ddi_pll_sel = SKL_DPLL0;

So we just don't assign anything else for the other ports? Why exactly?

Quoted 11 lines
drivers/gpu/drm/i915/intel_dp.c +1 -1
+       } else if (IS_HASWELL(dev) || IS_BROADWELL(dev))
                hsw_dp_set_ddi_pll_sel(pipe_config, intel_dp->link_bw);
        else
                intel_dp_set_clock(encoder, pipe_config, intel_dp->link_bw);
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#191 lore raw

Re: [PATCH 65/89] drm/i915/skl: Always use DPLL0 for eDP

Quoted 20 lines · Paulo Zanoni

2014-09-04 8:27 GMT-03:00 Damien Lespiau<[email protected]>:

Quoted 19 lines

From: Satheeshakrishna M<[email protected]>

DPLL0 is not part of the shared PLL infrastructure. We'll use on for eDP and rely on what the BIOS does for now.

---
  drivers/gpu/drm/i915/intel_dp.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp.c +0 -0
index 5755f59..93bd9bf 100644
@@ -1005,7 +1005,10 @@ found:
                                 &pipe_config->dp_m2_n2);
         }
 
Quoted 5 lines

drivers/gpu/drm/i915/intel_dp.c found: · line 1010

Quoted 4 lines
drivers/gpu/drm/i915/intel_dp.c +3 -1
-       if (IS_HASWELL(dev) || IS_BROADWELL(dev))
+       if (IS_SKYLAKE(dev)) {
+               if (is_edp(intel_dp))
+                       pipe_config->ddi_pll_sel = SKL_DPLL0;

So we just don't assign anything else for the other ports? Why exactly?

Other ports follow the shared dpll logic and assignment happens in intel_ddi

Quoted 13 lines
Quoted 12 lines
drivers/gpu/drm/i915/intel_dp.c +1 -1
+       } else if (IS_HASWELL(dev) || IS_BROADWELL(dev))
                 hsw_dp_set_ddi_pll_sel(pipe_config, intel_dp->link_bw);
         else
                 intel_dp_set_clock(encoder, pipe_config, intel_dp->link_bw);
--

1.8.3.1

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

#192 lore raw

PATCH 66/89 drm/i915/skl: Implementation of SKL DPLL programming

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

This patch implements SKL DPLL programming that includes:
- DPLL allocation
- wide range PLL calculation and programming
- DP link rate programming
- DDI to DPLL mapping

v2: Incorporated following changes
- Added vfunc for function required outside
- Fixed multiple comments in WRPLL calculation

v3: - Fix the DCO computation
- Move the initialization up to not clobber the computed values
- Use the correct macro for DP link rate programming.
- Use wait_for() to wait for the PLL locked bit

v4: Rebase on top of nigthly (Damien)

v5: A few code cleanups in the WRPLL computation (Damien)
- Use uint32_t when possible
- Use abs_diff() in the WRPLL computation
- Make the 64bits divisions use div64_u64()
- Fix typo in dco_central_feq_deviation (freq)
- Replace the chain of breaks with a goto

v6: Port of the patch to work on top of the shared DPLLs (Damien)
v7: Don't try to handle eDP in ddi_pll_select() (Damien)

---
 drivers/gpu/drm/i915/intel_ddi.c | 225 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 224 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +224 -1
index 439cd50..f68e04c 100644
@@ -915,6 +915,225 @@ hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
 	return true;
 }
 
+struct skl_wrpll_params {
+	uint32_t        dco_fraction;
+	uint32_t        dco_integer;
+	uint32_t        qdiv_ratio;
+	uint32_t        qdiv_mode;
+	uint32_t        kdiv;
+	uint32_t        pdiv;
+	uint32_t        central_freq;
+};
+
+static void
+skl_ddi_calculate_wrpll(int clock /* in Hz */,
+			struct skl_wrpll_params *wrpll_params)
+{
+	uint64_t afe_clock = clock * 5; /* AFE Clock is 5x Pixel clock */
+	uint64_t dco_central_freq[3] = {8400000000, 9000000000, 9600000000};
+	uint32_t min_dco_deviation = 400;
+	uint32_t min_dco_index = 3;
+	uint32_t P0[4] = {1, 2, 3, 7};
+	uint32_t P2[4] = {1, 2, 3, 5};
+	bool found = false;
+	uint32_t candidate_p = 0;
+	uint32_t candidate_p0[3] = {0}, candidate_p1[3] = {0};
+	uint32_t candidate_p2[3] = {0};
+	uint32_t dco_central_freq_deviation[3];
+	uint32_t i, P1, k, dco_count;
+	bool retry_with_odd = false;
+	uint64_t dco_freq;
+
+	/* Determine P0, P1 or P2 */
+	for (dco_count = 0; dco_count < 3; dco_count++) {
+		found = false;
+		candidate_p =
+			div64_u64(dco_central_freq[dco_count], afe_clock);
+		if (retry_with_odd == false)
+			candidate_p = (candidate_p % 2 == 0 ?
+				candidate_p : candidate_p + 1);
+
+		for (P1 = 1; P1 < candidate_p; P1++) {
+			for (i = 0; i < 4; i++) {
+				if (!(P0[i] != 1 || P1 == 1))
+					continue;
+
+				for (k = 0; k < 4; k++) {
+					if (!((P2[k] != 2 && P1 == 1) ||
+						(P2[k] == 2)))
+						continue;
+
+					if (candidate_p == P0[i] * P1 * P2[k]) {
+						/* Found possible P0, P1, P2 */
+						found = true;
+						candidate_p0[dco_count] = P0[i];
+						candidate_p1[dco_count] = P1;
+						candidate_p2[dco_count] = P2[k];
+						goto found;
+					}
+
+				}
+			}
+		}
+
+found:
+		if (found) {
+			dco_central_freq_deviation[dco_count] =
+				div64_u64(10000 *
+					  abs_diff((candidate_p * afe_clock),
+						   dco_central_freq[dco_count]),
+					  dco_central_freq[dco_count]);
+
+			if (dco_central_freq_deviation[dco_count] <
+				min_dco_deviation) {
+				min_dco_deviation =
+					dco_central_freq_deviation[dco_count];
+				min_dco_index = dco_count;
+			}
+		}
+
+		if (min_dco_index > 2 && dco_count == 2) {
+			retry_with_odd = true;
+			dco_count = 0;
+		}
+	}
+
+	if (min_dco_index > 2) {
+		WARN(1, "No valid values found for the given pixel clock\n");
+	} else {
+		 wrpll_params->central_freq = dco_central_freq[min_dco_index];
+
+		 switch (dco_central_freq[min_dco_index]) {
+		 case 9600000000:
+			wrpll_params->central_freq = 0;
+			break;
+		 case 9000000000:
+			wrpll_params->central_freq = 1;
+			break;
+		 case 8400000000:
+			wrpll_params->central_freq = 3;
+		 }
+
+		 switch (candidate_p0[min_dco_index]) {
+		 case 1:
+			wrpll_params->pdiv = 0;
+			break;
+		 case 2:
+			wrpll_params->pdiv = 1;
+			break;
+		 case 3:
+			wrpll_params->pdiv = 2;
+			break;
+		 case 7:
+			wrpll_params->pdiv = 4;
+			break;
+		 default:
+			WARN(1, "Incorrect PDiv\n");
+		 }
+
+		 switch (candidate_p2[min_dco_index]) {
+		 case 5:
+			wrpll_params->kdiv = 0;
+			break;
+		 case 2:
+			wrpll_params->kdiv = 1;
+			break;
+		 case 3:
+			wrpll_params->kdiv = 2;
+			break;
+		 case 1:
+			wrpll_params->kdiv = 3;
+			break;
+		 default:
+			WARN(1, "Incorrect KDiv\n");
+		 }
+
+		 wrpll_params->qdiv_ratio = candidate_p1[min_dco_index];
+		 wrpll_params->qdiv_mode =
+			(wrpll_params->qdiv_ratio == 1) ? 0 : 1;
+
+		 dco_freq = candidate_p0[min_dco_index] *
+			 candidate_p1[min_dco_index] *
+			 candidate_p2[min_dco_index] * afe_clock;
+
+		 /* Intermediate values are in Hz.
+		    Divide by MHz to match bsepc */
+		 wrpll_params->dco_integer = div_u64(dco_freq, (24 * MHz(1)));
+		 wrpll_params->dco_fraction =
+			 div_u64(((div_u64(dco_freq, 24) -
+				   wrpll_params->dco_integer * MHz(1)) * 0x8000), MHz(1));
+
+	}
+}
+
+
+static bool
+skl_ddi_pll_select(struct intel_crtc *intel_crtc,
+		   struct intel_encoder *intel_encoder,
+		   int clock)
+{
+	struct intel_shared_dpll *pll;
+	uint32_t ctrl1, cfgcr1, cfgcr2;
+
+	/*
+	 * See comment in intel_dpll_hw_state to understand why we always use 0
+	 * as the DPLL id in this function.
+	 */
+
+	ctrl1 = DPLL_CTRL1_OVERRIDE(0);
+
+	if (intel_encoder->type == INTEL_OUTPUT_HDMI) {
+		struct skl_wrpll_params wrpll_params = { 0, };
+
+		ctrl1 |= DPLL_CTRL1_HDMI_MODE(0);
+
+		skl_ddi_calculate_wrpll(clock * 1000, &wrpll_params);
+
+		cfgcr1 = DPLL_CFGCR1_FREQ_ENABLE |
+			 DPLL_CFGCR1_DCO_FRACTION(wrpll_params.dco_fraction) |
+			 wrpll_params.dco_integer;
+
+		cfgcr2 = DPLL_CFGCR2_QDIV_RATIO(wrpll_params.qdiv_ratio) |
+			 DPLL_CFGCR2_QDIV_MODE(wrpll_params.qdiv_mode) |
+			 DPLL_CFGCR2_KDIV(wrpll_params.kdiv) |
+			 DPLL_CFGCR2_PDIV(wrpll_params.pdiv) |
+			 wrpll_params.central_freq;
+	} else if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) {
+		struct drm_encoder *encoder = &intel_encoder->base;
+		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+
+		switch (intel_dp->link_bw) {
+		case DP_LINK_BW_1_62:
+			ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_810, 0);
+			break;
+		case DP_LINK_BW_2_7:
+			ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_1350, 0);
+			break;
+		case DP_LINK_BW_5_4:
+			ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_2700, 0);
+			break;
+		}
+
+		cfgcr1 = cfgcr2 = 0;
+	} else /* eDP */
+		return true;
+
+	intel_crtc->config.dpll_hw_state.ctrl1 = ctrl1;
+	intel_crtc->config.dpll_hw_state.cfgcr1 = cfgcr1;
+	intel_crtc->config.dpll_hw_state.cfgcr2 = cfgcr2;
+
+	pll = intel_get_shared_dpll(intel_crtc);
+	if (pll == NULL) {
+		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
+				 pipe_name(intel_crtc->pipe));
+		return false;
+	}
+
+	/* shared DPLL id 0 is DPLL 1 */
+	intel_crtc->config.ddi_pll_sel = pll->id + 1;
+
+	return true;
+}
 
 /*
  * Tries to find a *shared* PLL for the CRTC and store it in
@@ -926,12 +1145,16 @@ hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
 bool intel_ddi_pll_select(struct intel_crtc *intel_crtc)
 {
 	struct drm_crtc *crtc = &intel_crtc->base;
+	struct drm_device *dev = crtc->dev;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 	int clock = intel_crtc->config.port_clock;
 
 	intel_put_shared_dpll(intel_crtc);
 
-	return hsw_ddi_pll_select(intel_crtc, intel_encoder, clock);
+	if (IS_SKYLAKE(dev))
+		return skl_ddi_pll_select(intel_crtc, intel_encoder, clock);
+	else
+		return hsw_ddi_pll_select(intel_crtc, intel_encoder, clock);
 }
 
 void intel_ddi_set_pipe_settings(struct drm_crtc *crtc)
Signature · 1 line
1.8.3.1
#193 lore raw

Re: [PATCH 66/89] drm/i915/skl: Implementation of SKL DPLL programming

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 74 lines

From: Satheeshakrishna M <[email protected]>

This patch implements SKL DPLL programming that includes:
- DPLL allocation
- wide range PLL calculation and programming
- DP link rate programming
- DDI to DPLL mapping

v2: Incorporated following changes
- Added vfunc for function required outside
- Fixed multiple comments in WRPLL calculation

v3: - Fix the DCO computation
- Move the initialization up to not clobber the computed values
- Use the correct macro for DP link rate programming.
- Use wait_for() to wait for the PLL locked bit

v4: Rebase on top of nigthly (Damien)

v5: A few code cleanups in the WRPLL computation (Damien)
- Use uint32_t when possible
- Use abs_diff() in the WRPLL computation
- Make the 64bits divisions use div64_u64()
- Fix typo in dco_central_feq_deviation (freq)
- Replace the chain of breaks with a goto

v6: Port of the patch to work on top of the shared DPLLs (Damien)
v7: Don't try to handle eDP in ddi_pll_select() (Damien)

---
 drivers/gpu/drm/i915/intel_ddi.c | 225 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 224 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +31 -0
index 439cd50..f68e04c 100644
@@ -915,6 +915,225 @@ hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
        return true;
 }
 
+struct skl_wrpll_params {
+       uint32_t        dco_fraction;
+       uint32_t        dco_integer;
+       uint32_t        qdiv_ratio;
+       uint32_t        qdiv_mode;
+       uint32_t        kdiv;
+       uint32_t        pdiv;
+       uint32_t        central_freq;
+};
+
+static void
+skl_ddi_calculate_wrpll(int clock /* in Hz */,
+                       struct skl_wrpll_params *wrpll_params)
+{
+       uint64_t afe_clock = clock * 5; /* AFE Clock is 5x Pixel clock */
+       uint64_t dco_central_freq[3] = {8400000000, 9000000000, 9600000000};
+       uint32_t min_dco_deviation = 400;
+       uint32_t min_dco_index = 3;
+       uint32_t P0[4] = {1, 2, 3, 7};
+       uint32_t P2[4] = {1, 2, 3, 5};
+       bool found = false;
+       uint32_t candidate_p = 0;
+       uint32_t candidate_p0[3] = {0}, candidate_p1[3] = {0};
+       uint32_t candidate_p2[3] = {0};
+       uint32_t dco_central_freq_deviation[3];
+       uint32_t i, P1, k, dco_count;
+       bool retry_with_odd = false;
+       uint64_t dco_freq;
+
+       /* Determine P0, P1 or P2 */
+       for (dco_count = 0; dco_count < 3; dco_count++) {

drivers/gpu/drm/i915/intel_ddi.c hsw_ddi_pll_select(struct intel_crtc *intel_crtc, · line 958

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +10 -0
+               found = false;
+               candidate_p =
+                       div64_u64(dco_central_freq[dco_count], afe_clock);
+               if (retry_with_odd == false)
+                       candidate_p = (candidate_p % 2 == 0 ?
+                               candidate_p : candidate_p + 1);
+
+               for (P1 = 1; P1 < candidate_p; P1++) {
+                       for (i = 0; i < 4; i++) {
+                               if (!(P0[i] != 1 || P1 == 1))

I'd invert the logic of the statement above to match the spec.

drivers/gpu/drm/i915/intel_ddi.c hsw_ddi_pll_select(struct intel_crtc *intel_crtc, · line 963

Quoted 5 lines
drivers/gpu/drm/i915/intel_ddi.c +5 -0
+                                       continue;
+
+                               for (k = 0; k < 4; k++) {
+                                       if (!((P2[k] != 2 && P1 == 1) ||
+                                               (P2[k] == 2)))

This doesn't seem to match the docs. Why is the "P2[k] == 2" there?

Quoted 1 line

From the bikeshedding department, there's also a minor coding style

problem (missing "*" char in second line of comment) below, and the usual "is_skl" check leaving gen10+ on the same case as hsw/bdw.

Everything else looks like to be according to the specs.

With or without changes: Reviewed-by: Paulo Zanoni <[email protected]>

Quoted 201 lines
drivers/gpu/drm/i915/intel_ddi.c +178 -2
+                                               continue;
+
+                                       if (candidate_p == P0[i] * P1 * P2[k]) {
+                                               /* Found possible P0, P1, P2 */
+                                               found = true;
+                                               candidate_p0[dco_count] = P0[i];
+                                               candidate_p1[dco_count] = P1;
+                                               candidate_p2[dco_count] = P2[k];
+                                               goto found;
+                                       }
+
+                               }
+                       }
+               }
+
+found:
+               if (found) {
+                       dco_central_freq_deviation[dco_count] =
+                               div64_u64(10000 *
+                                         abs_diff((candidate_p * afe_clock),
+                                                  dco_central_freq[dco_count]),
+                                         dco_central_freq[dco_count]);
+
+                       if (dco_central_freq_deviation[dco_count] <
+                               min_dco_deviation) {
+                               min_dco_deviation =
+                                       dco_central_freq_deviation[dco_count];
+                               min_dco_index = dco_count;
+                       }
+               }
+
+               if (min_dco_index > 2 && dco_count == 2) {
+                       retry_with_odd = true;
+                       dco_count = 0;
+               }
+       }
+
+       if (min_dco_index > 2) {
+               WARN(1, "No valid values found for the given pixel clock\n");
+       } else {
+                wrpll_params->central_freq = dco_central_freq[min_dco_index];
+
+                switch (dco_central_freq[min_dco_index]) {
+                case 9600000000:
+                       wrpll_params->central_freq = 0;
+                       break;
+                case 9000000000:
+                       wrpll_params->central_freq = 1;
+                       break;
+                case 8400000000:
+                       wrpll_params->central_freq = 3;
+                }
+
+                switch (candidate_p0[min_dco_index]) {
+                case 1:
+                       wrpll_params->pdiv = 0;
+                       break;
+                case 2:
+                       wrpll_params->pdiv = 1;
+                       break;
+                case 3:
+                       wrpll_params->pdiv = 2;
+                       break;
+                case 7:
+                       wrpll_params->pdiv = 4;
+                       break;
+                default:
+                       WARN(1, "Incorrect PDiv\n");
+                }
+
+                switch (candidate_p2[min_dco_index]) {
+                case 5:
+                       wrpll_params->kdiv = 0;
+                       break;
+                case 2:
+                       wrpll_params->kdiv = 1;
+                       break;
+                case 3:
+                       wrpll_params->kdiv = 2;
+                       break;
+                case 1:
+                       wrpll_params->kdiv = 3;
+                       break;
+                default:
+                       WARN(1, "Incorrect KDiv\n");
+                }
+
+                wrpll_params->qdiv_ratio = candidate_p1[min_dco_index];
+                wrpll_params->qdiv_mode =
+                       (wrpll_params->qdiv_ratio == 1) ? 0 : 1;
+
+                dco_freq = candidate_p0[min_dco_index] *
+                        candidate_p1[min_dco_index] *
+                        candidate_p2[min_dco_index] * afe_clock;
+
+                /* Intermediate values are in Hz.
+                   Divide by MHz to match bsepc */
+                wrpll_params->dco_integer = div_u64(dco_freq, (24 * MHz(1)));
+                wrpll_params->dco_fraction =
+                        div_u64(((div_u64(dco_freq, 24) -
+                                  wrpll_params->dco_integer * MHz(1)) * 0x8000), MHz(1));
+
+       }
+}
+
+
+static bool
+skl_ddi_pll_select(struct intel_crtc *intel_crtc,
+                  struct intel_encoder *intel_encoder,
+                  int clock)
+{
+       struct intel_shared_dpll *pll;
+       uint32_t ctrl1, cfgcr1, cfgcr2;
+
+       /*
+        * See comment in intel_dpll_hw_state to understand why we always use 0
+        * as the DPLL id in this function.
+        */
+
+       ctrl1 = DPLL_CTRL1_OVERRIDE(0);
+
+       if (intel_encoder->type == INTEL_OUTPUT_HDMI) {
+               struct skl_wrpll_params wrpll_params = { 0, };
+
+               ctrl1 |= DPLL_CTRL1_HDMI_MODE(0);
+
+               skl_ddi_calculate_wrpll(clock * 1000, &wrpll_params);
+
+               cfgcr1 = DPLL_CFGCR1_FREQ_ENABLE |
+                        DPLL_CFGCR1_DCO_FRACTION(wrpll_params.dco_fraction) |
+                        wrpll_params.dco_integer;
+
+               cfgcr2 = DPLL_CFGCR2_QDIV_RATIO(wrpll_params.qdiv_ratio) |
+                        DPLL_CFGCR2_QDIV_MODE(wrpll_params.qdiv_mode) |
+                        DPLL_CFGCR2_KDIV(wrpll_params.kdiv) |
+                        DPLL_CFGCR2_PDIV(wrpll_params.pdiv) |
+                        wrpll_params.central_freq;
+       } else if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) {
+               struct drm_encoder *encoder = &intel_encoder->base;
+               struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+
+               switch (intel_dp->link_bw) {
+               case DP_LINK_BW_1_62:
+                       ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_810, 0);
+                       break;
+               case DP_LINK_BW_2_7:
+                       ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_1350, 0);
+                       break;
+               case DP_LINK_BW_5_4:
+                       ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_2700, 0);
+                       break;
+               }
+
+               cfgcr1 = cfgcr2 = 0;
+       } else /* eDP */
+               return true;
+
+       intel_crtc->config.dpll_hw_state.ctrl1 = ctrl1;
+       intel_crtc->config.dpll_hw_state.cfgcr1 = cfgcr1;
+       intel_crtc->config.dpll_hw_state.cfgcr2 = cfgcr2;
+
+       pll = intel_get_shared_dpll(intel_crtc);
+       if (pll == NULL) {
+               DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
+                                pipe_name(intel_crtc->pipe));
+               return false;
+       }
+
+       /* shared DPLL id 0 is DPLL 1 */
+       intel_crtc->config.ddi_pll_sel = pll->id + 1;
+
+       return true;
+}
 
 /*
  * Tries to find a *shared* PLL for the CRTC and store it in
@@ -926,12 +1145,16 @@ hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
 bool intel_ddi_pll_select(struct intel_crtc *intel_crtc)
 {
        struct drm_crtc *crtc = &intel_crtc->base;
+       struct drm_device *dev = crtc->dev;
        struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
        int clock = intel_crtc->config.port_clock;
 
        intel_put_shared_dpll(intel_crtc);
 
-       return hsw_ddi_pll_select(intel_crtc, intel_encoder, clock);
+       if (IS_SKYLAKE(dev))
+               return skl_ddi_pll_select(intel_crtc, intel_encoder, clock);
+       else
+               return hsw_ddi_pll_select(intel_crtc, intel_encoder, clock);
 }
 
 void intel_ddi_set_pipe_settings(struct drm_crtc *crtc)
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#194 lore raw

Re: [PATCH 66/89] drm/i915/skl: Implementation of SKL DPLL programming

Quoted 78 lines · Paulo Zanoni

2014-09-04 8:27 GMT-03:00 Damien Lespiau<[email protected]>:

Quoted 77 lines

From: Satheeshakrishna M<[email protected]>

This patch implements SKL DPLL programming that includes:
- DPLL allocation
- wide range PLL calculation and programming
- DP link rate programming
- DDI to DPLL mapping

v2: Incorporated following changes
- Added vfunc for function required outside
- Fixed multiple comments in WRPLL calculation

v3: - Fix the DCO computation
- Move the initialization up to not clobber the computed values
- Use the correct macro for DP link rate programming.
- Use wait_for() to wait for the PLL locked bit

v4: Rebase on top of nigthly (Damien)

v5: A few code cleanups in the WRPLL computation (Damien)
- Use uint32_t when possible
- Use abs_diff() in the WRPLL computation
- Make the 64bits divisions use div64_u64()
- Fix typo in dco_central_feq_deviation (freq)
- Replace the chain of breaks with a goto

v6: Port of the patch to work on top of the shared DPLLs (Damien)
v7: Don't try to handle eDP in ddi_pll_select() (Damien)

---
  drivers/gpu/drm/i915/intel_ddi.c | 225 ++++++++++++++++++++++++++++++++++++++-
  1 file changed, 224 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +34 -0
index 439cd50..f68e04c 100644
@@ -915,6 +915,225 @@ hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
         return true;
  }
 
+struct skl_wrpll_params {
+       uint32_t        dco_fraction;
+       uint32_t        dco_integer;
+       uint32_t        qdiv_ratio;
+       uint32_t        qdiv_mode;
+       uint32_t        kdiv;
+       uint32_t        pdiv;
+       uint32_t        central_freq;
+};
+
+static void
+skl_ddi_calculate_wrpll(int clock /* in Hz */,
+                       struct skl_wrpll_params *wrpll_params)
+{
+       uint64_t afe_clock = clock * 5; /* AFE Clock is 5x Pixel clock */
+       uint64_t dco_central_freq[3] = {8400000000, 9000000000, 9600000000};
+       uint32_t min_dco_deviation = 400;
+       uint32_t min_dco_index = 3;
+       uint32_t P0[4] = {1, 2, 3, 7};
+       uint32_t P2[4] = {1, 2, 3, 5};
+       bool found = false;
+       uint32_t candidate_p = 0;
+       uint32_t candidate_p0[3] = {0}, candidate_p1[3] = {0};
+       uint32_t candidate_p2[3] = {0};
+       uint32_t dco_central_freq_deviation[3];
+       uint32_t i, P1, k, dco_count;
+       bool retry_with_odd = false;
+       uint64_t dco_freq;
+
+       /* Determine P0, P1 or P2 */
+       for (dco_count = 0; dco_count < 3; dco_count++) {
+               found = false;
+               candidate_p =
+                       div64_u64(dco_central_freq[dco_count], afe_clock);
Quoted 8 lines

drivers/gpu/drm/i915/intel_ddi.c hsw_ddi_pll_select(struct intel_crtc *intel_crtc, · line 958

Quoted 7 lines
drivers/gpu/drm/i915/intel_ddi.c +7 -0
+               if (retry_with_odd == false)
+                       candidate_p = (candidate_p % 2 == 0 ?
+                               candidate_p : candidate_p + 1);
+
+               for (P1 = 1; P1 < candidate_p; P1++) {
+                       for (i = 0; i < 4; i++) {
+                               if (!(P0[i] != 1 || P1 == 1))

I'd invert the logic of the statement above to match the spec.

That's how it was. I had to change it to avoid multiple indentation and hence to meet max line length

Quoted 7 lines

drivers/gpu/drm/i915/intel_ddi.c hsw_ddi_pll_select(struct intel_crtc *intel_crtc, · line 963

Quoted 6 lines
drivers/gpu/drm/i915/intel_ddi.c +5 -0
+                                       continue;
+
+                               for (k = 0; k < 4; k++) {
+                                       if (!((P2[k] != 2 && P1 == 1) ||
+                                               (P2[k] == 2)))

This doesn't seem to match the docs. Why is the "P2[k] == 2" there?

ok, this can be simplified.

Quoted 201 lines

From the bikeshedding department, there's also a minor coding style
problem (missing "*" char in second line of comment) below, and the usual "is_skl" check leaving gen10+ on the same case as hsw/bdw.

Everything else looks like to be according to the specs.

With or without changes: Reviewed-by: Paulo Zanoni<[email protected]>

Quoted 193 lines
drivers/gpu/drm/i915/intel_ddi.c +178 -1
+                                               continue;
+
+                                       if (candidate_p == P0[i] * P1 * P2[k]) {
+                                               /* Found possible P0, P1, P2 */
+                                               found = true;
+                                               candidate_p0[dco_count] = P0[i];
+                                               candidate_p1[dco_count] = P1;
+                                               candidate_p2[dco_count] = P2[k];
+                                               goto found;
+                                       }
+
+                               }
+                       }
+               }
+
+found:
+               if (found) {
+                       dco_central_freq_deviation[dco_count] =
+                               div64_u64(10000 *
+                                         abs_diff((candidate_p * afe_clock),
+                                                  dco_central_freq[dco_count]),
+                                         dco_central_freq[dco_count]);
+
+                       if (dco_central_freq_deviation[dco_count] <
+                               min_dco_deviation) {
+                               min_dco_deviation =
+                                       dco_central_freq_deviation[dco_count];
+                               min_dco_index = dco_count;
+                       }
+               }
+
+               if (min_dco_index > 2 && dco_count == 2) {
+                       retry_with_odd = true;
+                       dco_count = 0;
+               }
+       }
+
+       if (min_dco_index > 2) {
+               WARN(1, "No valid values found for the given pixel clock\n");
+       } else {
+                wrpll_params->central_freq = dco_central_freq[min_dco_index];
+
+                switch (dco_central_freq[min_dco_index]) {
+                case 9600000000:
+                       wrpll_params->central_freq = 0;
+                       break;
+                case 9000000000:
+                       wrpll_params->central_freq = 1;
+                       break;
+                case 8400000000:
+                       wrpll_params->central_freq = 3;
+                }
+
+                switch (candidate_p0[min_dco_index]) {
+                case 1:
+                       wrpll_params->pdiv = 0;
+                       break;
+                case 2:
+                       wrpll_params->pdiv = 1;
+                       break;
+                case 3:
+                       wrpll_params->pdiv = 2;
+                       break;
+                case 7:
+                       wrpll_params->pdiv = 4;
+                       break;
+                default:
+                       WARN(1, "Incorrect PDiv\n");
+                }
+
+                switch (candidate_p2[min_dco_index]) {
+                case 5:
+                       wrpll_params->kdiv = 0;
+                       break;
+                case 2:
+                       wrpll_params->kdiv = 1;
+                       break;
+                case 3:
+                       wrpll_params->kdiv = 2;
+                       break;
+                case 1:
+                       wrpll_params->kdiv = 3;
+                       break;
+                default:
+                       WARN(1, "Incorrect KDiv\n");
+                }
+
+                wrpll_params->qdiv_ratio = candidate_p1[min_dco_index];
+                wrpll_params->qdiv_mode =
+                       (wrpll_params->qdiv_ratio == 1) ? 0 : 1;
+
+                dco_freq = candidate_p0[min_dco_index] *
+                        candidate_p1[min_dco_index] *
+                        candidate_p2[min_dco_index] * afe_clock;
+
+                /* Intermediate values are in Hz.
+                   Divide by MHz to match bsepc */
+                wrpll_params->dco_integer = div_u64(dco_freq, (24 * MHz(1)));
+                wrpll_params->dco_fraction =
+                        div_u64(((div_u64(dco_freq, 24) -
+                                  wrpll_params->dco_integer * MHz(1)) * 0x8000), MHz(1));
+
+       }
+}
+
+
+static bool
+skl_ddi_pll_select(struct intel_crtc *intel_crtc,
+                  struct intel_encoder *intel_encoder,
+                  int clock)
+{
+       struct intel_shared_dpll *pll;
+       uint32_t ctrl1, cfgcr1, cfgcr2;
+
+       /*
+        * See comment in intel_dpll_hw_state to understand why we always use 0
+        * as the DPLL id in this function.
+        */
+
+       ctrl1 = DPLL_CTRL1_OVERRIDE(0);
+
+       if (intel_encoder->type == INTEL_OUTPUT_HDMI) {
+               struct skl_wrpll_params wrpll_params = { 0, };
+
+               ctrl1 |= DPLL_CTRL1_HDMI_MODE(0);
+
+               skl_ddi_calculate_wrpll(clock * 1000, &wrpll_params);
+
+               cfgcr1 = DPLL_CFGCR1_FREQ_ENABLE |
+                        DPLL_CFGCR1_DCO_FRACTION(wrpll_params.dco_fraction) |
+                        wrpll_params.dco_integer;
+
+               cfgcr2 = DPLL_CFGCR2_QDIV_RATIO(wrpll_params.qdiv_ratio) |
+                        DPLL_CFGCR2_QDIV_MODE(wrpll_params.qdiv_mode) |
+                        DPLL_CFGCR2_KDIV(wrpll_params.kdiv) |
+                        DPLL_CFGCR2_PDIV(wrpll_params.pdiv) |
+                        wrpll_params.central_freq;
+       } else if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) {
+               struct drm_encoder *encoder = &intel_encoder->base;
+               struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+
+               switch (intel_dp->link_bw) {
+               case DP_LINK_BW_1_62:
+                       ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_810, 0);
+                       break;
+               case DP_LINK_BW_2_7:
+                       ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_1350, 0);
+                       break;
+               case DP_LINK_BW_5_4:
+                       ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_2700, 0);
+                       break;
+               }
+
+               cfgcr1 = cfgcr2 = 0;
+       } else /* eDP */
+               return true;
+
+       intel_crtc->config.dpll_hw_state.ctrl1 = ctrl1;
+       intel_crtc->config.dpll_hw_state.cfgcr1 = cfgcr1;
+       intel_crtc->config.dpll_hw_state.cfgcr2 = cfgcr2;
+
+       pll = intel_get_shared_dpll(intel_crtc);
+       if (pll == NULL) {
+               DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
+                                pipe_name(intel_crtc->pipe));
+               return false;
+       }
+
+       /* shared DPLL id 0 is DPLL 1 */
+       intel_crtc->config.ddi_pll_sel = pll->id + 1;
+
+       return true;
+}
 
  /*
   * Tries to find a *shared* PLL for the CRTC and store it in
@@ -926,12 +1145,16 @@ hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
  bool intel_ddi_pll_select(struct intel_crtc *intel_crtc)
  {
         struct drm_crtc *crtc = &intel_crtc->base;
+       struct drm_device *dev = crtc->dev;
         struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
         int clock = intel_crtc->config.port_clock;
 
         intel_put_shared_dpll(intel_crtc);
 
-       return hsw_ddi_pll_select(intel_crtc, intel_encoder, clock);
+       if (IS_SKYLAKE(dev))
+               return skl_ddi_pll_select(intel_crtc, intel_encoder, clock);
+       else
+               return hsw_ddi_pll_select(intel_crtc, intel_encoder, clock);
  }
 
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -1
  void intel_ddi_set_pipe_settings(struct drm_crtc *crtc)
--

1.8.3.1

_______________________________________________
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

#195 lore raw

PATCH v9 66/89 drm/i915/skl: Implementation of SKL DPLL programming

In reply to Paulo Zanoni

From: Satheeshakrishna M <[email protected]>

This patch implements SKL DPLL programming that includes:
- DPLL allocation
- wide range PLL calculation and programming
- DP link rate programming
- DDI to DPLL mapping

v2: Incorporated following changes
- Added vfunc for function required outside
- Fixed multiple comments in WRPLL calculation

v3: - Fix the DCO computation
- Move the initialization up to not clobber the computed values
- Use the correct macro for DP link rate programming.
- Use wait_for() to wait for the PLL locked bit

v4: Rebase on top of nigthly (Damien)

v5: A few code cleanups in the WRPLL computation (Damien)
- Use uint32_t when possible
- Use abs_diff() in the WRPLL computation
- Make the 64bits divisions use div64_u64()
- Fix typo in dco_central_feq_deviation (freq)
- Replace the chain of breaks with a goto

v6: Port of the patch to work on top of the shared DPLLs (Damien)
v7: Don't try to handle eDP in ddi_pll_select() (Damien)
v8: Modified as per review comments from Paulo (Satheesh)
v9: Rebase on top of Ander's clock computation staging work for atomic (Damien)

---
 drivers/gpu/drm/i915/intel_ddi.c | 226 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 225 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +225 -1
index e8cdc1a..9e1f4b2 100644
@@ -954,6 +954,226 @@ hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
 	return true;
 }
 
+struct skl_wrpll_params {
+	uint32_t        dco_fraction;
+	uint32_t        dco_integer;
+	uint32_t        qdiv_ratio;
+	uint32_t        qdiv_mode;
+	uint32_t        kdiv;
+	uint32_t        pdiv;
+	uint32_t        central_freq;
+};
+
+static void
+skl_ddi_calculate_wrpll(int clock /* in Hz */,
+			struct skl_wrpll_params *wrpll_params)
+{
+	uint64_t afe_clock = clock * 5; /* AFE Clock is 5x Pixel clock */
+	uint64_t dco_central_freq[3] = {8400000000, 9000000000, 9600000000};
+	uint32_t min_dco_deviation = 400;
+	uint32_t min_dco_index = 3;
+	uint32_t P0[4] = {1, 2, 3, 7};
+	uint32_t P2[4] = {1, 2, 3, 5};
+	bool found = false;
+	uint32_t candidate_p = 0;
+	uint32_t candidate_p0[3] = {0}, candidate_p1[3] = {0};
+	uint32_t candidate_p2[3] = {0};
+	uint32_t dco_central_freq_deviation[3];
+	uint32_t i, P1, k, dco_count;
+	bool retry_with_odd = false;
+	uint64_t dco_freq;
+
+	/* Determine P0, P1 or P2 */
+	for (dco_count = 0; dco_count < 3; dco_count++) {
+		found = false;
+		candidate_p =
+			div64_u64(dco_central_freq[dco_count], afe_clock);
+		if (retry_with_odd == false)
+			candidate_p = (candidate_p % 2 == 0 ?
+				candidate_p : candidate_p + 1);
+
+		for (P1 = 1; P1 < candidate_p; P1++) {
+			for (i = 0; i < 4; i++) {
+				if (!(P0[i] != 1 || P1 == 1))
+					continue;
+
+				for (k = 0; k < 4; k++) {
+					if (P1 != 1 && P2[k] != 2)
+						continue;
+
+					if (candidate_p == P0[i] * P1 * P2[k]) {
+						/* Found possible P0, P1, P2 */
+						found = true;
+						candidate_p0[dco_count] = P0[i];
+						candidate_p1[dco_count] = P1;
+						candidate_p2[dco_count] = P2[k];
+						goto found;
+					}
+
+				}
+			}
+		}
+
+found:
+		if (found) {
+			dco_central_freq_deviation[dco_count] =
+				div64_u64(10000 *
+					  abs_diff((candidate_p * afe_clock),
+						   dco_central_freq[dco_count]),
+					  dco_central_freq[dco_count]);
+
+			if (dco_central_freq_deviation[dco_count] <
+				min_dco_deviation) {
+				min_dco_deviation =
+					dco_central_freq_deviation[dco_count];
+				min_dco_index = dco_count;
+			}
+		}
+
+		if (min_dco_index > 2 && dco_count == 2) {
+			retry_with_odd = true;
+			dco_count = 0;
+		}
+	}
+
+	if (min_dco_index > 2) {
+		WARN(1, "No valid values found for the given pixel clock\n");
+	} else {
+		 wrpll_params->central_freq = dco_central_freq[min_dco_index];
+
+		 switch (dco_central_freq[min_dco_index]) {
+		 case 9600000000:
+			wrpll_params->central_freq = 0;
+			break;
+		 case 9000000000:
+			wrpll_params->central_freq = 1;
+			break;
+		 case 8400000000:
+			wrpll_params->central_freq = 3;
+		 }
+
+		 switch (candidate_p0[min_dco_index]) {
+		 case 1:
+			wrpll_params->pdiv = 0;
+			break;
+		 case 2:
+			wrpll_params->pdiv = 1;
+			break;
+		 case 3:
+			wrpll_params->pdiv = 2;
+			break;
+		 case 7:
+			wrpll_params->pdiv = 4;
+			break;
+		 default:
+			WARN(1, "Incorrect PDiv\n");
+		 }
+
+		 switch (candidate_p2[min_dco_index]) {
+		 case 5:
+			wrpll_params->kdiv = 0;
+			break;
+		 case 2:
+			wrpll_params->kdiv = 1;
+			break;
+		 case 3:
+			wrpll_params->kdiv = 2;
+			break;
+		 case 1:
+			wrpll_params->kdiv = 3;
+			break;
+		 default:
+			WARN(1, "Incorrect KDiv\n");
+		 }
+
+		 wrpll_params->qdiv_ratio = candidate_p1[min_dco_index];
+		 wrpll_params->qdiv_mode =
+			(wrpll_params->qdiv_ratio == 1) ? 0 : 1;
+
+		 dco_freq = candidate_p0[min_dco_index] *
+			 candidate_p1[min_dco_index] *
+			 candidate_p2[min_dco_index] * afe_clock;
+
+		/*
+		* Intermediate values are in Hz.
+		* Divide by MHz to match bsepc
+		*/
+		 wrpll_params->dco_integer = div_u64(dco_freq, (24 * MHz(1)));
+		 wrpll_params->dco_fraction =
+			 div_u64(((div_u64(dco_freq, 24) -
+				   wrpll_params->dco_integer * MHz(1)) * 0x8000), MHz(1));
+
+	}
+}
+
+
+static bool
+skl_ddi_pll_select(struct intel_crtc *intel_crtc,
+		   struct intel_encoder *intel_encoder,
+		   int clock)
+{
+	struct intel_shared_dpll *pll;
+	uint32_t ctrl1, cfgcr1, cfgcr2;
+
+	/*
+	 * See comment in intel_dpll_hw_state to understand why we always use 0
+	 * as the DPLL id in this function.
+	 */
+
+	ctrl1 = DPLL_CTRL1_OVERRIDE(0);
+
+	if (intel_encoder->type == INTEL_OUTPUT_HDMI) {
+		struct skl_wrpll_params wrpll_params = { 0, };
+
+		ctrl1 |= DPLL_CTRL1_HDMI_MODE(0);
+
+		skl_ddi_calculate_wrpll(clock * 1000, &wrpll_params);
+
+		cfgcr1 = DPLL_CFGCR1_FREQ_ENABLE |
+			 DPLL_CFGCR1_DCO_FRACTION(wrpll_params.dco_fraction) |
+			 wrpll_params.dco_integer;
+
+		cfgcr2 = DPLL_CFGCR2_QDIV_RATIO(wrpll_params.qdiv_ratio) |
+			 DPLL_CFGCR2_QDIV_MODE(wrpll_params.qdiv_mode) |
+			 DPLL_CFGCR2_KDIV(wrpll_params.kdiv) |
+			 DPLL_CFGCR2_PDIV(wrpll_params.pdiv) |
+			 wrpll_params.central_freq;
+	} else if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) {
+		struct drm_encoder *encoder = &intel_encoder->base;
+		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+
+		switch (intel_dp->link_bw) {
+		case DP_LINK_BW_1_62:
+			ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_810, 0);
+			break;
+		case DP_LINK_BW_2_7:
+			ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_1350, 0);
+			break;
+		case DP_LINK_BW_5_4:
+			ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_2700, 0);
+			break;
+		}
+
+		cfgcr1 = cfgcr2 = 0;
+	} else /* eDP */
+		return true;
+
+	intel_crtc->new_config->dpll_hw_state.ctrl1 = ctrl1;
+	intel_crtc->new_config->dpll_hw_state.cfgcr1 = cfgcr1;
+	intel_crtc->new_config->dpll_hw_state.cfgcr2 = cfgcr2;
+
+	pll = intel_get_shared_dpll(intel_crtc);
+	if (pll == NULL) {
+		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
+				 pipe_name(intel_crtc->pipe));
+		return false;
+	}
+
+	/* shared DPLL id 0 is DPLL 1 */
+	intel_crtc->new_config->ddi_pll_sel = pll->id + 1;
+
+	return true;
+}
 
 /*
  * Tries to find a *shared* PLL for the CRTC and store it in
@@ -964,11 +1184,15 @@ hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
  */
 bool intel_ddi_pll_select(struct intel_crtc *intel_crtc)
 {
+	struct drm_device *dev = intel_crtc->base.dev;
 	struct intel_encoder *intel_encoder =
 		intel_ddi_get_crtc_new_encoder(intel_crtc);
 	int clock = intel_crtc->new_config->port_clock;
 
-	return hsw_ddi_pll_select(intel_crtc, intel_encoder, clock);
+	if (IS_SKYLAKE(dev))
+		return skl_ddi_pll_select(intel_crtc, intel_encoder, clock);
+	else
+		return hsw_ddi_pll_select(intel_crtc, intel_encoder, clock);
 }
 
 void intel_ddi_set_pipe_settings(struct drm_crtc *crtc)
Signature · 6 lines
1.8.3.1

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

Re: [PATCH 66/89 v9] drm/i915/skl: Implementation of SKL DPLL programming

Hi

With this and the other patches you resent, you can add "Reviewed-by:
Paulo Zanoni <[email protected]>" to patches 58, 59, 60, 61, 62 and 66. And I guess this makes the "clocks" part of the series complete and ready to merge.

That said, this patch has some weird comment syntax on the comment that contains "Intermediate values are in HZ". I guess Daniel can add the 2 missing white spaces when merging :)

The only 2 requested bikesheds that I really miss would be an inline function to replace GET_CFG_CRx_REG() (from patch 61) and adding explicit values to "enum skl_dpll" (requested in my review to patch 62). But if we decide to do this, it's probably better to just do this in separate patches: let's not block this series anymore due to bikeshedding :)

Thanks,
Paulo

2014-11-04 14:26 GMT-02:00 Damien Lespiau <[email protected]>:

Quoted 288 lines

From: Satheeshakrishna M <[email protected]>

This patch implements SKL DPLL programming that includes:
- DPLL allocation
- wide range PLL calculation and programming
- DP link rate programming
- DDI to DPLL mapping

v2: Incorporated following changes
- Added vfunc for function required outside
- Fixed multiple comments in WRPLL calculation

v3: - Fix the DCO computation
- Move the initialization up to not clobber the computed values
- Use the correct macro for DP link rate programming.
- Use wait_for() to wait for the PLL locked bit

v4: Rebase on top of nigthly (Damien)

v5: A few code cleanups in the WRPLL computation (Damien)
- Use uint32_t when possible
- Use abs_diff() in the WRPLL computation
- Make the 64bits divisions use div64_u64()
- Fix typo in dco_central_feq_deviation (freq)
- Replace the chain of breaks with a goto

v6: Port of the patch to work on top of the shared DPLLs (Damien)
v7: Don't try to handle eDP in ddi_pll_select() (Damien)
v8: Modified as per review comments from Paulo (Satheesh)
v9: Rebase on top of Ander's clock computation staging work for atomic (Damien)

---
 drivers/gpu/drm/i915/intel_ddi.c | 226 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 225 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +225 -2
index e8cdc1a..9e1f4b2 100644
@@ -954,6 +954,226 @@ hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
        return true;
 }
 
+struct skl_wrpll_params {
+       uint32_t        dco_fraction;
+       uint32_t        dco_integer;
+       uint32_t        qdiv_ratio;
+       uint32_t        qdiv_mode;
+       uint32_t        kdiv;
+       uint32_t        pdiv;
+       uint32_t        central_freq;
+};
+
+static void
+skl_ddi_calculate_wrpll(int clock /* in Hz */,
+                       struct skl_wrpll_params *wrpll_params)
+{
+       uint64_t afe_clock = clock * 5; /* AFE Clock is 5x Pixel clock */
+       uint64_t dco_central_freq[3] = {8400000000, 9000000000, 9600000000};
+       uint32_t min_dco_deviation = 400;
+       uint32_t min_dco_index = 3;
+       uint32_t P0[4] = {1, 2, 3, 7};
+       uint32_t P2[4] = {1, 2, 3, 5};
+       bool found = false;
+       uint32_t candidate_p = 0;
+       uint32_t candidate_p0[3] = {0}, candidate_p1[3] = {0};
+       uint32_t candidate_p2[3] = {0};
+       uint32_t dco_central_freq_deviation[3];
+       uint32_t i, P1, k, dco_count;
+       bool retry_with_odd = false;
+       uint64_t dco_freq;
+
+       /* Determine P0, P1 or P2 */
+       for (dco_count = 0; dco_count < 3; dco_count++) {
+               found = false;
+               candidate_p =
+                       div64_u64(dco_central_freq[dco_count], afe_clock);
+               if (retry_with_odd == false)
+                       candidate_p = (candidate_p % 2 == 0 ?
+                               candidate_p : candidate_p + 1);
+
+               for (P1 = 1; P1 < candidate_p; P1++) {
+                       for (i = 0; i < 4; i++) {
+                               if (!(P0[i] != 1 || P1 == 1))
+                                       continue;
+
+                               for (k = 0; k < 4; k++) {
+                                       if (P1 != 1 && P2[k] != 2)
+                                               continue;
+
+                                       if (candidate_p == P0[i] * P1 * P2[k]) {
+                                               /* Found possible P0, P1, P2 */
+                                               found = true;
+                                               candidate_p0[dco_count] = P0[i];
+                                               candidate_p1[dco_count] = P1;
+                                               candidate_p2[dco_count] = P2[k];
+                                               goto found;
+                                       }
+
+                               }
+                       }
+               }
+
+found:
+               if (found) {
+                       dco_central_freq_deviation[dco_count] =
+                               div64_u64(10000 *
+                                         abs_diff((candidate_p * afe_clock),
+                                                  dco_central_freq[dco_count]),
+                                         dco_central_freq[dco_count]);
+
+                       if (dco_central_freq_deviation[dco_count] <
+                               min_dco_deviation) {
+                               min_dco_deviation =
+                                       dco_central_freq_deviation[dco_count];
+                               min_dco_index = dco_count;
+                       }
+               }
+
+               if (min_dco_index > 2 && dco_count == 2) {
+                       retry_with_odd = true;
+                       dco_count = 0;
+               }
+       }
+
+       if (min_dco_index > 2) {
+               WARN(1, "No valid values found for the given pixel clock\n");
+       } else {
+                wrpll_params->central_freq = dco_central_freq[min_dco_index];
+
+                switch (dco_central_freq[min_dco_index]) {
+                case 9600000000:
+                       wrpll_params->central_freq = 0;
+                       break;
+                case 9000000000:
+                       wrpll_params->central_freq = 1;
+                       break;
+                case 8400000000:
+                       wrpll_params->central_freq = 3;
+                }
+
+                switch (candidate_p0[min_dco_index]) {
+                case 1:
+                       wrpll_params->pdiv = 0;
+                       break;
+                case 2:
+                       wrpll_params->pdiv = 1;
+                       break;
+                case 3:
+                       wrpll_params->pdiv = 2;
+                       break;
+                case 7:
+                       wrpll_params->pdiv = 4;
+                       break;
+                default:
+                       WARN(1, "Incorrect PDiv\n");
+                }
+
+                switch (candidate_p2[min_dco_index]) {
+                case 5:
+                       wrpll_params->kdiv = 0;
+                       break;
+                case 2:
+                       wrpll_params->kdiv = 1;
+                       break;
+                case 3:
+                       wrpll_params->kdiv = 2;
+                       break;
+                case 1:
+                       wrpll_params->kdiv = 3;
+                       break;
+                default:
+                       WARN(1, "Incorrect KDiv\n");
+                }
+
+                wrpll_params->qdiv_ratio = candidate_p1[min_dco_index];
+                wrpll_params->qdiv_mode =
+                       (wrpll_params->qdiv_ratio == 1) ? 0 : 1;
+
+                dco_freq = candidate_p0[min_dco_index] *
+                        candidate_p1[min_dco_index] *
+                        candidate_p2[min_dco_index] * afe_clock;
+
+               /*
+               * Intermediate values are in Hz.
+               * Divide by MHz to match bsepc
+               */
+                wrpll_params->dco_integer = div_u64(dco_freq, (24 * MHz(1)));
+                wrpll_params->dco_fraction =
+                        div_u64(((div_u64(dco_freq, 24) -
+                                  wrpll_params->dco_integer * MHz(1)) * 0x8000), MHz(1));
+
+       }
+}
+
+
+static bool
+skl_ddi_pll_select(struct intel_crtc *intel_crtc,
+                  struct intel_encoder *intel_encoder,
+                  int clock)
+{
+       struct intel_shared_dpll *pll;
+       uint32_t ctrl1, cfgcr1, cfgcr2;
+
+       /*
+        * See comment in intel_dpll_hw_state to understand why we always use 0
+        * as the DPLL id in this function.
+        */
+
+       ctrl1 = DPLL_CTRL1_OVERRIDE(0);
+
+       if (intel_encoder->type == INTEL_OUTPUT_HDMI) {
+               struct skl_wrpll_params wrpll_params = { 0, };
+
+               ctrl1 |= DPLL_CTRL1_HDMI_MODE(0);
+
+               skl_ddi_calculate_wrpll(clock * 1000, &wrpll_params);
+
+               cfgcr1 = DPLL_CFGCR1_FREQ_ENABLE |
+                        DPLL_CFGCR1_DCO_FRACTION(wrpll_params.dco_fraction) |
+                        wrpll_params.dco_integer;
+
+               cfgcr2 = DPLL_CFGCR2_QDIV_RATIO(wrpll_params.qdiv_ratio) |
+                        DPLL_CFGCR2_QDIV_MODE(wrpll_params.qdiv_mode) |
+                        DPLL_CFGCR2_KDIV(wrpll_params.kdiv) |
+                        DPLL_CFGCR2_PDIV(wrpll_params.pdiv) |
+                        wrpll_params.central_freq;
+       } else if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) {
+               struct drm_encoder *encoder = &intel_encoder->base;
+               struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+
+               switch (intel_dp->link_bw) {
+               case DP_LINK_BW_1_62:
+                       ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_810, 0);
+                       break;
+               case DP_LINK_BW_2_7:
+                       ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_1350, 0);
+                       break;
+               case DP_LINK_BW_5_4:
+                       ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_2700, 0);
+                       break;
+               }
+
+               cfgcr1 = cfgcr2 = 0;
+       } else /* eDP */
+               return true;
+
+       intel_crtc->new_config->dpll_hw_state.ctrl1 = ctrl1;
+       intel_crtc->new_config->dpll_hw_state.cfgcr1 = cfgcr1;
+       intel_crtc->new_config->dpll_hw_state.cfgcr2 = cfgcr2;
+
+       pll = intel_get_shared_dpll(intel_crtc);
+       if (pll == NULL) {
+               DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
+                                pipe_name(intel_crtc->pipe));
+               return false;
+       }
+
+       /* shared DPLL id 0 is DPLL 1 */
+       intel_crtc->new_config->ddi_pll_sel = pll->id + 1;
+
+       return true;
+}
 
 /*
  * Tries to find a *shared* PLL for the CRTC and store it in
@@ -964,11 +1184,15 @@ hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
  */
 bool intel_ddi_pll_select(struct intel_crtc *intel_crtc)
 {
+       struct drm_device *dev = intel_crtc->base.dev;
        struct intel_encoder *intel_encoder =
                intel_ddi_get_crtc_new_encoder(intel_crtc);
        int clock = intel_crtc->new_config->port_clock;
 
-       return hsw_ddi_pll_select(intel_crtc, intel_encoder, clock);
+       if (IS_SKYLAKE(dev))
+               return skl_ddi_pll_select(intel_crtc, intel_encoder, clock);
+       else
+               return hsw_ddi_pll_select(intel_crtc, intel_encoder, clock);
 }
 
 void intel_ddi_set_pipe_settings(struct drm_crtc *crtc)
--

1.8.3.1

Signature · 5 lines
Paulo Zanoni
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#197 lore raw

Re: [PATCH 66/89] drm/i915/skl: Implementation of SKL DPLL programming

In reply to Damien Lespiau

Hi,

Quoted 28 lines · Damien Lespiau

From: Satheeshakrishna M <[email protected]>

This patch implements SKL DPLL programming that includes:
- DPLL allocation
- wide range PLL calculation and programming
- DP link rate programming
- DDI to DPLL mapping

v2: Incorporated following changes
- Added vfunc for function required outside
- Fixed multiple comments in WRPLL calculation

v3: - Fix the DCO computation
- Move the initialization up to not clobber the computed values
- Use the correct macro for DP link rate programming.
- Use wait_for() to wait for the PLL locked bit

v4: Rebase on top of nigthly (Damien)

v5: A few code cleanups in the WRPLL computation (Damien)
- Use uint32_t when possible
- Use abs_diff() in the WRPLL computation
- Make the 64bits divisions use div64_u64()
- Fix typo in dco_central_feq_deviation (freq)
- Replace the chain of breaks with a goto

v6: Port of the patch to work on top of the shared DPLLs (Damien)
v7: Don't try to handle eDP in ddi_pll_select() (Damien)

[snip]

Quoted 44 lines
drivers/gpu/drm/i915/intel_ddi.c +44 -0
+static bool
+skl_ddi_pll_select(struct intel_crtc *intel_crtc,
+		   struct intel_encoder *intel_encoder,
+		   int clock)
+{
+	struct intel_shared_dpll *pll;
+	uint32_t ctrl1, cfgcr1, cfgcr2;
+
+	/*
+	 * See comment in intel_dpll_hw_state to understand why we always use 0
+	 * as the DPLL id in this function.
+	 */
+
+	ctrl1 = DPLL_CTRL1_OVERRIDE(0);
+
+	if (intel_encoder->type == INTEL_OUTPUT_HDMI) {
+		struct skl_wrpll_params wrpll_params = { 0, };
+
+		ctrl1 |= DPLL_CTRL1_HDMI_MODE(0);
+
+		skl_ddi_calculate_wrpll(clock * 1000, &wrpll_params);
+
+		cfgcr1 = DPLL_CFGCR1_FREQ_ENABLE |
+			 DPLL_CFGCR1_DCO_FRACTION(wrpll_params.dco_fraction) |
+			 wrpll_params.dco_integer;
+
+		cfgcr2 = DPLL_CFGCR2_QDIV_RATIO(wrpll_params.qdiv_ratio) |
+			 DPLL_CFGCR2_QDIV_MODE(wrpll_params.qdiv_mode) |
+			 DPLL_CFGCR2_KDIV(wrpll_params.kdiv) |
+			 DPLL_CFGCR2_PDIV(wrpll_params.pdiv) |
+			 wrpll_params.central_freq;
+	} else if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) {
+		struct drm_encoder *encoder = &intel_encoder->base;
+		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+
+		switch (intel_dp->link_bw) {
+		case DP_LINK_BW_1_62:
+			ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_810, 0);
+			break;
+		case DP_LINK_BW_2_7:
+			ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_1350, 0);
+			break;
+		case DP_LINK_BW_5_4:
+			ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_2700, 0);

drivers/gpu/drm/i915/intel_ddi.c hsw_ddi_pll_select(struct intel_crtc *intel_crtc,

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +9 -0
+			break;
+		}
+
+		cfgcr1 = cfgcr2 = 0;
+	} else /* eDP */
+		return true;
 
+	intel_crtc->config.dpll_hw_state.ctrl1 = ctrl1;
+	intel_crtc->config.dpll_hw_state.cfgcr1 = cfgcr1;
+	intel_crtc->config.dpll_hw_state.cfgcr2 = cfgcr2;

The return before updating the dpll_hw_state in the eDP case interacts with:

commit 4978cc93d9ac240b435ce60431aef24239b4c270

Author: Ander Conselvan de Oliveira <[email protected]>
Date:   Tue Apr 21 17:13:21 2015 +0300

drm/i915: Preserve shared DPLL information in new pipe_config

And results with a bunch of:

[drm:check_crtc_state [i915]] *ERROR* mismatch in dpll_hw_state.ctrl1 (expected 0x00000000, found 0x00000001)

On boot and afterwards.

Not sure what is the fix so maybe someone knows?

Regards,

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

#198 lore raw

Re: [PATCH 66/89] drm/i915/skl: Implementation of SKL DPLL programming

Quoted 2 lines · Tvrtko Ursulin

Hi,

Hi Tvrtko,

Quoted 63 lines
Quoted 44 lines
drivers/gpu/drm/i915/intel_ddi.c +44 -0
+static bool
+skl_ddi_pll_select(struct intel_crtc *intel_crtc,
+		   struct intel_encoder *intel_encoder,
+		   int clock)
+{
+	struct intel_shared_dpll *pll;
+	uint32_t ctrl1, cfgcr1, cfgcr2;
+
+	/*
+	 * See comment in intel_dpll_hw_state to understand why we always use 0
+	 * as the DPLL id in this function.
+	 */
+
+	ctrl1 = DPLL_CTRL1_OVERRIDE(0);
+
+	if (intel_encoder->type == INTEL_OUTPUT_HDMI) {
+		struct skl_wrpll_params wrpll_params = { 0, };
+
+		ctrl1 |= DPLL_CTRL1_HDMI_MODE(0);
+
+		skl_ddi_calculate_wrpll(clock * 1000, &wrpll_params);
+
+		cfgcr1 = DPLL_CFGCR1_FREQ_ENABLE |
+			 DPLL_CFGCR1_DCO_FRACTION(wrpll_params.dco_fraction) |
+			 wrpll_params.dco_integer;
+
+		cfgcr2 = DPLL_CFGCR2_QDIV_RATIO(wrpll_params.qdiv_ratio) |
+			 DPLL_CFGCR2_QDIV_MODE(wrpll_params.qdiv_mode) |
+			 DPLL_CFGCR2_KDIV(wrpll_params.kdiv) |
+			 DPLL_CFGCR2_PDIV(wrpll_params.pdiv) |
+			 wrpll_params.central_freq;
+	} else if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) {
+		struct drm_encoder *encoder = &intel_encoder->base;
+		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+
+		switch (intel_dp->link_bw) {
+		case DP_LINK_BW_1_62:
+			ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_810, 0);
+			break;
+		case DP_LINK_BW_2_7:
+			ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_1350, 0);
+			break;
+		case DP_LINK_BW_5_4:
+			ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_2700, 0);

drivers/gpu/drm/i915/intel_ddi.c hsw_ddi_pll_select(struct intel_crtc *intel_crtc,

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +9 -0
+			break;
+		}
+
+		cfgcr1 = cfgcr2 = 0;
+	} else /* eDP */
+		return true;
 
+	intel_crtc->config.dpll_hw_state.ctrl1 = ctrl1;
+	intel_crtc->config.dpll_hw_state.cfgcr1 = cfgcr1;
+	intel_crtc->config.dpll_hw_state.cfgcr2 = cfgcr2;

The return before updating the dpll_hw_state in the eDP case interacts with:

commit 4978cc93d9ac240b435ce60431aef24239b4c270

Author: Ander Conselvan de Oliveira <[email protected]>
Date:   Tue Apr 21 17:13:21 2015 +0300

drm/i915: Preserve shared DPLL information in new pipe_config

Quoted 8 lines

And results with a bunch of:

[drm:check_crtc_state [i915]] *ERROR* mismatch in dpll_hw_state.ctrl1 (expected 0x00000000, found 0x00000001)

On boot and afterwards.

Not sure what is the fix so maybe someone knows?

I, since then, added the hint:

/*
* Tries to find a *shared* PLL for the CRTC and store it in
* intel_crtc->ddi_pll_sel.
*
* For private DPLLs, compute_config() should do the selection for us. This
* function should be folded into compute_config() eventually. */

The mess is because of the shared vs private PLLs. For eDP skl_edp_set_pll_config() in intel_dp.c should take care of computing the state.

Signature · 5 lines
Damien
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#199 lore raw

PATCH 67/89 drm/i915/skl: Provide skl-specific pll hw state cross-checking

In reply to Damien Lespiau

v2: rebase on top of the hw state flattening.

---
 drivers/gpu/drm/i915/intel_display.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/intel_display.c +3 -0
index 6e71250..0a4dd00 100644
@@ -10775,6 +10775,9 @@ intel_pipe_config_compare(struct drm_device *dev,
 	PIPE_CONF_CHECK_X(dpll_hw_state.fp0);
 	PIPE_CONF_CHECK_X(dpll_hw_state.fp1);
 	PIPE_CONF_CHECK_X(dpll_hw_state.wrpll);
+	PIPE_CONF_CHECK_X(dpll_hw_state.ctrl1);
+	PIPE_CONF_CHECK_X(dpll_hw_state.cfgcr1);
+	PIPE_CONF_CHECK_X(dpll_hw_state.cfgcr2);
 
 	if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5)
 		PIPE_CONF_CHECK_I(pipe_bpp);
Signature · 1 line
1.8.3.1
Reviewed-by on v1 67/89
#200 lore raw

Re: [PATCH 67/89] drm/i915/skl: Provide skl-specific pll hw state cross-checking

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 1 line

v2: rebase on top of the hw state flattening.

Quoted 27 lines
---
 drivers/gpu/drm/i915/intel_display.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/intel_display.c +3 -1
index 6e71250..0a4dd00 100644
@@ -10775,6 +10775,9 @@ intel_pipe_config_compare(struct drm_device *dev,
        PIPE_CONF_CHECK_X(dpll_hw_state.fp0);
        PIPE_CONF_CHECK_X(dpll_hw_state.fp1);
        PIPE_CONF_CHECK_X(dpll_hw_state.wrpll);
+       PIPE_CONF_CHECK_X(dpll_hw_state.ctrl1);
+       PIPE_CONF_CHECK_X(dpll_hw_state.cfgcr1);
+       PIPE_CONF_CHECK_X(dpll_hw_state.cfgcr2);
 
        if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5)
                PIPE_CONF_CHECK_I(pipe_bpp);
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#201 lore raw

PATCH 68/89 drm/i915/skl: Apply eDP WA only for gen < 9

In reply to Damien Lespiau

From: Vandana Kannan <[email protected]>

The eDP WA to stop link train based on port type is for HSW/BDW, not required for SKL+.
Suggested by Satheesh

v2: Simplified the check befoe stop_link_train. Suggested by Satheesh.

v3: stop_link_train need not be called from intel_enable_ddi for gen >= 9

---
 drivers/gpu/drm/i915/intel_ddi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +2 -2
index f68e04c..2561b40 100644
@@ -1491,7 +1491,7 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
 		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
 		intel_dp_start_link_train(intel_dp);
 		intel_dp_complete_link_train(intel_dp);
-		if (port != PORT_A)
+		if (port != PORT_A || INTEL_INFO(dev)->gen >= 9)
 			intel_dp_stop_link_train(intel_dp);
 	} else if (type == INTEL_OUTPUT_HDMI) {
 		struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
@@ -1567,7 +1567,7 @@ static void intel_enable_ddi(struct intel_encoder *intel_encoder)
 	} else if (type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
-		if (port == PORT_A)
+		if (port == PORT_A && INTEL_INFO(dev)->gen < 9)
 			intel_dp_stop_link_train(intel_dp);
 
 		intel_edp_backlight_on(intel_dp);
Signature · 1 line
1.8.3.1
Reviewed-by on v1 68/89
#202 lore raw

Re: [PATCH 68/89] drm/i915/skl: Apply eDP WA only for gen < 9

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 9 lines

From: Vandana Kannan <[email protected]>

The eDP WA to stop link train based on port type is for HSW/BDW, not required for SKL+.
Suggested by Satheesh

v2: Simplified the check befoe stop_link_train. Suggested by Satheesh.

v3: stop_link_train need not be called from intel_enable_ddi for gen >= 9

Quoted 39 lines
---
 drivers/gpu/drm/i915/intel_ddi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +2 -3
index f68e04c..2561b40 100644
@@ -1491,7 +1491,7 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
                intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
                intel_dp_start_link_train(intel_dp);
                intel_dp_complete_link_train(intel_dp);
-               if (port != PORT_A)
+               if (port != PORT_A || INTEL_INFO(dev)->gen >= 9)
                        intel_dp_stop_link_train(intel_dp);
        } else if (type == INTEL_OUTPUT_HDMI) {
                struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
@@ -1567,7 +1567,7 @@ static void intel_enable_ddi(struct intel_encoder *intel_encoder)
        } else if (type == INTEL_OUTPUT_EDP) {
                struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
-               if (port == PORT_A)
+               if (port == PORT_A && INTEL_INFO(dev)->gen < 9)
                        intel_dp_stop_link_train(intel_dp);
 
                intel_edp_backlight_on(intel_dp);
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#203 lore raw

PATCH 69/89 drm/i915/skl: Adding power domains for AUX controllers

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

Adding new power doamins for AUX controllers

v2: Added new power domains in power_domain_str per Imre's comment

v3: Added AUX power domains to older platforms

v4: Rebase on top of POWER_DOMAIN_PLLS.

---
 drivers/gpu/drm/i915/i915_debugfs.c |  8 ++++++++
 drivers/gpu/drm/i915/i915_drv.h     |  4 ++++
 drivers/gpu/drm/i915/intel_pm.c     | 12 ++++++++++++
 3 files changed, 24 insertions(+)
drivers/gpu/drm/i915/i915_debugfs.c +8 -0
index 88a4643..02cb310 100644
@@ -2273,6 +2273,14 @@ static const char *power_domain_str(enum intel_display_power_domain domain)
 		return "AUDIO";
 	case POWER_DOMAIN_PLLS:
 		return "PLLS";
+	case POWER_DOMAIN_AUX_A:
+		return "AUX_A";
+	case POWER_DOMAIN_AUX_B:
+		return "AUX_B";
+	case POWER_DOMAIN_AUX_C:
+		return "AUX_C";
+	case POWER_DOMAIN_AUX_D:
+		return "AUX_D";
 	case POWER_DOMAIN_INIT:
 		return "INIT";
 	default:
drivers/gpu/drm/i915/i915_drv.h +4 -0
index a6e14db..91ea2b7 100644
@@ -138,6 +138,10 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_VGA,
 	POWER_DOMAIN_AUDIO,
 	POWER_DOMAIN_PLLS,
+	POWER_DOMAIN_AUX_A,
+	POWER_DOMAIN_AUX_B,
+	POWER_DOMAIN_AUX_C,
+	POWER_DOMAIN_AUX_D,
 	POWER_DOMAIN_INIT,
 
 	POWER_DOMAIN_NUM,
drivers/gpu/drm/i915/intel_pm.c +12 -0
index 74a8519..ec849db 100644
@@ -7664,6 +7664,10 @@ EXPORT_SYMBOL_GPL(i915_get_cdclk_freq);
 	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |		\
 	BIT(POWER_DOMAIN_PORT_CRT) |			\
 	BIT(POWER_DOMAIN_PLLS) |			\
+	BIT(POWER_DOMAIN_AUX_A) |			\
+	BIT(POWER_DOMAIN_AUX_B) |			\
+	BIT(POWER_DOMAIN_AUX_C) |			\
+	BIT(POWER_DOMAIN_AUX_D) |			\
 	BIT(POWER_DOMAIN_INIT))
 #define HSW_DISPLAY_POWER_DOMAINS (				\
 	(POWER_DOMAIN_MASK & ~HSW_ALWAYS_ON_POWER_DOMAINS) |	\
@@ -7685,24 +7689,32 @@ EXPORT_SYMBOL_GPL(i915_get_cdclk_freq);
 	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_CRT) |		\
+	BIT(POWER_DOMAIN_AUX_A) |		\
+	BIT(POWER_DOMAIN_AUX_B) |		\
+	BIT(POWER_DOMAIN_AUX_C) |		\
+	BIT(POWER_DOMAIN_AUX_D) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define VLV_DPIO_TX_B_LANES_01_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_B) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define VLV_DPIO_TX_B_LANES_23_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_B) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define VLV_DPIO_TX_C_LANES_01_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_C) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_C) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define CHV_PIPE_A_POWER_DOMAINS (	\
Signature · 1 line
1.8.3.1
Reviewed-by on v1 69/89
#204 lore raw

Re: [PATCH 69/89] drm/i915/skl: Adding power domains for AUX controllers

Quoted 6 lines · Damien Lespiau

From: Satheeshakrishna M <[email protected]>

Adding new power doamins for AUX controllers

v2: Added new power domains in power_domain_str per Imre's comment

Quoted 8 lines

v3: Added AUX power domains to older platforms

v4: Rebase on top of POWER_DOMAIN_PLLS.

---

This needs to be rebased on the recent CHV changes, adding the AUX domains to the CMN and TX wells similarly to the VLV mappings. With that this looks ok:

Quoted 77 lines
 drivers/gpu/drm/i915/i915_debugfs.c |  8 ++++++++
 drivers/gpu/drm/i915/i915_drv.h     |  4 ++++
 drivers/gpu/drm/i915/intel_pm.c     | 12 ++++++++++++
 3 files changed, 24 insertions(+)
drivers/gpu/drm/i915/i915_debugfs.c +8 -0
index 88a4643..02cb310 100644
@@ -2273,6 +2273,14 @@ static const char *power_domain_str(enum intel_display_power_domain domain)
 		return "AUDIO";
 	case POWER_DOMAIN_PLLS:
 		return "PLLS";
+	case POWER_DOMAIN_AUX_A:
+		return "AUX_A";
+	case POWER_DOMAIN_AUX_B:
+		return "AUX_B";
+	case POWER_DOMAIN_AUX_C:
+		return "AUX_C";
+	case POWER_DOMAIN_AUX_D:
+		return "AUX_D";
 	case POWER_DOMAIN_INIT:
 		return "INIT";
 	default:
drivers/gpu/drm/i915/i915_drv.h +4 -0
index a6e14db..91ea2b7 100644
@@ -138,6 +138,10 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_VGA,
 	POWER_DOMAIN_AUDIO,
 	POWER_DOMAIN_PLLS,
+	POWER_DOMAIN_AUX_A,
+	POWER_DOMAIN_AUX_B,
+	POWER_DOMAIN_AUX_C,
+	POWER_DOMAIN_AUX_D,
 	POWER_DOMAIN_INIT,
 
 	POWER_DOMAIN_NUM,
drivers/gpu/drm/i915/intel_pm.c +10 -0
index 74a8519..ec849db 100644
@@ -7664,6 +7664,10 @@ EXPORT_SYMBOL_GPL(i915_get_cdclk_freq);
 	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |		\
 	BIT(POWER_DOMAIN_PORT_CRT) |			\
 	BIT(POWER_DOMAIN_PLLS) |			\
+	BIT(POWER_DOMAIN_AUX_A) |			\
+	BIT(POWER_DOMAIN_AUX_B) |			\
+	BIT(POWER_DOMAIN_AUX_C) |			\
+	BIT(POWER_DOMAIN_AUX_D) |			\
 	BIT(POWER_DOMAIN_INIT))
 #define HSW_DISPLAY_POWER_DOMAINS (				\
 	(POWER_DOMAIN_MASK & ~HSW_ALWAYS_ON_POWER_DOMAINS) |	\
@@ -7685,24 +7689,32 @@ EXPORT_SYMBOL_GPL(i915_get_cdclk_freq);
 	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_CRT) |		\
+	BIT(POWER_DOMAIN_AUX_A) |		\
+	BIT(POWER_DOMAIN_AUX_B) |		\
+	BIT(POWER_DOMAIN_AUX_C) |		\
+	BIT(POWER_DOMAIN_AUX_D) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define VLV_DPIO_TX_B_LANES_01_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_B) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define VLV_DPIO_TX_B_LANES_23_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_B) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define VLV_DPIO_TX_C_LANES_01_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |	\

drivers/gpu/drm/i915/intel_pm.c EXPORT_SYMBOL_GPL(i915_get_cdclk_freq); · line 7720

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
 	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_C) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_C) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define CHV_PIPE_A_POWER_DOMAINS (	\

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

#205 lore raw

Re: [PATCH 69/89] drm/i915/skl: Adding power domains for AUX controllers

Hi Imre,

I actually had some question there as well:

Quoted 9 lines · Imre Deak

drivers/gpu/drm/i915/intel_pm.c EXPORT_SYMBOL_GPL(i915_get_cdclk_freq); · line 7696

Quoted 9 lines
drivers/gpu/drm/i915/intel_pm.c +4 -0
@@ -7685,24 +7689,32 @@ EXPORT_SYMBOL_GPL(i915_get_cdclk_freq);
 	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_CRT) |		\
+	BIT(POWER_DOMAIN_AUX_A) |		\
+	BIT(POWER_DOMAIN_AUX_B) |		\
+	BIT(POWER_DOMAIN_AUX_C) |		\
+	BIT(POWER_DOMAIN_AUX_D) |		\
 	BIT(POWER_DOMAIN_INIT))

That's the VLV_DPIO_CMN_BC_POWER_DOMAINS, shouldn't we move AUX_A out of this define?

Where does the port A lanes/aux should be on VLV and CHV, I don't see a good fit nor where the POWER_DOMAIN_PORT_DDI_A_X_LANES is today

Quoted 10 lines

drivers/gpu/drm/i915/intel_pm.c EXPORT_SYMBOL_GPL(i915_get_cdclk_freq); · line 7707

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
 #define VLV_DPIO_TX_B_LANES_01_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_B) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define VLV_DPIO_TX_B_LANES_23_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_B) |		\
 	BIT(POWER_DOMAIN_INIT))

Wouldn't it better to leave the AUX domain in the LANES_01 power domain, otherwise we'll power up the full 4 lanes for aux transactions?

Thanks,

Signature · 1 line
Damien
#206 lore raw

Re: [PATCH 69/89] drm/i915/skl: Adding power domains for AUX controllers

Quoted 5 lines · Damien Lespiau

Hi Imre,

I actually had some question there as well:

On Tue, Sep 16, 2014 at 03:35:15PM +0300, Imre Deak wrote:

Quoted 12 lines
Quoted 9 lines

drivers/gpu/drm/i915/intel_pm.c EXPORT_SYMBOL_GPL(i915_get_cdclk_freq); · line 7696

Quoted 9 lines
drivers/gpu/drm/i915/intel_pm.c +4 -0
@@ -7685,24 +7689,32 @@ EXPORT_SYMBOL_GPL(i915_get_cdclk_freq);
 	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_CRT) |		\
+	BIT(POWER_DOMAIN_AUX_A) |		\
+	BIT(POWER_DOMAIN_AUX_B) |		\
+	BIT(POWER_DOMAIN_AUX_C) |		\
+	BIT(POWER_DOMAIN_AUX_D) |		\
 	BIT(POWER_DOMAIN_INIT))

That's the VLV_DPIO_CMN_BC_POWER_DOMAINS, shouldn't we move AUX_A out of this define?

Yes I haven't noticed this. Port A and D don't exist on VLV so we don't need to add them here. It wouldn't be a problem to add them, since we never ask for these domains on VLV, but I agree that it's confusing to add them here.

Quoted 2 lines

Where does the port A lanes/aux should be on VLV and CHV, I don't see a good fit nor where the POWER_DOMAIN_PORT_DDI_A_X_LANES is today

POWER_DOMAIN_PORT_DDI_A_X_LANES and POWER_DOMAIN_PORT_DDI_D_X_LANES is part of VLV_DISPLAY_POWER_DOMAINS, but again they are only a place holder there. The display power well is needed for all domains, so I defined the mapping simply accordingly.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
 #define VLV_DPIO_TX_B_LANES_01_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_B) |		\
 	BIT(POWER_DOMAIN_INIT))
 
Quoted 7 lines
Quoted 4 lines

drivers/gpu/drm/i915/intel_pm.c EXPORT_SYMBOL_GPL(i915_get_cdclk_freq); · line 7707

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
 #define VLV_DPIO_TX_B_LANES_23_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_B) |		\
 	BIT(POWER_DOMAIN_INIT))

Wouldn't it better to leave the AUX domain in the LANES_01 power domain, otherwise we'll power up the full 4 lanes for aux transactions?

With this patch I thought that we'd keep things as-is for all platforms except SKL. I imagined that we'd get only the AUX power domains for AUX functionality (in patch 72/89) and not take the port power domains for full port functionality. That would provide the extra power saving on SKL and would keep the other platforms unchanged.

You are right that we probably don't need the TX power wells for AUX functionality on VLV, but I haven't checked this yet, so this would need to be done separately as a follow-up.

--Imre

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

#207 lore raw

Re: [PATCH 69/89] drm/i915/skl: Adding power domains for AUX controllers

Quoted 22 lines · Imre Deak
Quoted 6 lines · Damien Lespiau
Quoted 6 lines
Quoted 6 lines

#define VLV_DPIO_TX_B_LANES_01_POWER_DOMAINS ( \

drivers/gpu/drm/i915/intel_pm.c +1 -0
 	BIT(POWER_DOMAIN_PORT_DDI_B_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_B) |		\
 	BIT(POWER_DOMAIN_INIT))
Quoted 7 lines
Quoted 4 lines

drivers/gpu/drm/i915/intel_pm.c EXPORT_SYMBOL_GPL(i915_get_cdclk_freq); · line 7702

Quoted 4 lines

#define VLV_DPIO_TX_B_LANES_23_POWER_DOMAINS ( \

drivers/gpu/drm/i915/intel_pm.c +1 -0
 	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_B) |		\
 	BIT(POWER_DOMAIN_INIT))

Wouldn't it better to leave the AUX domain in the LANES_01 power domain, otherwise we'll power up the full 4 lanes for aux transactions?

With this patch I thought that we'd keep things as-is for all platforms except SKL. I imagined that we'd get only the AUX power domains for AUX functionality (in patch 72/89) and not take the port power domains for full port functionality. That would provide the extra power saving on SKL and would keep the other platforms unchanged.

Quoted 3 lines

You are right that we probably don't need the TX power wells for AUX functionality on VLV, but I haven't checked this yet, so this would need to be done separately as a follow-up.

And we always have the nasty CMN vs. TX ordering issue on VLV. So unless someone adds the logic to bring the wells down and back up again when we need to power up TX wells when CMN is already up, we just have to keep TX wells powered whenever CMN is powered.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#208 lore raw

PATCH v5 69/89 drm/i915/skl: Adding power domains for AUX controllers

In reply to Imre Deak

From: Satheeshakrishna M <[email protected]>

Adding new power doamins for AUX controllers

v2: Added new power domains in power_domain_str per Imre's comment

v3: Added AUX power domains to older platforms

v4: Rebase on top of POWER_DOMAIN_PLLS.

v5: Modified to address review comments from Imre

---
 drivers/gpu/drm/i915/i915_debugfs.c     |  8 ++++++++
 drivers/gpu/drm/i915/i915_drv.h         |  4 ++++
 drivers/gpu/drm/i915/intel_runtime_pm.c | 15 +++++++++++++++
 3 files changed, 27 insertions(+)
drivers/gpu/drm/i915/i915_debugfs.c +8 -0
index 319da61..5b0f324 100644
@@ -2290,6 +2290,14 @@ static const char *power_domain_str(enum intel_display_power_domain domain)
 		return "AUDIO";
 	case POWER_DOMAIN_PLLS:
 		return "PLLS";
+	case POWER_DOMAIN_AUX_A:
+		return "AUX_A";
+	case POWER_DOMAIN_AUX_B:
+		return "AUX_B";
+	case POWER_DOMAIN_AUX_C:
+		return "AUX_C";
+	case POWER_DOMAIN_AUX_D:
+		return "AUX_D";
 	case POWER_DOMAIN_INIT:
 		return "INIT";
 	default:
drivers/gpu/drm/i915/i915_drv.h +4 -0
index 6fdca4b..a4c776a 100644
@@ -143,6 +143,10 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_VGA,
 	POWER_DOMAIN_AUDIO,
 	POWER_DOMAIN_PLLS,
+	POWER_DOMAIN_AUX_A,
+	POWER_DOMAIN_AUX_B,
+	POWER_DOMAIN_AUX_C,
+	POWER_DOMAIN_AUX_D,
 	POWER_DOMAIN_INIT,
 
 	POWER_DOMAIN_NUM,
drivers/gpu/drm/i915/intel_runtime_pm.c +15 -0
index dcbecff..e059cae 100644
@@ -710,6 +710,10 @@ void intel_display_power_put(struct drm_i915_private *dev_priv,
 	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |		\
 	BIT(POWER_DOMAIN_PORT_CRT) |			\
 	BIT(POWER_DOMAIN_PLLS) |			\
+	BIT(POWER_DOMAIN_AUX_A) |			\
+	BIT(POWER_DOMAIN_AUX_B) |			\
+	BIT(POWER_DOMAIN_AUX_C) |			\
+	BIT(POWER_DOMAIN_AUX_D) |			\
 	BIT(POWER_DOMAIN_INIT))
 #define HSW_DISPLAY_POWER_DOMAINS (				\
 	(POWER_DOMAIN_MASK & ~HSW_ALWAYS_ON_POWER_DOMAINS) |	\
@@ -731,24 +735,30 @@ void intel_display_power_put(struct drm_i915_private *dev_priv,
 	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_CRT) |		\
+	BIT(POWER_DOMAIN_AUX_B) |		\
+	BIT(POWER_DOMAIN_AUX_C) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define VLV_DPIO_TX_B_LANES_01_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_B) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define VLV_DPIO_TX_B_LANES_23_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_B) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define VLV_DPIO_TX_C_LANES_01_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_C) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_C) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define CHV_PIPE_A_POWER_DOMAINS (	\
@@ -768,20 +778,25 @@ void intel_display_power_put(struct drm_i915_private *dev_priv,
 	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_B) |		\
+	BIT(POWER_DOMAIN_AUX_C) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define CHV_DPIO_CMN_D_POWER_DOMAINS (		\
 	BIT(POWER_DOMAIN_PORT_DDI_D_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_D) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define CHV_DPIO_TX_D_LANES_01_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_D_2_LANES) |	\
 	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_D) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 #define CHV_DPIO_TX_D_LANES_23_POWER_DOMAINS (	\
 	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |	\
+	BIT(POWER_DOMAIN_AUX_D) |		\
 	BIT(POWER_DOMAIN_INIT))
 
 static const struct i915_power_well_ops i9xx_always_on_power_well_ops = {
Signature · 6 lines
1.8.3.1

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

PATCH 70/89 drm/i915/skl: Register definition for SKL power well

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

Defining new bit fields for SKL display power wells.

v2: Clean up unused macros

---
 drivers/gpu/drm/i915/i915_reg.h | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +7 -0
index 794d0ba..4d072a8 100644
@@ -6133,6 +6133,13 @@ enum punit_power_well {
 #define   HSW_PWR_WELL_FORCE_ON			(1<<19)
 #define HSW_PWR_WELL_CTL6			0x45414
 
+/* SKL Fuse Status */
+#define SKL_FUSE_STATUS				0x42000
+#define  SKL_FUSE_DOWNLOAD_STATUS              (1<<31)
+#define  SKL_FUSE_PG0_DIST_STATUS              (1<<27)
+#define  SKL_FUSE_PG1_DIST_STATUS              (1<<26)
+#define  SKL_FUSE_PG2_DIST_STATUS              (1<<25)
+
 /* Per-pipe DDI Function Control */
 #define TRANS_DDI_FUNC_CTL_A		0x60400
 #define TRANS_DDI_FUNC_CTL_B		0x61400
Signature · 1 line
1.8.3.1
Reviewed-by on v1 70/89
#210 lore raw

Re: [PATCH 70/89] drm/i915/skl: Register definition for SKL power well

Quoted 8 lines · Damien Lespiau

From: Satheeshakrishna M <[email protected]>

Defining new bit fields for SKL display power wells.

v2: Clean up unused macros

This looks ok, but it should be squashed into 71/89, where it's first used. Either way:

Quoted 12 lines
---
 drivers/gpu/drm/i915/i915_reg.h | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +0 -0
index 794d0ba..4d072a8 100644
@@ -6133,6 +6133,13 @@ enum punit_power_well {
 #define   HSW_PWR_WELL_FORCE_ON			(1<<19)
 #define HSW_PWR_WELL_CTL6			0x45414
 

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 6145

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +7 -0
+/* SKL Fuse Status */
+#define SKL_FUSE_STATUS				0x42000
+#define  SKL_FUSE_DOWNLOAD_STATUS              (1<<31)
+#define  SKL_FUSE_PG0_DIST_STATUS              (1<<27)
+#define  SKL_FUSE_PG1_DIST_STATUS              (1<<26)
+#define  SKL_FUSE_PG2_DIST_STATUS              (1<<25)
+
 /* Per-pipe DDI Function Control */
 #define TRANS_DDI_FUNC_CTL_A		0x60400
 #define TRANS_DDI_FUNC_CTL_B		0x61400

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

#211 lore raw

PATCH 71/89 drm/i915/skl: Implementation of SKL display power well support

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

This patch implements core logic of SKL display power well.

FIXME: hsw_pwr needs to go. The audio guys promised us that they'll do a proper implementation for skl+.

v2: Addressed Imre's comments
- Added respective DDIs under power well #1 and #2
- Simplified repetitive code in power well programming

v3: Implemented Imre's comments
- Further simplified power well programming
- Made sure that PW 1 is enabled prior to PW 2

v4: Fix minor conflict with the the cherryview support (Damien)

v5: Add the PLL power domain to the always on power well (Damien)

v6: Disable BIOS power well (Imre)
Use power well data for comparison (Imre)
Put the PLL power domain into PW1 as its needed for CDCLK (Satheesh, Damien)

---
 drivers/gpu/drm/i915/i915_reg.h |  13 +++
 drivers/gpu/drm/i915/intel_pm.c | 207 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 220 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +13 -0
index 4d072a8..84a0de6 100644
@@ -541,6 +541,19 @@ enum punit_power_well {
 	PUNIT_POWER_WELL_NUM,
 };
 
+enum skl_disp_power_wells {
+	SKL_DISP_PW_MISC_IO,
+	SKL_DISP_PW_DDI_A_E,
+	SKL_DISP_PW_DDI_B,
+	SKL_DISP_PW_DDI_C,
+	SKL_DISP_PW_DDI_D,
+	SKL_DISP_PW_1 = 14,
+	SKL_DISP_PW_2,
+};
+
+#define SKL_POWER_WELL_STATE(pw) (1 << (pw * 2))
+#define SKL_POWER_WELL_REQ(pw) (1 << ((pw * 2) + 1))
+
 #define PUNIT_REG_PWRGT_CTRL			0x60
 #define PUNIT_REG_PWRGT_STATUS			0x61
 #define   PUNIT_PWRGT_MASK(power_well)		(3 << ((power_well) * 2))
drivers/gpu/drm/i915/intel_pm.c +207 -0

237 lines not on this page · raw message

Signature · 1 line
1.8.3.1
Reviewed-by on v1 71/89
#212 lore raw

Re: [PATCH 71/89] drm/i915/skl: Implementation of SKL display power well support

Quoted 120 lines · Damien Lespiau

From: Satheeshakrishna M <[email protected]>

This patch implements core logic of SKL display power well.

FIXME: hsw_pwr needs to go. The audio guys promised us that they'll do a proper implementation for skl+.

v2: Addressed Imre's comments
- Added respective DDIs under power well #1 and #2
- Simplified repetitive code in power well programming

v3: Implemented Imre's comments
- Further simplified power well programming
- Made sure that PW 1 is enabled prior to PW 2

v4: Fix minor conflict with the the cherryview support (Damien)

v5: Add the PLL power domain to the always on power well (Damien)

v6: Disable BIOS power well (Imre)
Use power well data for comparison (Imre)
Put the PLL power domain into PW1 as its needed for CDCLK (Satheesh, Damien)

---
 drivers/gpu/drm/i915/i915_reg.h |  13 +++
 drivers/gpu/drm/i915/intel_pm.c | 207 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 220 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +13 -0
index 4d072a8..84a0de6 100644
@@ -541,6 +541,19 @@ enum punit_power_well {
 	PUNIT_POWER_WELL_NUM,
 };
 
+enum skl_disp_power_wells {
+	SKL_DISP_PW_MISC_IO,
+	SKL_DISP_PW_DDI_A_E,
+	SKL_DISP_PW_DDI_B,
+	SKL_DISP_PW_DDI_C,
+	SKL_DISP_PW_DDI_D,
+	SKL_DISP_PW_1 = 14,
+	SKL_DISP_PW_2,
+};
+
+#define SKL_POWER_WELL_STATE(pw) (1 << (pw * 2))
+#define SKL_POWER_WELL_REQ(pw) (1 << ((pw * 2) + 1))
+
 #define PUNIT_REG_PWRGT_CTRL			0x60
 #define PUNIT_REG_PWRGT_STATUS			0x61
 #define   PUNIT_PWRGT_MASK(power_well)		(3 << ((power_well) * 2))
drivers/gpu/drm/i915/intel_pm.c +57 -0
index ec849db..853b596 100644
@@ -7160,6 +7160,128 @@ static void hsw_set_power_well(struct drm_i915_private *dev_priv,
 	}
 }
 
+#define SKL_DISPLAY_POWERWELL_2_POWER_DOMAINS (                 \
+	BIT(POWER_DOMAIN_PIPE_B) |                      \
+	BIT(POWER_DOMAIN_TRANSCODER_B) |                \
+	BIT(POWER_DOMAIN_PIPE_C) |                      \
+	BIT(POWER_DOMAIN_TRANSCODER_C) |                \
+	BIT(POWER_DOMAIN_PIPE_B_PANEL_FITTER) |         \
+	BIT(POWER_DOMAIN_PIPE_C_PANEL_FITTER) |         \
+	BIT(POWER_DOMAIN_PORT_DDI_B_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_D_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |          \
+	BIT(POWER_DOMAIN_AUX_B) |                       \
+	BIT(POWER_DOMAIN_AUX_C) |                       \
+	BIT(POWER_DOMAIN_AUX_D) |                       \
+	BIT(POWER_DOMAIN_AUDIO) |                       \
+	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_POWERWELL_1_POWER_DOMAINS (         \
+	SKL_DISPLAY_POWERWELL_2_POWER_DOMAINS |         \
+	BIT(POWER_DOMAIN_PLLS) |			\
+	BIT(POWER_DOMAIN_PIPE_A) |                      \
+	BIT(POWER_DOMAIN_TRANSCODER_EDP) |              \
+	BIT(POWER_DOMAIN_PIPE_A_PANEL_FITTER) | \
+	BIT(POWER_DOMAIN_PORT_DDI_A_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_A_4_LANES) |          \
+	BIT(POWER_DOMAIN_AUX_A) |                       \
+	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_DDI_A_E_POWER_DOMAINS (                     \
+	BIT(POWER_DOMAIN_PORT_DDI_A_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_A_4_LANES) |          \
+	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_DDI_B_POWER_DOMAINS (                       \
+	BIT(POWER_DOMAIN_PORT_DDI_B_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |          \
+	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_DDI_C_POWER_DOMAINS (                       \
+	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |          \
+	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_DDI_D_POWER_DOMAINS (                       \
+	BIT(POWER_DOMAIN_PORT_DDI_D_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |          \
+	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_ALWAYS_ON_POWER_DOMAINS (           \
+	(POWER_DOMAIN_MASK & ~(SKL_DISPLAY_POWERWELL_1_POWER_DOMAINS |  \
+	SKL_DISPLAY_POWERWELL_2_POWER_DOMAINS |         \
+	SKL_DISPLAY_DDI_A_E_POWER_DOMAINS |             \
+	SKL_DISPLAY_DDI_B_POWER_DOMAINS |               \
+	SKL_DISPLAY_DDI_C_POWER_DOMAINS |               \
+	SKL_DISPLAY_DDI_D_POWER_DOMAINS)) |             \
+	BIT(POWER_DOMAIN_INIT))
+
+static void skl_set_power_well(struct drm_i915_private *dev_priv,
+			struct i915_power_well *power_well, bool enable)
+{
+	uint32_t tmp, fuse_status;

drivers/gpu/drm/i915/intel_pm.c static void hsw_set_power_well(struct drm_i915_private *dev_priv, · line 7229

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+	uint32_t req_mask, state_mask;
+	bool check_fuse_status = false;
+
+	tmp = I915_READ(HSW_PWR_WELL_DRIVER);
+	fuse_status = I915_READ(SKL_FUSE_STATUS);
+
+	switch (power_well->data) {
+	case SKL_DISP_PW_1:
+		if (wait_for((I915_READ(SKL_FUSE_STATUS) &
+			SKL_FUSE_PG0_DIST_STATUS), 5)) {

The spec says 5 us not 5 ms, so we could just wait for 1 ms. The same applies to similar places below.

Quoted 6 lines
drivers/gpu/drm/i915/intel_pm.c +6 -0
+			DRM_ERROR("PG0 not enabled\n");
+			return;
+		}
+		break;
+	case SKL_DISP_PW_2:
+		if (!(fuse_status & SKL_FUSE_PG1_DIST_STATUS)) {

drivers/gpu/drm/i915/intel_pm.c static void hsw_set_power_well(struct drm_i915_private *dev_priv, · line 7245

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+			DRM_ERROR("PG1 in disabled state\n");
+			return;
+		}
+		break;
+	case SKL_DISP_PW_DDI_A_E:
+	case SKL_DISP_PW_DDI_B:
+	case SKL_DISP_PW_DDI_C:
+	case SKL_DISP_PW_DDI_D:
+		break;
+	default:

This would be a driver bug, so it needs a WARN().

drivers/gpu/drm/i915/intel_pm.c static void hsw_set_power_well(struct drm_i915_private *dev_priv, · line 7257

Quoted 12 lines
drivers/gpu/drm/i915/intel_pm.c +12 -0
+		return;
+	}
+
+	req_mask = SKL_POWER_WELL_REQ(power_well->data);
+	state_mask = SKL_POWER_WELL_STATE(power_well->data);
+
+	if (enable) {
+		if (!(tmp & req_mask))
+			I915_WRITE(HSW_PWR_WELL_DRIVER, tmp | req_mask);
+
+		if (!(tmp & state_mask)) {
+			DRM_DEBUG_KMS("Enabling DDI power well\n");

Could be just "Enabling %s", power_well->name. Also we could miss the message depending on timing, so it needs to go above where the request bit is set.

With the above changes, this looks ok:

Quoted 134 lines
drivers/gpu/drm/i915/intel_pm.c +109 -0
+			if (wait_for((I915_READ(HSW_PWR_WELL_DRIVER) &
+				state_mask), 20))
+				DRM_ERROR("%s enable timeout\n",
+					power_well->name);
+			check_fuse_status = true;
+		}
+	} else {
+		if (tmp & req_mask) {
+			I915_WRITE(HSW_PWR_WELL_DRIVER,	tmp & ~req_mask);
+			POSTING_READ(HSW_PWR_WELL_DRIVER);
+			DRM_DEBUG_KMS("Disabling %s\n", power_well->name);
+		}
+	}
+
+	if (check_fuse_status) {
+		if (power_well->data == SKL_DISP_PW_1) {
+			if (wait_for((I915_READ(SKL_FUSE_STATUS) &
+				SKL_FUSE_PG1_DIST_STATUS), 5))
+				DRM_ERROR("PG1 distributing status timeout\n");
+		} else if (power_well->data == SKL_DISP_PW_2) {
+			if (wait_for((I915_READ(SKL_FUSE_STATUS) &
+				SKL_FUSE_PG2_DIST_STATUS), 1))
+				DRM_ERROR("PG2 distributing status timeout\n");
+		}
+	}
+}
+
 static void hsw_power_well_sync_hw(struct drm_i915_private *dev_priv,
 				   struct i915_power_well *power_well)
 {
@@ -7185,6 +7307,36 @@ static void hsw_power_well_disable(struct drm_i915_private *dev_priv,
 	hsw_set_power_well(dev_priv, power_well, false);
 }
 
+static bool skl_power_well_enabled(struct drm_i915_private *dev_priv,
+					struct i915_power_well *power_well)
+{
+	uint32_t mask = SKL_POWER_WELL_REQ(power_well->data) |
+		SKL_POWER_WELL_STATE(power_well->data);
+
+	return (I915_READ(HSW_PWR_WELL_DRIVER) & mask) == mask;
+}
+
+static void skl_power_well_sync_hw(struct drm_i915_private *dev_priv,
+				struct i915_power_well *power_well)
+{
+	skl_set_power_well(dev_priv, power_well, power_well->count > 0);
+
+	/* Clear any request made by BIOS as driver is taking over */
+	I915_WRITE(HSW_PWR_WELL_BIOS, 0);
+}
+
+static void skl_power_well_enable(struct drm_i915_private *dev_priv,
+				struct i915_power_well *power_well)
+{
+	skl_set_power_well(dev_priv, power_well, true);
+}
+
+static void skl_power_well_disable(struct drm_i915_private *dev_priv,
+				struct i915_power_well *power_well)
+{
+	skl_set_power_well(dev_priv, power_well, false);
+}
+
 static void i9xx_always_on_power_well_noop(struct drm_i915_private *dev_priv,
 					   struct i915_power_well *power_well)
 {
@@ -7787,6 +7939,13 @@ static const struct i915_power_well_ops hsw_power_well_ops = {
 	.is_enabled = hsw_power_well_enabled,
 };
 
+static const struct i915_power_well_ops skl_power_well_ops = {
+	.sync_hw = skl_power_well_sync_hw,
+	.enable = skl_power_well_enable,
+	.disable = skl_power_well_disable,
+	.is_enabled = skl_power_well_enabled,
+};
+
 static struct i915_power_well hsw_power_wells[] = {
 	{
 		.name = "always-on",
@@ -8009,6 +8168,51 @@ static struct i915_power_well *lookup_power_well(struct drm_i915_private *dev_pr
 	return NULL;
 }
 
+static struct i915_power_well skl_power_wells[] = {
+	{
+		.name = "always-on",
+		.always_on = 1,
+		.domains = SKL_DISPLAY_ALWAYS_ON_POWER_DOMAINS,
+		.ops = &i9xx_always_on_power_well_ops,
+	},
+	{
+		.name = "power well 1",
+		.domains = SKL_DISPLAY_POWERWELL_1_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_1,
+	},
+	{
+		.name = "power well 2",
+		.domains = SKL_DISPLAY_POWERWELL_2_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_2,
+	},
+	{
+		.name = "DDI A/E power well",
+		.domains = SKL_DISPLAY_DDI_A_E_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_DDI_A_E,
+	},
+	{
+		.name = "DDI B power well",
+		.domains = SKL_DISPLAY_DDI_B_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_DDI_B,
+	},
+	{
+		.name = "DDI C power well",
+		.domains = SKL_DISPLAY_DDI_C_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_DDI_C,
+	},
+	{
+		.name = "DDI D power well",
+		.domains = SKL_DISPLAY_DDI_D_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_DDI_D,
+	},
+};
+
 #define set_power_wells(power_domains, __power_wells) ({		\
 	(power_domains)->power_wells = (__power_wells);			\
 	(power_domains)->power_well_count = ARRAY_SIZE(__power_wells);	\

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

Quoted 9 lines
drivers/gpu/drm/i915/intel_pm.c +3 -0
@@ -8030,6 +8234,9 @@ int intel_power_domains_init(struct drm_i915_private *dev_priv)
 	} else if (IS_BROADWELL(dev_priv->dev)) {
 		set_power_wells(power_domains, bdw_power_wells);
 		hsw_pwr = power_domains;
+	} else if (IS_SKYLAKE(dev_priv->dev)) {
+		set_power_wells(power_domains, skl_power_wells);
+		hsw_pwr = power_domains;
 	} else if (IS_CHERRYVIEW(dev_priv->dev)) {
 		set_power_wells(power_domains, chv_power_wells);
 	} else if (IS_VALLEYVIEW(dev_priv->dev)) {

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

#213 lore raw

Re: [PATCH 71/89] drm/i915/skl: Implementation of SKL display power well support

Quoted 40 lines · Imre Deak
Quoted 39 lines · Damien Lespiau

From: Satheeshakrishna M <[email protected]>

This patch implements core logic of SKL display power well.

FIXME: hsw_pwr needs to go. The audio guys promised us that they'll do a proper implementation for skl+.

v2: Addressed Imre's comments
- Added respective DDIs under power well #1 and #2
- Simplified repetitive code in power well programming

v3: Implemented Imre's comments
- Further simplified power well programming
- Made sure that PW 1 is enabled prior to PW 2

v4: Fix minor conflict with the the cherryview support (Damien)

v5: Add the PLL power domain to the always on power well (Damien)

v6: Disable BIOS power well (Imre)
Use power well data for comparison (Imre)
Put the PLL power domain into PW1 as its needed for CDCLK (Satheesh, Damien)

---
 drivers/gpu/drm/i915/i915_reg.h |  13 +++
 drivers/gpu/drm/i915/intel_pm.c | 207 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 220 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +0 -0
index 4d072a8..84a0de6 100644
@@ -541,6 +541,19 @@ enum punit_power_well {
 	PUNIT_POWER_WELL_NUM,
 };
 
Quoted 12 lines

drivers/gpu/drm/i915/i915_reg.h enum punit_power_well { · line 555

Quoted 12 lines
drivers/gpu/drm/i915/i915_reg.h +12 -0
+enum skl_disp_power_wells {
+	SKL_DISP_PW_MISC_IO,
+	SKL_DISP_PW_DDI_A_E,
+	SKL_DISP_PW_DDI_B,
+	SKL_DISP_PW_DDI_C,
+	SKL_DISP_PW_DDI_D,
+	SKL_DISP_PW_1 = 14,
+	SKL_DISP_PW_2,
+};
+
+#define SKL_POWER_WELL_STATE(pw) (1 << (pw * 2))
+#define SKL_POWER_WELL_REQ(pw) (1 << ((pw * 2) + 1))

Missed this one: missing parentheses for pw.

Quoted 262 lines
Quoted 69 lines
drivers/gpu/drm/i915/i915_reg.h +1 -0
+
 #define PUNIT_REG_PWRGT_CTRL			0x60
 #define PUNIT_REG_PWRGT_STATUS			0x61
 #define   PUNIT_PWRGT_MASK(power_well)		(3 << ((power_well) * 2))
drivers/gpu/drm/i915/intel_pm.c +57 -0
index ec849db..853b596 100644
@@ -7160,6 +7160,128 @@ static void hsw_set_power_well(struct drm_i915_private *dev_priv,
 	}
 }
 
+#define SKL_DISPLAY_POWERWELL_2_POWER_DOMAINS (                 \
+	BIT(POWER_DOMAIN_PIPE_B) |                      \
+	BIT(POWER_DOMAIN_TRANSCODER_B) |                \
+	BIT(POWER_DOMAIN_PIPE_C) |                      \
+	BIT(POWER_DOMAIN_TRANSCODER_C) |                \
+	BIT(POWER_DOMAIN_PIPE_B_PANEL_FITTER) |         \
+	BIT(POWER_DOMAIN_PIPE_C_PANEL_FITTER) |         \
+	BIT(POWER_DOMAIN_PORT_DDI_B_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_D_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |          \
+	BIT(POWER_DOMAIN_AUX_B) |                       \
+	BIT(POWER_DOMAIN_AUX_C) |                       \
+	BIT(POWER_DOMAIN_AUX_D) |                       \
+	BIT(POWER_DOMAIN_AUDIO) |                       \
+	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_POWERWELL_1_POWER_DOMAINS (         \
+	SKL_DISPLAY_POWERWELL_2_POWER_DOMAINS |         \
+	BIT(POWER_DOMAIN_PLLS) |			\
+	BIT(POWER_DOMAIN_PIPE_A) |                      \
+	BIT(POWER_DOMAIN_TRANSCODER_EDP) |              \
+	BIT(POWER_DOMAIN_PIPE_A_PANEL_FITTER) | \
+	BIT(POWER_DOMAIN_PORT_DDI_A_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_A_4_LANES) |          \
+	BIT(POWER_DOMAIN_AUX_A) |                       \
+	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_DDI_A_E_POWER_DOMAINS (                     \
+	BIT(POWER_DOMAIN_PORT_DDI_A_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_A_4_LANES) |          \
+	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_DDI_B_POWER_DOMAINS (                       \
+	BIT(POWER_DOMAIN_PORT_DDI_B_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |          \
+	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_DDI_C_POWER_DOMAINS (                       \
+	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |          \
+	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_DDI_D_POWER_DOMAINS (                       \
+	BIT(POWER_DOMAIN_PORT_DDI_D_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |          \
+	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_ALWAYS_ON_POWER_DOMAINS (           \
+	(POWER_DOMAIN_MASK & ~(SKL_DISPLAY_POWERWELL_1_POWER_DOMAINS |  \
+	SKL_DISPLAY_POWERWELL_2_POWER_DOMAINS |         \
+	SKL_DISPLAY_DDI_A_E_POWER_DOMAINS |             \
+	SKL_DISPLAY_DDI_B_POWER_DOMAINS |               \
+	SKL_DISPLAY_DDI_C_POWER_DOMAINS |               \
+	SKL_DISPLAY_DDI_D_POWER_DOMAINS)) |             \
+	BIT(POWER_DOMAIN_INIT))
+
+static void skl_set_power_well(struct drm_i915_private *dev_priv,
+			struct i915_power_well *power_well, bool enable)
+{
+	uint32_t tmp, fuse_status;

drivers/gpu/drm/i915/intel_pm.c static void hsw_set_power_well(struct drm_i915_private *dev_priv, · line 7229

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+	uint32_t req_mask, state_mask;
+	bool check_fuse_status = false;
+
+	tmp = I915_READ(HSW_PWR_WELL_DRIVER);
+	fuse_status = I915_READ(SKL_FUSE_STATUS);
+
+	switch (power_well->data) {
+	case SKL_DISP_PW_1:
+		if (wait_for((I915_READ(SKL_FUSE_STATUS) &
+			SKL_FUSE_PG0_DIST_STATUS), 5)) {

The spec says 5 us not 5 ms, so we could just wait for 1 ms. The same applies to similar places below.

Quoted 6 lines
drivers/gpu/drm/i915/intel_pm.c +6 -0
+			DRM_ERROR("PG0 not enabled\n");
+			return;
+		}
+		break;
+	case SKL_DISP_PW_2:
+		if (!(fuse_status & SKL_FUSE_PG1_DIST_STATUS)) {

drivers/gpu/drm/i915/intel_pm.c static void hsw_set_power_well(struct drm_i915_private *dev_priv, · line 7245

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+			DRM_ERROR("PG1 in disabled state\n");
+			return;
+		}
+		break;
+	case SKL_DISP_PW_DDI_A_E:
+	case SKL_DISP_PW_DDI_B:
+	case SKL_DISP_PW_DDI_C:
+	case SKL_DISP_PW_DDI_D:
+		break;
+	default:

This would be a driver bug, so it needs a WARN().

drivers/gpu/drm/i915/intel_pm.c static void hsw_set_power_well(struct drm_i915_private *dev_priv, · line 7257

Quoted 12 lines
drivers/gpu/drm/i915/intel_pm.c +12 -0
+		return;
+	}
+
+	req_mask = SKL_POWER_WELL_REQ(power_well->data);
+	state_mask = SKL_POWER_WELL_STATE(power_well->data);
+
+	if (enable) {
+		if (!(tmp & req_mask))
+			I915_WRITE(HSW_PWR_WELL_DRIVER, tmp | req_mask);
+
+		if (!(tmp & state_mask)) {
+			DRM_DEBUG_KMS("Enabling DDI power well\n");

Could be just "Enabling %s", power_well->name. Also we could miss the message depending on timing, so it needs to go above where the request bit is set.

With the above changes, this looks ok:

Quoted 140 lines
drivers/gpu/drm/i915/intel_pm.c +112 -0
+			if (wait_for((I915_READ(HSW_PWR_WELL_DRIVER) &
+				state_mask), 20))
+				DRM_ERROR("%s enable timeout\n",
+					power_well->name);
+			check_fuse_status = true;
+		}
+	} else {
+		if (tmp & req_mask) {
+			I915_WRITE(HSW_PWR_WELL_DRIVER,	tmp & ~req_mask);
+			POSTING_READ(HSW_PWR_WELL_DRIVER);
+			DRM_DEBUG_KMS("Disabling %s\n", power_well->name);
+		}
+	}
+
+	if (check_fuse_status) {
+		if (power_well->data == SKL_DISP_PW_1) {
+			if (wait_for((I915_READ(SKL_FUSE_STATUS) &
+				SKL_FUSE_PG1_DIST_STATUS), 5))
+				DRM_ERROR("PG1 distributing status timeout\n");
+		} else if (power_well->data == SKL_DISP_PW_2) {
+			if (wait_for((I915_READ(SKL_FUSE_STATUS) &
+				SKL_FUSE_PG2_DIST_STATUS), 1))
+				DRM_ERROR("PG2 distributing status timeout\n");
+		}
+	}
+}
+
 static void hsw_power_well_sync_hw(struct drm_i915_private *dev_priv,
 				   struct i915_power_well *power_well)
 {
@@ -7185,6 +7307,36 @@ static void hsw_power_well_disable(struct drm_i915_private *dev_priv,
 	hsw_set_power_well(dev_priv, power_well, false);
 }
 
+static bool skl_power_well_enabled(struct drm_i915_private *dev_priv,
+					struct i915_power_well *power_well)
+{
+	uint32_t mask = SKL_POWER_WELL_REQ(power_well->data) |
+		SKL_POWER_WELL_STATE(power_well->data);
+
+	return (I915_READ(HSW_PWR_WELL_DRIVER) & mask) == mask;
+}
+
+static void skl_power_well_sync_hw(struct drm_i915_private *dev_priv,
+				struct i915_power_well *power_well)
+{
+	skl_set_power_well(dev_priv, power_well, power_well->count > 0);
+
+	/* Clear any request made by BIOS as driver is taking over */
+	I915_WRITE(HSW_PWR_WELL_BIOS, 0);
+}
+
+static void skl_power_well_enable(struct drm_i915_private *dev_priv,
+				struct i915_power_well *power_well)
+{
+	skl_set_power_well(dev_priv, power_well, true);
+}
+
+static void skl_power_well_disable(struct drm_i915_private *dev_priv,
+				struct i915_power_well *power_well)
+{
+	skl_set_power_well(dev_priv, power_well, false);
+}
+
 static void i9xx_always_on_power_well_noop(struct drm_i915_private *dev_priv,
 					   struct i915_power_well *power_well)
 {
@@ -7787,6 +7939,13 @@ static const struct i915_power_well_ops hsw_power_well_ops = {
 	.is_enabled = hsw_power_well_enabled,
 };
 
+static const struct i915_power_well_ops skl_power_well_ops = {
+	.sync_hw = skl_power_well_sync_hw,
+	.enable = skl_power_well_enable,
+	.disable = skl_power_well_disable,
+	.is_enabled = skl_power_well_enabled,
+};
+
 static struct i915_power_well hsw_power_wells[] = {
 	{
 		.name = "always-on",
@@ -8009,6 +8168,51 @@ static struct i915_power_well *lookup_power_well(struct drm_i915_private *dev_pr
 	return NULL;
 }
 
+static struct i915_power_well skl_power_wells[] = {
+	{
+		.name = "always-on",
+		.always_on = 1,
+		.domains = SKL_DISPLAY_ALWAYS_ON_POWER_DOMAINS,
+		.ops = &i9xx_always_on_power_well_ops,
+	},
+	{
+		.name = "power well 1",
+		.domains = SKL_DISPLAY_POWERWELL_1_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_1,
+	},
+	{
+		.name = "power well 2",
+		.domains = SKL_DISPLAY_POWERWELL_2_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_2,
+	},
+	{
+		.name = "DDI A/E power well",
+		.domains = SKL_DISPLAY_DDI_A_E_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_DDI_A_E,
+	},
+	{
+		.name = "DDI B power well",
+		.domains = SKL_DISPLAY_DDI_B_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_DDI_B,
+	},
+	{
+		.name = "DDI C power well",
+		.domains = SKL_DISPLAY_DDI_C_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_DDI_C,
+	},
+	{
+		.name = "DDI D power well",
+		.domains = SKL_DISPLAY_DDI_D_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_DDI_D,
+	},
+};
+
 #define set_power_wells(power_domains, __power_wells) ({		\
 	(power_domains)->power_wells = (__power_wells);			\
 	(power_domains)->power_well_count = ARRAY_SIZE(__power_wells);	\
@@ -8030,6 +8234,9 @@ int intel_power_domains_init(struct drm_i915_private *dev_priv)
 	} else if (IS_BROADWELL(dev_priv->dev)) {
 		set_power_wells(power_domains, bdw_power_wells);
 		hsw_pwr = power_domains;
+	} else if (IS_SKYLAKE(dev_priv->dev)) {
+		set_power_wells(power_domains, skl_power_wells);
+		hsw_pwr = power_domains;
Quoted 8 lines

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

Quoted 3 lines
drivers/gpu/drm/i915/intel_pm.c +0 -0
 	} else if (IS_CHERRYVIEW(dev_priv->dev)) {
 		set_power_wells(power_domains, chv_power_wells);
 	} else if (IS_VALLEYVIEW(dev_priv->dev)) {

_______________________________________________
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

#214 lore raw

PATCH 72/89 drm/i915/skl: Enable/disable power well for aux transaction

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

This patch enables power well 2 required for any aux transaction.

v2: Implemented Imre's comments
- In EDID/DPCD related routines, request AUX power well in SKL

v3: Implemented Imre's comments
- Call AUX power well domain unconditionally for all platforms

v4: Remove the check on the output type for the AUX power domain

v5: Rebase on top of drm-intel-nightly (Damien)

v6: Rebase on top of -nightly (minor conflict in intel_drv.h) (Damien)

v7: Remove platform check while getting power well for port (Imre)

v8: Fix aux power handling around Vdd on/off (Damien)

v9: Acquire aux power domain on enabling vdd in
intel_edp_panel_vdd_sanitize() (Satheesh)

v10: Rebase on top of Ville's patch to return early in this function intead of
having a big indented block. (Damien)

v12: Rebase on top of Chris EDID caching work (Damien)

---
 drivers/gpu/drm/i915/intel_display.c | 21 ++++++++++++
 drivers/gpu/drm/i915/intel_dp.c      | 62 ++++++++++++++++++++++++++----------
 drivers/gpu/drm/i915/intel_drv.h     |  2 ++
 3 files changed, 68 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/intel_display.c +21 -0
index 0a4dd00..abd4201 100644
@@ -4503,6 +4503,27 @@ intel_display_port_power_domain(struct intel_encoder *intel_encoder)
 	}
 }
 
+enum intel_display_power_domain
+intel_display_aux_power_domain(struct intel_encoder *intel_encoder)
+{
+	struct intel_digital_port *intel_dig_port;
+
+	intel_dig_port = enc_to_dig_port(&intel_encoder->base);
+	switch (intel_dig_port->port) {
+	case PORT_A:
+		return POWER_DOMAIN_AUX_A;
+	case PORT_B:
+		return POWER_DOMAIN_AUX_B;
+	case PORT_C:
+		return POWER_DOMAIN_AUX_C;
+	case PORT_D:
+		return POWER_DOMAIN_AUX_D;
+	default:
+		WARN_ON_ONCE(1);
+		return 0;
+	}
+}
+
 static unsigned long get_crtc_power_domains(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
drivers/gpu/drm/i915/intel_dp.c +45 -17

151 lines not on this page · raw message

drivers/gpu/drm/i915/intel_drv.h +2 -0
index 9558f07..a407d04 100644
@@ -916,6 +916,8 @@ void hsw_disable_ips(struct intel_crtc *crtc);
 void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
 enum intel_display_power_domain
 intel_display_port_power_domain(struct intel_encoder *intel_encoder);
+enum intel_display_power_domain
+intel_display_aux_power_domain(struct intel_encoder *intel_encoder);
 void intel_mode_from_pipe_config(struct drm_display_mode *mode,
 				 struct intel_crtc_config *pipe_config);
 int intel_format_to_fourcc(int format);
Signature · 1 line
1.8.3.1
#215 lore raw

Re: [PATCH 72/89] drm/i915/skl: Enable/disable power well for aux transaction

Quoted 23 lines · Damien Lespiau

From: Satheeshakrishna M <[email protected]>

This patch enables power well 2 required for any aux transaction.

v2: Implemented Imre's comments
- In EDID/DPCD related routines, request AUX power well in SKL

v3: Implemented Imre's comments
- Call AUX power well domain unconditionally for all platforms

v4: Remove the check on the output type for the AUX power domain

v5: Rebase on top of drm-intel-nightly (Damien)

v6: Rebase on top of -nightly (minor conflict in intel_drv.h) (Damien)

v7: Remove platform check while getting power well for port (Imre)

v8: Fix aux power handling around Vdd on/off (Damien)

v9: Acquire aux power domain on enabling vdd in
intel_edp_panel_vdd_sanitize() (Satheesh)

Quoted 7 lines

v10: Rebase on top of Ville's patch to return early in this function intead of
having a big indented block. (Damien)

v12: Rebase on top of Chris EDID caching work (Damien)

This patch needs to be rebased on the recent PPS changes at least getting/putting the AUX power domain in pps_lock()/pps_unlock() too. Also it should be squashed into 69/89. Some more comments below.

Quoted 43 lines
---
 drivers/gpu/drm/i915/intel_display.c | 21 ++++++++++++
 drivers/gpu/drm/i915/intel_dp.c      | 62 ++++++++++++++++++++++++++----------
 drivers/gpu/drm/i915/intel_drv.h     |  2 ++
 3 files changed, 68 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/intel_display.c +21 -0
index 0a4dd00..abd4201 100644
@@ -4503,6 +4503,27 @@ intel_display_port_power_domain(struct intel_encoder *intel_encoder)
 	}
 }
 
+enum intel_display_power_domain
+intel_display_aux_power_domain(struct intel_encoder *intel_encoder)
+{
+	struct intel_digital_port *intel_dig_port;
+
+	intel_dig_port = enc_to_dig_port(&intel_encoder->base);
+	switch (intel_dig_port->port) {
+	case PORT_A:
+		return POWER_DOMAIN_AUX_A;
+	case PORT_B:
+		return POWER_DOMAIN_AUX_B;
+	case PORT_C:
+		return POWER_DOMAIN_AUX_C;
+	case PORT_D:
+		return POWER_DOMAIN_AUX_D;
+	default:
+		WARN_ON_ONCE(1);
+		return 0;
+	}
+}
+
 static unsigned long get_crtc_power_domains(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
drivers/gpu/drm/i915/intel_dp.c +0 -0
index 93bd9bf..a983b40 100644

drivers/gpu/drm/i915/intel_dp.c static bool edp_panel_vdd_on(struct intel_dp *intel_dp) · line 1238

Quoted 6 lines
drivers/gpu/drm/i915/intel_dp.c +3 -0
@@ -1233,6 +1233,9 @@ static bool edp_panel_vdd_on(struct intel_dp *intel_dp)
 	power_domain = intel_display_port_power_domain(intel_encoder);
 	intel_display_power_get(dev_priv, power_domain);
 
+	power_domain = intel_display_aux_power_domain(intel_encoder);
+	intel_display_power_get(dev_priv, power_domain);
+

The AUX power domains were added to save power when only AUX functionality is needed, since then we don't need to power on the power domain needed for full port functionality. With the above change and everywhere else below we'll end up enabling both power domains, though we only need AUX functionality.

The power wells needed for AUX are a subset of those needed for full port functionality on all platforms (at least atm), so this patch won't change anything. The patch would make sense, if you requested only the AUX domains.

drivers/gpu/drm/i915/intel_dp.c static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp) · line 1318

Quoted 11 lines
drivers/gpu/drm/i915/intel_dp.c +3 -0
 	DRM_DEBUG_KMS("Turning eDP VDD on\n");
 
 	if (!edp_have_panel_power(intel_dp))
@@ -1309,8 +1312,12 @@ static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp)
 
 	power_domain = intel_display_port_power_domain(intel_encoder);
 	intel_display_power_put(dev_priv, power_domain);
+
+	power_domain = intel_display_aux_power_domain(intel_encoder);
+	intel_display_power_put(dev_priv, power_domain);
 }

intel_edp_panel_off() needs to be changed too accordingly.

drivers/gpu/drm/i915/intel_dp.c static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp) · line 1319

Quoted 2 lines
drivers/gpu/drm/i915/intel_dp.c +1 -0
+

Extra w/s.

Quoted 18 lines
drivers/gpu/drm/i915/intel_dp.c +6 -0
 static void edp_panel_vdd_work(struct work_struct *__work)
 {
 	struct intel_dp *intel_dp = container_of(to_delayed_work(__work),
@@ -3836,7 +3843,13 @@ g4x_dp_detect(struct intel_dp *intel_dp)
 static struct edid *
 intel_dp_get_edid(struct intel_dp *intel_dp)
 {
+	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
+	struct intel_encoder *intel_encoder = &intel_dig_port->base;
+	struct drm_device *dev = intel_encoder->base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_connector *intel_connector = intel_dp->attached_connector;
+	enum intel_display_power_domain power_domain;
+	struct edid *edid;
 
 	/* use cached edid if we have one */
 	if (intel_connector->edid) {

drivers/gpu/drm/i915/intel_dp.c intel_dp_get_edid(struct intel_dp *intel_dp) · line 3863

Quoted 9 lines
drivers/gpu/drm/i915/intel_dp.c +3 -3
@@ -3845,9 +3858,16 @@ intel_dp_get_edid(struct intel_dp *intel_dp)
 			return NULL;
 
 		return drm_edid_duplicate(intel_connector->edid);
-	} else
-		return drm_get_edid(&intel_connector->base,
-				    &intel_dp->aux.ddc);
+	} else {
+		power_domain = intel_display_aux_power_domain(intel_encoder);
+		intel_display_power_get(dev_priv, power_domain);

This is redundant, the higher level intel_dp_detect(), intel_dp_force() already get/put the needed power domains.

Quoted 57 lines
drivers/gpu/drm/i915/intel_dp.c +20 -8
+
+		edid = drm_get_edid(&intel_connector->base, &intel_dp->aux.ddc);
+
+		intel_display_power_put(dev_priv, power_domain);
+
+		return edid;
+	}
 }
 
 static void
@@ -3876,24 +3896,30 @@ intel_dp_unset_edid(struct intel_dp *intel_dp)
 	intel_dp->has_audio = false;
 }
 
-static enum intel_display_power_domain
-intel_dp_power_get(struct intel_dp *dp)
+static void intel_dp_power_get(struct intel_dp *dp)
 {
 	struct intel_encoder *encoder = &dp_to_dig_port(dp)->base;
+	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
 	enum intel_display_power_domain power_domain;
 
 	power_domain = intel_display_port_power_domain(encoder);
 	intel_display_power_get(to_i915(encoder->base.dev), power_domain);
 
-	return power_domain;
+	power_domain = intel_display_aux_power_domain(encoder);
+	intel_display_power_get(dev_priv, power_domain);
 }
 
-static void
-intel_dp_power_put(struct intel_dp *dp,
-		   enum intel_display_power_domain power_domain)
+static void intel_dp_power_put(struct intel_dp *dp)
 {
 	struct intel_encoder *encoder = &dp_to_dig_port(dp)->base;
-	intel_display_power_put(to_i915(encoder->base.dev), power_domain);
+	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
+	enum intel_display_power_domain power_domain;
+
+	power_domain = intel_display_port_power_domain(encoder);
+	intel_display_power_put(dev_priv, power_domain);
+
+	power_domain = intel_display_aux_power_domain(encoder);
+	intel_display_power_put(dev_priv, power_domain);
 }
 
 static enum drm_connector_status
@@ -3904,7 +3930,6 @@ intel_dp_detect(struct drm_connector *connector, bool force)
 	struct intel_encoder *intel_encoder = &intel_dig_port->base;
 	struct drm_device *dev = connector->dev;
 	enum drm_connector_status status;
-	enum intel_display_power_domain power_domain;
 	bool ret;
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",

drivers/gpu/drm/i915/intel_dp.c intel_dp_detect(struct drm_connector *connector, bool force) · line 3946

Quoted 5 lines
drivers/gpu/drm/i915/intel_dp.c +1 -1
@@ -3918,7 +3943,7 @@ intel_dp_detect(struct drm_connector *connector, bool force)
 		return connector_status_disconnected;
 	}
 
-	power_domain = intel_dp_power_get(intel_dp);
+	intel_dp_power_get(intel_dp);

Based on the above intel_dp_power_get() would only enable the AUX power domain, which means we could keep the current prototype for intel_dp_power_get()/put().

Quoted 59 lines
drivers/gpu/drm/i915/intel_dp.c +8 -5
 	/* Can't disconnect eDP, but you can close the lid... */
 	if (is_edp(intel_dp))
@@ -3949,7 +3974,7 @@ intel_dp_detect(struct drm_connector *connector, bool force)
 	status = connector_status_connected;
 
 out:
-	intel_dp_power_put(intel_dp, power_domain);
+	intel_dp_power_put(intel_dp);
 	return status;
 }
 
@@ -3958,7 +3983,6 @@ intel_dp_force(struct drm_connector *connector)
 {
 	struct intel_dp *intel_dp = intel_attached_dp(connector);
 	struct intel_encoder *intel_encoder = &dp_to_dig_port(intel_dp)->base;
-	enum intel_display_power_domain power_domain;
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
 		      connector->base.id, connector->name);
@@ -3967,11 +3991,11 @@ intel_dp_force(struct drm_connector *connector)
 	if (connector->status != connector_status_connected)
 		return;
 
-	power_domain = intel_dp_power_get(intel_dp);
+	intel_dp_power_get(intel_dp);
 
 	intel_dp_set_edid(intel_dp);
 
-	intel_dp_power_put(intel_dp, power_domain);
+	intel_dp_power_put(intel_dp);
 
 	if (intel_encoder->type != INTEL_OUTPUT_EDP)
 		intel_encoder->type = INTEL_OUTPUT_DISPLAYPORT;
@@ -4205,7 +4229,8 @@ intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool long_hpd)
 		      port_name(intel_dig_port->port),
 		      long_hpd ? "long" : "short");
 
-	power_domain = intel_display_port_power_domain(intel_encoder);
+	power_domain = intel_display_aux_power_domain(intel_encoder);
+
 	intel_display_power_get(dev_priv, power_domain);
 
 	if (long_hpd) {
@@ -4648,6 +4673,9 @@ void intel_edp_panel_vdd_sanitize(struct intel_encoder *intel_encoder)
 	power_domain = intel_display_port_power_domain(intel_encoder);
 	intel_display_power_get(dev_priv, power_domain);
 
+	power_domain = intel_display_aux_power_domain(intel_encoder);
+	intel_display_power_get(dev_priv, power_domain);
+
 	edp_panel_vdd_schedule_off(intel_dp);
 }
 
drivers/gpu/drm/i915/intel_drv.h +0 -0
index 9558f07..a407d04 100644

drivers/gpu/drm/i915/intel_drv.h void hsw_disable_ips(struct intel_crtc *crtc); · line 923

Quoted 8 lines
drivers/gpu/drm/i915/intel_drv.h +2 -0
@@ -916,6 +916,8 @@ void hsw_disable_ips(struct intel_crtc *crtc);
 void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
 enum intel_display_power_domain
 intel_display_port_power_domain(struct intel_encoder *intel_encoder);
+enum intel_display_power_domain
+intel_display_aux_power_domain(struct intel_encoder *intel_encoder);
 void intel_mode_from_pipe_config(struct drm_display_mode *mode,
 				 struct intel_crtc_config *pipe_config);
 int intel_format_to_fourcc(int format);

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

#216 lore raw

Re: [PATCH 72/89] drm/i915/skl: Enable/disable power well for aux transaction

Quoted 19 lines · Imre Deak

drivers/gpu/drm/i915/intel_dp.c static bool edp_panel_vdd_on(struct intel_dp *intel_dp) · line 1238

Quoted 11 lines · Damien Lespiau
drivers/gpu/drm/i915/intel_dp.c +3 -0
index 93bd9bf..a983b40 100644
@@ -1233,6 +1233,9 @@ static bool edp_panel_vdd_on(struct intel_dp *intel_dp)
 	power_domain = intel_display_port_power_domain(intel_encoder);
 	intel_display_power_get(dev_priv, power_domain);
 
+	power_domain = intel_display_aux_power_domain(intel_encoder);
+	intel_display_power_get(dev_priv, power_domain);
+

The AUX power domains were added to save power when only AUX functionality is needed, since then we don't need to power on the power domain needed for full port functionality. With the above change and everywhere else below we'll end up enabling both power domains, though we only need AUX functionality.

Quoted 4 lines

The power wells needed for AUX are a subset of those needed for full port functionality on all platforms (at least atm), so this patch won't change anything. The patch would make sense, if you requested only the AUX domains.

Also this changes shared code so should be split out from the stage 1 enabling. At least if we want to push it to 3.18 since drm-next already closed feature-wise for that kernel.
-Daniel

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

Re: [PATCH 72/89] drm/i915/skl: Enable/disable power well for aux transaction

In reply to Imre Deak
Quoted 11 lines · Imre Deak

drivers/gpu/drm/i915/intel_dp.c static bool edp_panel_vdd_on(struct intel_dp *intel_dp) · line 1238

Quoted 7 lines
drivers/gpu/drm/i915/intel_dp.c +3 -0
@@ -1233,6 +1233,9 @@ static bool edp_panel_vdd_on(struct intel_dp *intel_dp)
 	power_domain = intel_display_port_power_domain(intel_encoder);
 	intel_display_power_get(dev_priv, power_domain);
 
+	power_domain = intel_display_aux_power_domain(intel_encoder);
+	intel_display_power_get(dev_priv, power_domain);
+

The AUX power domains were added to save power when only AUX functionality is needed, since then we don't need to power on the power domain needed for full port functionality.

Hum I'm not sure about this. It seems to me that the value of the AUX power domain is to be able to shutdown the AUX hardware when AUX is not needed. That's slightly different from what you're saying; The cases where "only AUX functionality is needed" seem very transient to me, while having the main lanes working and no need for AUX sounds like the case where it's interesting to have the AUX hw powered down. Of course, with PSR we can do both.

Quoted 2 lines

With the above change and everywhere else below we'll end up enabling both power domains, though we only need AUX functionality.

If we're powering up the panel that's probably to use it very soon, so I don't really see the value not powering the main lanes at the same time, they are going to be used for training very soon? I'm probably missing something.

Quoted 4 lines

The power wells needed for AUX are a subset of those needed for full port functionality on all platforms (at least atm), so this patch won't change anything. The patch would make sense, if you requested only the AUX domains.

I think it's fine if this patch is not changing anything, at least for now, until we get to use this power domain to good ends?

This patch still need the reworks you mentionned in the previous mail, of course.

Signature · 5 lines
Damien
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#218 lore raw

Re: [PATCH 72/89] drm/i915/skl: Enable/disable power well for aux transaction

Quoted 13 lines · Damien Lespiau
Quoted 11 lines · Imre Deak

drivers/gpu/drm/i915/intel_dp.c static bool edp_panel_vdd_on(struct intel_dp *intel_dp) · line 1238

Quoted 7 lines
drivers/gpu/drm/i915/intel_dp.c +3 -0
@@ -1233,6 +1233,9 @@ static bool edp_panel_vdd_on(struct intel_dp *intel_dp)
 	power_domain = intel_display_port_power_domain(intel_encoder);
 	intel_display_power_get(dev_priv, power_domain);
 
+	power_domain = intel_display_aux_power_domain(intel_encoder);
+	intel_display_power_get(dev_priv, power_domain);
+

The AUX power domains were added to save power when only AUX functionality is needed, since then we don't need to power on the power domain needed for full port functionality.

Quoted 3 lines

Hum I'm not sure about this. It seems to me that the value of the AUX power domain is to be able to shutdown the AUX hardware when AUX is not needed. That's slightly different from what you're saying;

Ok, I didn't describe all uses cases where the AUX domains are useful, your description here was more complete. To summarize that for later reference:

1. only AUX (output inactive, we only do a connector detection)
2. only main lanes (most of the time when the output is active)
3. AUX+main lanes (link training/re-training)
4. no AUX, no main lanes (output is inactive)

Quoted 4 lines

The cases where "only AUX functionality is needed" seem very transient to me, while having the main lanes working and no need for AUX sounds like the case where it's interesting to have the AUX hw powered down. Of course, with PSR we can do both.

Perhaps, if case 1. above isn't very frequent. But my arguments were valid even for case 2. and 3.

Quoted 7 lines
Quoted 2 lines

With the above change and everywhere else below we'll end up enabling both power domains, though we only need AUX functionality.

If we're powering up the panel that's probably to use it very soon, so I don't really see the value not powering the main lanes at the same time, they are going to be used for training very soon? I'm probably missing something.

Again depends how important case 1. is. But my point was that in all the functions where this patch takes the AUX power domain (after rebasing the edp vdd on/off and the pps_lock/unlock functions) we only want to enable the resources needed for AUX communication. The power domain needed for main port functionality (that is the port power domain) is already taken in display.modeset_global_resources() for case 2. and 3. above.

Quoted 7 lines
Quoted 4 lines

The power wells needed for AUX are a subset of those needed for full port functionality on all platforms (at least atm), so this patch won't change anything. The patch would make sense, if you requested only the AUX domains.

I think it's fine if this patch is not changing anything, at least for now, until we get to use this power domain to good ends?

Well I'm ok not to change the functionality for now, but I'd still do this by taking here only the AUX power domain. Then by having the same power domain->power well mapping in intel_runtime_pm.c for the AUX domains as for the port domains we keep the existing behavior. This is actually done already for all existing platforms in patch 69/89 in your SKL patchset (except for CHV). Patch 71/89 adds the mappings for SKL and it doesn't include the SKL DDI_A_E,B,C,D power wells in the AUX power domains. I think this would need to be tested if it really works (triggering case 1. above), but you could also just do the easier thing for now and set the AUX mappings to be identical to the corresponding port mappings, as it's done for the other platforms.

--Imre

Quoted 2 lines

This patch still need the reworks you mentionned in the previous mail, of course.

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

#219 lore raw

Re: [PATCH 72/89] drm/i915/skl: Enable/disable power well for aux transaction

Quoted 27 lines · Imre Deak
Quoted 13 lines · Damien Lespiau
Quoted 11 lines · Imre Deak

drivers/gpu/drm/i915/intel_dp.c static bool edp_panel_vdd_on(struct intel_dp *intel_dp) · line 1238

Quoted 7 lines
drivers/gpu/drm/i915/intel_dp.c +3 -0
@@ -1233,6 +1233,9 @@ static bool edp_panel_vdd_on(struct intel_dp *intel_dp)
 	power_domain = intel_display_port_power_domain(intel_encoder);
 	intel_display_power_get(dev_priv, power_domain);
 
+	power_domain = intel_display_aux_power_domain(intel_encoder);
+	intel_display_power_get(dev_priv, power_domain);
+

The AUX power domains were added to save power when only AUX functionality is needed, since then we don't need to power on the power domain needed for full port functionality.

Quoted 3 lines

Hum I'm not sure about this. It seems to me that the value of the AUX power domain is to be able to shutdown the AUX hardware when AUX is not needed. That's slightly different from what you're saying;

Ok, I didn't describe all uses cases where the AUX domains are useful, your description here was more complete. To summarize that for later reference:

1. only AUX (output inactive, we only do a connector detection)
2. only main lanes (most of the time when the output is active)
3. AUX+main lanes (link training/re-training)
4. no AUX, no main lanes (output is inactive)

Quoted 7 lines
Quoted 4 lines

The cases where "only AUX functionality is needed" seem very transient to me, while having the main lanes working and no need for AUX sounds like the case where it's interesting to have the AUX hw powered down. Of course, with PSR we can do both.

Perhaps, if case 1. above isn't very frequent. But my arguments were valid even for case 2. and 3.

I agree with case 2., The training case (3.) is a transient state as well where we can have the AUX power well always on. But yes, we should make sure to turn off the AUX power domain most of the time when the display is on, you're absolutely right on that.

Quoted 14 lines
Quoted 2 lines

I think it's fine if this patch is not changing anything, at least for now, until we get to use this power domain to good ends?

Well I'm ok not to change the functionality for now, but I'd still do this by taking here only the AUX power domain. Then by having the same power domain->power well mapping in intel_runtime_pm.c for the AUX domains as for the port domains we keep the existing behavior. This is actually done already for all existing platforms in patch 69/89 in your SKL patchset (except for CHV). Patch 71/89 adds the mappings for SKL and it doesn't include the SKL DDI_A_E,B,C,D power wells in the AUX power domains. I think this would need to be tested if it really works (triggering case 1. above), but you could also just do the easier thing for now and set the AUX mappings to be identical to the corresponding port mappings, as it's done for the other platforms.

Ok, had another look, and, granted, it looks funny. What I'll try:

Have us always take the AUX power domain in the AUX ->transfer vfunc. This won't toggle the power well on/off for each transfer if we correctly wrap known heavy users of the AUX channel, intel_dp_detect(), intel_dp_get_edid(), intel_dp_force and intel_dp_hpd_pulse() so we keep the power well alive for the duration of those. This will also allow one-of AUX transfers from DRM core when the power is down.

Signature · 5 lines
Damien
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#220 lore raw

Re: [PATCH 72/89] drm/i915/skl: Enable/disable power well for aux transaction

Quoted 56 lines · Damien Lespiau
Quoted 27 lines · Imre Deak
Quoted 13 lines · Damien Lespiau
Quoted 11 lines · Imre Deak

drivers/gpu/drm/i915/intel_dp.c static bool edp_panel_vdd_on(struct intel_dp *intel_dp) · line 1238

Quoted 7 lines
drivers/gpu/drm/i915/intel_dp.c +3 -0
@@ -1233,6 +1233,9 @@ static bool edp_panel_vdd_on(struct intel_dp *intel_dp)
 	power_domain = intel_display_port_power_domain(intel_encoder);
 	intel_display_power_get(dev_priv, power_domain);
 
+	power_domain = intel_display_aux_power_domain(intel_encoder);
+	intel_display_power_get(dev_priv, power_domain);
+

The AUX power domains were added to save power when only AUX functionality is needed, since then we don't need to power on the power domain needed for full port functionality.

Quoted 3 lines

Hum I'm not sure about this. It seems to me that the value of the AUX power domain is to be able to shutdown the AUX hardware when AUX is not needed. That's slightly different from what you're saying;

Ok, I didn't describe all uses cases where the AUX domains are useful, your description here was more complete. To summarize that for later reference:

1. only AUX (output inactive, we only do a connector detection)
2. only main lanes (most of the time when the output is active)
3. AUX+main lanes (link training/re-training)
4. no AUX, no main lanes (output is inactive)

Quoted 7 lines
Quoted 4 lines

The cases where "only AUX functionality is needed" seem very transient to me, while having the main lanes working and no need for AUX sounds like the case where it's interesting to have the AUX hw powered down. Of course, with PSR we can do both.

Perhaps, if case 1. above isn't very frequent. But my arguments were valid even for case 2. and 3.

I agree with case 2., The training case (3.) is a transient state as well where we can have the AUX power well always on. But yes, we should make sure to turn off the AUX power domain most of the time when the display is on, you're absolutely right on that.

Quoted 14 lines
Quoted 2 lines

I think it's fine if this patch is not changing anything, at least for now, until we get to use this power domain to good ends?

Well I'm ok not to change the functionality for now, but I'd still do this by taking here only the AUX power domain. Then by having the same power domain->power well mapping in intel_runtime_pm.c for the AUX domains as for the port domains we keep the existing behavior. This is actually done already for all existing platforms in patch 69/89 in your SKL patchset (except for CHV). Patch 71/89 adds the mappings for SKL and it doesn't include the SKL DDI_A_E,B,C,D power wells in the AUX power domains. I think this would need to be tested if it really works (triggering case 1. above), but you could also just do the easier thing for now and set the AUX mappings to be identical to the corresponding port mappings, as it's done for the other platforms.

Quoted 8 lines

Ok, had another look, and, granted, it looks funny. What I'll try:

Have us always take the AUX power domain in the AUX ->transfer vfunc. This won't toggle the power well on/off for each transfer if we correctly wrap known heavy users of the AUX channel, intel_dp_detect(), intel_dp_get_edid(), intel_dp_force and intel_dp_hpd_pulse() so we keep the power well alive for the duration of those. This will also allow one-of AUX transfers from DRM core when the power is down.

Yes, this sounds ok to me. Iiuc this will change all places in intel_dp.c to take the AUX domain instead of the port domain. intel_dp_get_hw_state() should still check the port domain, since there we are only interested in the HW state for the main lanes not the HW state for AUX.

--Imre

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

#221 lore raw

Re: [PATCH 72/89] drm/i915/skl: Enable/disable power well for aux transaction

In reply to Damien Lespiau
Quoted 6 lines · Damien Lespiau

Have us always take the AUX power domain in the AUX ->transfer vfunc. This won't toggle the power well on/off for each transfer if we correctly wrap known heavy users of the AUX channel, intel_dp_detect(), intel_dp_get_edid(), intel_dp_force and intel_dp_hpd_pulse() so we keep the power well alive for the duration of those. This will also allow one-of AUX transfers from DRM core when the power is down.

This kind of high-freq flip-flop of power domains is why the linux power domain and runtime pm code has a disable timer. I guess as predicted, we'll eventually implement it all ;-)
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#222 lore raw

Re: [PATCH 72/89] drm/i915/skl: Enable/disable power well for aux transaction

In reply to Imre Deak
Quoted 27 lines · Imre Deak
Quoted 13 lines · Damien Lespiau
Quoted 11 lines · Imre Deak

drivers/gpu/drm/i915/intel_dp.c static bool edp_panel_vdd_on(struct intel_dp *intel_dp) · line 1238

Quoted 7 lines
drivers/gpu/drm/i915/intel_dp.c +3 -0
@@ -1233,6 +1233,9 @@ static bool edp_panel_vdd_on(struct intel_dp *intel_dp)
 	power_domain = intel_display_port_power_domain(intel_encoder);
 	intel_display_power_get(dev_priv, power_domain);
 
+	power_domain = intel_display_aux_power_domain(intel_encoder);
+	intel_display_power_get(dev_priv, power_domain);
+

The AUX power domains were added to save power when only AUX functionality is needed, since then we don't need to power on the power domain needed for full port functionality.

Quoted 3 lines

Hum I'm not sure about this. It seems to me that the value of the AUX power domain is to be able to shutdown the AUX hardware when AUX is not needed. That's slightly different from what you're saying;

Ok, I didn't describe all uses cases where the AUX domains are useful, your description here was more complete. To summarize that for later reference:

1. only AUX (output inactive, we only do a connector detection)
2. only main lanes (most of the time when the output is active)
3. AUX+main lanes (link training/re-training)
4. no AUX, no main lanes (output is inactive)

Quoted 7 lines
Quoted 4 lines

The cases where "only AUX functionality is needed" seem very transient to me, while having the main lanes working and no need for AUX sounds like the case where it's interesting to have the AUX hw powered down. Of course, with PSR we can do both.

Perhaps, if case 1. above isn't very frequent. But my arguments were valid even for case 2. and 3.

I've thought the point of case 1 is that we don't have to fire up the entire display clocks and power wells when just doing a few dp aux transactions to probe for outputs.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#223 lore raw

Re: [PATCH 72/89] drm/i915/skl: Enable/disable power well for aux transaction

In reply to Imre Deak
Quoted 3 lines · Imre Deak

This patch needs to be rebased on the recent PPS changes at least getting/putting the AUX power domain in pps_lock()/pps_unlock() too. Also it should be squashed into 69/89. Some more comments below.

Hum, do we really need to hold a reference to the AUX power in pps_lock(), it doesn't seem that the PPS hw should a specific dependency on the AUX power domain. We might as well just get the "port" power domain if that's enough.

Signature · 5 lines
Damien
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#224 lore raw

Re: [PATCH 72/89] drm/i915/skl: Enable/disable power well for aux transaction

Quoted 9 lines · Damien Lespiau
Quoted 3 lines · Imre Deak

This patch needs to be rebased on the recent PPS changes at least getting/putting the AUX power domain in pps_lock()/pps_unlock() too. Also it should be squashed into 69/89. Some more comments below.

Hum, do we really need to hold a reference to the AUX power in pps_lock(), it doesn't seem that the PPS hw should a specific dependency on the AUX power domain. We might as well just get the "port" power domain if that's enough.

pps_lock() doesn't *really* need any power domain references. The thing is that the VLV/CHV display power well hooks need to reset the pps_pipe assignment which means they should grab pps_mutex. However the vdd code can grab power domain references while already holding pps_mutex, which gets us into a neat locking inversion with the power domain mutex.

The workaround I did was to grab the power domain references always around pps_mutex, so that we dodge the problem. A better solution would be to never grab power domain references while already holding pps_mutex, but I wasn't happy with how the code started to look when I tried that. But I would welcome any efforts to make that happen since the current trick is rather hackish. Also the code is now otherwise cleaner than what it was when I tried to do that, so maybe it's easier now.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#225 lore raw

Re: [PATCH 72/89] drm/i915/skl: Enable/disable power well for aux transaction

Quoted 17 lines · Ville Syrjälä
Quoted 9 lines · Damien Lespiau
Quoted 3 lines · Imre Deak

This patch needs to be rebased on the recent PPS changes at least getting/putting the AUX power domain in pps_lock()/pps_unlock() too. Also it should be squashed into 69/89. Some more comments below.

Hum, do we really need to hold a reference to the AUX power in pps_lock(), it doesn't seem that the PPS hw should a specific dependency on the AUX power domain. We might as well just get the "port" power domain if that's enough.

pps_lock() doesn't *really* need any power domain references. The thing is that the VLV/CHV display power well hooks need to reset the pps_pipe assignment which means they should grab pps_mutex. However the vdd code can grab power domain references while already holding pps_mutex, which gets us into a neat locking inversion with the power domain mutex.

Quoted 7 lines

The workaround I did was to grab the power domain references always around pps_mutex, so that we dodge the problem. A better solution would be to never grab power domain references while already holding pps_mutex, but I wasn't happy with how the code started to look when I tried that. But I would welcome any efforts to make that happen since the current trick is rather hackish. Also the code is now otherwise cleaner than what it was when I tried to do that, so maybe it's easier now.

Right, but then the remark was that we don't need the aux power domain to keep the power well on on VLV/CHV, so would you be happy to just take the port power domain around pps_lock/unlock().

Signature · 5 lines
Damien
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#226 lore raw

Re: [PATCH 72/89] drm/i915/skl: Enable/disable power well for aux transaction

Quoted 26 lines · Damien Lespiau
Quoted 17 lines · Ville Syrjälä
Quoted 9 lines · Damien Lespiau
Quoted 3 lines · Imre Deak

This patch needs to be rebased on the recent PPS changes at least getting/putting the AUX power domain in pps_lock()/pps_unlock() too. Also it should be squashed into 69/89. Some more comments below.

Hum, do we really need to hold a reference to the AUX power in pps_lock(), it doesn't seem that the PPS hw should a specific dependency on the AUX power domain. We might as well just get the "port" power domain if that's enough.

pps_lock() doesn't *really* need any power domain references. The thing is that the VLV/CHV display power well hooks need to reset the pps_pipe assignment which means they should grab pps_mutex. However the vdd code can grab power domain references while already holding pps_mutex, which gets us into a neat locking inversion with the power domain mutex.

Quoted 7 lines

The workaround I did was to grab the power domain references always around pps_mutex, so that we dodge the problem. A better solution would be to never grab power domain references while already holding pps_mutex, but I wasn't happy with how the code started to look when I tried that. But I would welcome any efforts to make that happen since the current trick is rather hackish. Also the code is now otherwise cleaner than what it was when I tried to do that, so maybe it's easier now.

Quoted 3 lines

Right, but then the remark was that we don't need the aux power domain to keep the power well on on VLV/CHV, so would you be happy to just take the port power domain around pps_lock/unlock().

Yeah. Actually just the disp2/pipe-a well is needed, so even the port domains are pointless but I was feeling lazy when I came up with the hack.

I (or someone) should also do some tests on vlv/chv to see which power wells are actually needed for AUX. disp2d/pipe-a obviously just for the registers, but then I'm not sure if the phy cmnlane well is needed. On chv the docs do say that the AUX stuff is in the common lane, but IIRC on vlv it was said to be more of a separate lane. Anyway would be nice to know for sure.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#227 lore raw

PATCH 73/89 drm/i915/skl: Enabling MISC IO power well

In reply to Damien Lespiau

From: Satheeshakrishna M <[email protected]>

Earlier it was thought that MISC IO is always ON power well. But it doesn't looks like the case as confirmed by the HW team. Adding code to enable/disable MISC IO power well.

v2: Use power well data for comparison (Imre)

---
 drivers/gpu/drm/i915/intel_pm.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +22 -0
index 853b596..5425d85 100644
@@ -7204,6 +7204,21 @@ static void hsw_set_power_well(struct drm_i915_private *dev_priv,
 	BIT(POWER_DOMAIN_PORT_DDI_D_2_LANES) |          \
 	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |          \
 	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_MISC_IO_POWER_DOMAINS (                       \
+	BIT(POWER_DOMAIN_AUX_A) |                       \
+	BIT(POWER_DOMAIN_AUX_B) |                       \
+	BIT(POWER_DOMAIN_AUX_C) |                       \
+	BIT(POWER_DOMAIN_AUX_D) |                       \
+	BIT(POWER_DOMAIN_PORT_DDI_A_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_A_4_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_B_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_D_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |          \
+	BIT(POWER_DOMAIN_AUDIO) |                       \
+	BIT(POWER_DOMAIN_INIT))
 #define SKL_DISPLAY_ALWAYS_ON_POWER_DOMAINS (           \
 	(POWER_DOMAIN_MASK & ~(SKL_DISPLAY_POWERWELL_1_POWER_DOMAINS |  \
 	SKL_DISPLAY_POWERWELL_2_POWER_DOMAINS |         \
@@ -7241,6 +7256,7 @@ static void skl_set_power_well(struct drm_i915_private *dev_priv,
 	case SKL_DISP_PW_DDI_B:
 	case SKL_DISP_PW_DDI_C:
 	case SKL_DISP_PW_DDI_D:
+	case SKL_DISP_PW_MISC_IO:
 		break;
 	default:
 		return;
@@ -8211,6 +8227,12 @@ static struct i915_power_well skl_power_wells[] = {
 		.ops = &skl_power_well_ops,
 		.data = SKL_DISP_PW_DDI_D,
 	},
+	{
+		.name = "MISC IO power well",
+		.domains = SKL_DISPLAY_MISC_IO_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_MISC_IO,
+	}
 };
 
 #define set_power_wells(power_domains, __power_wells) ({		\
Signature · 1 line
1.8.3.1
Reviewed-by on v1 73/89
#228 lore raw

Re: [PATCH 73/89] drm/i915/skl: Enabling MISC IO power well

Quoted 27 lines · Damien Lespiau

From: Satheeshakrishna M <[email protected]>

Earlier it was thought that MISC IO is always ON power well. But it doesn't looks like the case as confirmed by the HW team. Adding code to enable/disable MISC IO power well.

v2: Use power well data for comparison (Imre)

---
 drivers/gpu/drm/i915/intel_pm.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +5 -0
index 853b596..5425d85 100644
@@ -7204,6 +7204,21 @@ static void hsw_set_power_well(struct drm_i915_private *dev_priv,
 	BIT(POWER_DOMAIN_PORT_DDI_D_2_LANES) |          \
 	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |          \
 	BIT(POWER_DOMAIN_INIT))
+#define SKL_DISPLAY_MISC_IO_POWER_DOMAINS (                       \
+	BIT(POWER_DOMAIN_AUX_A) |                       \
+	BIT(POWER_DOMAIN_AUX_B) |                       \
+	BIT(POWER_DOMAIN_AUX_C) |                       \
+	BIT(POWER_DOMAIN_AUX_D) |                       \

drivers/gpu/drm/i915/intel_pm.c static void hsw_set_power_well(struct drm_i915_private *dev_priv, · line 7221

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+	BIT(POWER_DOMAIN_PORT_DDI_A_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_A_4_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_B_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_B_4_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_C_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_C_4_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_D_2_LANES) |          \
+	BIT(POWER_DOMAIN_PORT_DDI_D_4_LANES) |          \
+	BIT(POWER_DOMAIN_AUDIO) |                       \
+	BIT(POWER_DOMAIN_INIT))

From the bspec page "Skylake Sequences to Initialize Display":
"""
Most display engine functions will not operate while display is not initialized. Only basic PCI, I/O, and MMIO register read/write operations are supported when display is not initialized. """

And for the display to be initialized we need power well#1 and the misc power well. Based on this we need the misc power well (and power well#1) for all domains, so simply:
#define SKL_DISPLAY_MISC_IO_POWER_DOMAINS POWER_DOMAIN_MASK

Quoted 12 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
 #define SKL_DISPLAY_ALWAYS_ON_POWER_DOMAINS (           \
 	(POWER_DOMAIN_MASK & ~(SKL_DISPLAY_POWERWELL_1_POWER_DOMAINS |  \
 	SKL_DISPLAY_POWERWELL_2_POWER_DOMAINS |         \
@@ -7241,6 +7256,7 @@ static void skl_set_power_well(struct drm_i915_private *dev_priv,
 	case SKL_DISP_PW_DDI_B:
 	case SKL_DISP_PW_DDI_C:
 	case SKL_DISP_PW_DDI_D:
+	case SKL_DISP_PW_MISC_IO:
 		break;
 	default:
 		return;

drivers/gpu/drm/i915/intel_pm.c static struct i915_power_well skl_power_wells[] = { · line 8235

Quoted 9 lines
drivers/gpu/drm/i915/intel_pm.c +6 -0
@@ -8211,6 +8227,12 @@ static struct i915_power_well skl_power_wells[] = {
 		.ops = &skl_power_well_ops,
 		.data = SKL_DISP_PW_DDI_D,
 	},
+	{
+		.name = "MISC IO power well",
+		.domains = SKL_DISPLAY_MISC_IO_POWER_DOMAINS,
+		.ops = &skl_power_well_ops,
+		.data = SKL_DISP_PW_MISC_IO,
+	}

Based on the above bspec page, the misc power well needs to be enabled before any other power wells, so it needs to be the first entry.

Optionally this patch could be squashed into 71/89.

With the above changes:

drivers/gpu/drm/i915/intel_pm.c static struct i915_power_well skl_power_wells[] = { · line 8238

Quoted 3 lines
drivers/gpu/drm/i915/intel_pm.c +0 -0
 };
 
 #define set_power_wells(power_domains, __power_wells) ({		\

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

#229 lore raw

PATCH 74/89 drm/i915/skl: Implement queue_flip

In reply to Damien Lespiau

A few bits have changed in MI_DISPLAY_FLIP to accomodate the new planes. DE_RRMR seems to have kept its plane flip bits backward compatible.

v2: Rebase on top of nightly
v2: Rebase on top of nightly (minor conflict in i915_reg.h)

---
 drivers/gpu/drm/i915/i915_reg.h      | 10 +++++
 drivers/gpu/drm/i915/intel_display.c | 78 ++++++++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +10 -0
index 84a0de6..176e84e 100644
@@ -240,6 +240,16 @@
 #define   MI_DISPLAY_FLIP_IVB_SPRITE_B (3 << 19)
 #define   MI_DISPLAY_FLIP_IVB_PLANE_C  (4 << 19)
 #define   MI_DISPLAY_FLIP_IVB_SPRITE_C (5 << 19)
+/* SKL ones */
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_A	(0 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_B	(1 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_C	(2 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_A	(4 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_B	(5 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_C	(6 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_A	(7 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_B	(8 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_C	(9 << 8)
 #define MI_SEMAPHORE_MBOX	MI_INSTR(0x16, 1) /* gen6, gen7 */
 #define   MI_SEMAPHORE_GLOBAL_GTT    (1<<22)
 #define   MI_SEMAPHORE_UPDATE	    (1<<21)
drivers/gpu/drm/i915/intel_display.c +78 -0

90 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#230 lore raw

Re: [PATCH 74/89] drm/i915/skl: Implement queue_flip

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 20 lines

A few bits have changed in MI_DISPLAY_FLIP to accomodate the new planes. DE_RRMR seems to have kept its plane flip bits backward compatible.

v2: Rebase on top of nightly
v2: Rebase on top of nightly (minor conflict in i915_reg.h)

---
 drivers/gpu/drm/i915/i915_reg.h      | 10 +++++
 drivers/gpu/drm/i915/intel_display.c | 78 ++++++++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +0 -0
index 84a0de6..176e84e 100644
@@ -240,6 +240,16 @@
 #define   MI_DISPLAY_FLIP_IVB_SPRITE_B (3 << 19)
 #define   MI_DISPLAY_FLIP_IVB_PLANE_C  (4 << 19)
 #define   MI_DISPLAY_FLIP_IVB_SPRITE_C (5 << 19)

drivers/gpu/drm/i915/i915_reg.h line 252

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +10 -0
+/* SKL ones */
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_A        (0 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_B        (1 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_C        (2 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_A        (4 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_B        (5 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_C        (6 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_A        (7 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_B        (8 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_C        (9 << 8)

BSpec seems to mention these bits on CHV too... Maybe we want the new function to run on CHV + GEN9? Ping Ville.

Quoted 16 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
 #define MI_SEMAPHORE_MBOX      MI_INSTR(0x16, 1) /* gen6, gen7 */
 #define   MI_SEMAPHORE_GLOBAL_GTT    (1<<22)
 #define   MI_SEMAPHORE_UPDATE      (1<<21)
drivers/gpu/drm/i915/intel_display.c +5 -0
index abd4201..393bd19 100644
@@ -9913,6 +9913,81 @@ static int intel_queue_mmio_flip(struct drm_device *dev,
        return 0;
 }
 
+static int intel_gen9_queue_flip(struct drm_device *dev,
+                                struct drm_crtc *crtc,
+                                struct drm_framebuffer *fb,
+                                struct drm_i915_gem_object *obj,
+                                struct intel_engine_cs *ring,

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9930

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+                                uint32_t flags)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+       uint32_t plane = 0, stride;
+       int ret;
+
+       ring = obj->ring;
+       if (ring == NULL || ring->id != BCS)
+               ring = &dev_priv->ring[RCS];

Why do we need these lines above? The other Gens don't have it. And it looks like ring shouldn't really be NULL, otherwise the other gens are going to crash.

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9934

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +4 -0
+
+       ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
+       if (ret)
+               goto err;

Our only caller (intel_crtc_page_flip) seems to do this for us already. Also, the other gens don't do this at their queue_flip implementations.

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9947

Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +13 -0
+
+       switch(intel_crtc->pipe) {
+       case PIPE_A:
+               plane = MI_DISPLAY_FLIP_SKL_PLANE_1_A;
+               break;
+       case PIPE_B:
+               plane = MI_DISPLAY_FLIP_SKL_PLANE_1_B;
+               break;
+       case PIPE_C:
+               plane = MI_DISPLAY_FLIP_SKL_PLANE_1_C;
+               break;
+       default:
+               BUG();

The gen7 version does WARN_ONCE() and returns -ENODEV instead of BUG(). Seems more reasonable to just not update the screen instead of killing the whole machine.

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9958

Quoted 11 lines
drivers/gpu/drm/i915/intel_display.c +11 -0
+       }
+
+       switch (obj->tiling_mode) {
+       case I915_TILING_NONE:
+               stride = fb->pitches[0] >> 6;
+               break;
+       case I915_TILING_X:
+               stride = fb->pitches[0] >> 9;
+               break;
+       default:
+               BUG();

Also replace this for a WARN and return an error code?

Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +6 -0
+       }
+
+       ret = intel_ring_begin(ring, 10);
+       if (ret)
+               goto err_unpin;
+

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9974

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+       intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
+       intel_ring_emit(ring, DERRMR);
+       intel_ring_emit(ring, ~(DERRMR_PIPEA_PRI_FLIP_DONE |
+                               DERRMR_PIPEB_PRI_FLIP_DONE |
+                               DERRMR_PIPEC_PRI_FLIP_DONE));
+       intel_ring_emit(ring, MI_STORE_REGISTER_MEM_GEN8(1) |
+                             MI_SRM_LRM_GLOBAL_GTT);
+       intel_ring_emit(ring, DERRMR);
+       intel_ring_emit(ring, ring->scratch.gtt_offset + 256);
+       intel_ring_emit(ring, 0);

Do we still need the DERRMR thing? BSpec doesn't seem to mention it anymore on the SKL page. And we only do it for RCS on Gens 7/8.

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9978

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +4 -0
+
+       intel_ring_emit(ring, MI_DISPLAY_FLIP_I915 | plane);
+       intel_ring_emit(ring, stride << 6 | obj->tiling_mode);
+       intel_ring_emit(ring, i915_gem_obj_ggtt_offset(obj));

Gen 7 uses intel_crtc->unpin_work->gtt_offset, which seems to be a little faster than calling i915_gem_obj_ggtt_offset() again. The work->gtt_offset was just set by the function that calls queue_flip(), so it should be correct.

Quoted 32 lines
drivers/gpu/drm/i915/intel_display.c +15 -1
+
+       intel_mark_page_flip_active(intel_crtc);
+       __intel_ring_advance(ring);
+
+       return 0;
+
+err_unpin:
+       intel_unpin_fb_obj(obj);
+err:
+       return ret;
+}
+
 static int intel_default_queue_flip(struct drm_device *dev,
                                    struct drm_crtc *crtc,
                                    struct drm_framebuffer *fb,
@@ -12740,6 +12815,9 @@ static void intel_init_display(struct drm_device *dev)
        case 8: /* FIXME(BDW): Check that the gen8 RCS flip works. */
                dev_priv->display.queue_flip = intel_gen7_queue_flip;
                break;
+       case 9:
+               dev_priv->display.queue_flip = intel_gen9_queue_flip;
+               break;
        }
 
        intel_panel_init_backlight_funcs(dev);
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#231 lore raw

Re: [PATCH 74/89] drm/i915/skl: Implement queue_flip

Quoted 6 lines · Paulo Zanoni

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 5 lines

A few bits have changed in MI_DISPLAY_FLIP to accomodate the new planes. DE_RRMR seems to have kept its plane flip bits backward compatible.

v2: Rebase on top of nightly
v2: Rebase on top of nightly (minor conflict in i915_reg.h)

v3

Quoted 1 line
Quoted 1 line

Some answers below, others in v4 that should follow shortly.

Quoted 18 lines
Quoted 18 lines
---
 drivers/gpu/drm/i915/i915_reg.h      | 10 +++++
 drivers/gpu/drm/i915/intel_display.c | 78 ++++++++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +5 -0
index 84a0de6..176e84e 100644
@@ -240,6 +240,16 @@
 #define   MI_DISPLAY_FLIP_IVB_SPRITE_B (3 << 19)
 #define   MI_DISPLAY_FLIP_IVB_PLANE_C  (4 << 19)
 #define   MI_DISPLAY_FLIP_IVB_SPRITE_C (5 << 19)
+/* SKL ones */
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_A        (0 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_B        (1 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_C        (2 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_A        (4 << 8)
Quoted 8 lines

drivers/gpu/drm/i915/i915_reg.h line 252

Quoted 5 lines
drivers/gpu/drm/i915/i915_reg.h +5 -0
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_B        (5 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_C        (6 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_A        (7 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_B        (8 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_C        (9 << 8)

BSpec seems to mention these bits on CHV too... Maybe we want the new function to run on CHV + GEN9? Ping Ville.

Funnily the bits at 21:19 are still documented on CHV. So maybe the current code works? Considering we only use queue_flip() for the primary planes at the moment ad we want to move to MMIO based flips in the near future, probably doesn't matter too much here.

Quoted 32 lines
Quoted 16 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
 #define MI_SEMAPHORE_MBOX      MI_INSTR(0x16, 1) /* gen6, gen7 */
 #define   MI_SEMAPHORE_GLOBAL_GTT    (1<<22)
 #define   MI_SEMAPHORE_UPDATE      (1<<21)
drivers/gpu/drm/i915/intel_display.c +5 -0
index abd4201..393bd19 100644
@@ -9913,6 +9913,81 @@ static int intel_queue_mmio_flip(struct drm_device *dev,
        return 0;
 }
 
+static int intel_gen9_queue_flip(struct drm_device *dev,
+                                struct drm_crtc *crtc,
+                                struct drm_framebuffer *fb,
+                                struct drm_i915_gem_object *obj,
+                                struct intel_engine_cs *ring,

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9930

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+                                uint32_t flags)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+       uint32_t plane = 0, stride;
+       int ret;
+
+       ring = obj->ring;
+       if (ring == NULL || ring->id != BCS)
+               ring = &dev_priv->ring[RCS];

Why do we need these lines above? The other Gens don't have it. And it looks like ring shouldn't really be NULL, otherwise the other gens are going to crash.

Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9934

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +4 -0
+
+       ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
+       if (ret)
+               goto err;

Our only caller (intel_crtc_page_flip) seems to do this for us already. Also, the other gens don't do this at their queue_flip implementations.

If you're looking for reasons, it's because the code elsewhere used to look like that and rebasing still worked, so this patch implements queue_flip() like it used to be implemented at the time of its writing. Should be fixed now.

Quoted 44 lines

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9947

Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +13 -0
+
+       switch(intel_crtc->pipe) {
+       case PIPE_A:
+               plane = MI_DISPLAY_FLIP_SKL_PLANE_1_A;
+               break;
+       case PIPE_B:
+               plane = MI_DISPLAY_FLIP_SKL_PLANE_1_B;
+               break;
+       case PIPE_C:
+               plane = MI_DISPLAY_FLIP_SKL_PLANE_1_C;
+               break;
+       default:
+               BUG();

The gen7 version does WARN_ONCE() and returns -ENODEV instead of BUG(). Seems more reasonable to just not update the screen instead of killing the whole machine.

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9958

Quoted 11 lines
drivers/gpu/drm/i915/intel_display.c +11 -0
+       }
+
+       switch (obj->tiling_mode) {
+       case I915_TILING_NONE:
+               stride = fb->pitches[0] >> 6;
+               break;
+       case I915_TILING_X:
+               stride = fb->pitches[0] >> 9;
+               break;
+       default:
+               BUG();

Also replace this for a WARN and return an error code?

Quoted 11 lines
drivers/gpu/drm/i915/intel_display.c +11 -0
+       }
+
+       ret = intel_ring_begin(ring, 10);
+       if (ret)
+               goto err_unpin;
+
+       intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
+       intel_ring_emit(ring, DERRMR);
+       intel_ring_emit(ring, ~(DERRMR_PIPEA_PRI_FLIP_DONE |
+                               DERRMR_PIPEB_PRI_FLIP_DONE |
+                               DERRMR_PIPEC_PRI_FLIP_DONE));
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9974

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5 -0
+       intel_ring_emit(ring, MI_STORE_REGISTER_MEM_GEN8(1) |
+                             MI_SRM_LRM_GLOBAL_GTT);
+       intel_ring_emit(ring, DERRMR);
+       intel_ring_emit(ring, ring->scratch.gtt_offset + 256);
+       intel_ring_emit(ring, 0);

Do we still need the DERRMR thing? BSpec doesn't seem to mention it anymore on the SKL page. And we only do it for RCS on Gens 7/8.

The answer we had from the HW guys (Art) for that is that the need to unmask DE_RRMR depends on the gen. Turns out, on gen9, we need to unmask those bits for the CS to receive the message as some internal state depends on receiving it. Without it, the flips weren't working.

Quoted 48 lines

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9978

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +4 -0
+
+       intel_ring_emit(ring, MI_DISPLAY_FLIP_I915 | plane);
+       intel_ring_emit(ring, stride << 6 | obj->tiling_mode);
+       intel_ring_emit(ring, i915_gem_obj_ggtt_offset(obj));

Gen 7 uses intel_crtc->unpin_work->gtt_offset, which seems to be a little faster than calling i915_gem_obj_ggtt_offset() again. The work->gtt_offset was just set by the function that calls queue_flip(), so it should be correct.

Quoted 32 lines
drivers/gpu/drm/i915/intel_display.c +15 -1
+
+       intel_mark_page_flip_active(intel_crtc);
+       __intel_ring_advance(ring);
+
+       return 0;
+
+err_unpin:
+       intel_unpin_fb_obj(obj);
+err:
+       return ret;
+}
+
 static int intel_default_queue_flip(struct drm_device *dev,
                                    struct drm_crtc *crtc,
                                    struct drm_framebuffer *fb,
@@ -12740,6 +12815,9 @@ static void intel_init_display(struct drm_device *dev)
        case 8: /* FIXME(BDW): Check that the gen8 RCS flip works. */
                dev_priv->display.queue_flip = intel_gen7_queue_flip;
                break;
+       case 9:
+               dev_priv->display.queue_flip = intel_gen9_queue_flip;
+               break;
        }
 
        intel_panel_init_backlight_funcs(dev);
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#232 lore raw

PATCH v4 74/89 drm/i915/skl: Implement queue_flip

In reply to Paulo Zanoni

A few bits have changed in MI_DISPLAY_FLIP to accomodate the new planes. DE_RRMR seems to have kept its plane flip bits backward compatible.

v2: Rebase on top of nightly
v3: Rebase on top of nightly (minor conflict in i915_reg.h)
v4: Remove code that is now part of intel_crtc_page_flip()

    Don't use BUG() in default:
    Use intel_crtc->unpin_work->gtt_offset
    (Paulo)
---
 drivers/gpu/drm/i915/i915_reg.h      | 10 ++++++
 drivers/gpu/drm/i915/intel_display.c | 66 ++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +10 -0
index 98413a8..bbbd4d8 100644
@@ -248,6 +248,16 @@
 #define   MI_DISPLAY_FLIP_IVB_SPRITE_B (3 << 19)
 #define   MI_DISPLAY_FLIP_IVB_PLANE_C  (4 << 19)
 #define   MI_DISPLAY_FLIP_IVB_SPRITE_C (5 << 19)
+/* SKL ones */
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_A	(0 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_B	(1 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_C	(2 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_A	(4 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_B	(5 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_C	(6 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_A	(7 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_B	(8 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_C	(9 << 8)
 #define MI_SEMAPHORE_MBOX	MI_INSTR(0x16, 1) /* gen6, gen7 */
 #define   MI_SEMAPHORE_GLOBAL_GTT    (1<<22)
 #define   MI_SEMAPHORE_UPDATE	    (1<<21)
drivers/gpu/drm/i915/intel_display.c +66 -0

78 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#233 lore raw

Re: [PATCH 74/89 v4] drm/i915/skl: Implement queue_flip

2014-09-29 14:13 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 47 lines

A few bits have changed in MI_DISPLAY_FLIP to accomodate the new planes. DE_RRMR seems to have kept its plane flip bits backward compatible.

v2: Rebase on top of nightly
v3: Rebase on top of nightly (minor conflict in i915_reg.h)
v4: Remove code that is now part of intel_crtc_page_flip()

    Don't use BUG() in default:
    Use intel_crtc->unpin_work->gtt_offset
    (Paulo)
---
 drivers/gpu/drm/i915/i915_reg.h      | 10 ++++++
 drivers/gpu/drm/i915/intel_display.c | 66 ++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +10 -0
index 98413a8..bbbd4d8 100644
@@ -248,6 +248,16 @@
 #define   MI_DISPLAY_FLIP_IVB_SPRITE_B (3 << 19)
 #define   MI_DISPLAY_FLIP_IVB_PLANE_C  (4 << 19)
 #define   MI_DISPLAY_FLIP_IVB_SPRITE_C (5 << 19)
+/* SKL ones */
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_A        (0 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_B        (1 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_1_C        (2 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_A        (4 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_B        (5 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_2_C        (6 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_A        (7 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_B        (8 << 8)
+#define   MI_DISPLAY_FLIP_SKL_PLANE_3_C        (9 << 8)
 #define MI_SEMAPHORE_MBOX      MI_INSTR(0x16, 1) /* gen6, gen7 */
 #define   MI_SEMAPHORE_GLOBAL_GTT    (1<<22)
 #define   MI_SEMAPHORE_UPDATE      (1<<21)
drivers/gpu/drm/i915/intel_display.c +2 -0
index 070c417..feed6d7 100644
@@ -9748,6 +9748,69 @@ static int intel_queue_mmio_flip(struct drm_device *dev,
        return 0;
 }
 
+static int intel_gen9_queue_flip(struct drm_device *dev,
+                                struct drm_crtc *crtc,

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9762

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+                                struct drm_framebuffer *fb,
+                                struct drm_i915_gem_object *obj,
+                                struct intel_engine_cs *ring,
+                                uint32_t flags)
+{
+       struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+       uint32_t plane = 0, stride;
+       int ret;
+
+       switch(intel_crtc->pipe) {

I just noticed that the gen7 function checks for intel_crtc->plane instead of ->pipe. This shouldn't be a problem on Gen 9, right?

If that's not a problem: Reviewed-by: Paulo Zanoni <[email protected]>

Quoted 71 lines
drivers/gpu/drm/i915/intel_display.c +54 -1
+       case PIPE_A:
+               plane = MI_DISPLAY_FLIP_SKL_PLANE_1_A;
+               break;
+       case PIPE_B:
+               plane = MI_DISPLAY_FLIP_SKL_PLANE_1_B;
+               break;
+       case PIPE_C:
+               plane = MI_DISPLAY_FLIP_SKL_PLANE_1_C;
+               break;
+       default:
+               WARN_ONCE(1, "unknown plane in flip command\n");
+               return -ENODEV;
+       }
+
+       switch (obj->tiling_mode) {
+       case I915_TILING_NONE:
+               stride = fb->pitches[0] >> 6;
+               break;
+       case I915_TILING_X:
+               stride = fb->pitches[0] >> 9;
+               break;
+       default:
+               WARN_ONCE(1, "unknown tiling in flip command\n");
+               return -ENODEV;
+       }
+
+       ret = intel_ring_begin(ring, 10);
+       if (ret)
+               return ret;
+
+       intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
+       intel_ring_emit(ring, DERRMR);
+       intel_ring_emit(ring, ~(DERRMR_PIPEA_PRI_FLIP_DONE |
+                               DERRMR_PIPEB_PRI_FLIP_DONE |
+                               DERRMR_PIPEC_PRI_FLIP_DONE));
+       intel_ring_emit(ring, MI_STORE_REGISTER_MEM_GEN8(1) |
+                             MI_SRM_LRM_GLOBAL_GTT);
+       intel_ring_emit(ring, DERRMR);
+       intel_ring_emit(ring, ring->scratch.gtt_offset + 256);
+       intel_ring_emit(ring, 0);
+
+       intel_ring_emit(ring, MI_DISPLAY_FLIP_I915 | plane);
+       intel_ring_emit(ring, stride << 6 | obj->tiling_mode);
+       intel_ring_emit(ring, intel_crtc->unpin_work->gtt_offset);
+
+       intel_mark_page_flip_active(intel_crtc);
+       __intel_ring_advance(ring);
+
+       return 0;
+}
+
 static int intel_default_queue_flip(struct drm_device *dev,
                                    struct drm_crtc *crtc,
                                    struct drm_framebuffer *fb,
@@ -12678,6 +12741,9 @@ static void intel_init_display(struct drm_device *dev)
        case 8: /* FIXME(BDW): Check that the gen8 RCS flip works. */
                dev_priv->display.queue_flip = intel_gen7_queue_flip;
                break;
+       case 9:
+               dev_priv->display.queue_flip = intel_gen9_queue_flip;
+               break;
        }
 
        intel_panel_init_backlight_funcs(dev);
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#234 lore raw

Re: [PATCH 74/89 v4] drm/i915/skl: Implement queue_flip

Quoted 16 lines · Paulo Zanoni

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 9762

Quoted 12 lines
drivers/gpu/drm/i915/intel_display.c +12 -0
+static int intel_gen9_queue_flip(struct drm_device *dev,
+                                struct drm_crtc *crtc,
+                                struct drm_framebuffer *fb,
+                                struct drm_i915_gem_object *obj,
+                                struct intel_engine_cs *ring,
+                                uint32_t flags)
+{
+       struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+       uint32_t plane = 0, stride;
+       int ret;
+
+       switch(intel_crtc->pipe) {

I just noticed that the gen7 function checks for intel_crtc->plane instead of ->pipe. This shouldn't be a problem on Gen 9, right?

Quoted 1 line

If that's not a problem: Reviewed-by: Paulo Zanoni <[email protected]>

Indeed, not a problem for all the platforms where crtc->plane == crtc->pipe (and I used pipe because I wanted to forget about that dark past).

AFAICS, the only case where crtc->plane != crtc->pipe is when:

  (HAS_FBC(dev) && INTEL_INFO(dev)->gen < 4) is true

(see intel_primary_plane_create())

Thanks for the review!

Signature · 1 line
Damien
#235 lore raw

PATCH 75/89 drm/i915/skl: fetch, enable/disable pfit as needed

In reply to Damien Lespiau

From: Jesse Barnes <[email protected]>

This moved around on SKL, so we need to make sure we read/write the correct regs.

---
 drivers/gpu/drm/i915/i915_reg.h      | 13 ++++++++
 drivers/gpu/drm/i915/intel_display.c | 61 +++++++++++++++++++++++++++++++++---
 2 files changed, 70 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +13 -0
index 176e84e..35c0759 100644
@@ -4833,6 +4833,19 @@ enum skl_disp_power_wells {
 #define PF_VSCALE(pipe)		_PIPE(pipe, _PFA_VSCALE, _PFB_VSCALE)
 #define PF_HSCALE(pipe)		_PIPE(pipe, _PFA_HSCALE, _PFB_HSCALE)
 
+#define _PSA_CTL		0x68180
+#define _PSB_CTL		0x68980
+#define PS_ENABLE		(1<<31)
+#define PS_PIPE_SEL(pipe)	((pipe)<<27)
+#define _PSA_WIN_SZ		0x68174
+#define _PSB_WIN_SZ		0x68974
+#define _PSA_WIN_POS		0x68178
+#define _PSB_WIN_POS		0x68978
+
+#define PS_CTL(pipe)		_PIPE(pipe, _PSA_CTL, _PSB_CTL)
+#define PS_WIN_SZ(pipe)		_PIPE(pipe, _PSA_WIN_SZ, _PSB_WIN_SZ)
+#define PS_WIN_POS(pipe)	_PIPE(pipe, _PSA_WIN_POS, _PSB_WIN_POS)
+
 /* legacy palette */
 #define _LGC_PALETTE_A           0x4a000
 #define _LGC_PALETTE_B           0x4a800
drivers/gpu/drm/i915/intel_display.c +57 -4

97 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#236 lore raw

Re: [PATCH 75/89] drm/i915/skl: fetch, enable/disable pfit as needed

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 17 lines

From: Jesse Barnes <[email protected]>

This moved around on SKL, so we need to make sure we read/write the correct regs.

---
 drivers/gpu/drm/i915/i915_reg.h      | 13 ++++++++
 drivers/gpu/drm/i915/intel_display.c | 61 +++++++++++++++++++++++++++++++++---
 2 files changed, 70 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +0 -0
index 176e84e..35c0759 100644

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 4839

Quoted 7 lines
drivers/gpu/drm/i915/i915_reg.h +4 -0
@@ -4833,6 +4833,19 @@ enum skl_disp_power_wells {
 #define PF_VSCALE(pipe)                _PIPE(pipe, _PFA_VSCALE, _PFB_VSCALE)
 #define PF_HSCALE(pipe)                _PIPE(pipe, _PFA_HSCALE, _PFB_HSCALE)
 
+#define _PSA_CTL               0x68180
+#define _PSB_CTL               0x68980
+#define PS_ENABLE              (1<<31)
+#define PS_PIPE_SEL(pipe)      ((pipe)<<27)

The PS_PIPE_SEL define is wrong, but it is also not used in the code you wrote, so just remove this line.

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 4842

Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +3 -0
+#define _PSA_WIN_SZ            0x68174
+#define _PSB_WIN_SZ            0x68974
+#define _PSA_WIN_POS           0x68178

0x68170

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 4843

Quoted 1 line
drivers/gpu/drm/i915/i915_reg.h +1 -0
+#define _PSB_WIN_POS           0x68978

0x68970

Quoted 49 lines
drivers/gpu/drm/i915/i915_reg.h +5 -0
+
+#define PS_CTL(pipe)           _PIPE(pipe, _PSA_CTL, _PSB_CTL)
+#define PS_WIN_SZ(pipe)                _PIPE(pipe, _PSA_WIN_SZ, _PSB_WIN_SZ)
+#define PS_WIN_POS(pipe)       _PIPE(pipe, _PSA_WIN_POS, _PSB_WIN_POS)
+
 /* legacy palette */
 #define _LGC_PALETTE_A           0x4a000
 #define _LGC_PALETTE_B           0x4a800
drivers/gpu/drm/i915/intel_display.c +18 -1
index 393bd19..9b31342 100644
@@ -3882,6 +3882,19 @@ static void cpt_verify_modeset(struct drm_device *dev, int pipe)
        }
 }
 
+static void skylake_pfit_enable(struct intel_crtc *crtc)
+{
+       struct drm_device *dev = crtc->base.dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       int pipe = crtc->pipe;
+
+       if (crtc->config.pch_pfit.enabled) {
+               I915_WRITE(PS_CTL(pipe), PS_ENABLE);
+               I915_WRITE(PS_WIN_POS(pipe), crtc->config.pch_pfit.pos);
+               I915_WRITE(PS_WIN_SZ(pipe), crtc->config.pch_pfit.size);
+       }
+}
+
 static void ironlake_pfit_enable(struct intel_crtc *crtc)
 {
        struct drm_device *dev = crtc->base.dev;
@@ -4264,7 +4277,10 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 
        intel_ddi_enable_pipe_clock(intel_crtc);
 
-       ironlake_pfit_enable(intel_crtc);
+       if (IS_SKYLAKE(dev))
+               skylake_pfit_enable(intel_crtc);
+       else
+               ironlake_pfit_enable(intel_crtc);
 
        /*
         * On ILK+ LUT must be loaded before the pipe is running but with
@@ -4295,6 +4311,20 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
        intel_crtc_enable_planes(crtc);
 }
 
+static void skylake_pfit_disable(struct intel_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc) · line 4324

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+{
+       struct drm_device *dev = crtc->base.dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       int pipe = crtc->pipe;
+
+       /* To avoid upsetting the power well on haswell only disable the pfit if
+        * it's in use. The hw state code will make sure we get this right. */
+       if (crtc->config.pch_pfit.enabled) {
+               I915_WRITE(PS_CTL(pipe), 0);
+               I915_WRITE(PS_WIN_SZ(pipe), 0);

Why not also zero _POS just like HSW? Can this affect the HW state checker output?

Everything else looks correct.

Quoted 63 lines
drivers/gpu/drm/i915/intel_display.c +29 -4
+       }
+}
+
 static void ironlake_pfit_disable(struct intel_crtc *crtc)
 {
        struct drm_device *dev = crtc->base.dev;
@@ -4399,7 +4429,10 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 
        intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
-       ironlake_pfit_disable(intel_crtc);
+       if (IS_SKYLAKE(dev))
+               skylake_pfit_disable(intel_crtc);
+       else
+               ironlake_pfit_disable(intel_crtc);
 
        intel_ddi_disable_pipe_clock(intel_crtc);
 
@@ -7382,6 +7415,22 @@ static void ironlake_get_fdi_m_n_config(struct intel_crtc *crtc,
                                     &pipe_config->fdi_m_n, NULL);
 }
 
+static void skylake_get_pfit_config(struct intel_crtc *crtc,
+                                   struct intel_crtc_config *pipe_config)
+{
+       struct drm_device *dev = crtc->base.dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       uint32_t tmp;
+
+       tmp = I915_READ(PS_CTL(crtc->pipe));
+
+       if (tmp & PS_ENABLE) {
+               pipe_config->pch_pfit.enabled = true;
+               pipe_config->pch_pfit.pos = I915_READ(PS_WIN_POS(crtc->pipe));
+               pipe_config->pch_pfit.size = I915_READ(PS_WIN_SZ(crtc->pipe));
+       }
+}
+
 static void ironlake_get_pfit_config(struct intel_crtc *crtc,
                                     struct intel_crtc_config *pipe_config)
 {
@@ -7940,8 +7989,12 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
        intel_get_pipe_timings(crtc, pipe_config);
 
        pfit_domain = POWER_DOMAIN_PIPE_PANEL_FITTER(crtc->pipe);
-       if (intel_display_power_enabled(dev_priv, pfit_domain))
-               ironlake_get_pfit_config(crtc, pipe_config);
+       if (intel_display_power_enabled(dev_priv, pfit_domain)) {
+               if (IS_SKYLAKE(dev))
+                       skylake_get_pfit_config(crtc, pipe_config);
+               else
+                       ironlake_get_pfit_config(crtc, pipe_config);
+       }
 
        if (IS_HASWELL(dev))
                pipe_config->ips_enabled = hsw_crtc_supports_ips(crtc) &&
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#237 lore raw

Re: [PATCH 75/89] drm/i915/skl: fetch, enable/disable pfit as needed

Hi Jesse,

Mind looking at those review comments?

Signature · 1 line
Damien
Quoted 173 lines · Paulo Zanoni

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 17 lines

From: Jesse Barnes <[email protected]>

This moved around on SKL, so we need to make sure we read/write the correct regs.

---
 drivers/gpu/drm/i915/i915_reg.h      | 13 ++++++++
 drivers/gpu/drm/i915/intel_display.c | 61 +++++++++++++++++++++++++++++++++---
 2 files changed, 70 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +0 -0
index 176e84e..35c0759 100644

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 4839

Quoted 7 lines
drivers/gpu/drm/i915/i915_reg.h +4 -0
@@ -4833,6 +4833,19 @@ enum skl_disp_power_wells {
 #define PF_VSCALE(pipe)                _PIPE(pipe, _PFA_VSCALE, _PFB_VSCALE)
 #define PF_HSCALE(pipe)                _PIPE(pipe, _PFA_HSCALE, _PFB_HSCALE)
 
+#define _PSA_CTL               0x68180
+#define _PSB_CTL               0x68980
+#define PS_ENABLE              (1<<31)
+#define PS_PIPE_SEL(pipe)      ((pipe)<<27)

The PS_PIPE_SEL define is wrong, but it is also not used in the code you wrote, so just remove this line.

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 4842

Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +3 -0
+#define _PSA_WIN_SZ            0x68174
+#define _PSB_WIN_SZ            0x68974
+#define _PSA_WIN_POS           0x68178

0x68170

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 4843

Quoted 1 line
drivers/gpu/drm/i915/i915_reg.h +1 -0
+#define _PSB_WIN_POS           0x68978

0x68970

Quoted 49 lines
drivers/gpu/drm/i915/i915_reg.h +5 -0
+
+#define PS_CTL(pipe)           _PIPE(pipe, _PSA_CTL, _PSB_CTL)
+#define PS_WIN_SZ(pipe)                _PIPE(pipe, _PSA_WIN_SZ, _PSB_WIN_SZ)
+#define PS_WIN_POS(pipe)       _PIPE(pipe, _PSA_WIN_POS, _PSB_WIN_POS)
+
 /* legacy palette */
 #define _LGC_PALETTE_A           0x4a000
 #define _LGC_PALETTE_B           0x4a800
drivers/gpu/drm/i915/intel_display.c +18 -1
index 393bd19..9b31342 100644
@@ -3882,6 +3882,19 @@ static void cpt_verify_modeset(struct drm_device *dev, int pipe)
        }
 }
 
+static void skylake_pfit_enable(struct intel_crtc *crtc)
+{
+       struct drm_device *dev = crtc->base.dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       int pipe = crtc->pipe;
+
+       if (crtc->config.pch_pfit.enabled) {
+               I915_WRITE(PS_CTL(pipe), PS_ENABLE);
+               I915_WRITE(PS_WIN_POS(pipe), crtc->config.pch_pfit.pos);
+               I915_WRITE(PS_WIN_SZ(pipe), crtc->config.pch_pfit.size);
+       }
+}
+
 static void ironlake_pfit_enable(struct intel_crtc *crtc)
 {
        struct drm_device *dev = crtc->base.dev;
@@ -4264,7 +4277,10 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 
        intel_ddi_enable_pipe_clock(intel_crtc);
 
-       ironlake_pfit_enable(intel_crtc);
+       if (IS_SKYLAKE(dev))
+               skylake_pfit_enable(intel_crtc);
+       else
+               ironlake_pfit_enable(intel_crtc);
 
        /*
         * On ILK+ LUT must be loaded before the pipe is running but with
@@ -4295,6 +4311,20 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
        intel_crtc_enable_planes(crtc);
 }
 
+static void skylake_pfit_disable(struct intel_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc) · line 4324

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+{
+       struct drm_device *dev = crtc->base.dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       int pipe = crtc->pipe;
+
+       /* To avoid upsetting the power well on haswell only disable the pfit if
+        * it's in use. The hw state code will make sure we get this right. */
+       if (crtc->config.pch_pfit.enabled) {
+               I915_WRITE(PS_CTL(pipe), 0);
+               I915_WRITE(PS_WIN_SZ(pipe), 0);

Why not also zero _POS just like HSW? Can this affect the HW state checker output?

Everything else looks correct.

Quoted 63 lines
drivers/gpu/drm/i915/intel_display.c +29 -4
+       }
+}
+
 static void ironlake_pfit_disable(struct intel_crtc *crtc)
 {
        struct drm_device *dev = crtc->base.dev;
@@ -4399,7 +4429,10 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 
        intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
-       ironlake_pfit_disable(intel_crtc);
+       if (IS_SKYLAKE(dev))
+               skylake_pfit_disable(intel_crtc);
+       else
+               ironlake_pfit_disable(intel_crtc);
 
        intel_ddi_disable_pipe_clock(intel_crtc);
 
@@ -7382,6 +7415,22 @@ static void ironlake_get_fdi_m_n_config(struct intel_crtc *crtc,
                                     &pipe_config->fdi_m_n, NULL);
 }
 
+static void skylake_get_pfit_config(struct intel_crtc *crtc,
+                                   struct intel_crtc_config *pipe_config)
+{
+       struct drm_device *dev = crtc->base.dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       uint32_t tmp;
+
+       tmp = I915_READ(PS_CTL(crtc->pipe));
+
+       if (tmp & PS_ENABLE) {
+               pipe_config->pch_pfit.enabled = true;
+               pipe_config->pch_pfit.pos = I915_READ(PS_WIN_POS(crtc->pipe));
+               pipe_config->pch_pfit.size = I915_READ(PS_WIN_SZ(crtc->pipe));
+       }
+}
+
 static void ironlake_get_pfit_config(struct intel_crtc *crtc,
                                     struct intel_crtc_config *pipe_config)
 {
@@ -7940,8 +7989,12 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
        intel_get_pipe_timings(crtc, pipe_config);
 
        pfit_domain = POWER_DOMAIN_PIPE_PANEL_FITTER(crtc->pipe);
-       if (intel_display_power_enabled(dev_priv, pfit_domain))
-               ironlake_get_pfit_config(crtc, pipe_config);
+       if (intel_display_power_enabled(dev_priv, pfit_domain)) {
+               if (IS_SKYLAKE(dev))
+                       skylake_get_pfit_config(crtc, pipe_config);
+               else
+                       ironlake_get_pfit_config(crtc, pipe_config);
+       }
 
        if (IS_HASWELL(dev))
                pipe_config->ips_enabled = hsw_crtc_supports_ips(crtc) &&
--

1.8.3.1

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

Signature · 1 line
Paulo Zanoni
#238 lore raw

Re: [PATCH 75/89] drm/i915/skl: fetch, enable/disable pfit as needed

In reply to Paulo Zanoni
Quoted 21 lines · On Tue, 23 Sep 2014 17:50:29 -0300 Paulo Zanoni <[email protected]> wrote:

2014-09-04 8:27 GMT-03:00 Damien Lespiau <[email protected]>:

Quoted 20 lines

From: Jesse Barnes <[email protected]>

This moved around on SKL, so we need to make sure we read/write the correct regs.

---
 drivers/gpu/drm/i915/i915_reg.h      | 13 ++++++++
 drivers/gpu/drm/i915/intel_display.c | 61 +++++++++++++++++++++++++++++++++---
 2 files changed, 70 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +0 -0
index 176e84e..35c0759 100644
@@ -4833,6 +4833,19 @@ enum skl_disp_power_wells {
 #define PF_VSCALE(pipe)                _PIPE(pipe, _PFA_VSCALE, _PFB_VSCALE)
 #define PF_HSCALE(pipe)                _PIPE(pipe, _PFA_HSCALE, _PFB_HSCALE)
 
Quoted 7 lines

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 4839

Quoted 4 lines
drivers/gpu/drm/i915/i915_reg.h +4 -0
+#define _PSA_CTL               0x68180
+#define _PSB_CTL               0x68980
+#define PS_ENABLE              (1<<31)
+#define PS_PIPE_SEL(pipe)      ((pipe)<<27)

The PS_PIPE_SEL define is wrong, but it is also not used in the code you wrote, so just remove this line.

Yeah that sounds fine.

Quoted 11 lines

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 4842

Quoted 5 lines
drivers/gpu/drm/i915/i915_reg.h +3 -0
+#define _PSA_WIN_SZ            0x68174
+#define _PSB_WIN_SZ            0x68974
+#define _PSA_WIN_POS           0x68178

0x68170

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 4843

Quoted 1 line
drivers/gpu/drm/i915/i915_reg.h +1 -0
+#define _PSB_WIN_POS           0x68978

0x68970

Ooh thanks.

Quoted 64 lines
Quoted 50 lines
drivers/gpu/drm/i915/i915_reg.h +5 -0
+
+#define PS_CTL(pipe)           _PIPE(pipe, _PSA_CTL, _PSB_CTL)
+#define PS_WIN_SZ(pipe)                _PIPE(pipe, _PSA_WIN_SZ, _PSB_WIN_SZ)
+#define PS_WIN_POS(pipe)       _PIPE(pipe, _PSA_WIN_POS, _PSB_WIN_POS)
+
 /* legacy palette */
 #define _LGC_PALETTE_A           0x4a000
 #define _LGC_PALETTE_B           0x4a800
drivers/gpu/drm/i915/intel_display.c +18 -1
index 393bd19..9b31342 100644
@@ -3882,6 +3882,19 @@ static void cpt_verify_modeset(struct drm_device *dev, int pipe)
        }
 }
 
+static void skylake_pfit_enable(struct intel_crtc *crtc)
+{
+       struct drm_device *dev = crtc->base.dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       int pipe = crtc->pipe;
+
+       if (crtc->config.pch_pfit.enabled) {
+               I915_WRITE(PS_CTL(pipe), PS_ENABLE);
+               I915_WRITE(PS_WIN_POS(pipe), crtc->config.pch_pfit.pos);
+               I915_WRITE(PS_WIN_SZ(pipe), crtc->config.pch_pfit.size);
+       }
+}
+
 static void ironlake_pfit_enable(struct intel_crtc *crtc)
 {
        struct drm_device *dev = crtc->base.dev;
@@ -4264,7 +4277,10 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 
        intel_ddi_enable_pipe_clock(intel_crtc);
 
-       ironlake_pfit_enable(intel_crtc);
+       if (IS_SKYLAKE(dev))
+               skylake_pfit_enable(intel_crtc);
+       else
+               ironlake_pfit_enable(intel_crtc);
 
        /*
         * On ILK+ LUT must be loaded before the pipe is running but with
@@ -4295,6 +4311,20 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
        intel_crtc_enable_planes(crtc);
 }
 
+static void skylake_pfit_disable(struct intel_crtc *crtc)

drivers/gpu/drm/i915/intel_display.c static void haswell_crtc_enable(struct drm_crtc *crtc) · line 4324

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+{
+       struct drm_device *dev = crtc->base.dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       int pipe = crtc->pipe;
+
+       /* To avoid upsetting the power well on haswell only disable the pfit if
+        * it's in use. The hw state code will make sure we get this right. */
+       if (crtc->config.pch_pfit.enabled) {
+               I915_WRITE(PS_CTL(pipe), 0);
+               I915_WRITE(PS_WIN_SZ(pipe), 0);

Why not also zero _POS just like HSW? Can this affect the HW state checker output?

Quoted 1 line

Everything else looks correct.

The checker will only if the fitter is enabled, but yeah it looks like it would be safer to zero it.

Damien, did you want to make these changes as part of your re-post or should I send an updated patch to replace this one?

Thanks,

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#239 lore raw

Re: [PATCH 75/89] drm/i915/skl: fetch, enable/disable pfit as needed

Quoted 2 lines · Jesse Barnes

Damien, did you want to make these changes as part of your re-post or should I send an updated patch to replace this one?

I wasn't planning to go through this one but let the author works for his commit :)

Signature · 1 line
Damien
#240 lore raw

PATCH 1/1 drm/i915/skl: fetch, enable/disable pfit as needed v2

In reply to Damien Lespiau

This moved around on SKL, so we need to make sure we read/write the correct regs.

v2: fixup WIN_POS offsets (Paulo)
zero out WIN_POS reg at disable time (Paulo)

---
 drivers/gpu/drm/i915/i915_reg.h      | 12 +++++++
 drivers/gpu/drm/i915/intel_display.c | 62 +++++++++++++++++++++++++++++++++---
 2 files changed, 70 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +12 -0
index 6f5a70f..44133fb 100644
@@ -4760,6 +4760,18 @@ enum punit_power_well {
 #define PF_VSCALE(pipe)		_PIPE(pipe, _PFA_VSCALE, _PFB_VSCALE)
 #define PF_HSCALE(pipe)		_PIPE(pipe, _PFA_HSCALE, _PFB_HSCALE)
 
+#define _PSA_CTL		0x68180
+#define _PSB_CTL		0x68980
+#define PS_ENABLE		(1<<31)
+#define _PSA_WIN_SZ		0x68174
+#define _PSB_WIN_SZ		0x68974
+#define _PSA_WIN_POS		0x68170
+#define _PSB_WIN_POS		0x68970
+
+#define PS_CTL(pipe)		_PIPE(pipe, _PSA_CTL, _PSB_CTL)
+#define PS_WIN_SZ(pipe)		_PIPE(pipe, _PSA_WIN_SZ, _PSB_WIN_SZ)
+#define PS_WIN_POS(pipe)	_PIPE(pipe, _PSA_WIN_POS, _PSB_WIN_POS)
+
 /* legacy palette */
 #define _LGC_PALETTE_A           0x4a000
 #define _LGC_PALETTE_B           0x4a800
drivers/gpu/drm/i915/intel_display.c +58 -4

98 lines not on this page · raw message

Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#241 lore raw

Re: [PATCH] drm/i915/skl: fetch, enable/disable pfit as needed v2

2014-09-25 14:58 GMT-03:00 Jesse Barnes <[email protected]>:

Quoted 5 lines

This moved around on SKL, so we need to make sure we read/write the correct regs.

v2: fixup WIN_POS offsets (Paulo)
zero out WIN_POS reg at disable time (Paulo)

Quoted 146 lines
---
 drivers/gpu/drm/i915/i915_reg.h      | 12 +++++++
 drivers/gpu/drm/i915/intel_display.c | 62 +++++++++++++++++++++++++++++++++---
 2 files changed, 70 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +12 -0
index 6f5a70f..44133fb 100644
@@ -4760,6 +4760,18 @@ enum punit_power_well {
 #define PF_VSCALE(pipe)                _PIPE(pipe, _PFA_VSCALE, _PFB_VSCALE)
 #define PF_HSCALE(pipe)                _PIPE(pipe, _PFA_HSCALE, _PFB_HSCALE)
 
+#define _PSA_CTL               0x68180
+#define _PSB_CTL               0x68980
+#define PS_ENABLE              (1<<31)
+#define _PSA_WIN_SZ            0x68174
+#define _PSB_WIN_SZ            0x68974
+#define _PSA_WIN_POS           0x68170
+#define _PSB_WIN_POS           0x68970
+
+#define PS_CTL(pipe)           _PIPE(pipe, _PSA_CTL, _PSB_CTL)
+#define PS_WIN_SZ(pipe)                _PIPE(pipe, _PSA_WIN_SZ, _PSB_WIN_SZ)
+#define PS_WIN_POS(pipe)       _PIPE(pipe, _PSA_WIN_POS, _PSB_WIN_POS)
+
 /* legacy palette */
 #define _LGC_PALETTE_A           0x4a000
 #define _LGC_PALETTE_B           0x4a800
drivers/gpu/drm/i915/intel_display.c +58 -5
index b8488a8..550cde3 100644
@@ -3911,6 +3911,19 @@ static void cpt_verify_modeset(struct drm_device *dev, int pipe)
        }
 }
 
+static void skylake_pfit_enable(struct intel_crtc *crtc)
+{
+       struct drm_device *dev = crtc->base.dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       int pipe = crtc->pipe;
+
+       if (crtc->config.pch_pfit.enabled) {
+               I915_WRITE(PS_CTL(pipe), PS_ENABLE);
+               I915_WRITE(PS_WIN_POS(pipe), crtc->config.pch_pfit.pos);
+               I915_WRITE(PS_WIN_SZ(pipe), crtc->config.pch_pfit.size);
+       }
+}
+
 static void ironlake_pfit_enable(struct intel_crtc *crtc)
 {
        struct drm_device *dev = crtc->base.dev;
@@ -4288,7 +4301,10 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 
        intel_ddi_enable_pipe_clock(intel_crtc);
 
-       ironlake_pfit_enable(intel_crtc);
+       if (IS_SKYLAKE(dev))
+               skylake_pfit_enable(intel_crtc);
+       else
+               ironlake_pfit_enable(intel_crtc);
 
        /*
         * On ILK+ LUT must be loaded before the pipe is running but with
@@ -4322,6 +4338,21 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
        intel_crtc_enable_planes(crtc);
 }
 
+static void skylake_pfit_disable(struct intel_crtc *crtc)
+{
+       struct drm_device *dev = crtc->base.dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       int pipe = crtc->pipe;
+
+       /* To avoid upsetting the power well on haswell only disable the pfit if
+        * it's in use. The hw state code will make sure we get this right. */
+       if (crtc->config.pch_pfit.enabled) {
+               I915_WRITE(PS_CTL(pipe), 0);
+               I915_WRITE(PS_WIN_POS(pipe), 0);
+               I915_WRITE(PS_WIN_SZ(pipe), 0);
+       }
+}
+
 static void ironlake_pfit_disable(struct intel_crtc *crtc)
 {
        struct drm_device *dev = crtc->base.dev;
@@ -4433,7 +4464,10 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 
        intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
 
-       ironlake_pfit_disable(intel_crtc);
+       if (IS_SKYLAKE(dev))
+               skylake_pfit_disable(intel_crtc);
+       else
+               ironlake_pfit_disable(intel_crtc);
 
        intel_ddi_disable_pipe_clock(intel_crtc);
 
@@ -7412,6 +7446,22 @@ static void ironlake_get_fdi_m_n_config(struct intel_crtc *crtc,
                                     &pipe_config->fdi_m_n, NULL);
 }
 
+static void skylake_get_pfit_config(struct intel_crtc *crtc,
+                                   struct intel_crtc_config *pipe_config)
+{
+       struct drm_device *dev = crtc->base.dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       uint32_t tmp;
+
+       tmp = I915_READ(PS_CTL(crtc->pipe));
+
+       if (tmp & PS_ENABLE) {
+               pipe_config->pch_pfit.enabled = true;
+               pipe_config->pch_pfit.pos = I915_READ(PS_WIN_POS(crtc->pipe));
+               pipe_config->pch_pfit.size = I915_READ(PS_WIN_SZ(crtc->pipe));
+       }
+}
+
 static void ironlake_get_pfit_config(struct intel_crtc *crtc,
                                     struct intel_crtc_config *pipe_config)
 {
@@ -7944,8 +7994,12 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
        intel_get_pipe_timings(crtc, pipe_config);
 
        pfit_domain = POWER_DOMAIN_PIPE_PANEL_FITTER(crtc->pipe);
-       if (intel_display_power_enabled(dev_priv, pfit_domain))
-               ironlake_get_pfit_config(crtc, pipe_config);
+       if (intel_display_power_enabled(dev_priv, pfit_domain)) {
+               if (IS_SKYLAKE(dev))
+                       skylake_get_pfit_config(crtc, pipe_config);
+               else
+                       ironlake_get_pfit_config(crtc, pipe_config);
+       }
 
        if (IS_HASWELL(dev))
                pipe_config->ips_enabled = hsw_crtc_supports_ips(crtc) &&
--

1.9.1

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

Signature · 1 line
Paulo Zanoni
#242 lore raw

Re: [PATCH] drm/i915/skl: fetch, enable/disable pfit as needed v2

Quoted 8 lines · Paulo Zanoni

2014-09-25 14:58 GMT-03:00 Jesse Barnes <[email protected]>:

Quoted 5 lines

This moved around on SKL, so we need to make sure we read/write the correct regs.

v2: fixup WIN_POS offsets (Paulo)
zero out WIN_POS reg at disable time (Paulo)

Thanks for the patch and review, I've queued it in my SKL branch that's queued for Daniel.

Signature · 1 line
Damien
#243 lore raw

PATCH 76/89 drm/i915/skl: Store the new WM state at the very end of the update

In reply to Damien Lespiau

We're going to add a new step, let's not hide the copy of the new WM state inside one inner function, but as a 1st level operation in the WM update.

v2: Split the staging results structure to not exceed the 1Kb stack
allocation in skl_update_wm()

---
 drivers/gpu/drm/i915/intel_pm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +3 -2
index 5425d85..7f7a2e2 100644
@@ -3432,8 +3432,6 @@ static void skl_write_wm_values(struct drm_i915_private *dev_priv,
 				   new->ddb.cursor[pipe].start);
 		}
 	}
-
-	dev_priv->wm.skl_hw = *new;
 }
 
 static bool skl_update_pipe_wm(struct drm_crtc *crtc,
@@ -3527,6 +3525,9 @@ static void skl_update_wm(struct drm_crtc *crtc)
 
 	skl_update_other_pipe_wm(dev, crtc, &config, results);
 	skl_write_wm_values(dev_priv, results);
+
+	/* store the new configuration */
+	dev_priv->wm.skl_hw = *results;
 }
 
 static void
Signature · 1 line
1.8.3.1
Reviewed-by on v1 76/89
#244 lore raw

Re: [PATCH 76/89] drm/i915/skl: Store the new WM state at the very end of the update

Quoted 3 lines · Damien Lespiau

We're going to add a new step, let's not hide the copy of the new WM state inside one inner function, but as a 1st level operation in the WM update.

The new step being the flush which needs to compare the currnet and new ddb state to figure out how to perform the update.

Quoted 40 lines

v2: Split the staging results structure to not exceed the 1Kb stack
allocation in skl_update_wm()

---
 drivers/gpu/drm/i915/intel_pm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +3 -2
index 5425d85..7f7a2e2 100644
@@ -3432,8 +3432,6 @@ static void skl_write_wm_values(struct drm_i915_private *dev_priv,
 				   new->ddb.cursor[pipe].start);
 		}
 	}
-
-	dev_priv->wm.skl_hw = *new;
 }
 
 static bool skl_update_pipe_wm(struct drm_crtc *crtc,
@@ -3527,6 +3525,9 @@ static void skl_update_wm(struct drm_crtc *crtc)
 
 	skl_update_other_pipe_wm(dev, crtc, &config, results);
 	skl_write_wm_values(dev_priv, results);
+
+	/* store the new configuration */
+	dev_priv->wm.skl_hw = *results;
 }
 
 static void
Signature · 6 lines
1.8.3.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#245 lore raw

PATCH 77/89 drm/i915: Introduce a for_each_plane() macro

In reply to Damien Lespiau

Tired of copy/pasting things around.

v2: Rebase on top of the for_each_pipe() change adding dev_priv as first
argument.

---
 drivers/gpu/drm/i915/i915_drv.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 91ea2b7..95e57dc 100644
@@ -176,6 +176,8 @@ enum hpd_pin {
 
 #define for_each_pipe(__dev_priv, __p) \
 	for ((__p) = 0; (__p) < INTEL_INFO(__dev_priv)->num_pipes; (__p)++)
+#define for_each_plane(pipe, p) \
+	for ((p) = 0; (p) < INTEL_INFO(dev)->num_sprites[(pipe)] + 1; (p)++)
 #define for_each_sprite(p, s) for ((s) = 0; (s) < INTEL_INFO(dev)->num_sprites[(p)]; (s)++)
 
 #define for_each_crtc(dev, crtc) \
Signature · 1 line
1.8.3.1
#246 lore raw

Re: [PATCH 77/89] drm/i915: Introduce a for_each_plane() macro

Quoted 6 lines · Damien Lespiau

Tired of copy/pasting things around.

v2: Rebase on top of the for_each_pipe() change adding dev_priv as first
argument.

Queued for -next, thanks for the patch.
-Daniel

Quoted 24 lines
---
 drivers/gpu/drm/i915/i915_drv.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 91ea2b7..95e57dc 100644
@@ -176,6 +176,8 @@ enum hpd_pin {
 
 #define for_each_pipe(__dev_priv, __p) \
 	for ((__p) = 0; (__p) < INTEL_INFO(__dev_priv)->num_pipes; (__p)++)
+#define for_each_plane(pipe, p) \
+	for ((p) = 0; (p) < INTEL_INFO(dev)->num_sprites[(pipe)] + 1; (p)++)
 #define for_each_sprite(p, s) for ((s) = 0; (s) < INTEL_INFO(dev)->num_sprites[(p)]; (s)++)
 
 #define for_each_crtc(dev, crtc) \
Signature · 6 lines
1.8.3.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#247 lore raw

Re: [PATCH 77/89] drm/i915: Introduce a for_each_plane() macro

In reply to Damien Lespiau
Quoted 15 lines · Damien Lespiau

Tired of copy/pasting things around.

v2: Rebase on top of the for_each_pipe() change adding dev_priv as first
argument.

---
 drivers/gpu/drm/i915/i915_drv.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 91ea2b7..95e57dc 100644

drivers/gpu/drm/i915/i915_drv.h enum hpd_pin { · line 180

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -176,6 +176,8 @@ enum hpd_pin {
 
 #define for_each_pipe(__dev_priv, __p) \
 	for ((__p) = 0; (__p) < INTEL_INFO(__dev_priv)->num_pipes; (__p)++)
+#define for_each_plane(pipe, p) \
+	for ((p) = 0; (p) < INTEL_INFO(dev)->num_sprites[(pipe)] + 1; (p)++)

We are adding new magic macros taking dev...

drivers/gpu/drm/i915/i915_drv.h enum hpd_pin { · line 181

Quoted 1 line
drivers/gpu/drm/i915/i915_drv.h +0 -0
 #define for_each_sprite(p, s) for ((s) = 0; (s) < INTEL_INFO(dev)->num_sprites[(p)]; (s)++)

I haven't asked you to fix this one yet either.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#248 lore raw

Re: [PATCH 77/89] drm/i915: Introduce a for_each_plane() macro

Quoted 24 lines · Chris Wilson
Quoted 15 lines · Damien Lespiau

Tired of copy/pasting things around.

v2: Rebase on top of the for_each_pipe() change adding dev_priv as first
argument.

---
 drivers/gpu/drm/i915/i915_drv.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 91ea2b7..95e57dc 100644

drivers/gpu/drm/i915/i915_drv.h enum hpd_pin { · line 180

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -176,6 +176,8 @@ enum hpd_pin {
 
 #define for_each_pipe(__dev_priv, __p) \
 	for ((__p) = 0; (__p) < INTEL_INFO(__dev_priv)->num_pipes; (__p)++)
+#define for_each_plane(pipe, p) \
+	for ((p) = 0; (p) < INTEL_INFO(dev)->num_sprites[(pipe)] + 1; (p)++)

We are adding new magic macros taking dev...

Quoted 2 lines

drivers/gpu/drm/i915/i915_drv.h enum hpd_pin { · line 181

Quoted 1 line
drivers/gpu/drm/i915/i915_drv.h +0 -0
 #define for_each_sprite(p, s) for ((s) = 0; (s) < INTEL_INFO(dev)->num_sprites[(p)]; (s)++)

I haven't asked you to fix this one yet either.

Ok, dropping again for now ...
-Daniel

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

Re: [PATCH 77/89] drm/i915: Introduce a for_each_plane() macro

Quoted 25 lines · Daniel Vetter
Quoted 24 lines · Chris Wilson
Quoted 15 lines · Damien Lespiau

Tired of copy/pasting things around.

v2: Rebase on top of the for_each_pipe() change adding dev_priv as first
argument.

---
 drivers/gpu/drm/i915/i915_drv.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 91ea2b7..95e57dc 100644

drivers/gpu/drm/i915/i915_drv.h enum hpd_pin { · line 180

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -176,6 +176,8 @@ enum hpd_pin {
 
 #define for_each_pipe(__dev_priv, __p) \
 	for ((__p) = 0; (__p) < INTEL_INFO(__dev_priv)->num_pipes; (__p)++)
+#define for_each_plane(pipe, p) \
+	for ((p) = 0; (p) < INTEL_INFO(dev)->num_sprites[(pipe)] + 1; (p)++)

We are adding new magic macros taking dev...

Quoted 4 lines
Quoted 2 lines

drivers/gpu/drm/i915/i915_drv.h enum hpd_pin { · line 181

Quoted 1 line
drivers/gpu/drm/i915/i915_drv.h +0 -0
 #define for_each_sprite(p, s) for ((s) = 0; (s) < INTEL_INFO(dev)->num_sprites[(p)]; (s)++)

I haven't asked you to fix this one yet either.

Ok, dropping again for now ...

The problem is that I then need to touch the patches that depend on it, some not very interesting manipulations. Can't we have this as is and I'll fix later?

Signature · 1 line
Damien
#250 lore raw

Re: [PATCH 77/89] drm/i915: Introduce a for_each_plane() macro

Quoted 26 lines · Damien Lespiau
Quoted 25 lines · Daniel Vetter
Quoted 24 lines · Chris Wilson
Quoted 15 lines · Damien Lespiau

Tired of copy/pasting things around.

v2: Rebase on top of the for_each_pipe() change adding dev_priv as first
argument.

---
 drivers/gpu/drm/i915/i915_drv.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 91ea2b7..95e57dc 100644

drivers/gpu/drm/i915/i915_drv.h enum hpd_pin { · line 180

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -176,6 +176,8 @@ enum hpd_pin {
 
 #define for_each_pipe(__dev_priv, __p) \
 	for ((__p) = 0; (__p) < INTEL_INFO(__dev_priv)->num_pipes; (__p)++)
+#define for_each_plane(pipe, p) \
+	for ((p) = 0; (p) < INTEL_INFO(dev)->num_sprites[(pipe)] + 1; (p)++)

We are adding new magic macros taking dev...

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

drivers/gpu/drm/i915/i915_drv.h enum hpd_pin { · line 181

Quoted 1 line
drivers/gpu/drm/i915/i915_drv.h +0 -0
 #define for_each_sprite(p, s) for ((s) = 0; (s) < INTEL_INFO(dev)->num_sprites[(p)]; (s)++)

I haven't asked you to fix this one yet either.

Ok, dropping again for now ...

The problem is that I then need to touch the patches that depend on it, some not very interesting manipulations. Can't we have this as is and I'll fix later?

Ok.

Queued for -next again, thanks for the patch.
-Daniel

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

Re: [PATCH 77/89] drm/i915: Introduce a for_each_plane() macro

In reply to Chris Wilson
Quoted 7 lines · Chris Wilson

drivers/gpu/drm/i915/i915_drv.h enum hpd_pin { · line 180

Quoted 2 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
+#define for_each_plane(pipe, p) \
+	for ((p) = 0; (p) < INTEL_INFO(dev)->num_sprites[(pipe)] + 1; (p)++)

We are adding new magic macros taking dev...

Quoted 1 line

#define for_each_sprite(p, s) for ((s) = 0; (s) < INTEL_INFO(dev)->num_sprites[(p)]; (s)++)

I haven't asked you to fix this one yet either.

I hereby promise I'll add those dev_priv arguments as followup up patches.

Signature · 1 line
Damien
#252 lore raw

PATCH 78/89 drm/i915/skl: Flush the WM configuration

In reply to Damien Lespiau

When we write new values for the DDB allocation and WM parameters, we now need to trigger the double buffer update for the pipe to take the new configuration into account.

As the DDB is a global resource shared between planes, enabling or disabling one plane will result in changes for all planes that are currently in use, thus the need write PLANE_SURF/CUR_BASE for more than the plane we're touching.

v2: Don't wait for pipes that are off

v3: Split the staging results structure to not exceed the 1Kb stack
allocation in skl_update_wm()

---
 drivers/gpu/drm/i915/intel_pm.c | 92 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +92 -0
index 7f7a2e2..d378879 100644
@@ -3198,6 +3198,22 @@ static bool skl_ddb_allocation_changed(const struct skl_ddb_allocation *new_ddb,
 	return false;
 }
 
+static unsigned int
+skl_ddb_pipe_allocation_size(const struct skl_ddb_allocation *ddb,
+			     const struct intel_crtc *intel_crtc)
+{
+	struct drm_device *dev = intel_crtc->base.dev;
+	unsigned int size = 0;
+	enum pipe pipe = intel_crtc->pipe;
+	int plane;
+
+	for_each_plane(pipe, plane)
+		size += skl_ddb_entry_size(&ddb->plane[pipe][plane]);
+	size += skl_ddb_entry_size(&ddb->cursor[pipe]);
+
+	return size;
+}
+
 static void skl_compute_wm_global_parameters(struct drm_device *dev,
 					     struct intel_wm_config *config)
 {
@@ -3434,6 +3450,81 @@ static void skl_write_wm_values(struct drm_i915_private *dev_priv,
 	}
 }
 
+static void skl_wm_flush_pipe(struct drm_i915_private *dev_priv, enum pipe pipe)
+{
+	struct drm_device *dev = dev_priv->dev;
+	int plane;
+
+	for_each_plane(pipe, plane) {
+		I915_WRITE(PLANE_SURF(pipe, plane),
+			   I915_READ(PLANE_SURF(pipe, plane)));
+	}
+	I915_WRITE(CURBASE(pipe), I915_READ(CURBASE(pipe)));
+}
+
+static void skl_flush_wm_values(struct drm_i915_private *dev_priv,
+				struct skl_wm_values *new_values)
+{
+	struct drm_device *dev = dev_priv->dev;
+	struct skl_ddb_allocation *cur_ddb, *new_ddb;
+	unsigned int cur_size[I915_MAX_PIPES], new_size[I915_MAX_PIPES];
+	struct intel_crtc *crtc;
+	enum pipe pipe;
+
+	new_ddb = &new_values->ddb;
+	cur_ddb = &dev_priv->wm.skl_hw.ddb;
+
+	/*
+	 * Start by computing the total allocated space for each pipe as we
+	 * need that values for the two passes.
+	 */
+	for_each_intel_crtc(dev, crtc) {
+		pipe = crtc->pipe;
+		new_size[pipe] = skl_ddb_pipe_allocation_size(new_ddb, crtc);
+		cur_size[pipe] = skl_ddb_pipe_allocation_size(cur_ddb, crtc);
+	}
+
+	/*
+	 * First pass: we flush the pipes that had their allocation reduced.
+	 *
+	 * We then have to wait until the pipe stops fetching pixels from the
+	 * previous allocation. This way, pipes that have just been allocated
+	 * more space won't try to fetch pixels belonging to a different pipe.
+	 */
+	for_each_intel_crtc(dev, crtc) {
+		if (!crtc->active)
+			continue;
+
+		pipe = crtc->pipe;
+
+		if (new_size[pipe] < cur_size[pipe]) {
+			skl_wm_flush_pipe(dev_priv, pipe);
+			intel_wait_for_vblank(dev, pipe);
+		}
+	}
+
+	/*
+	 * Second pass: flush the pipes that got more allocated space.
+	 *
+	 * We don't need to actively wait for the update here, next vblank
+	 * will just get more DDB space with the correct WM values.
+	 */
+	for_each_intel_crtc(dev, crtc) {
+		if (!crtc->active)
+			continue;
+
+		pipe = crtc->pipe;
+
+		if (new_size[pipe] < cur_size[pipe])
+			continue;
+
+		if (!skl_ddb_allocation_changed(new_ddb, crtc))
+			continue;
+
+		skl_wm_flush_pipe(dev_priv, pipe);
+	}
+}
+
 static bool skl_update_pipe_wm(struct drm_crtc *crtc,
 			       struct skl_pipe_wm_parameters *params,
 			       struct intel_wm_config *config,
@@ -3525,6 +3616,7 @@ static void skl_update_wm(struct drm_crtc *crtc)
 
 	skl_update_other_pipe_wm(dev, crtc, &config, results);
 	skl_write_wm_values(dev_priv, results);
+	skl_flush_wm_values(dev_priv, results);
 
 	/* store the new configuration */
 	dev_priv->wm.skl_hw = *results;
Signature · 1 line
1.8.3.1
#253 lore raw

Re: [PATCH 78/89] drm/i915/skl: Flush the WM configuration

Quoted 8 lines · Damien Lespiau

When we write new values for the DDB allocation and WM parameters, we now need to trigger the double buffer update for the pipe to take the new configuration into account.

As the DDB is a global resource shared between planes, enabling or disabling one plane will result in changes for all planes that are currently in use, thus the need write PLANE_SURF/CUR_BASE for more than the plane we're touching.

Ah, so here's the sequenced DDB update logic I was looking for.

Quoted 43 lines

v2: Don't wait for pipes that are off

v3: Split the staging results structure to not exceed the 1Kb stack
allocation in skl_update_wm()

---
 drivers/gpu/drm/i915/intel_pm.c | 92 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +17 -0
index 7f7a2e2..d378879 100644
@@ -3198,6 +3198,22 @@ static bool skl_ddb_allocation_changed(const struct skl_ddb_allocation *new_ddb,
 	return false;
 }
 
+static unsigned int
+skl_ddb_pipe_allocation_size(const struct skl_ddb_allocation *ddb,
+			     const struct intel_crtc *intel_crtc)
+{
+	struct drm_device *dev = intel_crtc->base.dev;
+	unsigned int size = 0;
+	enum pipe pipe = intel_crtc->pipe;
+	int plane;
+
+	for_each_plane(pipe, plane)
+		size += skl_ddb_entry_size(&ddb->plane[pipe][plane]);
+	size += skl_ddb_entry_size(&ddb->cursor[pipe]);
+
+	return size;
+}
+
 static void skl_compute_wm_global_parameters(struct drm_device *dev,
 					     struct intel_wm_config *config)
 {
@@ -3434,6 +3450,81 @@ static void skl_write_wm_values(struct drm_i915_private *dev_priv,
 	}
 }
 
+static void skl_wm_flush_pipe(struct drm_i915_private *dev_priv, enum pipe pipe)

drivers/gpu/drm/i915/intel_pm.c static void skl_write_wm_values(struct drm_i915_private *dev_priv, · line 3463

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+{
+	struct drm_device *dev = dev_priv->dev;
+	int plane;
+
+	for_each_plane(pipe, plane) {
+		I915_WRITE(PLANE_SURF(pipe, plane),
+			   I915_READ(PLANE_SURF(pipe, plane)));
+	}
+	I915_WRITE(CURBASE(pipe), I915_READ(CURBASE(pipe)));
+}

I'm not sure I really like this thing. The DDB/wm update should be part of the atomic pipe update. But since we're not really there yet I guess we need to start with something. And dealing with multiple pipes is a definite complication here.

Quoted 53 lines
drivers/gpu/drm/i915/intel_pm.c +53 -0
+
+static void skl_flush_wm_values(struct drm_i915_private *dev_priv,
+				struct skl_wm_values *new_values)
+{
+	struct drm_device *dev = dev_priv->dev;
+	struct skl_ddb_allocation *cur_ddb, *new_ddb;
+	unsigned int cur_size[I915_MAX_PIPES], new_size[I915_MAX_PIPES];
+	struct intel_crtc *crtc;
+	enum pipe pipe;
+
+	new_ddb = &new_values->ddb;
+	cur_ddb = &dev_priv->wm.skl_hw.ddb;
+
+	/*
+	 * Start by computing the total allocated space for each pipe as we
+	 * need that values for the two passes.
+	 */
+	for_each_intel_crtc(dev, crtc) {
+		pipe = crtc->pipe;
+		new_size[pipe] = skl_ddb_pipe_allocation_size(new_ddb, crtc);
+		cur_size[pipe] = skl_ddb_pipe_allocation_size(cur_ddb, crtc);
+	}
+
+	/*
+	 * First pass: we flush the pipes that had their allocation reduced.
+	 *
+	 * We then have to wait until the pipe stops fetching pixels from the
+	 * previous allocation. This way, pipes that have just been allocated
+	 * more space won't try to fetch pixels belonging to a different pipe.
+	 */
+	for_each_intel_crtc(dev, crtc) {
+		if (!crtc->active)
+			continue;
+
+		pipe = crtc->pipe;
+
+		if (new_size[pipe] < cur_size[pipe]) {
+			skl_wm_flush_pipe(dev_priv, pipe);
+			intel_wait_for_vblank(dev, pipe);
+		}
+	}
+
+	/*
+	 * Second pass: flush the pipes that got more allocated space.
+	 *
+	 * We don't need to actively wait for the update here, next vblank
+	 * will just get more DDB space with the correct WM values.
+	 */
+	for_each_intel_crtc(dev, crtc) {
+		if (!crtc->active)
+			continue;
+
+		pipe = crtc->pipe;

drivers/gpu/drm/i915/intel_pm.c static void skl_write_wm_values(struct drm_i915_private *dev_priv, · line 3526

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+
+		if (new_size[pipe] < cur_size[pipe])
+			continue;
+
+		if (!skl_ddb_allocation_changed(new_ddb, crtc))
+			continue;
+
+		skl_wm_flush_pipe(dev_priv, pipe);
+	}
+}

I don't think this logic will do the right thing. Consider for example when going from two pipes to three:

1. initially DDB looks like this
| B | C |
2. enable pipe A
3. reduce pipe B DDB allocation

   |     |  B..|     |
   |        |   C    |

Notice the part marked with .. is now used by both pipes B and C until the allocation for C also gets reduced. It would work correctly in case we would go AB->ABC or AC->ABC. Similar problem would be encountered when going ABC->AB. So we need more care in which order we update the DDB allocation for each pipe to avoid such overlaps.

Quoted 19 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
+
 static bool skl_update_pipe_wm(struct drm_crtc *crtc,
 			       struct skl_pipe_wm_parameters *params,
 			       struct intel_wm_config *config,
@@ -3525,6 +3616,7 @@ static void skl_update_wm(struct drm_crtc *crtc)
 
 	skl_update_other_pipe_wm(dev, crtc, &config, results);
 	skl_write_wm_values(dev_priv, results);
+	skl_flush_wm_values(dev_priv, results);
 
 	/* store the new configuration */
 	dev_priv->wm.skl_hw = *results;
Signature · 6 lines
1.8.3.1

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

PATCH 79/89 drm/i915/skl: Read back the DDB allocation hw state

In reply to Damien Lespiau

This logically belongs to the WM state, so do it there.

---
 drivers/gpu/drm/i915/intel_pm.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +29 -0
index d378879..8d24a4d 100644
@@ -3020,6 +3020,32 @@ static unsigned int skl_cursor_allocation(struct intel_wm_config *config)
 	return 8;
 }
 
+static void skl_ddb_entry_init_from_hw(struct skl_ddb_entry *entry, u32 reg)
+{
+	entry->start = reg & 0x3ff;
+	entry->end = (reg >> 16) & 0x3ff;
+}
+
+static void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
+				 struct skl_ddb_allocation *ddb /* out */)
+{
+	struct drm_device *dev = dev_priv->dev;
+	enum pipe pipe;
+	int plane;
+	u32 val;
+
+	for_each_pipe(dev_priv, pipe) {
+		for_each_plane(pipe, plane) {
+			val = I915_READ(PLANE_BUF_CFG(pipe, plane));
+			skl_ddb_entry_init_from_hw(&ddb->plane[pipe][plane],
+						   val);
+		}
+
+		val = I915_READ(CUR_BUF_CFG(pipe));
+		skl_ddb_entry_init_from_hw(&ddb->cursor[pipe], val);
+	}
+}
+
 static unsigned int
 skl_plane_relative_data_rate(struct intel_plane_wm_parameters *p)
 {
@@ -3810,8 +3836,11 @@ static void skl_pipe_wm_get_hw_state(struct drm_crtc *crtc)
 
 void skl_wm_get_hw_state(struct drm_device *dev)
 {
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct skl_ddb_allocation *ddb = &dev_priv->wm.skl_hw.ddb;
 	struct drm_crtc *crtc;
 
+	skl_ddb_get_hw_state(dev_priv, ddb);
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
 		skl_pipe_wm_get_hw_state(crtc);
 }
Signature · 1 line
1.8.3.1
Reviewed-by on v1 79/89
#255 lore raw

Re: [PATCH 79/89] drm/i915/skl: Read back the DDB allocation hw state

Quoted 12 lines · Damien Lespiau

This logically belongs to the WM state, so do it there.

---
 drivers/gpu/drm/i915/intel_pm.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +0 -0
index d378879..8d24a4d 100644

drivers/gpu/drm/i915/intel_pm.c static unsigned int skl_cursor_allocation(struct intel_wm_config *config) · line 3026

Quoted 7 lines
drivers/gpu/drm/i915/intel_pm.c +4 -0
@@ -3020,6 +3020,32 @@ static unsigned int skl_cursor_allocation(struct intel_wm_config *config)
 	return 8;
 }
 
+static void skl_ddb_entry_init_from_hw(struct skl_ddb_entry *entry, u32 reg)
+{
+	entry->start = reg & 0x3ff;
+	entry->end = (reg >> 16) & 0x3ff;

Would need a rebase in case the HW register is really inclusive and we make skl_ddb_entry.end exclusive.

Apart from that

Quoted 44 lines
drivers/gpu/drm/i915/intel_pm.c +25 -0
+}
+
+static void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
+				 struct skl_ddb_allocation *ddb /* out */)
+{
+	struct drm_device *dev = dev_priv->dev;
+	enum pipe pipe;
+	int plane;
+	u32 val;
+
+	for_each_pipe(dev_priv, pipe) {
+		for_each_plane(pipe, plane) {
+			val = I915_READ(PLANE_BUF_CFG(pipe, plane));
+			skl_ddb_entry_init_from_hw(&ddb->plane[pipe][plane],
+						   val);
+		}
+
+		val = I915_READ(CUR_BUF_CFG(pipe));
+		skl_ddb_entry_init_from_hw(&ddb->cursor[pipe], val);
+	}
+}
+
 static unsigned int
 skl_plane_relative_data_rate(struct intel_plane_wm_parameters *p)
 {
@@ -3810,8 +3836,11 @@ static void skl_pipe_wm_get_hw_state(struct drm_crtc *crtc)
 
 void skl_wm_get_hw_state(struct drm_device *dev)
 {
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct skl_ddb_allocation *ddb = &dev_priv->wm.skl_hw.ddb;
 	struct drm_crtc *crtc;
 
+	skl_ddb_get_hw_state(dev_priv, ddb);
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
 		skl_pipe_wm_get_hw_state(crtc);
 }
Signature · 6 lines
1.8.3.1

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

PATCH 80/89 drm/i915/skl: Augment the latency debugfs files for SKL

In reply to Damien Lespiau
---
 drivers/gpu/drm/i915/i915_debugfs.c | 76 ++++++++++++++++++++++++++++++-------
 1 file changed, 62 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +62 -14
index 02cb310..1520d1f 100644
@@ -3499,7 +3499,7 @@ static const struct file_operations i915_display_crc_ctl_fops = {
 	.write = display_crc_ctl_write
 };
 
-static void wm_latency_show(struct seq_file *m, const uint16_t wm[5])
+static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
 {
 	struct drm_device *dev = m->private;
 	int num_levels = ilk_wm_max_level(dev) + 1;
@@ -3510,13 +3510,17 @@ static void wm_latency_show(struct seq_file *m, const uint16_t wm[5])
 	for (level = 0; level < num_levels; level++) {
 		unsigned int latency = wm[level];
 
-		/* WM1+ latency values in 0.5us units */
-		if (level > 0)
+		/*
+		 * - WM1+ latency values in 0.5us units
+		 * - latencies are in us on gen9
+		 */
+		if (IS_GEN9(dev))
+			latency *= 10;
+		else if (level > 0)
 			latency *= 5;
 
 		seq_printf(m, "WM%d %u (%u.%u usec)\n",
-			   level, wm[level],
-			   latency / 10, latency % 10);
+			   level, wm[level], latency / 10, latency % 10);
 	}
 
 	drm_modeset_unlock_all(dev);
@@ -3525,8 +3529,15 @@ static void wm_latency_show(struct seq_file *m, const uint16_t wm[5])
 static int pri_wm_latency_show(struct seq_file *m, void *data)
 {
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const uint16_t *latencies;
+
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.pri_latency;
 
-	wm_latency_show(m, to_i915(dev)->wm.pri_latency);
+	wm_latency_show(m, latencies);
 
 	return 0;
 }
@@ -3534,8 +3545,15 @@ static int pri_wm_latency_show(struct seq_file *m, void *data)
 static int spr_wm_latency_show(struct seq_file *m, void *data)
 {
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const uint16_t *latencies;
+
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.spr_latency;
 
-	wm_latency_show(m, to_i915(dev)->wm.spr_latency);
+	wm_latency_show(m, latencies);
 
 	return 0;
 }
@@ -3543,8 +3561,15 @@ static int spr_wm_latency_show(struct seq_file *m, void *data)
 static int cur_wm_latency_show(struct seq_file *m, void *data)
 {
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const uint16_t *latencies;
+
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.cur_latency;
 
-	wm_latency_show(m, to_i915(dev)->wm.cur_latency);
+	wm_latency_show(m, latencies);
 
 	return 0;
 }
@@ -3580,11 +3605,11 @@ static int cur_wm_latency_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
-				size_t len, loff_t *offp, uint16_t wm[5])
+				size_t len, loff_t *offp, uint16_t wm[8])
 {
 	struct seq_file *m = file->private_data;
 	struct drm_device *dev = m->private;
-	uint16_t new[5] = { 0 };
+	uint16_t new[8] = { 0 };
 	int num_levels = ilk_wm_max_level(dev) + 1;
 	int level;
 	int ret;
@@ -3598,7 +3623,9 @@ static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
 
 	tmp[len] = '\0';
 
-	ret = sscanf(tmp, "%hu %hu %hu %hu %hu", &new[0], &new[1], &new[2], &new[3], &new[4]);
+	ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu",
+		     &new[0], &new[1], &new[2], &new[3],
+		     &new[4], &new[5], &new[6], &new[7]);
 	if (ret != num_levels)
 		return -EINVAL;
 
@@ -3618,8 +3645,15 @@ static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf,
 {
 	struct seq_file *m = file->private_data;
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	uint16_t *latencies;
 
-	return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.pri_latency);
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.pri_latency;
+
+	return wm_latency_write(file, ubuf, len, offp, latencies);
 }
 
 static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
@@ -3627,8 +3661,15 @@ static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
 {
 	struct seq_file *m = file->private_data;
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	uint16_t *latencies;
 
-	return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.spr_latency);
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.spr_latency;
+
+	return wm_latency_write(file, ubuf, len, offp, latencies);
 }
 
 static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
@@ -3636,8 +3677,15 @@ static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
 {
 	struct seq_file *m = file->private_data;
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	uint16_t *latencies;
+
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.cur_latency;
 
-	return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.cur_latency);
+	return wm_latency_write(file, ubuf, len, offp, latencies);
 }
 
 static const struct file_operations i915_pri_wm_latency_fops = {
Signature · 1 line
1.8.3.1
Reviewed-by on v1 80/89
#257 lore raw

Re: [PATCH 80/89] drm/i915/skl: Augment the latency debugfs files for SKL

Quoted 19 lines · Damien Lespiau
---
 drivers/gpu/drm/i915/i915_debugfs.c | 76 ++++++++++++++++++++++++++++++-------
 1 file changed, 62 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
index 02cb310..1520d1f 100644
@@ -3499,7 +3499,7 @@ static const struct file_operations i915_display_crc_ctl_fops = {
 	.write = display_crc_ctl_write
 };
 
-static void wm_latency_show(struct seq_file *m, const uint16_t wm[5])
+static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
 {
 	struct drm_device *dev = m->private;
 	int num_levels = ilk_wm_max_level(dev) + 1;

drivers/gpu/drm/i915/i915_debugfs.c static void wm_latency_show(struct seq_file *m, const uint16_t wm[5]) · line 3517

Quoted 10 lines
drivers/gpu/drm/i915/i915_debugfs.c +5 -2
@@ -3510,13 +3510,17 @@ static void wm_latency_show(struct seq_file *m, const uint16_t wm[5])
 	for (level = 0; level < num_levels; level++) {
 		unsigned int latency = wm[level];
 
-		/* WM1+ latency values in 0.5us units */
-		if (level > 0)
+		/*
+		 * - WM1+ latency values in 0.5us units
+		 * - latencies are in us on gen9
+		 */
+		if (IS_GEN9(dev))

gen >= 9 here to perhaps?

Apart from that it looks ok to me.

Quoted 145 lines
drivers/gpu/drm/i915/i915_debugfs.c +56 -11
+			latency *= 10;
+		else if (level > 0)
 			latency *= 5;
 
 		seq_printf(m, "WM%d %u (%u.%u usec)\n",
-			   level, wm[level],
-			   latency / 10, latency % 10);
+			   level, wm[level], latency / 10, latency % 10);
 	}
 
 	drm_modeset_unlock_all(dev);
@@ -3525,8 +3529,15 @@ static void wm_latency_show(struct seq_file *m, const uint16_t wm[5])
 static int pri_wm_latency_show(struct seq_file *m, void *data)
 {
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const uint16_t *latencies;
+
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.pri_latency;
 
-	wm_latency_show(m, to_i915(dev)->wm.pri_latency);
+	wm_latency_show(m, latencies);
 
 	return 0;
 }
@@ -3534,8 +3545,15 @@ static int pri_wm_latency_show(struct seq_file *m, void *data)
 static int spr_wm_latency_show(struct seq_file *m, void *data)
 {
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const uint16_t *latencies;
+
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.spr_latency;
 
-	wm_latency_show(m, to_i915(dev)->wm.spr_latency);
+	wm_latency_show(m, latencies);
 
 	return 0;
 }
@@ -3543,8 +3561,15 @@ static int spr_wm_latency_show(struct seq_file *m, void *data)
 static int cur_wm_latency_show(struct seq_file *m, void *data)
 {
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const uint16_t *latencies;
+
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.cur_latency;
 
-	wm_latency_show(m, to_i915(dev)->wm.cur_latency);
+	wm_latency_show(m, latencies);
 
 	return 0;
 }
@@ -3580,11 +3605,11 @@ static int cur_wm_latency_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
-				size_t len, loff_t *offp, uint16_t wm[5])
+				size_t len, loff_t *offp, uint16_t wm[8])
 {
 	struct seq_file *m = file->private_data;
 	struct drm_device *dev = m->private;
-	uint16_t new[5] = { 0 };
+	uint16_t new[8] = { 0 };
 	int num_levels = ilk_wm_max_level(dev) + 1;
 	int level;
 	int ret;
@@ -3598,7 +3623,9 @@ static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
 
 	tmp[len] = '\0';
 
-	ret = sscanf(tmp, "%hu %hu %hu %hu %hu", &new[0], &new[1], &new[2], &new[3], &new[4]);
+	ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu",
+		     &new[0], &new[1], &new[2], &new[3],
+		     &new[4], &new[5], &new[6], &new[7]);
 	if (ret != num_levels)
 		return -EINVAL;
 
@@ -3618,8 +3645,15 @@ static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf,
 {
 	struct seq_file *m = file->private_data;
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	uint16_t *latencies;
 
-	return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.pri_latency);
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.pri_latency;
+
+	return wm_latency_write(file, ubuf, len, offp, latencies);
 }
 
 static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
@@ -3627,8 +3661,15 @@ static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
 {
 	struct seq_file *m = file->private_data;
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	uint16_t *latencies;
 
-	return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.spr_latency);
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.spr_latency;
+
+	return wm_latency_write(file, ubuf, len, offp, latencies);
 }
 
 static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
@@ -3636,8 +3677,15 @@ static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
 {
 	struct seq_file *m = file->private_data;
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	uint16_t *latencies;
+
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.cur_latency;
 
-	return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.cur_latency);
+	return wm_latency_write(file, ubuf, len, offp, latencies);
 }
 
 static const struct file_operations i915_pri_wm_latency_fops = {
Signature · 6 lines
1.8.3.1

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

PATCH v2 80/89 drm/i915/skl: Augment the latency debugfs files for SKL

v2: Use the gen >= 9 in the debugfs file condition (Ville)

---
 drivers/gpu/drm/i915/i915_debugfs.c | 76 ++++++++++++++++++++++++++++++-------
 1 file changed, 62 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +62 -14
index 4e629e1..069b6a6 100644
@@ -3513,7 +3513,7 @@ static const struct file_operations i915_display_crc_ctl_fops = {
 	.write = display_crc_ctl_write
 };
 
-static void wm_latency_show(struct seq_file *m, const uint16_t wm[5])
+static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
 {
 	struct drm_device *dev = m->private;
 	int num_levels = ilk_wm_max_level(dev) + 1;
@@ -3524,13 +3524,17 @@ static void wm_latency_show(struct seq_file *m, const uint16_t wm[5])
 	for (level = 0; level < num_levels; level++) {
 		unsigned int latency = wm[level];
 
-		/* WM1+ latency values in 0.5us units */
-		if (level > 0)
+		/*
+		 * - WM1+ latency values in 0.5us units
+		 * - latencies are in us on gen9
+		 */
+		if (INTEL_INFO(dev)->gen >= 9)
+			latency *= 10;
+		else if (level > 0)
 			latency *= 5;
 
 		seq_printf(m, "WM%d %u (%u.%u usec)\n",
-			   level, wm[level],
-			   latency / 10, latency % 10);
+			   level, wm[level], latency / 10, latency % 10);
 	}
 
 	drm_modeset_unlock_all(dev);
@@ -3539,8 +3543,15 @@ static void wm_latency_show(struct seq_file *m, const uint16_t wm[5])
 static int pri_wm_latency_show(struct seq_file *m, void *data)
 {
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const uint16_t *latencies;
+
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.pri_latency;
 
-	wm_latency_show(m, to_i915(dev)->wm.pri_latency);
+	wm_latency_show(m, latencies);
 
 	return 0;
 }
@@ -3548,8 +3559,15 @@ static int pri_wm_latency_show(struct seq_file *m, void *data)
 static int spr_wm_latency_show(struct seq_file *m, void *data)
 {
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const uint16_t *latencies;
+
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.spr_latency;
 
-	wm_latency_show(m, to_i915(dev)->wm.spr_latency);
+	wm_latency_show(m, latencies);
 
 	return 0;
 }
@@ -3557,8 +3575,15 @@ static int spr_wm_latency_show(struct seq_file *m, void *data)
 static int cur_wm_latency_show(struct seq_file *m, void *data)
 {
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const uint16_t *latencies;
+
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.cur_latency;
 
-	wm_latency_show(m, to_i915(dev)->wm.cur_latency);
+	wm_latency_show(m, latencies);
 
 	return 0;
 }
@@ -3594,11 +3619,11 @@ static int cur_wm_latency_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
-				size_t len, loff_t *offp, uint16_t wm[5])
+				size_t len, loff_t *offp, uint16_t wm[8])
 {
 	struct seq_file *m = file->private_data;
 	struct drm_device *dev = m->private;
-	uint16_t new[5] = { 0 };
+	uint16_t new[8] = { 0 };
 	int num_levels = ilk_wm_max_level(dev) + 1;
 	int level;
 	int ret;
@@ -3612,7 +3637,9 @@ static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
 
 	tmp[len] = '\0';
 
-	ret = sscanf(tmp, "%hu %hu %hu %hu %hu", &new[0], &new[1], &new[2], &new[3], &new[4]);
+	ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu",
+		     &new[0], &new[1], &new[2], &new[3],
+		     &new[4], &new[5], &new[6], &new[7]);
 	if (ret != num_levels)
 		return -EINVAL;
 
@@ -3632,8 +3659,15 @@ static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf,
 {
 	struct seq_file *m = file->private_data;
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	uint16_t *latencies;
 
-	return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.pri_latency);
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.pri_latency;
+
+	return wm_latency_write(file, ubuf, len, offp, latencies);
 }
 
 static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
@@ -3641,8 +3675,15 @@ static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
 {
 	struct seq_file *m = file->private_data;
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	uint16_t *latencies;
 
-	return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.spr_latency);
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.spr_latency;
+
+	return wm_latency_write(file, ubuf, len, offp, latencies);
 }
 
 static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
@@ -3650,8 +3691,15 @@ static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
 {
 	struct seq_file *m = file->private_data;
 	struct drm_device *dev = m->private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	uint16_t *latencies;
+
+	if (INTEL_INFO(dev)->gen >= 9)
+		latencies = dev_priv->wm.skl_latency;
+	else
+		latencies = to_i915(dev)->wm.cur_latency;
 
-	return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.cur_latency);
+	return wm_latency_write(file, ubuf, len, offp, latencies);
 }
 
 static const struct file_operations i915_pri_wm_latency_fops = {
Signature · 6 lines
1.8.3.1

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

PATCH 81/89 drm/i915/skl: Expose skl_ddb_get_hw_state()

In reply to Damien Lespiau

So we can use it in the modeset checker.

v2: Rebase on top of nigthly

v3: Rebase on top of -nigthly (minor conflict in intel_drv.h)

---
 drivers/gpu/drm/i915/intel_drv.h | 2 ++
 drivers/gpu/drm/i915/intel_pm.c  | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +2 -0
index a407d04..782dfbc 100644
@@ -1108,6 +1108,8 @@ void intel_init_runtime_pm(struct drm_i915_private *dev_priv);
 void intel_fini_runtime_pm(struct drm_i915_private *dev_priv);
 void ilk_wm_get_hw_state(struct drm_device *dev);
 void skl_wm_get_hw_state(struct drm_device *dev);
+void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
+			  struct skl_ddb_allocation *ddb /* out */);
 
 
 /* intel_sdvo.c */
drivers/gpu/drm/i915/intel_pm.c +2 -2
index 8d24a4d..ff0d8cb 100644
@@ -3026,8 +3026,8 @@ static void skl_ddb_entry_init_from_hw(struct skl_ddb_entry *entry, u32 reg)
 	entry->end = (reg >> 16) & 0x3ff;
 }
 
-static void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
-				 struct skl_ddb_allocation *ddb /* out */)
+void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
+			  struct skl_ddb_allocation *ddb /* out */)
 {
 	struct drm_device *dev = dev_priv->dev;
 	enum pipe pipe;
Signature · 1 line
1.8.3.1
#260 lore raw

Re: [PATCH 81/89] drm/i915/skl: Expose skl_ddb_get_hw_state()

Quoted 7 lines · Damien Lespiau

So we can use it in the modeset checker.

v2: Rebase on top of nigthly

v3: Rebase on top of -nigthly (minor conflict in intel_drv.h)

I don't know if I should even bother with the r-b. Feel free to slap one on if you want :)

Quoted 40 lines
---
 drivers/gpu/drm/i915/intel_drv.h | 2 ++
 drivers/gpu/drm/i915/intel_pm.c  | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +2 -0
index a407d04..782dfbc 100644
@@ -1108,6 +1108,8 @@ void intel_init_runtime_pm(struct drm_i915_private *dev_priv);
 void intel_fini_runtime_pm(struct drm_i915_private *dev_priv);
 void ilk_wm_get_hw_state(struct drm_device *dev);
 void skl_wm_get_hw_state(struct drm_device *dev);
+void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
+			  struct skl_ddb_allocation *ddb /* out */);
 
 
 /* intel_sdvo.c */
drivers/gpu/drm/i915/intel_pm.c +2 -2
index 8d24a4d..ff0d8cb 100644
@@ -3026,8 +3026,8 @@ static void skl_ddb_entry_init_from_hw(struct skl_ddb_entry *entry, u32 reg)
 	entry->end = (reg >> 16) & 0x3ff;
 }
 
-static void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
-				 struct skl_ddb_allocation *ddb /* out */)
+void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
+			  struct skl_ddb_allocation *ddb /* out */)
 {
 	struct drm_device *dev = dev_priv->dev;
 	enum pipe pipe;
Signature · 6 lines
1.8.3.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#261 lore raw

Re: [PATCH 81/89] drm/i915/skl: Expose skl_ddb_get_hw_state()

Quoted 11 lines · Ville Syrjälä
Quoted 7 lines · Damien Lespiau

So we can use it in the modeset checker.

v2: Rebase on top of nigthly

v3: Rebase on top of -nigthly (minor conflict in intel_drv.h)

I don't know if I should even bother with the r-b. Feel free to slap one on if you want :)

I do feel dirty, this patch was before we agreed it wasn't a necessity to split those kind of changes, but put them along with the patch using them.

Will fold into the right patch if I remember it.

Signature · 5 lines
Damien
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#262 lore raw

PATCH 82/89 drm/i915/skl: Add a debugfs file to dump the DDB allocation

In reply to Damien Lespiau

v2: minor conflict in i915_debugfs.c
v3: Rebase on top of the for_each_pipe() change adding dev_priv as first
argument.
v4: minor conflict in the i915_debugfs_files array
v5: minor conflict in the i915_debugfs_files array

---
 drivers/gpu/drm/i915/i915_debugfs.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
drivers/gpu/drm/i915/i915_debugfs.c +37 -0
index 1520d1f..0468ec9 100644
@@ -2669,6 +2669,42 @@ static int i915_wa_registers(struct seq_file *m, void *unused)
 	return 0;
 }
 
+static int i915_ddb_info(struct seq_file *m, void *unused)
+{
+	struct drm_info_node *node = m->private;
+	struct drm_device *dev = node->minor->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct skl_ddb_allocation *ddb;
+	struct skl_ddb_entry *entry;
+	enum pipe pipe;
+	int plane;
+
+	drm_modeset_lock_all(dev);
+
+	ddb = &dev_priv->wm.skl_hw.ddb;
+
+	seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size");
+
+	for_each_pipe(dev_priv, pipe) {
+		seq_printf(m, "Pipe %c\n", pipe_name(pipe));
+
+		for_each_plane(pipe, plane) {
+			entry = &ddb->plane[pipe][plane];
+			seq_printf(m, "  Plane%-8d%8u%8u%8u\n", plane + 1,
+				   entry->start, entry->end,
+				   skl_ddb_entry_size(entry));
+		}
+
+		entry = &ddb->cursor[pipe];
+		seq_printf(m, "  %-13s%8u%8u%8u\n", "Cursor", entry->start,
+			   entry->end, skl_ddb_entry_size(entry));
+	}
+
+	drm_modeset_unlock_all(dev);
+
+	return 0;
+}
+
 struct pipe_crc_info {
 	const char *name;
 	struct drm_device *dev;
@@ -4249,6 +4285,7 @@ static const struct drm_info_list i915_debugfs_list[] = {
 	{"i915_shared_dplls_info", i915_shared_dplls_info, 0},
 	{"i915_dp_mst_info", i915_dp_mst_info, 0},
 	{"i915_wa_registers", i915_wa_registers, 0},
+	{"i915_ddb_info", i915_ddb_info, 0},
 };
 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
 
Signature · 1 line
1.8.3.1
Reviewed-by on v1 82/89
#263 lore raw

Re: [PATCH 82/89] drm/i915/skl: Add a debugfs file to dump the DDB allocation

Quoted 7 lines · Damien Lespiau

v2: minor conflict in i915_debugfs.c
v3: Rebase on top of the for_each_pipe() change adding dev_priv as first
argument.
v4: minor conflict in the i915_debugfs_files array
v5: minor conflict in the i915_debugfs_files array

Quoted 66 lines
---
 drivers/gpu/drm/i915/i915_debugfs.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
drivers/gpu/drm/i915/i915_debugfs.c +37 -0
index 1520d1f..0468ec9 100644
@@ -2669,6 +2669,42 @@ static int i915_wa_registers(struct seq_file *m, void *unused)
 	return 0;
 }
 
+static int i915_ddb_info(struct seq_file *m, void *unused)
+{
+	struct drm_info_node *node = m->private;
+	struct drm_device *dev = node->minor->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct skl_ddb_allocation *ddb;
+	struct skl_ddb_entry *entry;
+	enum pipe pipe;
+	int plane;
+
+	drm_modeset_lock_all(dev);
+
+	ddb = &dev_priv->wm.skl_hw.ddb;
+
+	seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size");
+
+	for_each_pipe(dev_priv, pipe) {
+		seq_printf(m, "Pipe %c\n", pipe_name(pipe));
+
+		for_each_plane(pipe, plane) {
+			entry = &ddb->plane[pipe][plane];
+			seq_printf(m, "  Plane%-8d%8u%8u%8u\n", plane + 1,
+				   entry->start, entry->end,
+				   skl_ddb_entry_size(entry));
+		}
+
+		entry = &ddb->cursor[pipe];
+		seq_printf(m, "  %-13s%8u%8u%8u\n", "Cursor", entry->start,
+			   entry->end, skl_ddb_entry_size(entry));
+	}
+
+	drm_modeset_unlock_all(dev);
+
+	return 0;
+}
+
 struct pipe_crc_info {
 	const char *name;
 	struct drm_device *dev;
@@ -4249,6 +4285,7 @@ static const struct drm_info_list i915_debugfs_list[] = {
 	{"i915_shared_dplls_info", i915_shared_dplls_info, 0},
 	{"i915_dp_mst_info", i915_dp_mst_info, 0},
 	{"i915_wa_registers", i915_wa_registers, 0},
+	{"i915_ddb_info", i915_ddb_info, 0},
 };
 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
 
Signature · 6 lines
1.8.3.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#264 lore raw

PATCH 83/89 drm/i915/skl: Check the DDB state at modeset

In reply to Damien Lespiau

v2: Don't check DDB on pre-SKL platforms
Don't check DDB state on disabled pipes

---
 drivers/gpu/drm/i915/i915_drv.h      |  9 +++++++
 drivers/gpu/drm/i915/intel_display.c | 51 ++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +9 -0
index 95e57dc..0baf7f3 100644
@@ -1424,6 +1424,15 @@ static inline uint16_t skl_ddb_entry_size(const struct skl_ddb_entry *entry)
 	return entry->end - entry->start + 1;
 }
 
+static inline bool skl_ddb_entry_equal(const struct skl_ddb_entry *e1,
+				       const struct skl_ddb_entry *e2)
+{
+	if (e1->start == e2->start && e1->end == e2->end)
+		return true;
+
+	return false;
+}
+
 struct skl_ddb_allocation {
 	struct skl_ddb_entry plane[I915_MAX_PIPES][I915_MAX_PLANES];
 	struct skl_ddb_entry cursor[I915_MAX_PIPES];
drivers/gpu/drm/i915/intel_display.c +51 -0

63 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#265 lore raw

Re: [PATCH 83/89] drm/i915/skl: Check the DDB state at modeset

Quoted 4 lines · Damien Lespiau

v2: Don't check DDB on pre-SKL platforms
Don't check DDB state on disabled pipes

We probably want to do this with a vfunc eventually ... but reall deferring to Ville here, he'll know best what might be useful to make sure that the wm readout/takeover is accurate enough. So lgtm for now. -Daniel

Quoted 101 lines
---
 drivers/gpu/drm/i915/i915_drv.h      |  9 +++++++
 drivers/gpu/drm/i915/intel_display.c | 51 ++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +9 -0
index 95e57dc..0baf7f3 100644
@@ -1424,6 +1424,15 @@ static inline uint16_t skl_ddb_entry_size(const struct skl_ddb_entry *entry)
 	return entry->end - entry->start + 1;
 }
 
+static inline bool skl_ddb_entry_equal(const struct skl_ddb_entry *e1,
+				       const struct skl_ddb_entry *e2)
+{
+	if (e1->start == e2->start && e1->end == e2->end)
+		return true;
+
+	return false;
+}
+
 struct skl_ddb_allocation {
 	struct skl_ddb_entry plane[I915_MAX_PIPES][I915_MAX_PLANES];
 	struct skl_ddb_entry cursor[I915_MAX_PIPES];
drivers/gpu/drm/i915/intel_display.c +51 -0
index 9b31342..35d3389 100644
@@ -10944,6 +10944,56 @@ intel_pipe_config_compare(struct drm_device *dev,
 	return true;
 }
 
+static void check_wm_state(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct skl_ddb_allocation hw_ddb, *sw_ddb;
+	struct intel_crtc *intel_crtc;
+	int plane;
+
+	if (INTEL_INFO(dev)->gen < 9)
+		return;
+
+	skl_ddb_get_hw_state(dev_priv, &hw_ddb);
+	sw_ddb = &dev_priv->wm.skl_hw.ddb;
+
+	for_each_intel_crtc(dev, intel_crtc) {
+		struct skl_ddb_entry *hw_entry, *sw_entry;
+		const enum pipe pipe = intel_crtc->pipe;
+
+		if (!intel_crtc->active)
+			continue;
+
+		/* planes */
+		for_each_plane(pipe, plane) {
+			hw_entry = &hw_ddb.plane[pipe][plane];
+			sw_entry = &sw_ddb->plane[pipe][plane];
+
+			if (skl_ddb_entry_equal(hw_entry, sw_entry))
+				continue;
+
+			DRM_ERROR("mismatch in DDB state pipe %c plane %d "
+				  "(expected (%u,%u), found (%u,%u))\n",
+				  pipe_name(pipe), plane + 1,
+				  sw_entry->start, sw_entry->end,
+				  hw_entry->start, hw_entry->end);
+		}
+
+		/* cursor */
+		hw_entry = &hw_ddb.cursor[pipe];
+		sw_entry = &sw_ddb->cursor[pipe];
+
+		if (skl_ddb_entry_equal(hw_entry, sw_entry))
+			continue;
+
+		DRM_ERROR("mismatch in DDB state pipe %c cursor "
+			  "(expected (%u,%u), found (%u,%u))\n",
+			  pipe_name(pipe),
+			  sw_entry->start, sw_entry->end,
+			  hw_entry->start, hw_entry->end);
+	}
+}
+
 static void
 check_connector_state(struct drm_device *dev)
 {
@@ -11143,6 +11193,7 @@ check_shared_dpll_state(struct drm_device *dev)
 void
 intel_modeset_check_state(struct drm_device *dev)
 {
+	check_wm_state(dev);
 	check_connector_state(dev);
 	check_encoder_state(dev);
 	check_crtc_state(dev);
Signature · 6 lines
1.8.3.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Reviewed-by
#266 lore raw

Re: [PATCH 83/89] drm/i915/skl: Check the DDB state at modeset

Quoted 9 lines · Daniel Vetter
Quoted 4 lines · Damien Lespiau

v2: Don't check DDB on pre-SKL platforms
Don't check DDB state on disabled pipes

We probably want to do this with a vfunc eventually ... but reall deferring to Ville here, he'll know best what might be useful to make sure that the wm readout/takeover is accurate enough. So lgtm for now.

Yeah seems fine as is for now. On SKL checking the WMs too would be fairly easy I guess. On ILK it'd be a bit more fuzzy due to the (eventual) two part update + multi pipe merging stuff.

Doing it unconditionally at modeset time seems OK since it's a slow operation anyway. We might want to do it for plane updates as well, but I think that probably needs to be hidden behind some debug knob since we don't want to pile on too much overhead there.

Quoted 112 lines

-Daniel

Quoted 101 lines
---
 drivers/gpu/drm/i915/i915_drv.h      |  9 +++++++
 drivers/gpu/drm/i915/intel_display.c | 51 ++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +9 -0
index 95e57dc..0baf7f3 100644
@@ -1424,6 +1424,15 @@ static inline uint16_t skl_ddb_entry_size(const struct skl_ddb_entry *entry)
 	return entry->end - entry->start + 1;
 }
 
+static inline bool skl_ddb_entry_equal(const struct skl_ddb_entry *e1,
+				       const struct skl_ddb_entry *e2)
+{
+	if (e1->start == e2->start && e1->end == e2->end)
+		return true;
+
+	return false;
+}
+
 struct skl_ddb_allocation {
 	struct skl_ddb_entry plane[I915_MAX_PIPES][I915_MAX_PLANES];
 	struct skl_ddb_entry cursor[I915_MAX_PIPES];
drivers/gpu/drm/i915/intel_display.c +51 -0
index 9b31342..35d3389 100644
@@ -10944,6 +10944,56 @@ intel_pipe_config_compare(struct drm_device *dev,
 	return true;
 }
 
+static void check_wm_state(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct skl_ddb_allocation hw_ddb, *sw_ddb;
+	struct intel_crtc *intel_crtc;
+	int plane;
+
+	if (INTEL_INFO(dev)->gen < 9)
+		return;
+
+	skl_ddb_get_hw_state(dev_priv, &hw_ddb);
+	sw_ddb = &dev_priv->wm.skl_hw.ddb;
+
+	for_each_intel_crtc(dev, intel_crtc) {
+		struct skl_ddb_entry *hw_entry, *sw_entry;
+		const enum pipe pipe = intel_crtc->pipe;
+
+		if (!intel_crtc->active)
+			continue;
+
+		/* planes */
+		for_each_plane(pipe, plane) {
+			hw_entry = &hw_ddb.plane[pipe][plane];
+			sw_entry = &sw_ddb->plane[pipe][plane];
+
+			if (skl_ddb_entry_equal(hw_entry, sw_entry))
+				continue;
+
+			DRM_ERROR("mismatch in DDB state pipe %c plane %d "
+				  "(expected (%u,%u), found (%u,%u))\n",
+				  pipe_name(pipe), plane + 1,
+				  sw_entry->start, sw_entry->end,
+				  hw_entry->start, hw_entry->end);
+		}
+
+		/* cursor */
+		hw_entry = &hw_ddb.cursor[pipe];
+		sw_entry = &sw_ddb->cursor[pipe];
+
+		if (skl_ddb_entry_equal(hw_entry, sw_entry))
+			continue;
+
+		DRM_ERROR("mismatch in DDB state pipe %c cursor "
+			  "(expected (%u,%u), found (%u,%u))\n",
+			  pipe_name(pipe),
+			  sw_entry->start, sw_entry->end,
+			  hw_entry->start, hw_entry->end);
+	}
+}
+
 static void
 check_connector_state(struct drm_device *dev)
 {
@@ -11143,6 +11193,7 @@ check_shared_dpll_state(struct drm_device *dev)
 void
 intel_modeset_check_state(struct drm_device *dev)
 {
+	check_wm_state(dev);
 	check_connector_state(dev);
 	check_encoder_state(dev);
 	check_crtc_state(dev);
Signature · 6 lines
1.8.3.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#267 lore raw

PATCH 84/89 drm/i915/skl: add turbo support

In reply to Damien Lespiau

From: Jesse Barnes <[email protected]>

Per latest PM programming guide.

v2: the wrong flavour of the function updating the ring frequency was
called, leading to dead locks (Tvrtko)

---
 drivers/gpu/drm/i915/intel_pm.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +29 -0
index ff0d8cb..9e9377a 100644
@@ -4708,9 +4708,36 @@ void bdw_software_turbo(struct drm_device *dev)
 			&current_time, &current_c0);
 }
 
+/* See the Gen9_GT_PM_Programming_Guide doc for the below */
 static void gen9_enable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
+
+	I915_WRITE(GEN6_RPNSWREQ, 0xc800000);
+	I915_WRITE(GEN6_RC_VIDEO_FREQ, 0xc800000);
+
+	I915_WRITE(GEN6_RP_DOWN_TIMEOUT, 0xf4240);
+	I915_WRITE(GEN6_RP_INTERRUPT_LIMITS, 0x12060000);
+	I915_WRITE(GEN6_RP_UP_THRESHOLD, 0xe808);
+	I915_WRITE(GEN6_RP_DOWN_THRESHOLD, 0x3bd08);
+	I915_WRITE(GEN6_RP_UP_EI, 0x101d0);
+	I915_WRITE(GEN6_RP_DOWN_EI, 0x55730);
+	I915_WRITE(GEN6_RP_IDLE_HYSTERSIS, 0xa);
+	I915_WRITE(GEN6_PMINTRMSK, 0x6);
+	I915_WRITE(GEN6_RP_CONTROL, GEN6_RP_MEDIA_TURBO |
+		   GEN6_RP_MEDIA_HW_MODE | GEN6_RP_ENABLE |
+		   GEN6_RP_UP_BUSY_AVG | GEN6_RP_DOWN_IDLE_AVG);
+
+	gen8_enable_rps_interrupts(dev);
+
+	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
+}
+
+static void gen9_enable_rc6(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine_cs *ring;
 	uint32_t rc6_mask = 0;
 	int unused;
@@ -6355,7 +6382,9 @@ static void intel_gen6_powersave_work(struct work_struct *work)
 	} else if (IS_VALLEYVIEW(dev)) {
 		valleyview_enable_rps(dev);
 	} else if (INTEL_INFO(dev)->gen >= 9) {
+		gen9_enable_rc6(dev);
 		gen9_enable_rps(dev);
+		__gen6_update_ring_freq(dev);
 	} else if (IS_BROADWELL(dev)) {
 		gen8_enable_rps(dev);
 		__gen6_update_ring_freq(dev);
Signature · 1 line
1.8.3.1
#268 lore raw

Re: [PATCH 84/89] drm/i915/skl: add turbo support

Quoted 32 lines · Damien Lespiau

From: Jesse Barnes <[email protected]>

Per latest PM programming guide.

v2: the wrong flavour of the function updating the ring frequency was
called, leading to dead locks (Tvrtko)

---
 drivers/gpu/drm/i915/intel_pm.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +8 -0
index ff0d8cb..9e9377a 100644
@@ -4708,9 +4708,36 @@ void bdw_software_turbo(struct drm_device *dev)
 			&current_time, &current_c0);
 }
 
+/* See the Gen9_GT_PM_Programming_Guide doc for the below */
 static void gen9_enable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
+
+	I915_WRITE(GEN6_RPNSWREQ, 0xc800000);
+	I915_WRITE(GEN6_RC_VIDEO_FREQ, 0xc800000);
+
+	I915_WRITE(GEN6_RP_DOWN_TIMEOUT, 0xf4240);

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

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+	I915_WRITE(GEN6_RP_INTERRUPT_LIMITS, 0x12060000);
+	I915_WRITE(GEN6_RP_UP_THRESHOLD, 0xe808);
+	I915_WRITE(GEN6_RP_DOWN_THRESHOLD, 0x3bd08);
+	I915_WRITE(GEN6_RP_UP_EI, 0x101d0);
+	I915_WRITE(GEN6_RP_DOWN_EI, 0x55730);
+	I915_WRITE(GEN6_RP_IDLE_HYSTERSIS, 0xa);
+	I915_WRITE(GEN6_PMINTRMSK, 0x6);
+	I915_WRITE(GEN6_RP_CONTROL, GEN6_RP_MEDIA_TURBO |
+		   GEN6_RP_MEDIA_HW_MODE | GEN6_RP_ENABLE |
+		   GEN6_RP_UP_BUSY_AVG | GEN6_RP_DOWN_IDLE_AVG);

GEN6_RP_MEDIA_IS_GFX missing?

-Mika

Quoted 29 lines
drivers/gpu/drm/i915/intel_pm.c +11 -0
+
+	gen8_enable_rps_interrupts(dev);
+
+	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
+}
+
+static void gen9_enable_rc6(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine_cs *ring;
 	uint32_t rc6_mask = 0;
 	int unused;
@@ -6355,7 +6382,9 @@ static void intel_gen6_powersave_work(struct work_struct *work)
 	} else if (IS_VALLEYVIEW(dev)) {
 		valleyview_enable_rps(dev);
 	} else if (INTEL_INFO(dev)->gen >= 9) {
+		gen9_enable_rc6(dev);
 		gen9_enable_rps(dev);
+		__gen6_update_ring_freq(dev);
 	} else if (IS_BROADWELL(dev)) {
 		gen8_enable_rps(dev);
 		__gen6_update_ring_freq(dev);
Signature · 6 lines
1.8.3.1

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

PATCH 85/89 drm/i915/skl: Retrieve the frequency limits

In reply to Damien Lespiau
---
 drivers/gpu/drm/i915/intel_pm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +4 -0
index 9e9377a..77e1d52 100644
@@ -4712,9 +4712,13 @@ void bdw_software_turbo(struct drm_device *dev)
 static void gen9_enable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
+	u32 rp_state_cap;
 
 	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
 
+	rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
+	parse_rp_state_cap(dev_priv, rp_state_cap);
+
 	I915_WRITE(GEN6_RPNSWREQ, 0xc800000);
 	I915_WRITE(GEN6_RC_VIDEO_FREQ, 0xc800000);
 
Signature · 1 line
1.8.3.1
Reviewed-by on v1 85/89
#270 lore raw

Re: [PATCH 85/89] drm/i915/skl: Retrieve the frequency limits

Quoted 1 line · Damien Lespiau
Quoted 29 lines
---
 drivers/gpu/drm/i915/intel_pm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +4 -0
index 9e9377a..77e1d52 100644
@@ -4712,9 +4712,13 @@ void bdw_software_turbo(struct drm_device *dev)
 static void gen9_enable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
+	u32 rp_state_cap;
 
 	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
 
+	rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
+	parse_rp_state_cap(dev_priv, rp_state_cap);
+
 	I915_WRITE(GEN6_RPNSWREQ, 0xc800000);
 	I915_WRITE(GEN6_RC_VIDEO_FREQ, 0xc800000);
 
Signature · 6 lines
1.8.3.1

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

PATCH 86/89 drm/i915: only reset media, blt, and render engines on GPU hangs

In reply to Damien Lespiau

From: Jesse Barnes <[email protected]>

No need to mess with display.

---
 drivers/gpu/drm/i915/intel_uncore.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_uncore.c +2 -1
index ce1214b..29aa63e 100644
@@ -1472,7 +1472,8 @@ static int gen6_do_reset(struct drm_device *dev)
 	 * for fifo space for the write or forcewake the chip for
 	 * the read
 	 */
-	__raw_i915_write32(dev_priv, GEN6_GDRST, GEN6_GRDOM_FULL);
+	__raw_i915_write32(dev_priv, GEN6_GDRST, GEN6_GRDOM_MEDIA |
+			   GEN6_GRDOM_BLT | GEN6_GRDOM_RENDER);
 
 	/* Spin waiting for the device to ack the reset request */
 	ret = wait_for((__raw_i915_read32(dev_priv, GEN6_GDRST) & GEN6_GRDOM_FULL) == 0, 500);
Signature · 1 line
1.8.3.1
maintainer
#272 lore raw

Re: [PATCH 86/89] drm/i915: only reset media, blt, and render engines on GPU hangs

Quoted 3 lines · Damien Lespiau

From: Jesse Barnes <[email protected]>

No need to mess with display.

Why is this patch part of the skl enabling series? The commit message is a bit thin on the details too...

BR,
Jani.

Quoted 28 lines
---
 drivers/gpu/drm/i915/intel_uncore.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_uncore.c +2 -1
index ce1214b..29aa63e 100644
@@ -1472,7 +1472,8 @@ static int gen6_do_reset(struct drm_device *dev)
 	 * for fifo space for the write or forcewake the chip for
 	 * the read
 	 */
-	__raw_i915_write32(dev_priv, GEN6_GDRST, GEN6_GRDOM_FULL);
+	__raw_i915_write32(dev_priv, GEN6_GDRST, GEN6_GRDOM_MEDIA |
+			   GEN6_GRDOM_BLT | GEN6_GRDOM_RENDER);
 
 	/* Spin waiting for the device to ack the reset request */
 	ret = wait_for((__raw_i915_read32(dev_priv, GEN6_GDRST) & GEN6_GRDOM_FULL) == 0, 500);
Signature · 6 lines
1.8.3.1

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

Re: [PATCH 86/89] drm/i915: only reset media, blt, and render engines on GPU hangs

Quoted 7 lines · Jani Nikula
Quoted 3 lines · Damien Lespiau

From: Jesse Barnes <[email protected]>

No need to mess with display.

Why is this patch part of the skl enabling series? The commit message is a bit thin on the details too...

I did hesitate with this one, this is indeed orthogonal to SKL enabling and was just a shot in the dark.

Jesse, do you mind if we just drop this one?

Signature · 1 line
Damien
#274 lore raw

Re: [PATCH 86/89] drm/i915: only reset media, blt, and render engines on GPU hangs

Quoted 6 lines · Damien Lespiau
Quoted 5 lines · Jani Nikula
Quoted 3 lines · Damien Lespiau

From: Jesse Barnes <[email protected]>

No need to mess with display.

Quoted 7 lines
Quoted 2 lines

Why is this patch part of the skl enabling series? The commit message is a bit thin on the details too...

I did hesitate with this one, this is indeed orthogonal to SKL enabling and was just a shot in the dark.

Jesse, do you mind if we just drop this one?

Afaik we only reset GT (i.e. media/blit) and not display on gen6+, at least all the display stuff survives. This has been the case since roughly g4x+, and we actually have a bunch of testcases now to verify that. Specifically the crc vs reset tests will start to fail if anything in the display block goes south.
-Daniel

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

Re: [PATCH 86/89] drm/i915: only reset media, blt, and render engines on GPU hangs

In reply to Damien Lespiau
Quoted 6 lines · On Thu, 4 Sep 2014 13:29:06 +0100 Damien Lespiau <[email protected]>…
Quoted 5 lines · Jani Nikula
Quoted 3 lines · Damien Lespiau

From: Jesse Barnes <[email protected]>

No need to mess with display.

Quoted 7 lines
Quoted 2 lines

Why is this patch part of the skl enabling series? The commit message is a bit thin on the details too...

I did hesitate with this one, this is indeed orthogonal to SKL enabling and was just a shot in the dark.

Jesse, do you mind if we just drop this one?

Yeah it doesn't belong in the SKL series. But iirc it's been outstanding for awhile from different authors. Does anyone remember why we haven't merged something like this yet?

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#276 lore raw

Re: [PATCH 86/89] drm/i915: only reset media, blt, and render engines on GPU hangs

In reply to Damien Lespiau
Quoted 15 lines · Damien Lespiau

From: Jesse Barnes <[email protected]>

No need to mess with display.

---
 drivers/gpu/drm/i915/intel_uncore.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_uncore.c +0 -0
index ce1214b..29aa63e 100644

drivers/gpu/drm/i915/intel_uncore.c static int gen6_do_reset(struct drm_device *dev) · line 1476

Quoted 6 lines
drivers/gpu/drm/i915/intel_uncore.c +2 -1
@@ -1472,7 +1472,8 @@ static int gen6_do_reset(struct drm_device *dev)
 	 * for fifo space for the write or forcewake the chip for
 	 * the read
 	 */
-	__raw_i915_write32(dev_priv, GEN6_GDRST, GEN6_GRDOM_FULL);
+	__raw_i915_write32(dev_priv, GEN6_GDRST, GEN6_GRDOM_MEDIA |
+			   GEN6_GRDOM_BLT | GEN6_GRDOM_RENDER);

You need to reset more engines even if you don't do full reset. Vebox is missing atleast.

-Mika

Quoted 9 lines
drivers/gpu/drm/i915/intel_uncore.c +0 -0
 	/* Spin waiting for the device to ack the reset request */
 	ret = wait_for((__raw_i915_read32(dev_priv, GEN6_GDRST) & GEN6_GRDOM_FULL) == 0, 500);
Signature · 6 lines
1.8.3.1

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