Skip to contentSkip to conversation

drm/i915: Improve PSR activation timing

PATCH In review Rodrigo Vivi 5 participants 7 messages Feb 28, 2018 – Mar 7, 2018

Subsystems (2)
lore
Share & tools
lore

Rodrigo Vivi

author maintainer
#0 lore raw

PATCH 1/3 drm/i915: Improve PSR activation timing

From: Andy Lutomirski <[email protected]>

The current PSR code has a two call sites that each schedule delayed work to activate PSR. As far as I can tell, each call site intends to keep PSR inactive for the given amount of time and then allow it to be activated.

The call sites are:

- intel_psr_enable(), which explicitly states in a comment that it's trying to keep PSR off a short time after the dispay is initialized as a workaround.

- intel_psr_flush(). There isn't an explcit explanation, but the intent is presumably to keep PSR off until the display has been idle for 100ms.

The current code doesn't actually accomplish either of these goals. Rather than keeping PSR inactive for the given amount of time, it will schedule PSR for activation after the given time, with the earliest target time in such a request winning.

In other words, if intel_psr_enable() is immediately followed by intel_psr_flush(), then PSR will be activated after 100ms even if intel_psr_enable() wanted a longer delay. And, if the screen is being constantly updated so that intel_psr_flush() is called once per frame at 60Hz, PSR will still be activated once every 100ms.

Rewrite the code so that it does what was intended. This adds a new function intel_psr_schedule(), which will enable PSR after the requested time but no sooner.

v3: (by Rodrigo): Rebased on top of recent drm-tip without any
modification from the original.

---
 drivers/gpu/drm/i915/i915_debugfs.c |  9 +++--
 drivers/gpu/drm/i915/i915_drv.h     |  4 ++-
 drivers/gpu/drm/i915/intel_psr.c    | 69 ++++++++++++++++++++++++++++++++-----
 3 files changed, 71 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +7 -2
index 33fbf3965309..1ac942d1742e 100644
@@ -2572,8 +2572,13 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
 	seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active));
 	seq_printf(m, "Busy frontbuffer bits: 0x%03x\n",
 		   dev_priv->psr.busy_frontbuffer_bits);
