drm/i915: Fix pipe off timeout handling for pre-gen4
Subsystems (2)
PATCH 1/1 drm/i915: Fix pipe off timeout handling for pre-gen4
From: Ville Syrjälä <[email protected]>
The current pre-gen4 pipe off code might break out of the loop due to the timeout, but then the fail to print the warning.
Fix the issue by making sure we pair up the correct time comparison functions. It would be enough to change just the final check to use time_after_eq(), but also changing the loop condition to use time_before() instead of time_after() makes the whole thing look a bit saner since then we always compare jiffies and timeout in the same order, and the words before and after now feel more natural when talking about the timeout.
--- drivers/gpu/drm/i915/intel_display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +2 -2
@@ -845,8 +845,8 @@ void intel_wait_for_pipe_off(struct drm_device *dev, int pipe) last_line =I915_READ (reg) & line_mask;mdelay (5 ); }while (((I915_READ (reg) & line_mask) != last_line) && -time_after (timeout, jiffies)); -if (time_after (jiffies, timeout)) +time_before (jiffies, timeout)); +if (time_after_eq (jiffies, timeout))WARN (1 ,"pipe_off wait timed out\n" ); } }
Signature · 6 lines
1.8.1.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedQuoted 13 lines · On Thu, Oct 10, 2013 at 08:32:23PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
The current pre-gen4 pipe off code might break out of the loop due to the timeout, but then the fail to print the warning.
Fix the issue by making sure we pair up the correct time comparison functions. It would be enough to change just the final check to use
time_after_eq(), but also changing the loop condition to usetime_before()instead oftime_after()makes the whole thing look a bit saner since then we always compare jiffies and timeout in the same order, and the words before and after now feel more natural when talking about the timeout.
Quoted 1 line
Signed-off-by Ville Syrjälä <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 5 lines · On Thu, Oct 10, 2013 at 08:32:23PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
The current pre-gen4 pipe off code might break out of the loop due to the timeout, but then the fail to print the warning.
Quoted 7 lines
Fix the issue by making sure we pair up the correct time comparison functions. It would be enough to change just the final check to use
time_after_eq(), but also changing the loop condition to usetime_before()instead oftime_after()makes the whole thing look a bit saner since then we always compare jiffies and timeout in the same order, and the words before and after now feel more natural when talking about the timeout.
Don't you also want to recheck last_line just in case it managed to finish in the nick of time?
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 14 lines · Chris Wilson
Quoted 5 lines · On Thu, Oct 10, 2013 at 08:32:23PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
The current pre-gen4 pipe off code might break out of the loop due to the timeout, but then the fail to print the warning.
Quoted 7 lines
Fix the issue by making sure we pair up the correct time comparison functions. It would be enough to change just the final check to use
time_after_eq(), but also changing the loop condition to usetime_before()instead oftime_after()makes the whole thing look a bit saner since then we always compare jiffies and timeout in the same order, and the words before and after now feel more natural when talking about the timeout.
Quoted 2 lines
Don't you also want to recheck
last_linejust in case it managed to finish in the nick of time?
Indeed, this is the same bug as with all those waits - we need to recheck the condition after the wait in case the scheduler was a bully and didn't give us any cpu time before the timeout elapsed.
I'll drop the patch again and hide in shame ;-)
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH v2 1/1 drm/i915: Fix pipe off timeout handling for pre-gen4
In reply to Chris WilsonFrom: Ville Syrjälä <[email protected]>
The current pre-gen4 pipe off code might break out of the loop due to the timeout, but then the fail to print the warning.
Refactor the code a bit to use wait_for() to avoid the problem, and that we also re-check the condition after the timeout has expired.
v2: Use wait_for()
--- drivers/gpu/drm/i915/intel_display.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/intel_display.c +20 -15
@@ -800,6 +800,25 @@ void intel_wait_for_vblank(struct drm_device *dev, int pipe)DRM_DEBUG_KMS ("vblank wait timed out\n" ); } +static bool pipe_dsl_stopped (struct drm_device *dev,enum pipe pipe) +{ +struct drm_i915_private *dev_priv = dev->dev_private; +u32 reg =PIPEDSL (pipe); +u32 line1, line2; +u32 line_mask; + +if (IS_GEN2 (dev)) + line_mask =DSL_LINEMASK_GEN2 ; +else + line_mask =DSL_LINEMASK_GEN3 ; + + line1 =I915_READ (reg) & line_mask; +mdelay (5 ); + line2 =I915_READ (reg) & line_mask; + +return line1 == line2; +} +/* * intel_wait_for_pipe_off - wait for pipe to turn off * @dev: drm device
@@ -831,22 +850,8 @@ void intel_wait_for_pipe_off(struct drm_device *dev, int pipe) 100))WARN (1 ,"pipe_off wait timed out\n" ); }else { -u32 last_line, line_mask; -int reg =PIPEDSL (pipe); -unsigned long timeout = jiffies +msecs_to_jiffies (100 ); - -if (IS_GEN2 (dev)) - line_mask =DSL_LINEMASK_GEN2 ; -else - line_mask =DSL_LINEMASK_GEN3 ; -/* Wait for the display line to settle */ -do { - last_line =I915_READ (reg) & line_mask; -mdelay (5 ); - }while (((I915_READ (reg) & line_mask) != last_line) && -time_after (timeout, jiffies)); -if (time_after (jiffies, timeout)) +if (wait_for (pipe_dsl_stopped (dev, pipe),100 ))WARN (1 ,"pipe_off wait timed out\n" ); } }
Signature · 6 lines
1.8.1.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 5 lines · On Fri, Oct 11, 2013 at 02:21:31PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
The current pre-gen4 pipe off code might break out of the loop due to the timeout, but then the fail to print the warning.
Quoted 7 lines
Refactor the code a bit to use
wait_for()to avoid the problem, and that we also re-check the condition after the timeout has expired.v2: Use
wait_for()Signed-off-by Ville Syrjälä <[email protected]>
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Daniel Vetter
AppliedQuoted 6 lines · Chris Wilson
Quoted 5 lines · On Fri, Oct 11, 2013 at 02:21:31PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
The current pre-gen4 pipe off code might break out of the loop due to the timeout, but then the fail to print the warning.
Quoted 8 lines
Quoted 7 lines
Refactor the code a bit to use
wait_for()to avoid the problem, and that we also re-check the condition after the timeout has expired.v2: Use
wait_for()Signed-off-by Ville Syrjälä <[email protected]>Reviewed-by Chris Wilson <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch