drm/i915/psr: Lockless version of psr_wait_for_idle
Subsystems (2)
PATCH v8 1/2 drm/i915/psr: Lockless version of psr_wait_for_idle
This is a lockless version of the exisiting psr_wait_for_idle(). We want to wait for PSR to idle out inside intel_pipe_update_start. At the time of a pipe update, we should never race with any psr enable or disable code, which is a part of crtc enable/disable. The follow up patch will use this lockless wait inside pipe_update_ start to wait for PSR to idle out before checking for vblank evasion. We need to keep the wait in pipe_update_start to as less as it can be. So,we can live and flourish w/o taking any psr locks at all.
Even if psr is never enabled, psr2_enabled will be false and this function will wait for PSR1 to idle out, which should just return immediately, so a very short (~1-2 usec) wait for cases where PSR is disabled.
v2: Add comment to explain the 25msec timeout (DK)
v3: Rename psr_wait_for_idle to __psr_wait_for_idle_locked to avoid
naming conflicts and propagate err (if any) to the caller (Chris)
v5: Form a series with the next patch
v7: Better explain the need for lockless wait and increase the max
timeout to handle refresh rates < 60 Hz (Daniel Vetter)
v8: Rebase
--- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_psr.c | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -1922,6 +1922,7 @@ void intel_psr_compute_config(struct intel_dp *intel_dp,void intel_psr_irq_control (struct drm_i915_private *dev_priv,bool debug);void intel_psr_irq_handler (struct drm_i915_private *dev_priv,u32 psr_iir);void intel_psr_short_pulse (struct intel_dp *intel_dp); +int intel_psr_wait_for_idle (struct drm_i915_private *dev_priv);/* intel_runtime_pm.c */ int intel_power_domains_init (struct drm_i915_private *);
drivers/gpu/drm/i915/intel_psr.c +34 -2
@@ -717,7 +717,39 @@ void intel_psr_disable(struct intel_dp *intel_dp,cancel_work_sync (&dev_priv->psr.work); } -static bool psr_wait_for_idle (struct drm_i915_private *dev_priv) +int intel_psr_wait_for_idle (struct drm_i915_private *dev_priv) +{ +i915_reg_t reg; +u32 mask; + +/* +* The sole user right now is intel_pipe_update_start(), +* which won't race with psr_enable/disable, which is +* where psr2_enabled is written to. So, we don't need +* to acquire the psr.lock. More importantly, we want the +* latency inside intel_pipe_update_start() to be as low +* as possible, so no need to acquire psr.lock when it is +* not needed and will induce latencies in the atomic +* update path. +*/ +if (dev_priv->psr.psr2_enabled) { + reg =EDP_PSR2_STATUS ; + mask =EDP_PSR2_STATUS_STATE_MASK ; + }else { + reg =EDP_PSR_STATUS ; + mask =EDP_PSR_STATUS_STATE_MASK ; + } + +/* +* Max time for PSR to idle = Inverse of the refresh rate + +* 6 ms of exit training time + 1.5 ms of aux channel +* handshake. 50 msec is defesive enough to cover everything. +*/ +return intel_wait_for_register (dev_priv, reg, mask, +EDP_PSR_STATUS_STATE_IDLE ,50 ); +} + +static bool __psr_wait_for_idle_locked (struct drm_i915_private *dev_priv) {struct intel_dp *intel_dp;i915_reg_t reg;
@@ -763,7 +795,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 (!psr_wait_for_idle (dev_priv)) +if (!__psr_wait_for_idle_locked (dev_priv)) goto unlock;/*
Signature · 6 lines
2.13.5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v8 2/2 drm/i915: Wait for PSR exit before checking for vblank evasion
The PIPEDSL freezes on PSR entry and if PSR hasn't fully exited, then the pipe_update_start call schedules itself out to check back later.
On ChromeOS-4.4 kernel, which is fairly up-to-date w.r.t drm/i915 but lags w.r.t core kernel code, hot plugging an external display triggers tons of "potential atomic update errors" in the dmesg, on *pipe A*. A closer analysis reveals that we try to read the scanline 3 times and eventually timeout, b/c PSR hasn't exited fully leading to a PIPEDSL stuck @ 1599. This issue is not seen on upstream kernels, b/c for *some* reason we loop inside intel_pipe_update start for ~2+ msec which in this case is more than enough to exit PSR fully, hence an *unstuck* PIPEDSL counter, hence no error. On the other hand, the ChromeOS kernel spends ~1.1 msec looping inside intel_pipe_update_start and hence errors out b/c the source is still in PSR.
Regardless, we should wait for PSR exit (if PSR is disabled, we incur a ~1-2 usec penalty) before reading the PIPEDSL, b/c if we haven't fully exited PSR, then checking for vblank evasion isn't actually applicable.
v4: Comment explaining psr_wait after enabling VBL interrupts (DK)
v5: CAN_PSR() to handle platforms that don't support PSR.
v6: Handle local_irq_disable on early return (Chris)
--- drivers/gpu/drm/i915/intel_sprite.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_sprite.c +16 -4
@@ -107,13 +107,21 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state) VBLANK_EVASION_TIME_US); max = vblank_start -1 ; -local_irq_disable (); -if (min <=0 || max <=0 ) -return ; + goto irq_disable;if (WARN_ON (drm_crtc_vblank_get (&crtc->base))) -return ; + goto irq_disable; + +/* +* Wait for psr to idle out after enabling the VBL interrupts +* VBL interrupts will start the PSR exit and prevent a PSR +* re-entry as well. +*/ +if (CAN_PSR (dev_priv) &&intel_psr_wait_for_idle (dev_priv)) +DRM_ERROR ("PSR idle timed out, atomic update may fail\n" ); + +local_irq_disable (); crtc->debug.min_vbl = min; crtc->debug.max_vbl = max;
@@ -171,6 +179,10 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state) crtc->debug.start_vbl_count =intel_crtc_get_vblank_counter (crtc);trace_i915_pipe_update_vblank_evaded (crtc); +return ; + +irq_disable: +local_irq_disable (); }/**
Signature · 6 lines
2.13.5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v8 2/2] drm/i915: Wait for PSR exit before checking for vblank evasion
Quoted 25 lines · Tarun Vyas
The PIPEDSL freezes on PSR entry and if PSR hasn't fully exited, then the
pipe_update_startcall schedules itself out to check back later.On ChromeOS-4.4 kernel, which is fairly up-to-date w.r.t drm/i915 but lags w.r.t core kernel code, hot plugging an external display triggers
tons of "potential atomic update errors" in the dmesg, on *pipe A*. A closer analysis reveals that we try to read the scanline 3 times and eventually timeout, b/c PSR hasn't exited fully leading to a PIPEDSL stuck @ 1599. This issue is not seen on upstream kernels, b/c for *some*
reason we loop insideintel_pipe_updatestart for ~2+ msec which in this
case is more than enough to exit PSR fully, hence an *unstuck* PIPEDSL
counter, hence no error. On the other hand, the ChromeOS kernel spends
~1.1 msec looping insideintel_pipe_update_startand hence errors out b/c the source is still in PSR.Regardless, we should wait for PSR exit (if PSR is disabled, we incur a ~1-2 usec penalty) before reading the PIPEDSL, b/c if we haven't fully exited PSR, then checking for vblank evasion isn't actually applicable.
Quoted 5 lines
v4: Comment explaining
psr_waitafter enabling VBL interrupts (DK)v5:
CAN_PSR()to handle platforms that don't support PSR.v6: Handle
local_irq_disableon early return (Chris)
Series Reviewed-by: Dhinakaran Pandiyan
<[email protected]>
Daniel's questions were addressed over IRC, I'll push this version if they aren't any other concerns.
-DK
Quoted 51 lines
Signed-off-by Tarun Vyas <[email protected]>---
drivers/gpu/drm/i915/intel_sprite.c | 20 ++++++++++++++++----1 file changed, 16 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/intel_sprite.c +0
-0@@ -107,13 +107,21 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state)VBLANK_EVASION
_TIME_US);
max =vblank_start- 1;drivers/gpu/drm/i915/intel_sprite.c +0
-2-local_irq_disable (); -if (min <= 0 || max <= 0)
drivers/gpu/drm/i915/intel_sprite.c +1
-1-return ; + goto irq_disable;
if (WARN_ON(drm_crtc_vblank_get(&crtc->base)))drivers/gpu/drm/i915/intel_sprite.c +4
-1-return ; + goto irq_disable; + +/* +* Wait for psr to idle out after enabling the VBL interrupts
drivers/gpu/drm/i915/intel_sprite.c +5
-0+* VBL interrupts will start the PSR exit and prevent a PSR +* re-entry as well. +*/ +if (CAN_PSR (dev_priv) &&intel_psr_wait_for_idle (dev_priv)) + DRM_ERROR("PSR idle timed out, atomic update mayfail\n");
drivers/gpu/drm/i915/intel_sprite.c +2
-0+ +local_irq_disable ();
crtc->debug.min_vbl= min;
crtc->debug.max_vbl= max;drivers/gpu/drm/i915/intel_sprite.c +0
-0@@ -171,6 +179,10 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state)
crtc->debug.start_vbl_count=intel_crtc_get_vblank_counter(crtc);
trace_i915_pipe_update_vblank_evaded(crtc);drivers/gpu/drm/i915/intel_sprite.c +4
-0+return ; + +irq_disable: +local_irq_disable ();
Quoted 3 lines
}
/**
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v8 2/2] drm/i915: Wait for PSR exit before checking for vblank evasion
Quoted 39 lines · Dhinakaran Pandiyan
Quoted 38 lines · Tarun Vyas
The PIPEDSL freezes on PSR entry and if PSR hasn't fully exited, then
thepipe_update_startcall schedules itself out to check back later.On ChromeOS-4.4 kernel, which is fairly up-to-date w.r.t drm/i915 but
lags w.r.t core kernel code, hot plugging an external display triggers
tons of "potential atomic update errors" in the dmesg, on *pipe A*. A
closer analysis reveals that we try to read the scanline 3 times and
eventually timeout, b/c PSR hasn't exited fully leading to a PIPEDSL
stuck @ 1599. This issue is not seen on upstream kernels, b/c for *some*
reason we loop insideintel_pipe_updatestart for ~2+ msec which in this
case is more than enough to exit PSR fully, hence an *unstuck* PIPEDSL
counter, hence no error. On the other hand, the ChromeOS kernel spends
~1.1 msec looping insideintel_pipe_update_startand hence errors out
b/c the source is still in PSR.Regardless, we should wait for PSR exit (if PSR is disabled, we incur
a ~1-2 usec penalty) before reading the PIPEDSL, b/c if we haven't fully exited PSR, then checking for vblank evasion isn't actually applicable.v4: Comment explaining
psr_waitafter enabling VBL interrupts (DK)v5:
CAN_PSR()to handle platforms that don't support PSR.
Quoted 7 lines
Quoted 1 line
v6: Handle
local_irq_disableon early return (Chris)
Series Reviewed-by: Dhinakaran Pandiyan
<[email protected]>Daniel's questions were addressed over IRC, I'll push this version if they aren't any other concerns.
and pushed to -dinq with Daniel's irc ack.
"<dhnkrn> ickle: danvet ack on the PSR wait_for_idle series? <danvet> sure"
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [v8,1/2] drm/i915/psr: Lockless version of psr_wait_for_idle
In reply to Tarun Vyas== Series Details ==
== Series Details ==
Series: series starting with [v8,1/2] drm/i915/psr: Lockless version of psr_wait_for_idle
URL : https://patchwork.freedesktop.org/series/45524/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4391 -> Patchwork_9453 =
== Summary - SUCCESS ==
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/45524/revisions/1/mbox/
== Known issues ==
Here are the changes found in Patchwork_9453 that come from known issues:
=== IGT changes ===
==== Possible fixes ====
igt@gem_ctx_create@basic-files:
fi-glk-dsi: DMESG-WARN (fdo#106954) -> PASSfdo#106954 https://bugs.freedesktop.org/show_bug.cgi?id=106954
== Participating hosts (44 -> 40) ==
Additional (1): fi-byt-j1900
Missing (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u
== Build changes ==
* Linux: CI_DRM_4391 -> Patchwork_9453
CI_DRM_4391: 9134bde2e681ec232f4d8bec56aa3700177630fe @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4530: 0e98bf69f146eb72fe3a7c3b19a049b5786f0ca3 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9453: 7a0d28ca8e878141795a1f3044fd373ad5593ac9 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
7a0d28ca8e87 drm/i915: Wait for PSR exit before checking for vblank evasion f6ed4df15922 drm/i915/psr: Lockless version of psr_wait_for_idle
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9453/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for series starting with [v8,1/2] drm/i915/psr: Lockless version of psr_wait_for_idle
In reply to Tarun Vyas== Series Details ==
== Series Details ==
Series: series starting with [v8,1/2] drm/i915/psr: Lockless version of psr_wait_for_idle
URL : https://patchwork.freedesktop.org/series/45524/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4391_full -> Patchwork_9453_full =
== Summary - WARNING ==
Minor unknown changes coming with Patchwork_9453_full need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_9453_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
== Possible new issues ==
Here are the unknown changes that may have been introduced in Patchwork_9453_full:
=== IGT changes ===
==== Warnings ====
igt@gem_exec_schedule@deep-bsd2:
shard-kbl: SKIP -> PASS
igt@gem_exec_schedule@deep-vebox:
shard-kbl: PASS -> SKIP== Known issues ==
Here are the changes found in Patchwork_9453_full that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@drv_selftest@live_gtt:
shard-glk: PASS -> FAIL (fdo#105347)
igt@drv_suspend@shrink:
shard-apl: PASS -> FAIL (fdo#106886, fdo#107054)
igt@gem_exec_big:
shard-hsw: PASS -> INCOMPLETE (fdo#103540)
igt@gem_exec_schedule@pi-ringfull-bsd1:
shard-kbl: NOTRUN -> FAIL (fdo#103158)
igt@gem_exec_schedule@pi-ringfull-render:
{shard-glk9}: NOTRUN -> FAIL (fdo#103158)
igt@gem_exec_schedule@preemptive-hang-render:
shard-snb: SKIP -> INCOMPLETE (fdo#105411)
igt@kms_flip@plain-flip-ts-check-interruptible:
shard-glk: NOTRUN -> FAIL (fdo#100368)
igt@kms_flip_tiling@flip-to-x-tiled:
{shard-glk9}: NOTRUN -> FAIL (fdo#104724)
igt@kms_flip_tiling@flip-to-y-tiled:
shard-glk: PASS -> FAIL (fdo#104724, fdo#103822)
igt@kms_frontbuffer_tracking@fbc-2p-primscrn-pri-shrfb-draw-mmap-wc:
{shard-glk9}: NOTRUN -> FAIL (fdo#103167, fdo#104724)
igt@kms_setmode@basic:
{shard-glk9}: NOTRUN -> FAIL (fdo#99912)
==== Possible fixes ====
igt@gem_ctx_isolation@rcs0-s3:
shard-kbl: INCOMPLETE (fdo#103665) -> PASS
igt@kms_flip_tiling@flip-y-tiled:
shard-glk: FAIL (fdo#104724, fdo#103822) -> PASS {name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158
fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#103822 https://bugs.freedesktop.org/show_bug.cgi?id=103822
fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
fdo#105347 https://bugs.freedesktop.org/show_bug.cgi?id=105347
fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
fdo#106886 https://bugs.freedesktop.org/show_bug.cgi?id=106886
fdo#107054 https://bugs.freedesktop.org/show_bug.cgi?id=107054
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
== Participating hosts (6 -> 6) ==
No changes in participating hosts
== Build changes ==
* Linux: CI_DRM_4391 -> Patchwork_9453
CI_DRM_4391: 9134bde2e681ec232f4d8bec56aa3700177630fe @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4530: 0e98bf69f146eb72fe3a7c3b19a049b5786f0ca3 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9453: 7a0d28ca8e878141795a1f3044fd373ad5593ac9 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9453/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx