Skip to contentSkip to conversation

drm/i915/psr: vbt change for psr

PATCH In review vathsala nagaraju 3 participants 8 messages May 18, 2018 – May 22, 2018

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

PATCH 1/1 drm/i915/psr: vbt change for psr

From: Vathsala Nagaraju <[email protected]>

For psr block #9, the vbt description has moved to options [0-3] for TP1,TP2,TP3 Wakeup time from decimal value without any change to vbt structure. Since spec does not mention from which VBT version this change was added to vbt.bsf file, we cannot depend on bdb->version check to change for all the platforms.

There is RCR inplace for GOP team to provide the version number to make generic change. Since Kabylake with bdb version 209 is having this change, limiting this change to gen9_bc and version 209+ to unblock google.

Tested on skl(bdb version 203,without options) and kabylake(bdb version 209,212) having new options.

bspec 20131

v2: (Jani and Rodrigo)
move the 165 version check to intel_bios.c
v3: Jani
Move the abstraction to intel_bios.
v4: Jani
Rename tp*_wakeup_time to have "us" suffix.
For values outside range[0-3],default to max 2500us. Old decimal value was wake up time in multiples of 100us.
v5: Jani and Rodrigo
Handle option 2 in default condition.
Print oustide range value.
For negetive values default to 2500us.
v6: Jani
Handle default first and then fall through for case 2.
v7: Rodrigo
Apply this change for IS_GEN9_BC and vbt version > 209.
v8: Puthik
add new function vbt_psr_to_us.

Cc Rodrigo Vivi <[email protected]>
Cc Puthikorn Voravootivat <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc José Roberto de Souza <[email protected]>
Cc Jani Nikula <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h   |  4 ++--
 drivers/gpu/drm/i915/i915_reg.h   |  8 ++++----
 drivers/gpu/drm/i915/intel_bios.c | 38 ++++++++++++++++++++++++++++++++++++--
 drivers/gpu/drm/i915/intel_psr.c  | 39 ++++++++++++++++++++-------------------
 4 files changed, 62 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -2
index e33c380..dcfa791 100644
@@ -1078,8 +1078,8 @@ struct intel_vbt_data {
 		bool require_aux_wakeup;
 		int idle_frames;
 		enum psr_lines_to_wait lines_to_wait;
-		int tp1_wakeup_time;
-		int tp2_tp3_wakeup_time;
+		int tp1_wakeup_time_us;
+		int tp2_tp3_wakeup_time_us;
 	} psr;
 
 	struct {
drivers/gpu/drm/i915/i915_reg.h +4 -4
index 196a0eb..513b4a4 100644
@@ -4088,10 +4088,10 @@ enum {
 #define   EDP_Y_COORDINATE_ENABLE	(1<<25) /* GLK and CNL+ */
 #define   EDP_MAX_SU_DISABLE_TIME(t)	((t)<<20)
 #define   EDP_MAX_SU_DISABLE_TIME_MASK	(0x1f<<20)
-#define   EDP_PSR2_TP2_TIME_500		(0<<8)
-#define   EDP_PSR2_TP2_TIME_100		(1<<8)
-#define   EDP_PSR2_TP2_TIME_2500	(2<<8)
-#define   EDP_PSR2_TP2_TIME_50		(3<<8)
+#define   EDP_PSR2_TP2_TIME_500us	(0<<8)
+#define   EDP_PSR2_TP2_TIME_100us	(1<<8)
+#define   EDP_PSR2_TP2_TIME_2500us	(2<<8)
+#define   EDP_PSR2_TP2_TIME_50us	(3<<8)
 #define   EDP_PSR2_TP2_TIME_MASK	(3<<8)
 #define   EDP_PSR2_FRAME_BEFORE_SU_SHIFT 4
 #define   EDP_PSR2_FRAME_BEFORE_SU_MASK	(0xf<<4)
drivers/gpu/drm/i915/intel_bios.c +36 -2
index 54270bd..5d8c29f 100644
@@ -647,12 +647,26 @@ static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv,
 	}
 }
 
+static int vbt_psr_to_us(bool is_waketime_options, int vbt_value)
+{
+	if (is_waketime_options) {
+		int waketime_map[] = {500, 100, 2500, 0};
+		/* Reset to value 2 = 2500us for outside range [0-3] */
+		if (vbt_value < 0 || vbt_value > 3)
+			vbt_value = 2;
+		return waketime_map[vbt_value];
+	} else {
+		return vbt_value * 100;
+	}
+}
+
 static void
 parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
 {
 	const struct bdb_psr *psr;
 	const struct psr_table *psr_table;
 	int panel_type = dev_priv->vbt.panel_type;
+	bool is_waketime_options = false;
 
 	psr = find_section(bdb, BDB_PSR);
 	if (!psr) {
@@ -688,8 +702,28 @@ static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv,
 		break;
 	}
 
-	dev_priv->vbt.psr.tp1_wakeup_time = psr_table->tp1_wakeup_time;
-	dev_priv->vbt.psr.tp2_tp3_wakeup_time = psr_table->tp2_tp3_wakeup_time;
+	/*
+	 * New psr wake options 0=500us, 1=100us, 2=2500us, 3=0us
+	 * Old decimal value is wake up time in multiples of 100 us.
+	 * TODO: add other platforms having new psr options.
+	 */
+	is_waketime_options = ((bdb->version >= 209) && IS_GEN9_BC(dev_priv));
+	if (is_waketime_options) {
+		/* Reset to value 2 = 2500us for outside range [0-3] */
+		if (psr_table->tp1_wakeup_time < 0 ||
+			psr_table->tp1_wakeup_time > 3) {
+			DRM_DEBUG_KMS("VBT tp1 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
+					psr_table->tp1_wakeup_time);
+		}
+		if (psr_table->tp2_tp3_wakeup_time < 0 ||
+			psr_table->tp2_tp3_wakeup_time > 3) {
+			DRM_DEBUG_KMS("VBT tp2_tp3 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
+					psr_table->tp2_tp3_wakeup_time);
+		}
+	}
+
+	dev_priv->vbt.psr.tp1_wakeup_time_us = vbt_psr_to_us(is_waketime_options, psr_table->tp1_wakeup_time);
+	dev_priv->vbt.psr.tp2_tp3_wakeup_time_us = vbt_psr_to_us(is_waketime_options, psr_table->tp2_tp3_wakeup_time);
 }
 
 static void parse_dsi_backlight_ports(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_psr.c +20 -19
index db27f2f..d64f039 100644
@@ -461,23 +461,23 @@ static void hsw_activate_psr1(struct intel_dp *intel_dp)
 	if (dev_priv->psr.link_standby)
 		val |= EDP_PSR_LINK_STANDBY;
 
-	if (dev_priv->vbt.psr.tp1_wakeup_time > 5)
-		val |= EDP_PSR_TP1_TIME_2500us;
-	else if (dev_priv->vbt.psr.tp1_wakeup_time > 1)
-		val |= EDP_PSR_TP1_TIME_500us;
-	else if (dev_priv->vbt.psr.tp1_wakeup_time > 0)
+	if (dev_priv->vbt.psr.tp1_wakeup_time_us == 0)
+		val |=  EDP_PSR_TP1_TIME_0us;
+	else if (dev_priv->vbt.psr.tp1_wakeup_time_us <= 100)
 		val |= EDP_PSR_TP1_TIME_100us;
+	else if (dev_priv->vbt.psr.tp1_wakeup_time_us <= 500)
+		val |= EDP_PSR_TP1_TIME_500us;
 	else
-		val |= EDP_PSR_TP1_TIME_0us;
+		val |= EDP_PSR_TP1_TIME_2500us;
 
-	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
-		val |= EDP_PSR_TP2_TP3_TIME_2500us;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
-		val |= EDP_PSR_TP2_TP3_TIME_500us;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 0)
+	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us == 0)
+		val |=  EDP_PSR_TP2_TP3_TIME_0us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 100)
 		val |= EDP_PSR_TP2_TP3_TIME_100us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 500)
+		val |= EDP_PSR_TP2_TP3_TIME_500us;
 	else
-		val |= EDP_PSR_TP2_TP3_TIME_0us;
+		val |= EDP_PSR_TP2_TP3_TIME_2500us;
 
 	if (intel_dp_source_supports_hbr2(intel_dp) &&
 	    drm_dp_tps3_supported(intel_dp->dpcd))
@@ -513,14 +513,15 @@ static void hsw_activate_psr2(struct intel_dp *intel_dp)
 
 	val |= EDP_PSR2_FRAME_BEFORE_SU(dev_priv->psr.sink_sync_latency + 1);
 
-	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
-		val |= EDP_PSR2_TP2_TIME_2500;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
-		val |= EDP_PSR2_TP2_TIME_500;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 0)
-		val |= EDP_PSR2_TP2_TIME_100;
+	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us >= 0 &&
+	    dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 50)
+		val |= EDP_PSR2_TP2_TIME_50us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 100)
+		val |= EDP_PSR2_TP2_TIME_100us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 500)
+		val |= EDP_PSR2_TP2_TIME_500us;
 	else
-		val |= EDP_PSR2_TP2_TIME_50;
+		val |= EDP_PSR2_TP2_TIME_2500us;
 
 	I915_WRITE(EDP_PSR2_CTL, val);
 }
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer
#1 lore raw
Quoted 131 lines · vathsala nagaraju

From: Vathsala Nagaraju <[email protected]>

For psr block #9, the vbt description has moved to options [0-3] for TP1,TP2,TP3 Wakeup time from decimal value without any change to vbt structure. Since spec does not mention from which VBT version this change was added to vbt.bsf file, we cannot depend on bdb->version check to change for all the platforms.

There is RCR inplace for GOP team to provide the version number to make generic change. Since Kabylake with bdb version 209 is having this change, limiting this change to gen9_bc and version 209+ to unblock google.

Tested on skl(bdb version 203,without options) and kabylake(bdb version 209,212) having new options.

bspec 20131

v2: (Jani and Rodrigo)
move the 165 version check to intel_bios.c
v3: Jani
Move the abstraction to intel_bios.
v4: Jani
Rename tp*_wakeup_time to have "us" suffix.
For values outside range[0-3],default to max 2500us. Old decimal value was wake up time in multiples of 100us.
v5: Jani and Rodrigo
Handle option 2 in default condition.
Print oustide range value.
For negetive values default to 2500us.
v6: Jani
Handle default first and then fall through for case 2.
v7: Rodrigo
Apply this change for IS_GEN9_BC and vbt version > 209.
v8: Puthik
add new function vbt_psr_to_us.

Cc Rodrigo Vivi <[email protected]>
Cc Puthikorn Voravootivat <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc José Roberto de Souza <[email protected]>
Cc Jani Nikula <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h   |  4 ++--
 drivers/gpu/drm/i915/i915_reg.h   |  8 ++++----
 drivers/gpu/drm/i915/intel_bios.c | 38 ++++++++++++++++++++++++++++++++++++--
 drivers/gpu/drm/i915/intel_psr.c  | 39 ++++++++++++++++++++-------------------
 4 files changed, 62 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -2
index e33c380..dcfa791 100644
@@ -1078,8 +1078,8 @@ struct intel_vbt_data {
 		bool require_aux_wakeup;
 		int idle_frames;
 		enum psr_lines_to_wait lines_to_wait;
-		int tp1_wakeup_time;
-		int tp2_tp3_wakeup_time;
+		int tp1_wakeup_time_us;
+		int tp2_tp3_wakeup_time_us;
 	} psr;
 
 	struct {
drivers/gpu/drm/i915/i915_reg.h +4 -4
index 196a0eb..513b4a4 100644
@@ -4088,10 +4088,10 @@ enum {
 #define   EDP_Y_COORDINATE_ENABLE	(1<<25) /* GLK and CNL+ */
 #define   EDP_MAX_SU_DISABLE_TIME(t)	((t)<<20)
 #define   EDP_MAX_SU_DISABLE_TIME_MASK	(0x1f<<20)
-#define   EDP_PSR2_TP2_TIME_500		(0<<8)
-#define   EDP_PSR2_TP2_TIME_100		(1<<8)
-#define   EDP_PSR2_TP2_TIME_2500	(2<<8)
-#define   EDP_PSR2_TP2_TIME_50		(3<<8)
+#define   EDP_PSR2_TP2_TIME_500us	(0<<8)
+#define   EDP_PSR2_TP2_TIME_100us	(1<<8)
+#define   EDP_PSR2_TP2_TIME_2500us	(2<<8)
+#define   EDP_PSR2_TP2_TIME_50us	(3<<8)
 #define   EDP_PSR2_TP2_TIME_MASK	(3<<8)
 #define   EDP_PSR2_FRAME_BEFORE_SU_SHIFT 4
 #define   EDP_PSR2_FRAME_BEFORE_SU_MASK	(0xf<<4)
drivers/gpu/drm/i915/intel_bios.c +23 -2
index 54270bd..5d8c29f 100644
@@ -647,12 +647,26 @@ static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv,
 	}
 }
 
