Skip to contentSkip to conversation

drm/i915/dp: optimize eDP 1.4+ link config fast and narrow

RFC In review Jani Nikula 5 participants 7 messages May 9, 2018

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

RFC 1/1 drm/i915/dp: optimize eDP 1.4+ link config fast and narrow

We've opted to use the maximum link rate and lane count for eDP panels, because typically the maximum supported configuration reported by the panel has matched the native resolution requirements of the panel, and optimizing the link has lead to problems.

With eDP 1.4 rate select method and DSC features, this is decreasingly the case. There's a need to optimize the link parameters. Moreover, already eDP 1.3 states fast link with fewer lanes is preferred over the wide and slow. (Wide and slow should still be more reliable for longer cable lengths.)

Additionally, there have been reports of panels failing on arbitrary link configurations, although arguably all configurations they claim to support should work.

Optimize eDP 1.4+ link config fast and narrow.

Side note: The implementation has a near duplicate of the link config function, with just the two inner for loops turned inside out. Perhaps there'd be a way to make this, say, more table driven to reduce the duplication, but seems like that would lead to duplication in the table generation. We'll also have to see how the link config optimization for DSC turns out.

Cc: Ville Syrjälä <[email protected]>
Cc: Manasi Navare <[email protected]>
Cc: Rodrigo Vivi <[email protected]>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105267

---

Untested. It's possible this helps the referenced bug. The downside is that this patch has a bunch of dependencies that are too much to backport to stable kernels. If the patch works, we may need to consider hacking together an uglier backport.

---
 drivers/gpu/drm/i915/intel_dp.c | 73 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 62 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +62 -11
index dde92e4af5d3..1ec62965ece3 100644
@@ -1768,6 +1768,42 @@ intel_dp_compute_link_config_wide(struct intel_dp *intel_dp,
 	return false;
 }
 
+/* Optimize link config in order: max bpp, min lanes, min clock */
+static bool
+intel_dp_compute_link_config_fast(struct intel_dp *intel_dp,
+				  struct intel_crtc_state *pipe_config,
+				  const struct link_config_limits *limits)
+{
+	struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
+	int bpp, clock, lane_count;
+	int mode_rate, link_clock, link_avail;
+
+	for (bpp = limits->max_bpp; bpp >= limits->min_bpp; bpp -= 2 * 3) {
+		mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock,
+						   bpp);
+
+		for (lane_count = limits->min_lane_count;
+		     lane_count <= limits->max_lane_count;
+		     lane_count <<= 1) {
+			for (clock = limits->min_clock; clock <= limits->max_clock; clock++) {
+				link_clock = intel_dp->common_rates[clock];
+				link_avail = intel_dp_max_data_rate(link_clock,
+								    lane_count);
+
+				if (mode_rate <= link_avail) {
+					pipe_config->lane_count = lane_count;
+					pipe_config->pipe_bpp = bpp;
+					pipe_config->port_clock = link_clock;
+
+					return true;
+				}
+			}
+		}
+	}
+
+	return false;
+}
+
 static bool
 intel_dp_compute_link_config(struct intel_encoder *encoder,
 			     struct intel_crtc_state *pipe_config)
@@ -1792,13 +1828,15 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
 	limits.min_bpp = 6 * 3;
 	limits.max_bpp = intel_dp_compute_bpp(intel_dp, pipe_config);
 
