Bug 67600

Summary: [IVB/HSW] gen7_queue_flip doesn't work on RCS
Product: DRI Reporter: Stephane Marchesin <marchesin>
Component: DRM/IntelAssignee: Daniel Vetter <daniel>
Status: CLOSED FIXED QA Contact: Intel GFX Bugs mailing list <intel-gfx-bugs>
Severity: normal    
Priority: high CC: ben
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
i915_error_state
none
The patch I used to switch queue_flip to RCS
none
RCS flips + DERRMR=0 on Haswell
none
Use RCS flips on ivb+ none

Description Stephane Marchesin 2013-08-01 01:50:22 UTC
Created attachment 83409 [details]
i915_error_state

I noticed that on IVB, page flips ioctls end up blocking when the GPU is busy. Specifically the RCS -> BCS ring switch seems to be what's taking time (this time is spent in i915_gem_object_pin_to_display_plane).

When I try to use the RCS instead of the BCS ring (by changing gen7_queue_flip) on my IVB chromebook (8086:0166) I get GPU lockups. Attached is the i915_error_state (undecoded).
Comment 1 Stephane Marchesin 2013-08-01 16:26:03 UTC
Created attachment 83453 [details] [review]
The patch I used to switch queue_flip to RCS
Comment 2 Ben Widawsky 2013-08-01 21:50:04 UTC
This is reproducible on Sandybridge and HSW as well.
Comment 3 Ben Widawsky 2013-08-03 03:00:25 UTC
Bug filed internally. Will get support from design/validation teams.
Comment 4 Daniel Vetter 2013-08-04 20:48:37 UTC
Yeah, pageflips don't work on RCS, which is why we issue them on the blitter. The ring switch should only block if you have semaphores disabled (which is not the default pretty much for this reason).

I suspect we have a "semaphores are a bit broken" bug underlying here, but closing this for now since the apparent bug isn't one.
Comment 5 Daniel Vetter 2013-08-06 17:09:39 UTC
Ben asked me to reopen this.
Comment 6 Daniel Vetter 2013-08-06 17:17:48 UTC
(In reply to comment #0)
> Created attachment 83409 [details]
> i915_error_state
> 
> I noticed that on IVB, page flips ioctls end up blocking when the GPU is
> busy. Specifically the RCS -> BCS ring switch seems to be what's taking time
> (this time is spent in i915_gem_object_pin_to_display_plane).

Ok, Ben is looking into why pageflipping on the RCS doesn't work, since he thinks it should.

Orthogonal to that issue we shouldn't block in pin_to_display_plane, at least if semaphores are enabled (which they are by default). Stephane can you please dig into where exactly we blow through massive amounts of time in there?
Comment 7 Ben Widawsky 2013-08-06 17:46:25 UTC
I may have lied about SNB being broken in an earlier commit. RCS flips do not hang on SNB. Whether or not we get the same double interrupts I'm seeing on ge7 is TBD.

Still leaving this as a HSW bug so we're more in sync with internal validation.
Comment 8 Ben Widawsky 2013-08-09 04:21:33 UTC
unmasking DERRMR (0x44050) makes the hang go away. Still investigating why this only effects RCS, and still investigating why we see 2 interrupts per flip.
Comment 9 Chris Wilson 2013-08-09 08:22:11 UTC
Note that unmasking DERRMR around the MI_DISPLAY_FLIP is insufficient.
Comment 10 Chris Wilson 2013-08-11 11:05:15 UTC
Also HSW has a different vsync mechanism, so you are free to play fun and games with DERRMR there.
Comment 11 Chris Wilson 2013-08-18 09:35:29 UTC
Messing around, the semaphore stall here greatly impacts UX. With BCS flips, there is perceptibly greater lag than RCS flips.
Comment 12 Chris Wilson 2013-08-19 18:03:18 UTC
So the DERRMR trick fails on IVB with multiple planes as it misses some events. Appears to be stable on HSW though.
Comment 13 Chris Wilson 2013-08-19 18:12:37 UTC
Created attachment 84278 [details] [review]
RCS flips + DERRMR=0 on Haswell
Comment 14 Chris Wilson 2013-08-19 21:09:44 UTC
Created attachment 84293 [details] [review]
Use RCS flips on ivb+

This is still surviving on my ivb desktop that easily failed with DERRMR==0.
Comment 15 Ben Widawsky 2013-08-29 17:04:02 UTC
Patch is on the mailing list. Assigning to Daniel for merging.

https://patchwork.kernel.org/patch/2849753/
https://patchwork.kernel.org/patch/2849754/
Comment 16 Chris Wilson 2013-09-08 14:13:43 UTC
commit ffe74d75502e3a9b0791240b5562bcbecc6ab8dc
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Aug 26 20:58:12 2013 +0100

    drm/i915: Use RCS flips on Ivybridge+
    
    RCS flips do work on Iybridge+ so long as we can unmask the messages
    through DERRMR. However, there are quite a few workarounds mentioned
    regarding unmasking more than one event or triggering more than one
    message through DERRMR. Those workarounds in principle prevent us from
    performing pipelined flips (and asynchronous flips across multiple
    planes) and equally apply to the "known good" BCS ring. Given that it
    already appears to work, and also appears to work with unmasking all 3
    planes at once (and queuing flips across multiple planes), be brave.
    
    Bugzlla: https://bugs.freedesktop.org/show_bug.cgi?id=67600
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
    Lightly-tested-by: Stephane Marchesin <marchesin@icps.u-strasbg.fr>
    Cc: Stephane Marchesin <marchesin@icps.u-strasbg.fr>
    Cc: Ben Widawsky <ben@bwidawsk.net>
    Tested-by: Stéphane Marchesin <marcheu@chromium.org>
    Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.