+static int vbt_psr_to_us(bool is_waketime_options, int vbt_value)
+{
+	if (is_waketime_options) {
+		int waketime_map[] = {500, 100, 2500, 0};
+		/* Reset to value 2 = 2500us for outside range [0-3] */
+		if (vbt_value < 0 || vbt_value > 3)
+			vbt_value = 2;
+		return waketime_map[vbt_value];
+	} else {
+		return vbt_value * 100;
+	}
+}
+
 static void
 parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
 {
 	const struct bdb_psr *psr;
 	const struct psr_table *psr_table;
 	int panel_type = dev_priv->vbt.panel_type;
+	bool is_waketime_options = false;
 
 	psr = find_section(bdb, BDB_PSR);
 	if (!psr) {
@@ -688,8 +702,28 @@ static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv,
 		break;
 	}
 
-	dev_priv->vbt.psr.tp1_wakeup_time = psr_table->tp1_wakeup_time;
-	dev_priv->vbt.psr.tp2_tp3_wakeup_time = psr_table->tp2_tp3_wakeup_time;
+	/*
+	 * New psr wake options 0=500us, 1=100us, 2=2500us, 3=0us
+	 * Old decimal value is wake up time in multiples of 100 us.
+	 * TODO: add other platforms having new psr options.
+	 */
+	is_waketime_options = ((bdb->version >= 209) && IS_GEN9_BC(dev_priv));
+	if (is_waketime_options) {
+		/* Reset to value 2 = 2500us for outside range [0-3] */
+		if (psr_table->tp1_wakeup_time < 0 ||

drivers/gpu/drm/i915/intel_bios.c static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv, · line 723

Quoted 10 lines
drivers/gpu/drm/i915/intel_bios.c +10 -0
+			psr_table->tp1_wakeup_time > 3) {
+			DRM_DEBUG_KMS("VBT tp1 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
+					psr_table->tp1_wakeup_time);
+		}
+		if (psr_table->tp2_tp3_wakeup_time < 0 ||
+			psr_table->tp2_tp3_wakeup_time > 3) {
+			DRM_DEBUG_KMS("VBT tp2_tp3 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
+					psr_table->tp2_tp3_wakeup_time);
+		}
+	}

Why did you take something that was obvious at a glance and turn it into this complicated mess?

I'd rather take the previous version, even with the duplication.

BR,
Jani.

Quoted 69 lines
drivers/gpu/drm/i915/intel_bios.c +3 -0
+
+	dev_priv->vbt.psr.tp1_wakeup_time_us = vbt_psr_to_us(is_waketime_options, psr_table->tp1_wakeup_time);
+	dev_priv->vbt.psr.tp2_tp3_wakeup_time_us = vbt_psr_to_us(is_waketime_options, psr_table->tp2_tp3_wakeup_time);
 }
 
 static void parse_dsi_backlight_ports(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_psr.c +20 -19
index db27f2f..d64f039 100644
@@ -461,23 +461,23 @@ static void hsw_activate_psr1(struct intel_dp *intel_dp)
 	if (dev_priv->psr.link_standby)
 		val |= EDP_PSR_LINK_STANDBY;
 
-	if (dev_priv->vbt.psr.tp1_wakeup_time > 5)
-		val |= EDP_PSR_TP1_TIME_2500us;
-	else if (dev_priv->vbt.psr.tp1_wakeup_time > 1)
-		val |= EDP_PSR_TP1_TIME_500us;
-	else if (dev_priv->vbt.psr.tp1_wakeup_time > 0)
+	if (dev_priv->vbt.psr.tp1_wakeup_time_us == 0)
+		val |=  EDP_PSR_TP1_TIME_0us;
+	else if (dev_priv->vbt.psr.tp1_wakeup_time_us <= 100)
 		val |= EDP_PSR_TP1_TIME_100us;
+	else if (dev_priv->vbt.psr.tp1_wakeup_time_us <= 500)
+		val |= EDP_PSR_TP1_TIME_500us;
 	else
-		val |= EDP_PSR_TP1_TIME_0us;
+		val |= EDP_PSR_TP1_TIME_2500us;
 
-	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
-		val |= EDP_PSR_TP2_TP3_TIME_2500us;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
-		val |= EDP_PSR_TP2_TP3_TIME_500us;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 0)
+	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us == 0)
+		val |=  EDP_PSR_TP2_TP3_TIME_0us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 100)
 		val |= EDP_PSR_TP2_TP3_TIME_100us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 500)
+		val |= EDP_PSR_TP2_TP3_TIME_500us;
 	else
-		val |= EDP_PSR_TP2_TP3_TIME_0us;
+		val |= EDP_PSR_TP2_TP3_TIME_2500us;
 
 	if (intel_dp_source_supports_hbr2(intel_dp) &&
 	    drm_dp_tps3_supported(intel_dp->dpcd))
@@ -513,14 +513,15 @@ static void hsw_activate_psr2(struct intel_dp *intel_dp)
 
 	val |= EDP_PSR2_FRAME_BEFORE_SU(dev_priv->psr.sink_sync_latency + 1);
 
-	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
-		val |= EDP_PSR2_TP2_TIME_2500;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
-		val |= EDP_PSR2_TP2_TIME_500;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 0)
-		val |= EDP_PSR2_TP2_TIME_100;
+	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us >= 0 &&
+	    dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 50)
+		val |= EDP_PSR2_TP2_TIME_50us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 100)
+		val |= EDP_PSR2_TP2_TIME_100us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 500)
+		val |= EDP_PSR2_TP2_TIME_500us;
 	else
-		val |= EDP_PSR2_TP2_TIME_50;
+		val |= EDP_PSR2_TP2_TIME_2500us;
 
 	I915_WRITE(EDP_PSR2_CTL, val);
 }
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 136 lines · Jani Nikula
Quoted 135 lines · vathsala nagaraju

From: Vathsala Nagaraju <[email protected]>

For psr block #9, the vbt description has moved to options [0-3] for TP1,TP2,TP3 Wakeup time from decimal value without any change to vbt structure. Since spec does not mention from which VBT version this change was added to vbt.bsf file, we cannot depend on bdb->version check to change for all the platforms.

There is RCR inplace for GOP team to provide the version number to make generic change. Since Kabylake with bdb version 209 is having this change, limiting this change to gen9_bc and version 209+ to unblock google.

Tested on skl(bdb version 203,without options) and kabylake(bdb version 209,212) having new options.

bspec 20131

v2: (Jani and Rodrigo)
move the 165 version check to intel_bios.c
v3: Jani
Move the abstraction to intel_bios.
v4: Jani
Rename tp*_wakeup_time to have "us" suffix.
For values outside range[0-3],default to max 2500us. Old decimal value was wake up time in multiples of 100us.
v5: Jani and Rodrigo
Handle option 2 in default condition.
Print oustide range value.
For negetive values default to 2500us.
v6: Jani
Handle default first and then fall through for case 2.
v7: Rodrigo
Apply this change for IS_GEN9_BC and vbt version > 209.
v8: Puthik
add new function vbt_psr_to_us.

Cc Rodrigo Vivi <[email protected]>
Cc Puthikorn Voravootivat <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc José Roberto de Souza <[email protected]>
Cc Jani Nikula <[email protected]>
---
  drivers/gpu/drm/i915/i915_drv.h   |  4 ++--
  drivers/gpu/drm/i915/i915_reg.h   |  8 ++++----
  drivers/gpu/drm/i915/intel_bios.c | 38 ++++++++++++++++++++++++++++++++++++--
  drivers/gpu/drm/i915/intel_psr.c  | 39 ++++++++++++++++++++-------------------
  4 files changed, 62 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -2
index e33c380..dcfa791 100644
@@ -1078,8 +1078,8 @@ struct intel_vbt_data {
  		bool require_aux_wakeup;
  		int idle_frames;
  		enum psr_lines_to_wait lines_to_wait;
-		int tp1_wakeup_time;
-		int tp2_tp3_wakeup_time;
+		int tp1_wakeup_time_us;
+		int tp2_tp3_wakeup_time_us;
  	} psr;
 
  	struct {
drivers/gpu/drm/i915/i915_reg.h +4 -4
index 196a0eb..513b4a4 100644
@@ -4088,10 +4088,10 @@ enum {
  #define   EDP_Y_COORDINATE_ENABLE	(1<<25) /* GLK and CNL+ */
  #define   EDP_MAX_SU_DISABLE_TIME(t)	((t)<<20)
  #define   EDP_MAX_SU_DISABLE_TIME_MASK	(0x1f<<20)
-#define   EDP_PSR2_TP2_TIME_500		(0<<8)
-#define   EDP_PSR2_TP2_TIME_100		(1<<8)
-#define   EDP_PSR2_TP2_TIME_2500	(2<<8)
-#define   EDP_PSR2_TP2_TIME_50		(3<<8)
+#define   EDP_PSR2_TP2_TIME_500us	(0<<8)
+#define   EDP_PSR2_TP2_TIME_100us	(1<<8)
+#define   EDP_PSR2_TP2_TIME_2500us	(2<<8)
+#define   EDP_PSR2_TP2_TIME_50us	(3<<8)
  #define   EDP_PSR2_TP2_TIME_MASK	(3<<8)
  #define   EDP_PSR2_FRAME_BEFORE_SU_SHIFT 4
  #define   EDP_PSR2_FRAME_BEFORE_SU_MASK	(0xf<<4)
drivers/gpu/drm/i915/intel_bios.c +27 -2
index 54270bd..5d8c29f 100644
@@ -647,12 +647,26 @@ static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv,
  	}
  }
 