-	if (intel_dp_is_edp(intel_dp)) {
+	if (intel_dp_is_edp(intel_dp) && intel_dp->edp_dpcd[0] < DP_EDP_14) {
 		/*
 		 * Use the maximum clock and number of lanes the eDP panel
-		 * advertizes being capable of. The panels are generally
-		 * designed to support only a single clock and lane
-		 * configuration, and typically these values correspond to the
-		 * native resolution of the panel.
+		 * advertizes being capable of. The eDP 1.3 and earlier panels
+		 * are generally designed to support only a single clock and
+		 * lane configuration, and typically these values correspond to
+		 * the native resolution of the panel. With eDP 1.4 rate select
+		 * and DSC, this is decreasingly the case, and we need to be
+		 * able to select less than maximum link config.
 		 */
 		limits.min_lane_count = limits.max_lane_count;
 		limits.min_clock = limits.max_clock;
@@ -1812,12 +1850,25 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
 		      intel_dp->common_rates[limits.max_clock],
 		      limits.max_bpp, adjusted_mode->crtc_clock);
 
-	/*
-	 * Optimize for slow and wide. This is the place to add alternative
-	 * optimization policy.
-	 */
-	if (!intel_dp_compute_link_config_wide(intel_dp, pipe_config, &limits))
-		return false;
+	if (intel_dp_is_edp(intel_dp)) {
+		/*
+		 * Optimize for fast and narrow. eDP 1.3 section 3.3 and eDP 1.4
+		 * section A.1: "It is recommended that the minimum number of
+		 * lanes be used, using the minimum link rate allowed for that
+		 * lane configuration."
+		 *
+		 * Note that we use the max clock and lane count for eDP 1.3 and
+		 * earlier, and fast vs. wide is irrelevant.
+		 */
+		if (!intel_dp_compute_link_config_fast(intel_dp, pipe_config,
+						       &limits))
+			return false;
+	} else {
+		/* Optimize for slow and wide. */
+		if (!intel_dp_compute_link_config_wide(intel_dp, pipe_config,
+						       &limits))
+			return false;
+	}
 
 	DRM_DEBUG_KMS("DP lane count %d clock %d bpp %d\n",
 		      pipe_config->lane_count, pipe_config->port_clock,
Signature · 6 lines
2.11.0

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

✓ Fi.CI.BAT: success for drm/i915/dp: optimize eDP 1.4+ link config fast and narrow

== Series Details ==

== Series Details ==

Series: drm/i915/dp: optimize eDP 1.4+ link config fast and narrow
URL : https://patchwork.freedesktop.org/series/42923/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4161 -> Patchwork_8957 =

== Summary - WARNING ==

Minor unknown changes coming with Patchwork_8957 need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_8957, 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/42923/revisions/1/mbox/

== Possible new issues ==

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

=== IGT changes ===

    ==== Warnings ====

    igt@gem_exec_gttfill@basic:
      fi-pnv-d510:        PASS -> SKIP

== Known issues ==

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

=== IGT changes ===

    ==== Issues hit ====

    igt@debugfs_test@read_all_entries:
      fi-snb-2520m:       PASS -> INCOMPLETE (fdo#103713)

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

    igt@kms_frontbuffer_tracking@basic:
      fi-cnl-y3:          PASS -> FAIL (fdo#104724, fdo#103167)

    igt@kms_pipe_crc_basic@read-crc-pipe-b-frame-sequence:
      fi-skl-guc:         PASS -> FAIL (fdo#103191, fdo#104724)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-cnl-y3:          PASS -> DMESG-WARN (fdo#104951)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
      fi-bxt-dsi:         PASS -> INCOMPLETE (fdo#103927)

fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
fdo#104951 https://bugs.freedesktop.org/show_bug.cgi?id=104951

== Participating hosts (40 -> 37) ==

Additional (1): fi-glk-j4005
Missing (4): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-skl-6700hq

== Build changes ==

* Linux: CI_DRM_4161 -> Patchwork_8957

CI_DRM_4161: f20dbaa0dfba8b33c677c084d39fc730309c5af2 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4468: 548a894dc904c4628522dbbc77cb179a4c965ebc @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_8957: 14195da35f10255240ce36a4f0c2628ba2340110 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4468: 1e60f1499e5b71b6d5a747189d7c28f57359a87f @ git://anongit.freedesktop.org/piglit

== Linux commits ==

14195da35f10 drm/i915/dp: optimize eDP 1.4+ link config fast and narrow

== Logs ==

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

#2 lore raw

✓ Fi.CI.IGT: success for drm/i915/dp: optimize eDP 1.4+ link config fast and narrow

In reply to Jani Nikula
== Series Details ==

== Series Details ==

Series: drm/i915/dp: optimize eDP 1.4+ link config fast and narrow
URL : https://patchwork.freedesktop.org/series/42923/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4161_full -> Patchwork_8957_full =

== Summary - WARNING ==

Minor unknown changes coming with Patchwork_8957_full need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_8957_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/42923/revisions/1/mbox/

== Possible new issues ==

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

=== IGT changes ===

    ==== Warnings ====

    igt@gem_exec_schedule@deep-blt:
      shard-kbl:          SKIP -> PASS +1

== Known issues ==

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

=== IGT changes ===

    ==== Issues hit ====

    igt@kms_flip@2x-flip-vs-absolute-wf_vblank:
      shard-hsw:          PASS -> FAIL (fdo#100368)

    igt@kms_flip@flip-vs-expired-vblank-interruptible:
      shard-glk:          PASS -> FAIL (fdo#102887)

    igt@kms_flip@plain-flip-fb-recreate-interruptible:
      shard-glk:          PASS -> FAIL (fdo#100368) +2

    
    ==== Possible fixes ====

    igt@kms_flip@dpms-vs-vblank-race-interruptible:
      shard-glk:          FAIL (fdo#103060) -> PASS

    igt@kms_flip@flip-vs-wf_vblank-interruptible:
      shard-glk:          FAIL (fdo#100368) -> PASS +1

    igt@kms_flip@modeset-vs-vblank-race:
      shard-hsw:          FAIL (fdo#103060) -> PASS

    igt@kms_vblank@pipe-b-accuracy-idle:
      shard-hsw:          FAIL (fdo#102583) -> PASS

fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#102583 https://bugs.freedesktop.org/show_bug.cgi?id=102583
fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060

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

No changes in participating hosts

== Build changes ==

* Linux: CI_DRM_4161 -> Patchwork_8957

CI_DRM_4161: f20dbaa0dfba8b33c677c084d39fc730309c5af2 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4468: 548a894dc904c4628522dbbc77cb179a4c965ebc @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_8957: 14195da35f10255240ce36a4f0c2628ba2340110 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4468: 1e60f1499e5b71b6d5a747189d7c28f57359a87f @ git://anongit.freedesktop.org/piglit

== Logs ==

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

maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Jani Nikula
Quoted 24 lines · Jani Nikula

We've opted to use the maximum link rate and lane count for eDP panels, because typically the maximum supported configuration reported by the panel has matched the native resolution requirements of the panel, and optimizing the link has lead to problems.

With eDP 1.4 rate select method and DSC features, this is decreasingly the case. There's a need to optimize the link parameters. Moreover, already eDP 1.3 states fast link with fewer lanes is preferred over the wide and slow. (Wide and slow should still be more reliable for longer cable lengths.)

Additionally, there have been reports of panels failing on arbitrary link configurations, although arguably all configurations they claim to support should work.

Optimize eDP 1.4+ link config fast and narrow.

Side note: The implementation has a near duplicate of the link config function, with just the two inner for loops turned inside out. Perhaps there'd be a way to make this, say, more table driven to reduce the duplication, but seems like that would lead to duplication in the table generation. We'll also have to see how the link config optimization for DSC turns out.

Quoted 3 lines
Cc Ville Syrjälä <[email protected]>
Cc Manasi Navare <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Matt Atwood <[email protected]>

I believe Matt is interested on this and know who could test this for us.

Quoted 2 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105267

This matches my understand of the eDP 1.4 spec I believe this is the way to go, so

but probably better to get a proper review and wait for someone to test...

Quoted 114 lines

---

Untested. It's possible this helps the referenced bug. The downside is that this patch has a bunch of dependencies that are too much to backport to stable kernels. If the patch works, we may need to consider hacking together an uglier backport.

---
 drivers/gpu/drm/i915/intel_dp.c | 73 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 62 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +62 -11
index dde92e4af5d3..1ec62965ece3 100644
@@ -1768,6 +1768,42 @@ intel_dp_compute_link_config_wide(struct intel_dp *intel_dp,
 	return false;
 }
 
+/* Optimize link config in order: max bpp, min lanes, min clock */
+static bool
+intel_dp_compute_link_config_fast(struct intel_dp *intel_dp,
+				  struct intel_crtc_state *pipe_config,
+				  const struct link_config_limits *limits)
+{
+	struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
+	int bpp, clock, lane_count;
+	int mode_rate, link_clock, link_avail;
+
+	for (bpp = limits->max_bpp; bpp >= limits->min_bpp; bpp -= 2 * 3) {
+		mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock,
+						   bpp);
+
+		for (lane_count = limits->min_lane_count;
+		     lane_count <= limits->max_lane_count;
+		     lane_count <<= 1) {
+			for (clock = limits->min_clock; clock <= limits->max_clock; clock++) {
+				link_clock = intel_dp->common_rates[clock];
+				link_avail = intel_dp_max_data_rate(link_clock,
+								    lane_count);
+
+				if (mode_rate <= link_avail) {
+					pipe_config->lane_count = lane_count;
+					pipe_config->pipe_bpp = bpp;
+					pipe_config->port_clock = link_clock;
+
+					return true;
+				}
+			}
+		}
+	}
+
+	return false;
+}
+
 static bool
 intel_dp_compute_link_config(struct intel_encoder *encoder,
 			     struct intel_crtc_state *pipe_config)
@@ -1792,13 +1828,15 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
 	limits.min_bpp = 6 * 3;
 	limits.max_bpp = intel_dp_compute_bpp(intel_dp, pipe_config);
 
-	if (intel_dp_is_edp(intel_dp)) {
+	if (intel_dp_is_edp(intel_dp) && intel_dp->edp_dpcd[0] < DP_EDP_14) {
 		/*
 		 * Use the maximum clock and number of lanes the eDP panel
-		 * advertizes being capable of. The panels are generally
-		 * designed to support only a single clock and lane
-		 * configuration, and typically these values correspond to the
-		 * native resolution of the panel.
+		 * advertizes being capable of. The eDP 1.3 and earlier panels
+		 * are generally designed to support only a single clock and
+		 * lane configuration, and typically these values correspond to
+		 * the native resolution of the panel. With eDP 1.4 rate select
+		 * and DSC, this is decreasingly the case, and we need to be
+		 * able to select less than maximum link config.
 		 */
 		limits.min_lane_count = limits.max_lane_count;
 		limits.min_clock = limits.max_clock;
@@ -1812,12 +1850,25 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
 		      intel_dp->common_rates[limits.max_clock],
 		      limits.max_bpp, adjusted_mode->crtc_clock);
 
-	/*
-	 * Optimize for slow and wide. This is the place to add alternative
-	 * optimization policy.
-	 */
-	if (!intel_dp_compute_link_config_wide(intel_dp, pipe_config, &limits))
-		return false;
+	if (intel_dp_is_edp(intel_dp)) {
+		/*
+		 * Optimize for fast and narrow. eDP 1.3 section 3.3 and eDP 1.4
+		 * section A.1: "It is recommended that the minimum number of
+		 * lanes be used, using the minimum link rate allowed for that
+		 * lane configuration."
+		 *
+		 * Note that we use the max clock and lane count for eDP 1.3 and
+		 * earlier, and fast vs. wide is irrelevant.
+		 */
+		if (!intel_dp_compute_link_config_fast(intel_dp, pipe_config,
+						       &limits))
+			return false;
+	} else {
+		/* Optimize for slow and wide. */
+		if (!intel_dp_compute_link_config_wide(intel_dp, pipe_config,
+						       &limits))
+			return false;
+	}
 
 	DRM_DEBUG_KMS("DP lane count %d clock %d bpp %d\n",
 		      pipe_config->lane_count, pipe_config->port_clock,
Signature · 1 line
2.11.0

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

#4 lore raw
Quoted 37 lines · Rodrigo Vivi
Quoted 36 lines · Jani Nikula

We've opted to use the maximum link rate and lane count for eDP panels,
because typically the maximum supported configuration reported by the
panel has matched the native resolution requirements of the panel, and
optimizing the link has lead to problems.

With eDP 1.4 rate select method and DSC features, this is decreasingly
the case. There's a need to optimize the link parameters. Moreover, already eDP 1.3 states fast link with fewer lanes is preferred over the
wide and slow. (Wide and slow should still be more reliable for longer
cable lengths.)

Additionally, there have been reports of panels failing on arbitrary
link configurations, although arguably all configurations they claim to
support should work.

Optimize eDP 1.4+ link config fast and narrow.

Side note: The implementation has a near duplicate of the link config
function, with just the two inner for loops turned inside out. Perhaps
there'd be a way to make this, say, more table driven to reduce the duplication, but seems like that would lead to duplication in the table
generation. We'll also have to see how the link config optimization for
DSC turns out.

Quoted 8 lines
Quoted 3 lines
Cc Ville Syrjälä <[email protected]>
Cc Manasi Navare <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Matt Atwood <[email protected]>

I believe Matt is interested on this and know who could test this for us.

I'm actually in the process of working with my counterpart at Google to actually quantify what power is saved. With both chromeos- 4.14/chromeos-4.4 patches to do so across multiple boards and multiple systems.

Quoted 36 lines
Quoted 3 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105267

This matches my understand of the eDP 1.4 spec I believe this is the way to go, so

but probably better to get a proper review and wait for someone to test...

Quoted 24 lines

---

Untested. It's possible this helps the referenced bug. The downside is
that this patch has a bunch of dependencies that are too much to backport to stable kernels. If the patch works, we may need to consider
hacking together an uglier backport.

---
 drivers/gpu/drm/i915/intel_dp.c | 73
++++++++++++++++++++++++++++++++++-------
 1 file changed, 62 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +0 -0
index dde92e4af5d3..1ec62965ece3 100644
@@ -1768,6 +1768,42 @@ intel_dp_compute_link_config_wide(struct
 intel_dp *intel_dp,
 	return false;
 }
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_dp.c intel_dp_compute_link_config_wide(struct · line 1778

Quoted 7 lines
drivers/gpu/drm/i915/intel_dp.c +5 -0
+/* Optimize link config in order: max bpp, min lanes, min clock */
+static bool
+intel_dp_compute_link_config_fast(struct intel_dp *intel_dp,
+				  struct intel_crtc_state
 *pipe_config,
+				  const struct link_config_limits
 *limits)

I personally called this intel_dp_compute_link_config_narrow as a counterpart to the "wide" implementation.

Quoted 96 lines
Quoted 96 lines
drivers/gpu/drm/i915/intel_dp.c +2 -0
+{
+	struct drm_display_mode *adjusted_mode = &pipe_config-
Quoted 1 line

base.adjusted_mode;

drivers/gpu/drm/i915/intel_dp.c +4 -0
+	int bpp, clock, lane_count;
+	int mode_rate, link_clock, link_avail;
+
+	for (bpp = limits->max_bpp; bpp >= limits->min_bpp; bpp -=

2 * 3) {

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		mode_rate = intel_dp_link_required(adjusted_mode-
Quoted 1 line

crtc_clock,

drivers/gpu/drm/i915/intel_dp.c +6 -0
+						   bpp);
+
+		for (lane_count = limits->min_lane_count;
+		     lane_count <= limits->max_lane_count;
+		     lane_count <<= 1) {
+			for (clock = limits->min_clock; clock <=

limits->max_clock; clock++) {

drivers/gpu/drm/i915/intel_dp.c +1 -0
+				link_clock = intel_dp-
Quoted 1 line

common_rates[clock];

drivers/gpu/drm/i915/intel_dp.c +1 -0
+				link_avail =

intel_dp_max_data_rate(link_clock,

drivers/gpu/drm/i915/intel_dp.c +4 -0
+								  
  lane_count);
+
+				if (mode_rate <= link_avail) {
+					pipe_config->lane_count =

lane_count;

drivers/gpu/drm/i915/intel_dp.c +1 -0
+					pipe_config->pipe_bpp =

bpp;

drivers/gpu/drm/i915/intel_dp.c +1 -0
+					pipe_config->port_clock =

link_clock;

drivers/gpu/drm/i915/intel_dp.c +11 -1
+
+					return true;
+				}
+			}
+		}
+	}
+
+	return false;
+}
+
 static bool
 intel_dp_compute_link_config(struct intel_encoder *encoder,
 			     struct intel_crtc_state *pipe_config)
@@ -1792,13 +1828,15 @@ intel_dp_compute_link_config(struct
 intel_encoder *encoder,
 	limits.min_bpp = 6 * 3;
 	limits.max_bpp = intel_dp_compute_bpp(intel_dp,
 pipe_config);
 
-	if (intel_dp_is_edp(intel_dp)) {
+	if (intel_dp_is_edp(intel_dp) && intel_dp->edp_dpcd[0] <
 DP_EDP_14) {
 		/*
 		 * Use the maximum clock and number of lanes the

eDP panel

drivers/gpu/drm/i915/intel_dp.c +0 -1
-		 * advertizes being capable of. The panels are

generally

drivers/gpu/drm/i915/intel_dp.c +0 -1
-		 * designed to support only a single clock and

lane

drivers/gpu/drm/i915/intel_dp.c +0 -1
-		 * configuration, and typically these values

correspond to the

drivers/gpu/drm/i915/intel_dp.c +1 -1
-		 * native resolution of the panel.
+		 * advertizes being capable of. The eDP 1.3 and

earlier panels

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		 * are generally designed to support only a single

clock and

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		 * lane configuration, and typically these values

correspond to

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		 * the native resolution of the panel. With eDP

1.4 rate select

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		 * and DSC, this is decreasingly the case, and we

need to be

drivers/gpu/drm/i915/intel_dp.c +1 -2
+		 * able to select less than maximum link config.
 		 */
 		limits.min_lane_count = limits.max_lane_count;
 		limits.min_clock = limits.max_clock;
@@ -1812,12 +1850,25 @@ intel_dp_compute_link_config(struct
 intel_encoder *encoder,
 		      intel_dp->common_rates[limits.max_clock],
 		      limits.max_bpp, adjusted_mode->crtc_clock);
 
-	/*
-	 * Optimize for slow and wide. This is the place to add

alternative

drivers/gpu/drm/i915/intel_dp.c +0 -3
-	 * optimization policy.
-	 */
-	if (!intel_dp_compute_link_config_wide(intel_dp,

pipe_config, &limits))

drivers/gpu/drm/i915/intel_dp.c +3 -1
-		return false;
+	if (intel_dp_is_edp(intel_dp)) {
+		/*
+		 * Optimize for fast and narrow. eDP 1.3 section

3.3 and eDP 1.4

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		 * section A.1: "It is recommended that the

minimum number of

Quoted 8 lines

drivers/gpu/drm/i915/intel_dp.c intel_dp_compute_link_config(struct intel_encoder *encoder, · line 1862

Quoted 8 lines
drivers/gpu/drm/i915/intel_dp.c +1 -0
+		 * lanes be used, using the minimum link rate

allowed for that

drivers/gpu/drm/i915/intel_dp.c +3 -0
+		 * lane configuration."
+		 *
+		 * Note that we use the max clock and lane count

for eDP 1.3 and

drivers/gpu/drm/i915/intel_dp.c +2 -0
+		 * earlier, and fast vs. wide is irrelevant.
+		 */

This is where I got hung up on *many* eDP panels. This will break many pre edp 1.4 panels. I wrapped mine on a DPCD compare to DP_DPCD_REV.

Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/i915/intel_dp.c +1 -0
+		if (!intel_dp_compute_link_config_fast(intel_dp,

pipe_config,

drivers/gpu/drm/i915/intel_dp.c +5 -0
+						       &limits))
+			return false;
+	} else {
+		/* Optimize for slow and wide. */
+		if (!intel_dp_compute_link_config_wide(intel_dp,

pipe_config,

drivers/gpu/drm/i915/intel_dp.c +3 -0
+						       &limits))
+			return false;
+	}
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_dp.c +0 -0
 	DRM_DEBUG_KMS("DP lane count %d clock %d bpp %d\n",
 		      pipe_config->lane_count, pipe_config-
Quoted 1 line

port_clock,

Signature · 1 line
2.11.0

I'm honestly glad that someone else cares I know in the case of the wide optimization on a product I was working one we saved 200 uW, I'm hoping for a bigger share with the narrow/fast implementation.

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

#5 lore raw
Quoted 222 lines · Matt Atwood
Quoted 46 lines · Rodrigo Vivi
Quoted 41 lines · Jani Nikula

We've opted to use the maximum link rate and lane count for eDP panels,
because typically the maximum supported configuration reported by the
panel has matched the native resolution requirements of the panel,
and
optimizing the link has lead to problems.

With eDP 1.4 rate select method and DSC features, this is decreasingly
the case. There's a need to optimize the link parameters. Moreover,
already eDP 1.3 states fast link with fewer lanes is preferred over
the
wide and slow. (Wide and slow should still be more reliable for longer
cable lengths.)

Additionally, there have been reports of panels failing on arbitrary
link configurations, although arguably all configurations they claim to
support should work.

Optimize eDP 1.4+ link config fast and narrow.

Side note: The implementation has a near duplicate of the link config
function, with just the two inner for loops turned inside out. Perhaps
there'd be a way to make this, say, more table driven to reduce the
duplication, but seems like that would lead to duplication in the table
generation. We'll also have to see how the link config optimization
for
DSC turns out.

Quoted 3 lines
Cc Ville Syrjälä <[email protected]>
Cc Manasi Navare <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Quoted 5 lines
Cc Matt Atwood <[email protected]>

I believe Matt is interested on this and know who could test this for
us.

I'm actually in the process of working with my counterpart at Google to
actually quantify what power is saved. With both chromeos- 4.14/chromeos-4.4 patches to do so across multiple boards and multiple
systems.

Quoted 38 lines
Quoted 3 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105267

This matches my understand of the eDP 1.4 spec I believe this is the
way to go, so

but probably better to get a proper review and wait for someone to test...

Quoted 25 lines

---

Untested. It's possible this helps the referenced bug. The downside
is
that this patch has a bunch of dependencies that are too much to backport to stable kernels. If the patch works, we may need to consider
hacking together an uglier backport.

---
 drivers/gpu/drm/i915/intel_dp.c | 73
++++++++++++++++++++++++++++++++++-------
 1 file changed, 62 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +0 -0
index dde92e4af5d3..1ec62965ece3 100644
@@ -1768,6 +1768,42 @@ intel_dp_compute_link_config_wide(struct
 intel_dp *intel_dp,
 	return false;
 }
 
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_dp.c +5 -0
+/* Optimize link config in order: max bpp, min lanes, min clock
 */
+static bool
+intel_dp_compute_link_config_fast(struct intel_dp *intel_dp,
+				  struct intel_crtc_state
 *pipe_config,
+				  const struct

link_config_limits
*limits)

I personally called this intel_dp_compute_link_config_narrow as a counterpart to the "wide" implementation.

Quoted 113 lines
Quoted 113 lines
drivers/gpu/drm/i915/intel_dp.c +2 -0
+{
+	struct drm_display_mode *adjusted_mode = &pipe_config-
Quoted 1 line

base.adjusted_mode;

drivers/gpu/drm/i915/intel_dp.c +4 -1
+	int bpp, clock, lane_count;
+	int mode_rate, link_clock, link_avail;
+
+	for (bpp = limits->max_bpp; bpp >= limits->min_bpp; bpp
-=

2 * 3) {

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		mode_rate =

intel_dp_link_required(adjusted_mode-

Quoted 1 line

crtc_clock,

drivers/gpu/drm/i915/intel_dp.c +6 -0
+						   bpp);
+
+		for (lane_count = limits->min_lane_count;
+		     lane_count <= limits->max_lane_count;
+		     lane_count <<= 1) {
+			for (clock = limits->min_clock; clock <=

limits->max_clock; clock++) {

drivers/gpu/drm/i915/intel_dp.c +1 -0
+				link_clock = intel_dp-
Quoted 1 line

common_rates[clock];

drivers/gpu/drm/i915/intel_dp.c +1 -0
+				link_avail =

intel_dp_max_data_rate(link_clock,

drivers/gpu/drm/i915/intel_dp.c +4 -0
+								
 
  lane_count);
+
+				if (mode_rate <= link_avail) {
+					pipe_config->lane_count

=
lane_count;

drivers/gpu/drm/i915/intel_dp.c +1 -0
+					pipe_config->pipe_bpp =

bpp;

drivers/gpu/drm/i915/intel_dp.c +1 -0
+					pipe_config->port_clock

=
link_clock;

drivers/gpu/drm/i915/intel_dp.c +10 -0
+
+					return true;
+				}
+			}
+		}
+	}
+
+	return false;
+}
+
 static bool
 intel_dp_compute_link_config(struct intel_encoder *encoder,
 			     struct intel_crtc_state

*pipe_config)

drivers/gpu/drm/i915/intel_dp.c +1 -1
@@ -1792,13 +1828,15 @@ intel_dp_compute_link_config(struct
 intel_encoder *encoder,
 	limits.min_bpp = 6 * 3;
 	limits.max_bpp = intel_dp_compute_bpp(intel_dp,
 pipe_config);
 
-	if (intel_dp_is_edp(intel_dp)) {
+	if (intel_dp_is_edp(intel_dp) && intel_dp->edp_dpcd[0] <
 DP_EDP_14) {
 		/*
 		 * Use the maximum clock and number of lanes the

eDP panel

drivers/gpu/drm/i915/intel_dp.c +0 -1
-		 * advertizes being capable of. The panels are

generally

drivers/gpu/drm/i915/intel_dp.c +0 -1
-		 * designed to support only a single clock and

lane

drivers/gpu/drm/i915/intel_dp.c +0 -1
-		 * configuration, and typically these values

correspond to the

drivers/gpu/drm/i915/intel_dp.c +1 -1
-		 * native resolution of the panel.
+		 * advertizes being capable of. The eDP 1.3 and

earlier panels

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		 * are generally designed to support only a

single
clock and

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		 * lane configuration, and typically these

values
correspond to

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		 * the native resolution of the panel. With eDP

1.4 rate select

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		 * and DSC, this is decreasingly the case, and

we
need to be

drivers/gpu/drm/i915/intel_dp.c +1 -2
+		 * able to select less than maximum link config.
 		 */
 		limits.min_lane_count = limits.max_lane_count;
 		limits.min_clock = limits.max_clock;
@@ -1812,12 +1850,25 @@ intel_dp_compute_link_config(struct
 intel_encoder *encoder,
 		      intel_dp->common_rates[limits.max_clock],
 		      limits.max_bpp, adjusted_mode-
 >crtc_clock);
 
-	/*
-	 * Optimize for slow and wide. This is the place to add

alternative

drivers/gpu/drm/i915/intel_dp.c +0 -3
-	 * optimization policy.
-	 */
-	if (!intel_dp_compute_link_config_wide(intel_dp,

pipe_config, &limits))

drivers/gpu/drm/i915/intel_dp.c +3 -1
-		return false;
+	if (intel_dp_is_edp(intel_dp)) {
+		/*
+		 * Optimize for fast and narrow. eDP 1.3 section

3.3 and eDP 1.4

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		 * section A.1: "It is recommended that the

minimum number of

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		 * lanes be used, using the minimum link rate

allowed for that

drivers/gpu/drm/i915/intel_dp.c +2 -0
+		 * lane configuration."
+		 *
Quoted 8 lines
Quoted 4 lines

drivers/gpu/drm/i915/intel_dp.c intel_dp_compute_link_config(struct intel_encoder *encoder, · line 1862

Quoted 4 lines
drivers/gpu/drm/i915/intel_dp.c +1 -0
+		 * Note that we use the max clock and lane count

for eDP 1.3 and

drivers/gpu/drm/i915/intel_dp.c +2 -0
+		 * earlier, and fast vs. wide is irrelevant.
+		 */

This is where I got hung up on *many* eDP panels. This will break many
pre edp 1.4 panels. I wrapped mine on a DPCD compare to DP_DPCD_REV.

disregard this statement missed the second conditional

Quoted 20 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/i915/intel_dp.c +1 -0
+		if (!intel_dp_compute_link_config_fast(intel_dp,

pipe_config,

drivers/gpu/drm/i915/intel_dp.c +5 -0
+						       &limits))
+			return false;
+	} else {
+		/* Optimize for slow and wide. */
+		if (!intel_dp_compute_link_config_wide(intel_dp,

pipe_config,

drivers/gpu/drm/i915/intel_dp.c +3 -0
+						       &limits))
+			return false;
+	}
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_dp.c +0 -0
 	DRM_DEBUG_KMS("DP lane count %d clock %d bpp %d\n",
 		      pipe_config->lane_count, pipe_config-
Quoted 1 line

port_clock,

Signature · 1 line
2.11.0
Quoted 5 lines

I'm honestly glad that someone else cares I know in the case of the wide optimization on a product I was working one we saved 200 uW, I'm hoping for a bigger share with the narrow/fast implementation.

-Matt

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

#6 lore raw
In reply to Jani Nikula
Quoted 15 lines · Jani Nikula

We've opted to use the maximum link rate and lane count for eDP panels, because typically the maximum supported configuration reported by the panel has matched the native resolution requirements of the panel, and optimizing the link has lead to problems.

With eDP 1.4 rate select method and DSC features, this is decreasingly the case. There's a need to optimize the link parameters. Moreover, already eDP 1.3 states fast link with fewer lanes is preferred over the wide and slow. (Wide and slow should still be more reliable for longer cable lengths.)

Additionally, there have been reports of panels failing on arbitrary link configurations, although arguably all configurations they claim to support should work.

Quoted 8 lines

Optimize eDP 1.4+ link config fast and narrow.

Side note: The implementation has a near duplicate of the link config function, with just the two inner for loops turned inside out. Perhaps there'd be a way to make this, say, more table driven to reduce the duplication, but seems like that would lead to duplication in the table generation. We'll also have to see how the link config optimization for DSC turns out.

Yes for DSC for eDP we currently try fast and wide and if that doesnt fit the requested mode then we enable DSC.
Now with the fast and narrow approach, again for power savings we can try the fastest link rate with narrowest lane count and see if DSC can be enabled there before increasing the lane count. But anyways that calls for a separate optimization discussion.

Otherwise yes this method looks correct as per eDP 1.4 spec.

Quoted 22 lines

Cc: Ville Syrjälä <[email protected]>
Cc: Manasi Navare <[email protected]>
Cc: Rodrigo Vivi <[email protected]>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105267

---

Untested. It's possible this helps the referenced bug. The downside is that this patch has a bunch of dependencies that are too much to backport to stable kernels. If the patch works, we may need to consider hacking together an uglier backport.

---
 drivers/gpu/drm/i915/intel_dp.c | 73 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 62 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +0 -0
index dde92e4af5d3..1ec62965ece3 100644

drivers/gpu/drm/i915/intel_dp.c intel_dp_compute_link_config_wide(struct intel_dp *intel_dp, · line 1775

Quoted 8 lines
drivers/gpu/drm/i915/intel_dp.c +5 -0
@@ -1768,6 +1768,42 @@ intel_dp_compute_link_config_wide(struct intel_dp *intel_dp,
 	return false;
 }
 
+/* Optimize link config in order: max bpp, min lanes, min clock */
+static bool
+intel_dp_compute_link_config_fast(struct intel_dp *intel_dp,
+				  struct intel_crtc_state *pipe_config,
+				  const struct link_config_limits *limits)

Should we make the name of this function intel_dp_compute_link_config_fast_narrow() to make it more intuitive to the optimization approach

And while at it change the other one also to _wide_slow()? Just a suggestion but otherwise everything else LGTM.

Regards
Manasi

Quoted 90 lines
drivers/gpu/drm/i915/intel_dp.c +57 -11
+{
+	struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
+	int bpp, clock, lane_count;
+	int mode_rate, link_clock, link_avail;
+
+	for (bpp = limits->max_bpp; bpp >= limits->min_bpp; bpp -= 2 * 3) {
+		mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock,
+						   bpp);
+
+		for (lane_count = limits->min_lane_count;
+		     lane_count <= limits->max_lane_count;
+		     lane_count <<= 1) {
+			for (clock = limits->min_clock; clock <= limits->max_clock; clock++) {
+				link_clock = intel_dp->common_rates[clock];
+				link_avail = intel_dp_max_data_rate(link_clock,
+								    lane_count);
+
+				if (mode_rate <= link_avail) {
+					pipe_config->lane_count = lane_count;
+					pipe_config->pipe_bpp = bpp;
+					pipe_config->port_clock = link_clock;
+
+					return true;
+				}
+			}
+		}
+	}
+
+	return false;
+}
+
 static bool
 intel_dp_compute_link_config(struct intel_encoder *encoder,
 			     struct intel_crtc_state *pipe_config)
@@ -1792,13 +1828,15 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
 	limits.min_bpp = 6 * 3;
 	limits.max_bpp = intel_dp_compute_bpp(intel_dp, pipe_config);
 
-	if (intel_dp_is_edp(intel_dp)) {
+	if (intel_dp_is_edp(intel_dp) && intel_dp->edp_dpcd[0] < DP_EDP_14) {
 		/*
 		 * Use the maximum clock and number of lanes the eDP panel
-		 * advertizes being capable of. The panels are generally
-		 * designed to support only a single clock and lane
-		 * configuration, and typically these values correspond to the
-		 * native resolution of the panel.
+		 * advertizes being capable of. The eDP 1.3 and earlier panels
+		 * are generally designed to support only a single clock and
+		 * lane configuration, and typically these values correspond to
+		 * the native resolution of the panel. With eDP 1.4 rate select
+		 * and DSC, this is decreasingly the case, and we need to be
+		 * able to select less than maximum link config.
 		 */
 		limits.min_lane_count = limits.max_lane_count;
 		limits.min_clock = limits.max_clock;
@@ -1812,12 +1850,25 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
 		      intel_dp->common_rates[limits.max_clock],
 		      limits.max_bpp, adjusted_mode->crtc_clock);
 
-	/*
-	 * Optimize for slow and wide. This is the place to add alternative
-	 * optimization policy.
-	 */
-	if (!intel_dp_compute_link_config_wide(intel_dp, pipe_config, &limits))
-		return false;
+	if (intel_dp_is_edp(intel_dp)) {
+		/*
+		 * Optimize for fast and narrow. eDP 1.3 section 3.3 and eDP 1.4
+		 * section A.1: "It is recommended that the minimum number of
+		 * lanes be used, using the minimum link rate allowed for that
+		 * lane configuration."
+		 *
+		 * Note that we use the max clock and lane count for eDP 1.3 and
+		 * earlier, and fast vs. wide is irrelevant.
+		 */
+		if (!intel_dp_compute_link_config_fast(intel_dp, pipe_config,
+						       &limits))
+			return false;
+	} else {
+		/* Optimize for slow and wide. */
+		if (!intel_dp_compute_link_config_wide(intel_dp, pipe_config,
+						       &limits))
+			return false;
+	}
 
 	DRM_DEBUG_KMS("DP lane count %d clock %d bpp %d\n",
 		      pipe_config->lane_count, pipe_config->port_clock,
Signature · 1 line
2.11.0

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