-	seq_printf(m, "Re-enable work scheduled: %s\n",
-		   yesno(work_busy(&dev_priv->psr.work.work)));
+
+	if (timer_pending(&dev_priv->psr.activate_timer))
+		seq_printf(m, "Activate scheduled: yes, in %ldms\n",
+			   (long)(dev_priv->psr.earliest_activate - jiffies) *
+			   1000 / HZ);
+	else
+		seq_printf(m, "Re-enable scheduled: no\n");
 
 	if (HAS_DDI(dev_priv)) {
 		if (dev_priv->psr.psr2_support)
drivers/gpu/drm/i915/i915_drv.h +3 -1
index 7bbec5546d12..6e6cf2ce3749 100644
@@ -764,7 +764,9 @@ struct i915_psr {
 	bool sink_support;
 	struct intel_dp *enabled;
 	bool active;
-	struct delayed_work work;
+	struct timer_list activate_timer;
+	struct work_struct activate_work;
+	unsigned long earliest_activate;
 	unsigned busy_frontbuffer_bits;
 	bool psr2_support;
 	bool aux_frame_sync;
drivers/gpu/drm/i915/intel_psr.c +61 -8

126 lines not on this page · raw message

Signature · 6 lines
2.13.6

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

PATCH 2/3 drm/i915/psr: Kill scheduled work for Core platforms.

It is a fact that scheduled work is now improved.

But it is also a fact that on core platforms that shouldn't be needed. We only need to actually wait on VLV/CHV.

The immediate enabling is actually not an issue for the HW perspective for core platforms that have HW tracking. HW will wait few identical idle frames before transitioning to actual psr active anyways.

Note that this patch also remove the delayed activation on HSW and BDW introduced by commit 'd0ac896a477d ("drm/i915: Delay first PSR activation.")'. This was introduced to fix a blank screen on VLV/CHV and also masked some frozen screens on other core platforms. Probably the same that we are now properly hunting and fixing.

Furthermore, if we stop using delayed activation on core platforms we will be able, on following up patches, to use available workarounds to make HW tracking properly exit PSR instead of the big nuke of disabling psr and re-enable on exit and activate respectively.
At least on few reliable cases.

v2:(DK): Remove unnecessary WARN_ONs and make some other
VLV | CHV more readable.

Cc Dhinakaran Pandiyan <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 22 +++++++++++-----------
 drivers/gpu/drm/i915/intel_psr.c    | 28 ++++++++++++++++++----------
 2 files changed, 29 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +11 -11
index 1ac942d1742e..fb106b4a3eaf 100644
@@ -2573,19 +2573,14 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
 	seq_printf(m, "Busy frontbuffer bits: 0x%03x\n",
 		   dev_priv->psr.busy_frontbuffer_bits);
 
-	if (timer_pending(&dev_priv->psr.activate_timer))
-		seq_printf(m, "Activate scheduled: yes, in %ldms\n",
-			   (long)(dev_priv->psr.earliest_activate - jiffies) *
+	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
+		if (timer_pending(&dev_priv->psr.activate_timer))
+			seq_printf(m, "Activate scheduled: yes, in %ldms\n",
+				   (long)(dev_priv->psr.earliest_activate - jiffies) *
 			   1000 / HZ);
-	else
-		seq_printf(m, "Re-enable scheduled: no\n");
-
-	if (HAS_DDI(dev_priv)) {
-		if (dev_priv->psr.psr2_support)
-			enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE;
 		else
-			enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE;
-	} else {
+			seq_printf(m, "Re-enable scheduled: no\n");
+
 		for_each_pipe(dev_priv, pipe) {
 			enum transcoder cpu_transcoder =
 				intel_pipe_to_cpu_transcoder(dev_priv, pipe);
@@ -2604,6 +2599,11 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
 
 			intel_display_power_put(dev_priv, power_domain);
 		}
+	} else {
+		if (dev_priv->psr.psr2_support)
+			enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE;
+		else
+			enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE;
 	}
 
 	seq_printf(m, "Main link in standby mode: %s\n",
drivers/gpu/drm/i915/intel_psr.c +18 -10
index c10d5225dc7c..6d413a7bb39f 100644
@@ -575,6 +575,9 @@ static void intel_psr_schedule(struct drm_i915_private *dev_priv,
 {
 	unsigned long next;
 
+	if (WARN_ON(!(IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))))
+		return;
+
 	lockdep_assert_held(&dev_priv->psr.lock);
 
 	/*
@@ -667,9 +670,7 @@ void intel_psr_enable(struct intel_dp *intel_dp,
 	dev_priv->psr.enable_source(intel_dp, crtc_state);
 	dev_priv->psr.enabled = intel_dp;
 
-	if (INTEL_GEN(dev_priv) >= 9) {
-		intel_psr_activate(intel_dp);
-	} else {
+	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
 		/*
 		 * FIXME: Activation should happen immediately since this
 		 * function is just called after pipe is fully trained and
@@ -677,10 +678,10 @@ void intel_psr_enable(struct intel_dp *intel_dp,
 		 * However on some platforms we face issues when first
 		 * activation follows a modeset so quickly.
 		 *     - On VLV/CHV we get bank screen on first activation
-		 *     - On HSW/BDW we get a recoverable frozen screen until
-		 *       next exit-activate sequence.
 		 */
 		intel_psr_schedule(dev_priv, intel_dp->panel_power_cycle_delay * 5);
+	} else {
+		intel_psr_activate(intel_dp);
 	}
 
 unlock:
@@ -1072,9 +1073,12 @@ void intel_psr_flush(struct drm_i915_private *dev_priv,
 	if (frontbuffer_bits)
 		intel_psr_exit(dev_priv);
 
-	if (!dev_priv->psr.active && !dev_priv->psr.busy_frontbuffer_bits)
-		intel_psr_schedule(dev_priv, 100);
-
+	if (!dev_priv->psr.active && !dev_priv->psr.busy_frontbuffer_bits) {
+		if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
+			intel_psr_schedule(dev_priv, 100);
+		else
+			intel_psr_activate(dev_priv->psr.enabled);
+	}
 	mutex_unlock(&dev_priv->psr.lock);
 }
 
@@ -1121,8 +1125,12 @@ void intel_psr_init(struct drm_i915_private *dev_priv)
 		dev_priv->psr.link_standby = false;
 	}
 
-	timer_setup(&dev_priv->psr.activate_timer, intel_psr_timer_fn, 0);
-	INIT_WORK(&dev_priv->psr.activate_work, intel_psr_work);
+	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
+		timer_setup(&dev_priv->psr.activate_timer,
+			    intel_psr_timer_fn, 0);
+		INIT_WORK(&dev_priv->psr.activate_work, intel_psr_work);
+	}
+
 	mutex_init(&dev_priv->psr.lock);
 
 	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
Signature · 6 lines
2.13.6

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

PATCH 3/3 drm/i915/psr: Display WA 0884 applied broadly for more HW tracking.

In reply to Rodrigo Vivi

WA 0884:bxt:all,cnl:*:A - "When FBC is enabled with eDP PSR, the CPU host modify writes may not get updated on the Display as expected.
WA: Write 0x00000000 to CUR_SURFLIVE_A with every CPU host modify write to trigger PSR exit."

We can also find on spec other cases where they describe bogus writes to cursor registers to force PSR exit with HW tracking. And it was confirmed by HW engineers that this Wa can be safely applied for any frontbuffer activity.

So let's use this more and more here instead of forcibly disable and re-enable PSR everytime that we have a simple reliable flush case.

Other commits improve the fbcon/fbdev use a lot, but this approach is the only when where we can get a fully reliable console with no slowness or missed frames and PSR still enabled and active.

v2: - Rebase on drm-tip
- (DK) Add a comment to explain that WA
tells about writing 0 to CUR_SURFLIVE_A but we write to CUR_SURFLIVE(pipe).

Cc Dhinakaran Pandiyan <[email protected]>
---
 drivers/gpu/drm/i915/i915_reg.h  |  3 +++
 drivers/gpu/drm/i915/intel_psr.c | 18 ++++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +3 -0
index eea5b2c537d4..592fad4e43ae 100644
@@ -6014,6 +6014,9 @@ enum {
 #define IVB_CURSOR_B_OFFSET 0x71080
 #define IVB_CURSOR_C_OFFSET 0x72080
 
+#define _CUR_SURLIVE		0x700AC
+#define CUR_SURLIVE(pipe)	_CURSOR2(pipe, _CUR_SURLIVE)
+
 /* Display A control */
 #define _DSPACNTR				0x70180
 #define   DISPLAY_PLANE_ENABLE			(1<<31)
drivers/gpu/drm/i915/intel_psr.c +16 -2
index 6d413a7bb39f..a65efdec9026 100644
@@ -1070,8 +1070,22 @@ void intel_psr_flush(struct drm_i915_private *dev_priv,
 	dev_priv->psr.busy_frontbuffer_bits &= ~frontbuffer_bits;
 
 	/* By definition flush = invalidate + flush */
-	if (frontbuffer_bits)
-		intel_psr_exit(dev_priv);
+	if (frontbuffer_bits) {
+		if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
+			intel_psr_exit(dev_priv);
+		} else {
+			/*
+			 * Display WA #0884: all
+			 * This documented WA for bxt can be safely applied
+			 * broadly so we can force HW tracking to exit PSR
+			 * instead of disabling and re-enabling.
+			 * Workaround tells us to write 0 to CUR_SURLIVE_A,
+			 * but it makes more sense write to the current active
+			 * pipe.
+			 */
+			I915_WRITE(CUR_SURLIVE(pipe), 0);
+		}
+	}
 
 	if (!dev_priv->psr.active && !dev_priv->psr.busy_frontbuffer_bits) {
 		if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
Signature · 6 lines
2.13.6

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw
In reply to Rodrigo Vivi

Quoting Rodrigo Vivi (2018-02-28 00:14:08)

Quoted 49 lines

From: Andy Lutomirski <[email protected]>

The current PSR code has a two call sites that each schedule delayed work to activate PSR. As far as I can tell, each call site intends to keep PSR inactive for the given amount of time and then allow it to be activated.

The call sites are:

- intel_psr_enable(), which explicitly states in a comment that it's trying to keep PSR off a short time after the dispay is initialized as a workaround.

- intel_psr_flush(). There isn't an explcit explanation, but the intent is presumably to keep PSR off until the display has been idle for 100ms.

The current code doesn't actually accomplish either of these goals. Rather than keeping PSR inactive for the given amount of time, it will schedule PSR for activation after the given time, with the earliest target time in such a request winning.

In other words, if intel_psr_enable() is immediately followed by intel_psr_flush(), then PSR will be activated after 100ms even if intel_psr_enable() wanted a longer delay. And, if the screen is being constantly updated so that intel_psr_flush() is called once per frame at 60Hz, PSR will still be activated once every 100ms.

Rewrite the code so that it does what was intended. This adds a new function intel_psr_schedule(), which will enable PSR after the requested time but no sooner.

v3: (by Rodrigo): Rebased on top of recent drm-tip without any
modification from the original.

---
 drivers/gpu/drm/i915/i915_debugfs.c |  9 +++--
 drivers/gpu/drm/i915/i915_drv.h     |  4 ++-
 drivers/gpu/drm/i915/intel_psr.c    | 69 ++++++++++++++++++++++++++++++++-----
 3 files changed, 71 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
index 33fbf3965309..1ac942d1742e 100644

drivers/gpu/drm/i915/i915_debugfs.c static int i915_edp_psr_status(struct seq_file *m, void *data) · line 2578

Quoted 9 lines
drivers/gpu/drm/i915/i915_debugfs.c +4 -2
@@ -2572,8 +2572,13 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
        seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active));
        seq_printf(m, "Busy frontbuffer bits: 0x%03x\n",
                   dev_priv->psr.busy_frontbuffer_bits);
-       seq_printf(m, "Re-enable work scheduled: %s\n",
-                  yesno(work_busy(&dev_priv->psr.work.work)));
+
+       if (timer_pending(&dev_priv->psr.activate_timer))
+               seq_printf(m, "Activate scheduled: yes, in %ldms\n",
+                          (long)(dev_priv->psr.earliest_activate - jiffies) *

msecs_from_jiffies

Quoted 11 lines
drivers/gpu/drm/i915/i915_debugfs.c +3 -0
+                          1000 / HZ);
+       else
+               seq_printf(m, "Re-enable scheduled: no\n");
 
        if (HAS_DDI(dev_priv)) {
                if (dev_priv->psr.psr2_support)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 7bbec5546d12..6e6cf2ce3749 100644

drivers/gpu/drm/i915/i915_drv.h struct i915_psr { · line 769

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h +3 -1
@@ -764,7 +764,9 @@ struct i915_psr {
        bool sink_support;
        struct intel_dp *enabled;
        bool active;
-       struct delayed_work work;
+       struct timer_list activate_timer;
+       struct work_struct activate_work;
+       unsigned long earliest_activate;

Incorporated into struct timer_list, so this is redundant. -Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
Quoted 66 lines · Chris Wilson

Quoting Rodrigo Vivi (2018-02-28 00:14:08)

Quoted 49 lines

From: Andy Lutomirski <[email protected]>

The current PSR code has a two call sites that each schedule delayed work to activate PSR. As far as I can tell, each call site intends to keep PSR inactive for the given amount of time and then allow it to be activated.

The call sites are:

- intel_psr_enable(), which explicitly states in a comment that it's trying to keep PSR off a short time after the dispay is initialized as a workaround.

- intel_psr_flush(). There isn't an explcit explanation, but the intent is presumably to keep PSR off until the display has been idle for 100ms.

The current code doesn't actually accomplish either of these goals. Rather than keeping PSR inactive for the given amount of time, it will schedule PSR for activation after the given time, with the earliest target time in such a request winning.

In other words, if intel_psr_enable() is immediately followed by intel_psr_flush(), then PSR will be activated after 100ms even if intel_psr_enable() wanted a longer delay. And, if the screen is being constantly updated so that intel_psr_flush() is called once per frame at 60Hz, PSR will still be activated once every 100ms.

Rewrite the code so that it does what was intended. This adds a new function intel_psr_schedule(), which will enable PSR after the requested time but no sooner.

v3: (by Rodrigo): Rebased on top of recent drm-tip without any
modification from the original.

---
 drivers/gpu/drm/i915/i915_debugfs.c |  9 +++--
 drivers/gpu/drm/i915/i915_drv.h     |  4 ++-
 drivers/gpu/drm/i915/intel_psr.c    | 69 ++++++++++++++++++++++++++++++++-----
 3 files changed, 71 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
index 33fbf3965309..1ac942d1742e 100644

drivers/gpu/drm/i915/i915_debugfs.c static int i915_edp_psr_status(struct seq_file *m, void *data) · line 2578

Quoted 9 lines
drivers/gpu/drm/i915/i915_debugfs.c +4 -2
@@ -2572,8 +2572,13 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
        seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active));
        seq_printf(m, "Busy frontbuffer bits: 0x%03x\n",
                   dev_priv->psr.busy_frontbuffer_bits);
-       seq_printf(m, "Re-enable work scheduled: %s\n",
-                  yesno(work_busy(&dev_priv->psr.work.work)));
+
+       if (timer_pending(&dev_priv->psr.activate_timer))
+               seq_printf(m, "Activate scheduled: yes, in %ldms\n",
+                          (long)(dev_priv->psr.earliest_activate - jiffies) *

msecs_from_jiffies

Quoted 4 lines
drivers/gpu/drm/i915/i915_debugfs.c +3 -0
+                          1000 / HZ);
+       else
+               seq_printf(m, "Re-enable scheduled: no\n");
 
Quoted 16 lines
Quoted 7 lines
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
        if (HAS_DDI(dev_priv)) {
                if (dev_priv->psr.psr2_support)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 7bbec5546d12..6e6cf2ce3749 100644

drivers/gpu/drm/i915/i915_drv.h struct i915_psr { · line 769

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h +3 -1
@@ -764,7 +764,9 @@ struct i915_psr {
        bool sink_support;
        struct intel_dp *enabled;
        bool active;
-       struct delayed_work work;
+       struct timer_list activate_timer;
+       struct work_struct activate_work;
+       unsigned long earliest_activate;

Incorporated into struct timer_list, so this is redundant.

This way gives a clean way to say "don't do the work before such-and-such time". I don't think we can do it with mod_timer() since the timer might already have started firing, and we can't del_timer_sync() because there would be a lock inversion.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

✗ Fi.CI.BAT: warning for series starting with [1/3] drm/i915: Improve PSR activation timing

In reply to Rodrigo Vivi
== Series Details ==

== Series Details ==

Series: series starting with [1/3] drm/i915: Improve PSR activation timing
URL : https://patchwork.freedesktop.org/series/39075/
State : warning

== Summary ==

Series 39075v1 series starting with [1/3] drm/i915: Improve PSR activation timing
https://patchwork.freedesktop.org/api/1.0/series/39075/revisions/1/mbox/

---- Possible new issues:

Test kms_psr_sink_crc:

        Subgroup psr_basic:
                pass       -> DMESG-WARN (fi-cfl-s2)
                pass       -> DMESG-WARN (fi-cnl-y3)
                pass       -> DMESG-WARN (fi-glk-1)
                pass       -> DMESG-WARN (fi-kbl-7560u)
                pass       -> DMESG-WARN (fi-kbl-r)
                pass       -> DMESG-WARN (fi-skl-6600u)

---- Known issues:

Test gem_exec_suspend:

        Subgroup basic-s3:
                dmesg-warn -> PASS       (fi-skl-6700k2) fdo#104108
Test gem_ringfill:
        Subgroup basic-default-hang:
                dmesg-warn -> PASS       (fi-pnv-d510) fdo#101600
Test kms_psr_sink_crc:
        Subgroup psr_basic:
                pass       -> DMESG-WARN (fi-skl-6700hq) fdo#101144

fdo#104108 https://bugs.freedesktop.org/show_bug.cgi?id=104108
fdo#101600 https://bugs.freedesktop.org/show_bug.cgi?id=101600
fdo#101144 https://bugs.freedesktop.org/show_bug.cgi?id=101144

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:417s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:421s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:482s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:283s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:476s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:463s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:451s
fi-cfl-8700k     total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:396s
fi-cfl-s2        total:288  pass:261  dwarn:1   dfail:0   fail:0   skip:26  time:558s
fi-cnl-y3        total:288  pass:261  dwarn:1   dfail:0   fail:0   skip:26  time:584s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:413s
fi-gdg-551       total:288  pass:179  dwarn:0   dfail:0   fail:1   skip:108 time:284s
fi-glk-1         total:288  pass:259  dwarn:1   dfail:0   fail:0   skip:28  time:502s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:389s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:451s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:413s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:447s
fi-kbl-7560u     total:288  pass:268  dwarn:1   dfail:0   fail:0   skip:19  time:487s
fi-kbl-r         total:288  pass:260  dwarn:1   dfail:0   fail:0   skip:27  time:490s
fi-pnv-d510      total:288  pass:223  dwarn:0   dfail:0   fail:0   skip:65  time:560s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:425s
fi-skl-6600u     total:288  pass:260  dwarn:1   dfail:0   fail:0   skip:27  time:499s
fi-skl-6700hq    total:288  pass:261  dwarn:1   dfail:0   fail:0   skip:26  time:517s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:482s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:480s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:406s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:428s
fi-snb-2520m     total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:520s
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:390s

fi-ilk-650 failed to collect. IGT log at Patchwork_8182/fi-ilk-650/run0.log fi-kbl-7567u failed to collect. IGT log at Patchwork_8182/fi-kbl-7567u/run0.log

5d22ee63b365bf7e08e0c06d4c7ff62501f27477 drm-tip: 2018y-02m-28d-00h-25m-02s UTC integration manifest 5b51ba8b960a drm/i915/psr: Display WA 0884 applied broadly for more HW tracking. a3a9e922d588 drm/i915/psr: Kill scheduled work for Core platforms.
8e859ebcdb11 drm/i915: Improve PSR activation timing

== Logs ==

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

#6 lore raw
In reply to Rodrigo Vivi
Quoted 125 lines · Rodrigo Vivi

From: Andy Lutomirski <[email protected]>

The current PSR code has a two call sites that each schedule delayed work to activate PSR. As far as I can tell, each call site intends to keep PSR inactive for the given amount of time and then allow it to be activated.

The call sites are:

- intel_psr_enable(), which explicitly states in a comment that it's trying to keep PSR off a short time after the dispay is initialized as a workaround.

- intel_psr_flush(). There isn't an explcit explanation, but the intent is presumably to keep PSR off until the display has been idle for 100ms.

The current code doesn't actually accomplish either of these goals. Rather than keeping PSR inactive for the given amount of time, it will schedule PSR for activation after the given time, with the earliest target time in such a request winning.

In other words, if intel_psr_enable() is immediately followed by intel_psr_flush(), then PSR will be activated after 100ms even if intel_psr_enable() wanted a longer delay. And, if the screen is being constantly updated so that intel_psr_flush() is called once per frame at 60Hz, PSR will still be activated once every 100ms.

Rewrite the code so that it does what was intended. This adds a new function intel_psr_schedule(), which will enable PSR after the requested time but no sooner.

v3: (by Rodrigo): Rebased on top of recent drm-tip without any
modification from the original.

---
 drivers/gpu/drm/i915/i915_debugfs.c |  9 +++--
 drivers/gpu/drm/i915/i915_drv.h     |  4 ++-
 drivers/gpu/drm/i915/intel_psr.c    | 69 ++++++++++++++++++++++++++++++++-----
 3 files changed, 71 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +7 -2
index 33fbf3965309..1ac942d1742e 100644
@@ -2572,8 +2572,13 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
 	seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active));
 	seq_printf(m, "Busy frontbuffer bits: 0x%03x\n",
 		   dev_priv->psr.busy_frontbuffer_bits);
-	seq_printf(m, "Re-enable work scheduled: %s\n",
-		   yesno(work_busy(&dev_priv->psr.work.work)));
+
+	if (timer_pending(&dev_priv->psr.activate_timer))
+		seq_printf(m, "Activate scheduled: yes, in %ldms\n",
+			   (long)(dev_priv->psr.earliest_activate - jiffies) *
+			   1000 / HZ);
+	else
+		seq_printf(m, "Re-enable scheduled: no\n");
 
 	if (HAS_DDI(dev_priv)) {
 		if (dev_priv->psr.psr2_support)
drivers/gpu/drm/i915/i915_drv.h +3 -1
index 7bbec5546d12..6e6cf2ce3749 100644
@@ -764,7 +764,9 @@ struct i915_psr {
 	bool sink_support;
 	struct intel_dp *enabled;
 	bool active;
-	struct delayed_work work;
+	struct timer_list activate_timer;
+	struct work_struct activate_work;
+	unsigned long earliest_activate;
 	unsigned busy_frontbuffer_bits;
 	bool psr2_support;
 	bool aux_frame_sync;
drivers/gpu/drm/i915/intel_psr.c +25 -2
index 05770790a4e9..c10d5225dc7c 100644
@@ -570,6 +570,30 @@ static void intel_psr_activate(struct intel_dp *intel_dp)
 	dev_priv->psr.active = true;
 }
 
+static void intel_psr_schedule(struct drm_i915_private *dev_priv,
+			       unsigned long min_wait_ms)
+{
+	unsigned long next;
+
+	lockdep_assert_held(&dev_priv->psr.lock);
+
+	/*
+	 * We update next_enable *and* call mod_timer() because it's
+	 * possible that intel_psr_work() has already been called and is
+	 * waiting for psr.lock.  If that's the case, we don't want it
+	 * to immediately enable PSR.
+	 *
+	 * We also need to make sure that PSR is never activated earlier
+	 * than requested to avoid breaking intel_psr_enable()'s workaround
+	 * for pre-gen9 hardware.
+	 */
+	next = jiffies + msecs_to_jiffies(min_wait_ms);
+	if (time_after(next, dev_priv->psr.earliest_activate)) {
+		dev_priv->psr.earliest_activate = next;
+		mod_timer(&dev_priv->psr.activate_timer, next);
+	}
+}
+
 static void hsw_psr_enable_source(struct intel_dp *intel_dp,
 				  const struct intel_crtc_state *crtc_state)
 {
@@ -656,8 +680,7 @@ void intel_psr_enable(struct intel_dp *intel_dp,
 		 *     - On HSW/BDW we get a recoverable frozen screen until
 		 *       next exit-activate sequence.
 		 */
-		schedule_delayed_work(&dev_priv->psr.work,
-				      msecs_to_jiffies(intel_dp->panel_power_cycle_delay * 5));
+		intel_psr_schedule(dev_priv, intel_dp->panel_power_cycle_delay * 5);
 	}
 
 unlock:

drivers/gpu/drm/i915/intel_psr.c void intel_psr_disable(struct intel_dp *intel_dp, · line 804

Quoted 6 lines
drivers/gpu/drm/i915/intel_psr.c +2 -1
@@ -777,13 +800,14 @@ void intel_psr_disable(struct intel_dp *intel_dp,
 	dev_priv->psr.enabled = NULL;
 	mutex_unlock(&dev_priv->psr.lock);
 
-	cancel_delayed_work_sync(&dev_priv->psr.work);
+	cancel_work_sync(&dev_priv->psr.activate_work);
+	del_timer_sync(&dev_priv->psr.activate_timer);

lockdep does not seem to be happy.

[  555.236359] Setting dangerous option enable_psr - tainting kernel
[  557.368892] INFO: trying to register non-static key.
[  557.368899] the code is fine but needs lockdep annotation.
[  557.368902] turning off the locking correctness validator.
[  557.368907] CPU: 3 PID: 4404 Comm: kms_psr_sink_cr Tainted: G     U
4.16.0-rc3-CI-Patchwork_8182+ #1
[  557.368910] Hardware name: TOSHIBA SATELLITE
P50-C/06F4                            , BIOS 1.40 03/29/2016
[  557.368913] Call Trace:
[  557.368922]  dump_stack+0x5f/0x86
[  557.368931]  register_lock_class+0x57e/0x590
[  557.368936]  ? lock_acquire+0xaf/0x200
[  557.368941]  __lock_acquire+0xa4/0x1b60
[  557.368948]  ? try_to_del_timer_sync+0x60/0x60
[  557.368955]  ? drm_dp_dpcd_access+0xdb/0xf0
[  557.368960]  ? lock_acquire+0xaf/0x200
[  557.368966]  lock_acquire+0xaf/0x200
[  557.368971]  ? try_to_del_timer_sync+0x60/0x60
[  557.368977]  del_timer_sync+0x37/0xb0
[  557.368982]  ? try_to_del_timer_sync+0x60/0x60
[  557.369052]  intel_psr_disable+0xc5/0xe0 [i915]
[  557.369120]  intel_disable_ddi+0x75/0xf0 [i915]

Full log here:
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8182/fi-skl-6600u/dmesg0.log

Quoted 81 lines
drivers/gpu/drm/i915/intel_psr.c +32 -5
 }
 
 static void intel_psr_work(struct work_struct *work)
 {
 	struct drm_i915_private *dev_priv =
-		container_of(work, typeof(*dev_priv), psr.work.work);
+		container_of(work, typeof(*dev_priv), psr.activate_work);
 	struct intel_dp *intel_dp = dev_priv->psr.enabled;
 	struct drm_crtc *crtc = dp_to_dig_port(intel_dp)->base.base.crtc;
 	enum pipe pipe = to_intel_crtc(crtc)->pipe;
@@ -793,6 +817,7 @@ static void intel_psr_work(struct work_struct *work)
 	 * PSR might take some time to get fully disabled
 	 * and be ready for re-enable.
 	 */
+
 	if (HAS_DDI(dev_priv)) {
 		if (dev_priv->psr.psr2_support) {
 			if (intel_wait_for_register(dev_priv,
@@ -829,6 +854,18 @@ static void intel_psr_work(struct work_struct *work)
 	if (!intel_dp)
 		goto unlock;
 
+
+	if (!time_after_eq(jiffies, dev_priv->psr.earliest_activate)) {
+		/*
+		 * We raced: intel_psr_schedule() tried to delay us, but
+		 * we were already in intel_psr_timer_fn() or already in
+		 * the workqueue.  We can safely return -- the
+		 * intel_psr_schedule() call that put earliest_activeate
+		 * in the future will have called mod_timer().
+		 */
+		goto unlock;
+	}
+
 	/*
 	 * The delayed work can race with an invalidate hence we need to
 	 * recheck. Since psr_flush first clears this and then reschedules we
@@ -842,6 +879,20 @@ static void intel_psr_work(struct work_struct *work)
 	mutex_unlock(&dev_priv->psr.lock);
 }
 
+static void intel_psr_timer_fn(struct timer_list *timer)
+{
+	struct drm_i915_private *dev_priv =
+		container_of(timer, typeof(*dev_priv), psr.activate_timer);
+
+	/*
+	 * We need a non-atomic context to activate PSR.  Using
+	 * delayed_work wouldn't be an improvement -- delayed_work is
+	 * just a timer that schedules work when it fires, but there's
+	 * no equivalent of mod_timer() for delayed_work.
+	 */
+	schedule_work(&dev_priv->psr.activate_work);
+}
+
 static void intel_psr_exit(struct drm_i915_private *dev_priv)
 {
 	struct intel_dp *intel_dp = dev_priv->psr.enabled;
@@ -1022,9 +1073,8 @@ void intel_psr_flush(struct drm_i915_private *dev_priv,
 		intel_psr_exit(dev_priv);
 
 	if (!dev_priv->psr.active && !dev_priv->psr.busy_frontbuffer_bits)
-		if (!work_busy(&dev_priv->psr.work.work))
-			schedule_delayed_work(&dev_priv->psr.work,
-					      msecs_to_jiffies(100));
+		intel_psr_schedule(dev_priv, 100);
+
 	mutex_unlock(&dev_priv->psr.lock);
 }
 
@@ -1071,7 +1121,8 @@ void intel_psr_init(struct drm_i915_private *dev_priv)
 		dev_priv->psr.link_standby = false;
 	}
 
-	INIT_DELAYED_WORK(&dev_priv->psr.work, intel_psr_work);
+	timer_setup(&dev_priv->psr.activate_timer, intel_psr_timer_fn, 0);
+	INIT_WORK(&dev_priv->psr.activate_work, intel_psr_work);
 	mutex_init(&dev_priv->psr.lock);
 
 	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {

drivers/gpu/drm/i915/intel_psr.c void intel_psr_init(struct drm_i915_private *dev_priv) · line 1143

Quoted 6 lines
drivers/gpu/drm/i915/intel_psr.c +2 -0
@@ -1087,4 +1138,6 @@ void intel_psr_init(struct drm_i915_private *dev_priv)
 		dev_priv->psr.activate = hsw_psr_activate;
 		dev_priv->psr.setup_vsc = hsw_psr_setup_vsc;
 	}
+
+	dev_priv->psr.earliest_activate = jiffies;
 }

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