+static int vbt_psr_to_us(bool is_waketime_options, int vbt_value)
+{
+	if (is_waketime_options) {
+		int waketime_map[] = {500, 100, 2500, 0};
+		/* Reset to value 2 = 2500us for outside range [0-3] */
+		if (vbt_value < 0 || vbt_value > 3)
+			vbt_value = 2;
+		return waketime_map[vbt_value];
+	} else {
+		return vbt_value * 100;
+	}
+}
+
  static void
  parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
  {
  	const struct bdb_psr *psr;
  	const struct psr_table *psr_table;
  	int panel_type = dev_priv->vbt.panel_type;
+	bool is_waketime_options = false;
 
  	psr = find_section(bdb, BDB_PSR);
  	if (!psr) {
@@ -688,8 +702,28 @@ static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv,
  		break;
  	}
 
-	dev_priv->vbt.psr.tp1_wakeup_time = psr_table->tp1_wakeup_time;
-	dev_priv->vbt.psr.tp2_tp3_wakeup_time = psr_table->tp2_tp3_wakeup_time;
+	/*
+	 * New psr wake options 0=500us, 1=100us, 2=2500us, 3=0us
+	 * Old decimal value is wake up time in multiples of 100 us.
+	 * TODO: add other platforms having new psr options.
+	 */
+	is_waketime_options = ((bdb->version >= 209) && IS_GEN9_BC(dev_priv));
+	if (is_waketime_options) {
+		/* Reset to value 2 = 2500us for outside range [0-3] */
+		if (psr_table->tp1_wakeup_time < 0 ||
+			psr_table->tp1_wakeup_time > 3) {
+			DRM_DEBUG_KMS("VBT tp1 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
+					psr_table->tp1_wakeup_time);
+		}
Quoted 8 lines

drivers/gpu/drm/i915/intel_bios.c static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv, · line 723

Quoted 6 lines
drivers/gpu/drm/i915/intel_bios.c +6 -0
+		if (psr_table->tp2_tp3_wakeup_time < 0 ||
+			psr_table->tp2_tp3_wakeup_time > 3) {
+			DRM_DEBUG_KMS("VBT tp2_tp3 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
+					psr_table->tp2_tp3_wakeup_time);
+		}
+	}

Why did you take something that was obvious at a glance and turn it into this complicated mess?

Which parts you find it complicated?
new version is
1) check if vbt data is  wake_options
2) if wake options , then  if out of range print the message
3)then  for both new and old version , we call vbt_psr_to_us , which takes care of the mapping and conversion to us.

Quoted 2 lines

I'd rather take the previous version, even with the duplication.

puthik suggested to use vbt_psr_to_us to remove code duplication. Puthik , is it okay if  we switch to v7 version?

Quoted 71 lines

BR,
Jani.

Quoted 67 lines
drivers/gpu/drm/i915/intel_bios.c +3 -0
+
+	dev_priv->vbt.psr.tp1_wakeup_time_us = vbt_psr_to_us(is_waketime_options, psr_table->tp1_wakeup_time);
+	dev_priv->vbt.psr.tp2_tp3_wakeup_time_us = vbt_psr_to_us(is_waketime_options, psr_table->tp2_tp3_wakeup_time);
  }
 
  static void parse_dsi_backlight_ports(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_psr.c +20 -19
index db27f2f..d64f039 100644
@@ -461,23 +461,23 @@ static void hsw_activate_psr1(struct intel_dp *intel_dp)
  	if (dev_priv->psr.link_standby)
  		val |= EDP_PSR_LINK_STANDBY;
 
-	if (dev_priv->vbt.psr.tp1_wakeup_time > 5)
-		val |= EDP_PSR_TP1_TIME_2500us;
-	else if (dev_priv->vbt.psr.tp1_wakeup_time > 1)
-		val |= EDP_PSR_TP1_TIME_500us;
-	else if (dev_priv->vbt.psr.tp1_wakeup_time > 0)
+	if (dev_priv->vbt.psr.tp1_wakeup_time_us == 0)
+		val |=  EDP_PSR_TP1_TIME_0us;
+	else if (dev_priv->vbt.psr.tp1_wakeup_time_us <= 100)
  		val |= EDP_PSR_TP1_TIME_100us;
+	else if (dev_priv->vbt.psr.tp1_wakeup_time_us <= 500)
+		val |= EDP_PSR_TP1_TIME_500us;
  	else
-		val |= EDP_PSR_TP1_TIME_0us;
+		val |= EDP_PSR_TP1_TIME_2500us;
 
-	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
-		val |= EDP_PSR_TP2_TP3_TIME_2500us;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
-		val |= EDP_PSR_TP2_TP3_TIME_500us;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 0)
+	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us == 0)
+		val |=  EDP_PSR_TP2_TP3_TIME_0us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 100)
  		val |= EDP_PSR_TP2_TP3_TIME_100us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 500)
+		val |= EDP_PSR_TP2_TP3_TIME_500us;
  	else
-		val |= EDP_PSR_TP2_TP3_TIME_0us;
+		val |= EDP_PSR_TP2_TP3_TIME_2500us;
 
  	if (intel_dp_source_supports_hbr2(intel_dp) &&
  	    drm_dp_tps3_supported(intel_dp->dpcd))
@@ -513,14 +513,15 @@ static void hsw_activate_psr2(struct intel_dp *intel_dp)
 
  	val |= EDP_PSR2_FRAME_BEFORE_SU(dev_priv->psr.sink_sync_latency + 1);
 
-	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
-		val |= EDP_PSR2_TP2_TIME_2500;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
-		val |= EDP_PSR2_TP2_TIME_500;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 0)
-		val |= EDP_PSR2_TP2_TIME_100;
+	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us >= 0 &&
+	    dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 50)
+		val |= EDP_PSR2_TP2_TIME_50us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 100)
+		val |= EDP_PSR2_TP2_TIME_100us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 500)
+		val |= EDP_PSR2_TP2_TIME_500us;
  	else
-		val |= EDP_PSR2_TP2_TIME_50;
+		val |= EDP_PSR2_TP2_TIME_2500us;
 
Quoted 2 lines

drivers/gpu/drm/i915/intel_psr.c static void hsw_activate_psr2(struct intel_dp *intel_dp) · line 527

Quoted 2 lines
drivers/gpu/drm/i915/intel_psr.c +0 -0
  	I915_WRITE(EDP_PSR2_CTL, val);
  }

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

maintainer
#3 lore raw
Quoted 145 lines · Vathsala
Quoted 136 lines · Jani Nikula
Quoted 135 lines · vathsala nagaraju

From: Vathsala Nagaraju <[email protected]>

For psr block #9, the vbt description has moved to options [0-3] for TP1,TP2,TP3 Wakeup time from decimal value without any change to vbt structure. Since spec does not mention from which VBT version this change was added to vbt.bsf file, we cannot depend on bdb->version check to change for all the platforms.

There is RCR inplace for GOP team to provide the version number to make generic change. Since Kabylake with bdb version 209 is having this change, limiting this change to gen9_bc and version 209+ to unblock google.

Tested on skl(bdb version 203,without options) and kabylake(bdb version 209,212) having new options.

bspec 20131

v2: (Jani and Rodrigo)
move the 165 version check to intel_bios.c
v3: Jani
Move the abstraction to intel_bios.
v4: Jani
Rename tp*_wakeup_time to have "us" suffix.
For values outside range[0-3],default to max 2500us. Old decimal value was wake up time in multiples of 100us.
v5: Jani and Rodrigo
Handle option 2 in default condition.
Print oustide range value.
For negetive values default to 2500us.
v6: Jani
Handle default first and then fall through for case 2.
v7: Rodrigo
Apply this change for IS_GEN9_BC and vbt version > 209.
v8: Puthik
add new function vbt_psr_to_us.

Cc Rodrigo Vivi <[email protected]>
Cc Puthikorn Voravootivat <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc José Roberto de Souza <[email protected]>
Cc Jani Nikula <[email protected]>
---
  drivers/gpu/drm/i915/i915_drv.h   |  4 ++--
  drivers/gpu/drm/i915/i915_reg.h   |  8 ++++----
  drivers/gpu/drm/i915/intel_bios.c | 38 ++++++++++++++++++++++++++++++++++++--
  drivers/gpu/drm/i915/intel_psr.c  | 39 ++++++++++++++++++++-------------------
  4 files changed, 62 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -2
index e33c380..dcfa791 100644
@@ -1078,8 +1078,8 @@ struct intel_vbt_data {
  		bool require_aux_wakeup;
  		int idle_frames;
  		enum psr_lines_to_wait lines_to_wait;
-		int tp1_wakeup_time;
-		int tp2_tp3_wakeup_time;
+		int tp1_wakeup_time_us;
+		int tp2_tp3_wakeup_time_us;
  	} psr;
 
  	struct {
drivers/gpu/drm/i915/i915_reg.h +4 -4
index 196a0eb..513b4a4 100644
@@ -4088,10 +4088,10 @@ enum {
  #define   EDP_Y_COORDINATE_ENABLE	(1<<25) /* GLK and CNL+ */
  #define   EDP_MAX_SU_DISABLE_TIME(t)	((t)<<20)
  #define   EDP_MAX_SU_DISABLE_TIME_MASK	(0x1f<<20)
-#define   EDP_PSR2_TP2_TIME_500		(0<<8)
-#define   EDP_PSR2_TP2_TIME_100		(1<<8)
-#define   EDP_PSR2_TP2_TIME_2500	(2<<8)
-#define   EDP_PSR2_TP2_TIME_50		(3<<8)
+#define   EDP_PSR2_TP2_TIME_500us	(0<<8)
+#define   EDP_PSR2_TP2_TIME_100us	(1<<8)
+#define   EDP_PSR2_TP2_TIME_2500us	(2<<8)
+#define   EDP_PSR2_TP2_TIME_50us	(3<<8)
  #define   EDP_PSR2_TP2_TIME_MASK	(3<<8)
  #define   EDP_PSR2_FRAME_BEFORE_SU_SHIFT 4
  #define   EDP_PSR2_FRAME_BEFORE_SU_MASK	(0xf<<4)
drivers/gpu/drm/i915/intel_bios.c +27 -2
index 54270bd..5d8c29f 100644
@@ -647,12 +647,26 @@ static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv,
  	}
  }
 
+static int vbt_psr_to_us(bool is_waketime_options, int vbt_value)
+{
+	if (is_waketime_options) {
+		int waketime_map[] = {500, 100, 2500, 0};
+		/* Reset to value 2 = 2500us for outside range [0-3] */
+		if (vbt_value < 0 || vbt_value > 3)
+			vbt_value = 2;
+		return waketime_map[vbt_value];
+	} else {
+		return vbt_value * 100;
+	}
+}
+
  static void
  parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
  {
  	const struct bdb_psr *psr;
  	const struct psr_table *psr_table;
  	int panel_type = dev_priv->vbt.panel_type;
+	bool is_waketime_options = false;
 
  	psr = find_section(bdb, BDB_PSR);
  	if (!psr) {
@@ -688,8 +702,28 @@ static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv,
  		break;
  	}
 
-	dev_priv->vbt.psr.tp1_wakeup_time = psr_table->tp1_wakeup_time;
-	dev_priv->vbt.psr.tp2_tp3_wakeup_time = psr_table->tp2_tp3_wakeup_time;
+	/*
+	 * New psr wake options 0=500us, 1=100us, 2=2500us, 3=0us
+	 * Old decimal value is wake up time in multiples of 100 us.
+	 * TODO: add other platforms having new psr options.
+	 */
+	is_waketime_options = ((bdb->version >= 209) && IS_GEN9_BC(dev_priv));
+	if (is_waketime_options) {
+		/* Reset to value 2 = 2500us for outside range [0-3] */
+		if (psr_table->tp1_wakeup_time < 0 ||
+			psr_table->tp1_wakeup_time > 3) {
+			DRM_DEBUG_KMS("VBT tp1 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
+					psr_table->tp1_wakeup_time);
+		}
Quoted 8 lines

drivers/gpu/drm/i915/intel_bios.c static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv, · line 723

Quoted 6 lines
drivers/gpu/drm/i915/intel_bios.c +6 -0
+		if (psr_table->tp2_tp3_wakeup_time < 0 ||
+			psr_table->tp2_tp3_wakeup_time > 3) {
+			DRM_DEBUG_KMS("VBT tp2_tp3 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
+					psr_table->tp2_tp3_wakeup_time);
+		}
+	}

Why did you take something that was obvious at a glance and turn it into this complicated mess?

Quoted 1 line

Which parts you find it complicated?

This splits and duplicates the checks for valid values to two places that you need to keep in sync as the spec inevitably gets updated. The responsibilities between the caller and the callee are unclear, which is just silly for such a small amount of code. You have checks for negative values but the field is unsigned. I could go on.

The bottom line is that the spec makes a fundamentally simple thing unnecessarily complicated, and it's our job to implement that in a way that makes it again simple for human beings. That's the primary goal, make the code easy for the reader. We have enough hard things, we should not have to stop and think about simple things.

BR,
Jani.

Quoted 84 lines

new version is
1) check if vbt data is  wake_options
2) if wake options , then  if out of range print the message 3)then  for both new and old version , we call vbt_psr_to_us , which takes care of the mapping and conversion to us.

Quoted 2 lines

I'd rather take the previous version, even with the duplication.

puthik suggested to use vbt_psr_to_us to remove code duplication. Puthik , is it okay if  we switch to v7 version?

Quoted 73 lines

BR,
Jani.

Quoted 69 lines
drivers/gpu/drm/i915/intel_bios.c +3 -0
+
+	dev_priv->vbt.psr.tp1_wakeup_time_us = vbt_psr_to_us(is_waketime_options, psr_table->tp1_wakeup_time);
+	dev_priv->vbt.psr.tp2_tp3_wakeup_time_us = vbt_psr_to_us(is_waketime_options, psr_table->tp2_tp3_wakeup_time);
  }
 
  static void parse_dsi_backlight_ports(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_psr.c +20 -19
index db27f2f..d64f039 100644
@@ -461,23 +461,23 @@ static void hsw_activate_psr1(struct intel_dp *intel_dp)
  	if (dev_priv->psr.link_standby)
  		val |= EDP_PSR_LINK_STANDBY;
 
-	if (dev_priv->vbt.psr.tp1_wakeup_time > 5)
-		val |= EDP_PSR_TP1_TIME_2500us;
-	else if (dev_priv->vbt.psr.tp1_wakeup_time > 1)
-		val |= EDP_PSR_TP1_TIME_500us;
-	else if (dev_priv->vbt.psr.tp1_wakeup_time > 0)
+	if (dev_priv->vbt.psr.tp1_wakeup_time_us == 0)
+		val |=  EDP_PSR_TP1_TIME_0us;
+	else if (dev_priv->vbt.psr.tp1_wakeup_time_us <= 100)
  		val |= EDP_PSR_TP1_TIME_100us;
+	else if (dev_priv->vbt.psr.tp1_wakeup_time_us <= 500)
+		val |= EDP_PSR_TP1_TIME_500us;
  	else
-		val |= EDP_PSR_TP1_TIME_0us;
+		val |= EDP_PSR_TP1_TIME_2500us;
 
-	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
-		val |= EDP_PSR_TP2_TP3_TIME_2500us;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
-		val |= EDP_PSR_TP2_TP3_TIME_500us;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 0)
+	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us == 0)
+		val |=  EDP_PSR_TP2_TP3_TIME_0us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 100)
  		val |= EDP_PSR_TP2_TP3_TIME_100us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 500)
+		val |= EDP_PSR_TP2_TP3_TIME_500us;
  	else
-		val |= EDP_PSR_TP2_TP3_TIME_0us;
+		val |= EDP_PSR_TP2_TP3_TIME_2500us;
 
  	if (intel_dp_source_supports_hbr2(intel_dp) &&
  	    drm_dp_tps3_supported(intel_dp->dpcd))
@@ -513,14 +513,15 @@ static void hsw_activate_psr2(struct intel_dp *intel_dp)
 
  	val |= EDP_PSR2_FRAME_BEFORE_SU(dev_priv->psr.sink_sync_latency + 1);
 
-	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
-		val |= EDP_PSR2_TP2_TIME_2500;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
-		val |= EDP_PSR2_TP2_TIME_500;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 0)
-		val |= EDP_PSR2_TP2_TIME_100;
+	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us >= 0 &&
+	    dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 50)
+		val |= EDP_PSR2_TP2_TIME_50us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 100)
+		val |= EDP_PSR2_TP2_TIME_100us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 500)
+		val |= EDP_PSR2_TP2_TIME_500us;
  	else
-		val |= EDP_PSR2_TP2_TIME_50;
+		val |= EDP_PSR2_TP2_TIME_2500us;
 
  	I915_WRITE(EDP_PSR2_CTL, val);
  }
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 153 lines · Jani Nikula
Quoted 145 lines · Vathsala
Quoted 136 lines · Jani Nikula
Quoted 135 lines · vathsala nagaraju

From: Vathsala Nagaraju <[email protected]>

For psr block #9, the vbt description has moved to options [0-3] for TP1,TP2,TP3 Wakeup time from decimal value without any change to vbt structure. Since spec does not mention from which VBT version this change was added to vbt.bsf file, we cannot depend on bdb->version check to change for all the platforms.

There is RCR inplace for GOP team to provide the version number to make generic change. Since Kabylake with bdb version 209 is having this change, limiting this change to gen9_bc and version 209+ to unblock google.

Tested on skl(bdb version 203,without options) and kabylake(bdb version 209,212) having new options.

bspec 20131

v2: (Jani and Rodrigo)
move the 165 version check to intel_bios.c
v3: Jani
Move the abstraction to intel_bios.
v4: Jani
Rename tp*_wakeup_time to have "us" suffix.
For values outside range[0-3],default to max 2500us. Old decimal value was wake up time in multiples of 100us.
v5: Jani and Rodrigo
Handle option 2 in default condition.
Print oustide range value.
For negetive values default to 2500us.
v6: Jani
Handle default first and then fall through for case 2.
v7: Rodrigo
Apply this change for IS_GEN9_BC and vbt version > 209.
v8: Puthik
add new function vbt_psr_to_us.

Cc Rodrigo Vivi <[email protected]>
Cc Puthikorn Voravootivat <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc José Roberto de Souza <[email protected]>
Cc Jani Nikula <[email protected]>
---
   drivers/gpu/drm/i915/i915_drv.h   |  4 ++--
   drivers/gpu/drm/i915/i915_reg.h   |  8 ++++----
   drivers/gpu/drm/i915/intel_bios.c | 38 ++++++++++++++++++++++++++++++++++++--
   drivers/gpu/drm/i915/intel_psr.c  | 39 ++++++++++++++++++++-------------------
   4 files changed, 62 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -2
index e33c380..dcfa791 100644
@@ -1078,8 +1078,8 @@ struct intel_vbt_data {
   		bool require_aux_wakeup;
   		int idle_frames;
   		enum psr_lines_to_wait lines_to_wait;
-		int tp1_wakeup_time;
-		int tp2_tp3_wakeup_time;
+		int tp1_wakeup_time_us;
+		int tp2_tp3_wakeup_time_us;
   	} psr;
 
   	struct {
drivers/gpu/drm/i915/i915_reg.h +4 -4
index 196a0eb..513b4a4 100644
@@ -4088,10 +4088,10 @@ enum {
   #define   EDP_Y_COORDINATE_ENABLE	(1<<25) /* GLK and CNL+ */
   #define   EDP_MAX_SU_DISABLE_TIME(t)	((t)<<20)
   #define   EDP_MAX_SU_DISABLE_TIME_MASK	(0x1f<<20)
-#define   EDP_PSR2_TP2_TIME_500		(0<<8)
-#define   EDP_PSR2_TP2_TIME_100		(1<<8)
-#define   EDP_PSR2_TP2_TIME_2500	(2<<8)
-#define   EDP_PSR2_TP2_TIME_50		(3<<8)
+#define   EDP_PSR2_TP2_TIME_500us	(0<<8)
+#define   EDP_PSR2_TP2_TIME_100us	(1<<8)
+#define   EDP_PSR2_TP2_TIME_2500us	(2<<8)
+#define   EDP_PSR2_TP2_TIME_50us	(3<<8)
   #define   EDP_PSR2_TP2_TIME_MASK	(3<<8)
   #define   EDP_PSR2_FRAME_BEFORE_SU_SHIFT 4
   #define   EDP_PSR2_FRAME_BEFORE_SU_MASK	(0xf<<4)
drivers/gpu/drm/i915/intel_bios.c +27 -2
index 54270bd..5d8c29f 100644
@@ -647,12 +647,26 @@ static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv,
   	}
   }
 
+static int vbt_psr_to_us(bool is_waketime_options, int vbt_value)
+{
+	if (is_waketime_options) {
+		int waketime_map[] = {500, 100, 2500, 0};
+		/* Reset to value 2 = 2500us for outside range [0-3] */
+		if (vbt_value < 0 || vbt_value > 3)
+			vbt_value = 2;
+		return waketime_map[vbt_value];
+	} else {
+		return vbt_value * 100;
+	}
+}
+
   static void
   parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
   {
   	const struct bdb_psr *psr;
   	const struct psr_table *psr_table;
   	int panel_type = dev_priv->vbt.panel_type;
+	bool is_waketime_options = false;
 
   	psr = find_section(bdb, BDB_PSR);
   	if (!psr) {
@@ -688,8 +702,28 @@ static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv,
   		break;
   	}
 
-	dev_priv->vbt.psr.tp1_wakeup_time = psr_table->tp1_wakeup_time;
-	dev_priv->vbt.psr.tp2_tp3_wakeup_time = psr_table->tp2_tp3_wakeup_time;
+	/*
+	 * New psr wake options 0=500us, 1=100us, 2=2500us, 3=0us
+	 * Old decimal value is wake up time in multiples of 100 us.
+	 * TODO: add other platforms having new psr options.
+	 */
+	is_waketime_options = ((bdb->version >= 209) && IS_GEN9_BC(dev_priv));
+	if (is_waketime_options) {
+		/* Reset to value 2 = 2500us for outside range [0-3] */
+		if (psr_table->tp1_wakeup_time < 0 ||
+			psr_table->tp1_wakeup_time > 3) {
+			DRM_DEBUG_KMS("VBT tp1 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
+					psr_table->tp1_wakeup_time);
+		}
Quoted 8 lines

drivers/gpu/drm/i915/intel_bios.c static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv, · line 723

Quoted 6 lines
drivers/gpu/drm/i915/intel_bios.c +6 -0
+		if (psr_table->tp2_tp3_wakeup_time < 0 ||
+			psr_table->tp2_tp3_wakeup_time > 3) {
+			DRM_DEBUG_KMS("VBT tp2_tp3 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
+					psr_table->tp2_tp3_wakeup_time);
+		}
+	}

Why did you take something that was obvious at a glance and turn it into this complicated mess?

Quoted 1 line

Which parts you find it complicated?

This splits and duplicates the checks for valid values to two places that you need to keep in sync as the spec inevitably gets updated. The responsibilities between the caller and the callee are unclear, which is just silly for such a small amount of code. You have checks for negative values but the field is unsigned. I could go on.

Quoted 9 lines

The bottom line is that the spec makes a fundamentally simple thing unnecessarily complicated, and it's our job to implement that in a way that makes it again simple for human beings. That's the primary goal, make the code easy for the reader. We have enough hard things, we should not have to stop and think about simple things.

BR,
Jani.

Thanks, will stick with the previous version (v7)

Quoted 80 lines
Quoted 80 lines

new version is
1) check if vbt data is  wake_options
2) if wake options , then  if out of range print the message 3)then  for both new and old version , we call vbt_psr_to_us , which takes care of the mapping and conversion to us.

Quoted 1 line

I'd rather take the previous version, even with the duplication.

puthik suggested to use vbt_psr_to_us to remove code duplication. Puthik , is it okay if  we switch to v7 version?

Quoted 71 lines

BR,
Jani.

Quoted 67 lines
drivers/gpu/drm/i915/intel_bios.c +3 -0
+
+	dev_priv->vbt.psr.tp1_wakeup_time_us = vbt_psr_to_us(is_waketime_options, psr_table->tp1_wakeup_time);
+	dev_priv->vbt.psr.tp2_tp3_wakeup_time_us = vbt_psr_to_us(is_waketime_options, psr_table->tp2_tp3_wakeup_time);
   }
 
   static void parse_dsi_backlight_ports(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_psr.c +20 -19
index db27f2f..d64f039 100644
@@ -461,23 +461,23 @@ static void hsw_activate_psr1(struct intel_dp *intel_dp)
   	if (dev_priv->psr.link_standby)
   		val |= EDP_PSR_LINK_STANDBY;
 
-	if (dev_priv->vbt.psr.tp1_wakeup_time > 5)
-		val |= EDP_PSR_TP1_TIME_2500us;
-	else if (dev_priv->vbt.psr.tp1_wakeup_time > 1)
-		val |= EDP_PSR_TP1_TIME_500us;
-	else if (dev_priv->vbt.psr.tp1_wakeup_time > 0)
+	if (dev_priv->vbt.psr.tp1_wakeup_time_us == 0)
+		val |=  EDP_PSR_TP1_TIME_0us;
+	else if (dev_priv->vbt.psr.tp1_wakeup_time_us <= 100)
   		val |= EDP_PSR_TP1_TIME_100us;
+	else if (dev_priv->vbt.psr.tp1_wakeup_time_us <= 500)
+		val |= EDP_PSR_TP1_TIME_500us;
   	else
-		val |= EDP_PSR_TP1_TIME_0us;
+		val |= EDP_PSR_TP1_TIME_2500us;
 
-	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
-		val |= EDP_PSR_TP2_TP3_TIME_2500us;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
-		val |= EDP_PSR_TP2_TP3_TIME_500us;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 0)
+	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us == 0)
+		val |=  EDP_PSR_TP2_TP3_TIME_0us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 100)
   		val |= EDP_PSR_TP2_TP3_TIME_100us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 500)
+		val |= EDP_PSR_TP2_TP3_TIME_500us;
   	else
-		val |= EDP_PSR_TP2_TP3_TIME_0us;
+		val |= EDP_PSR_TP2_TP3_TIME_2500us;
 
   	if (intel_dp_source_supports_hbr2(intel_dp) &&
   	    drm_dp_tps3_supported(intel_dp->dpcd))
@@ -513,14 +513,15 @@ static void hsw_activate_psr2(struct intel_dp *intel_dp)
 
   	val |= EDP_PSR2_FRAME_BEFORE_SU(dev_priv->psr.sink_sync_latency + 1);
 
-	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
-		val |= EDP_PSR2_TP2_TIME_2500;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
-		val |= EDP_PSR2_TP2_TIME_500;
-	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 0)
-		val |= EDP_PSR2_TP2_TIME_100;
+	if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us >= 0 &&
+	    dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 50)
+		val |= EDP_PSR2_TP2_TIME_50us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 100)
+		val |= EDP_PSR2_TP2_TIME_100us;
+	else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time_us <= 500)
+		val |= EDP_PSR2_TP2_TIME_500us;
   	else
-		val |= EDP_PSR2_TP2_TIME_50;
+		val |= EDP_PSR2_TP2_TIME_2500us;
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/i915/intel_psr.c static void hsw_activate_psr2(struct intel_dp *intel_dp) · line 527

Quoted 2 lines
drivers/gpu/drm/i915/intel_psr.c +0 -0
   	I915_WRITE(EDP_PSR2_CTL, val);
   }

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

#5 lore raw

✗ Fi.CI.CHECKPATCH: warning for drm/i915/psr: vbt change for psr (rev8)

In reply to vathsala nagaraju
== Series Details ==

== Series Details ==

Series: drm/i915/psr: vbt change for psr (rev8)
URL : https://patchwork.freedesktop.org/series/41289/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
46adf06c3a05 drm/i915/psr: vbt change for psr
-:79: CHECK:SPACING: spaces preferred around that '<<' (ctx:VxV)
#79: FILE: drivers/gpu/drm/i915/i915_reg.h:4091:
+#define   EDP_PSR2_TP2_TIME_500us	(0<<8)
                                  	  ^

-:80: CHECK:SPACING: spaces preferred around that '<<' (ctx:VxV) #80: FILE: drivers/gpu/drm/i915/i915_reg.h:4092:
+#define EDP_PSR2_TP2_TIME_100us (1<<8)

                                  	  ^

-:81: CHECK:SPACING: spaces preferred around that '<<' (ctx:VxV) #81: FILE: drivers/gpu/drm/i915/i915_reg.h:4093:
+#define EDP_PSR2_TP2_TIME_2500us (2<<8)

                                   	  ^

-:82: CHECK:SPACING: spaces preferred around that '<<' (ctx:VxV) #82: FILE: drivers/gpu/drm/i915/i915_reg.h:4094:
+#define EDP_PSR2_TP2_TIME_50us (3<<8)

                                 	  ^

-:132: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #132: FILE: drivers/gpu/drm/i915/intel_bios.c:714:
+ if (psr_table->tp1_wakeup_time < 0 ||
+ psr_table->tp1_wakeup_time > 3) {

-:134: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #134: FILE: drivers/gpu/drm/i915/intel_bios.c:716:
+ DRM_DEBUG_KMS("VBT tp1 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
+ psr_table->tp1_wakeup_time);

-:137: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #137: FILE: drivers/gpu/drm/i915/intel_bios.c:719:
+ if (psr_table->tp2_tp3_wakeup_time < 0 ||
+ psr_table->tp2_tp3_wakeup_time > 3) {

-:139: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #139: FILE: drivers/gpu/drm/i915/intel_bios.c:721:
+ DRM_DEBUG_KMS("VBT tp2_tp3 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
+ psr_table->tp2_tp3_wakeup_time);

-:143: WARNING:LONG_LINE: line over 100 characters #143: FILE: drivers/gpu/drm/i915/intel_bios.c:725:
+ dev_priv->vbt.psr.tp1_wakeup_time_us = vbt_psr_to_us(is_waketime_options, psr_table->tp1_wakeup_time);

-:144: WARNING:LONG_LINE: line over 100 characters #144: FILE: drivers/gpu/drm/i915/intel_bios.c:726:
+ dev_priv->vbt.psr.tp2_tp3_wakeup_time_us = vbt_psr_to_us(is_waketime_options, psr_table->tp2_tp3_wakeup_time);

total: 0 errors, 2 warnings, 8 checks, 137 lines checked

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

#6 lore raw

✓ Fi.CI.BAT: success for drm/i915/psr: vbt change for psr (rev8)

In reply to vathsala nagaraju
== Series Details ==

== Series Details ==

Series: drm/i915/psr: vbt change for psr (rev8)
URL : https://patchwork.freedesktop.org/series/41289/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4204 -> Patchwork_9044 =

== Summary - SUCCESS ==

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/41289/revisions/8/mbox/

== Known issues ==

Here are the changes found in Patchwork_9044 that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@gem_mmap_gtt@basic-small-bo-tiledx:
      fi-gdg-551:         PASS -> FAIL (fdo#102575)

    igt@kms_frontbuffer_tracking@basic:
      fi-hsw-4200u:       PASS -> DMESG-FAIL (fdo#106103, fdo#102614)

    igt@kms_psr_sink_crc@basic:
      fi-elk-e7500:       SKIP -> INCOMPLETE (fdo#103989)

    
    ==== Possible fixes ====

    igt@kms_flip@basic-flip-vs-wf_vblank:
      fi-cnl-psr:         FAIL (fdo#100368) -> PASS

fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
fdo#103989 https://bugs.freedesktop.org/show_bug.cgi?id=103989
fdo#106103 https://bugs.freedesktop.org/show_bug.cgi?id=106103

== Participating hosts (42 -> 39) ==

Additional (1): fi-byt-j1900
Missing (4): fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-skl-6700hq

== Build changes ==

* Linux: CI_DRM_4204 -> Patchwork_9044

CI_DRM_4204: 1bffedaef627748248914f5a043e379fee0b121d @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4487: eccae1360d6d01e73c6af2bd97122cef708207ef @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9044: 46adf06c3a05a9975ff258f3e786bd31c79173e1 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4487: 6ab75f7eb5e1dccbb773e1739beeb2d7cbd6ad0d @ git://anongit.freedesktop.org/piglit

== Linux commits ==

46adf06c3a05 drm/i915/psr: vbt change for psr

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9044/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

✗ Fi.CI.IGT: failure for drm/i915/psr: vbt change for psr (rev8)

In reply to vathsala nagaraju
== Series Details ==

== Series Details ==

Series: drm/i915/psr: vbt change for psr (rev8)
URL : https://patchwork.freedesktop.org/series/41289/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4204_full -> Patchwork_9044_full =

== Summary - FAILURE ==

Serious unknown changes coming with Patchwork_9044_full absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_9044_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://patchwork.freedesktop.org/api/1.0/series/41289/revisions/8/mbox/

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_9044_full:

=== IGT changes ===

    ==== Possible regressions ====

    igt@kms_vblank@pipe-a-query-idle:
      shard-kbl:          PASS -> FAIL

    
    ==== Warnings ====

    igt@gem_mocs_settings@mocs-rc6-ctx-dirty-render:
      shard-kbl:          SKIP -> PASS

    igt@kms_cursor_crc@cursor-256x256-offscreen:
      shard-snb:          SKIP -> PASS

    igt@kms_plane_lowres@pipe-c-tiling-x:
      shard-apl:          PASS -> SKIP

== Known issues ==

Here are the changes found in Patchwork_9044_full that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@kms_flip_tiling@flip-x-tiled:
      shard-glk:          PASS -> FAIL (fdo#104724, fdo#103822) +1

    igt@kms_flip_tiling@flip-y-tiled:
      shard-glk:          PASS -> FAIL (fdo#104724)

    igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-blt:
      shard-kbl:          PASS -> DMESG-WARN (fdo#105602, fdo#103558, fdo#103313) +3

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-mmap-gtt:
      shard-apl:          PASS -> DMESG-FAIL (fdo#105602, fdo#103558)

    igt@kms_pipe_crc_basic@hang-read-crc-pipe-c:
      shard-apl:          PASS -> DMESG-WARN (fdo#105602, fdo#103558) +9

    igt@kms_setmode@basic:
      shard-apl:          PASS -> FAIL (fdo#99912)

    igt@kms_universal_plane@universal-plane-gen9-features-pipe-a:
      shard-kbl:          PASS -> DMESG-WARN (fdo#105602, fdo#103558) +9

    igt@kms_vblank@pipe-c-ts-continuation-suspend:
      shard-kbl:          PASS -> DMESG-WARN (fdo#103841, fdo#105602, fdo#103558)

    
    ==== Possible fixes ====

    igt@kms_cursor_legacy@2x-long-flip-vs-cursor-legacy:
      shard-glk:          FAIL (fdo#104873) -> PASS

    igt@kms_flip@2x-flip-vs-blocking-wf-vblank:
      shard-hsw:          FAIL (fdo#100368) -> PASS

    igt@kms_flip@blocking-wf_vblank:
      shard-hsw:          FAIL (fdo#103928) -> PASS

    igt@kms_flip@plain-flip-ts-check-interruptible:
      shard-glk:          FAIL (fdo#100368) -> PASS +1

    igt@kms_rotation_crc@primary-rotation-90:
      shard-apl:          FAIL (fdo#104724, fdo#103925) -> PASS

fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#103313 https://bugs.freedesktop.org/show_bug.cgi?id=103313
fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
fdo#103822 https://bugs.freedesktop.org/show_bug.cgi?id=103822
fdo#103841 https://bugs.freedesktop.org/show_bug.cgi?id=103841
fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
fdo#103928 https://bugs.freedesktop.org/show_bug.cgi?id=103928
fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
fdo#104873 https://bugs.freedesktop.org/show_bug.cgi?id=104873
fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912

== Participating hosts (9 -> 9) ==

No changes in participating hosts

== Build changes ==

* Linux: CI_DRM_4204 -> Patchwork_9044

CI_DRM_4204: 1bffedaef627748248914f5a043e379fee0b121d @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4487: eccae1360d6d01e73c6af2bd97122cef708207ef @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9044: 46adf06c3a05a9975ff258f3e786bd31c79173e1 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4487: 6ab75f7eb5e1dccbb773e1739beeb2d7cbd6ad0d @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9044/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx