drm/i915: don't queue flips during a flip pending event
A message that is not in the archive (sent off-list or not yet received): 20100405140831.00892ba7@jbarnes-piketon
Quoted 29 lines · Jesse Barnes
Hardware will set the flip pending ISR bit as soon as it receives the flip instruction, and (supposedly) clear it once the flip completes (e.g. at the next vblank). If we try to send down a flip instruction while the ISR bit is set, the hardware can become very confused, and we may never receive the corresponding flip pending interrupt, effectively hanging the chip.
Fixes fdo bug #27040.
Signed-off-by Jesse Barnes <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)drivers/gpu/drm/i915/intel_display.c +1
-0@@ -4235,6 +4235,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,unsigned long flags;int pipesrc_reg = (intel_crtc->pipe ==0 ) ?PIPEASRC :PIPEBSRC ;int ret, pipesrc; +u32 flip_mask;RING_LOCALS ; work =kzalloc (sizeof *work,GFP_KERNEL );@@ -4285,6 +4286,15 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,atomic_inc (&obj_priv->pending_flip); work->pending_flip_obj = obj;
drivers/gpu/drm/i915/intel_display.c static int intel_crtc_page_flip(struct drm_crtc *crtc, · line 4297
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +9
-0+if (intel_crtc->plane) + flip_mask =I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT ; +else + flip_mask =I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT ; + +/* Wait for any previous flip to finish */ +while (I915_READ (ISR ) & flip_mask) + ; +
I'm confused about how this patch works. It looks like there's a race where the ISR bit could get set at this point after the loop checking it, and you would lose. The whole thing seems very dubious -- why does the state of the ISR at the time you queue a flip matter? I could imagine there being an issue with the state of the ISR at the point that a flip packet is processed, but this doesn't handle that (seems like only throttling flips to avoid outstanding flips would)
Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +0
-0BEGIN_LP_RING (4 );if (IS_I965G (dev)) { OUT_RING(MI_DISPLAY_FLIP |Signature · 1 line
1.6.6.1
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 11 lines · On Thu, 29 Apr 2010 15:52:36 -0700 Eric Anholt <[email protected]> wrote:
Review
Quoted 10 lines
(quoted diff) +2
-0+ if (intel_crtc->plane) + flip_mask =
I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;(quoted diff) +2
-0+ else + flip_mask =
I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT; +(quoted diff) +4
-0+ /* Wait for any previous flip to finish */ + while (I915_READ(ISR) & flip_mask) + ; +
Quoted 7 lines
I'm confused about how this patch works. It looks like there's a race where the ISR bit could get set at this point after the loop checking it, and you would lose. The whole thing seems very dubious -- why does the state of the ISR at the time you queue a flip matter? I could imagine there being an issue with the state of the ISR at the point that a flip packet is processed, but this doesn't handle that (seems like only throttling flips to avoid outstanding flips would)
[We talked about this in person; this is for posterity]
We have mutexes and spinlocks in place to make sure only one flip is queued at once, so checking the ISR should be safe here.
The reason we need to check is that hw could have queued a previous flip, and we may even have completed the first half of it (due to the flip pending interrupt). But until the flip actually completes at vblank time, queuing another one will be "undefined" according to the docs. Turns out in this case "undefined" means hangs and other bad behavior.
That said, I think this needs an Ironlake check too, since the bits have moved recently.
Jesse
Quoted 33 lines · Jesse Barnes
Quoted 11 lines · On Thu, 29 Apr 2010 15:52:36 -0700 Eric Anholt <[email protected]> wrote:
Review
Quoted 10 lines
(quoted diff) +2
-0+ if (intel_crtc->plane) + flip_mask =
I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;(quoted diff) +2
-0+ else + flip_mask =
I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT; +(quoted diff) +4
-0+ /* Wait for any previous flip to finish */ + while (I915_READ(ISR) & flip_mask) + ; +Quoted 7 lines
I'm confused about how this patch works. It looks like there's a race where the ISR bit could get set at this point after the loop checking it, and you would lose. The whole thing seems very dubious -- why does the state of the ISR at the time you queue a flip matter? I could imagine there being an issue with the state of the ISR at the point that a flip packet is processed, but this doesn't handle that (seems like only throttling flips to avoid outstanding flips would)
[We talked about this in person; this is for posterity]
We have mutexes and spinlocks in place to make sure only one flip is queued at once, so checking the ISR should be safe here.
The reason we need to check is that hw could have queued a previous flip, and we may even have completed the first half of it (due to the flip pending interrupt). But until the flip actually completes at vblank time, queuing another one will be "undefined" according to the docs. Turns out in this case "undefined" means hangs and other bad behavior.
Quoted 2 lines
That said, I think this needs an Ironlake check too, since the bits have moved recently.
status update: taking this one off my todo list, since it needs to be updated for ironlake
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 34 lines · On Thu, 01 Jul 2010 16:09:00 -0700 Eric Anholt <[email protected]> wrote:
Quoted 33 lines · Jesse Barnes
Quoted 11 lines · On Thu, 29 Apr 2010 15:52:36 -0700 Eric Anholt <[email protected]> wrote:
Review
Quoted 10 lines
(quoted diff) +2
-0+ if (intel_crtc->plane) + flip_mask =
I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;(quoted diff) +2
-0+ else + flip_mask =
I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT; +(quoted diff) +4
-0+ /* Wait for any previous flip to finish */ + while (I915_READ(ISR) & flip_mask) + ; +Quoted 7 lines
I'm confused about how this patch works. It looks like there's a race where the ISR bit could get set at this point after the loop checking it, and you would lose. The whole thing seems very dubious -- why does the state of the ISR at the time you queue a flip matter? I could imagine there being an issue with the state of the ISR at the point that a flip packet is processed, but this doesn't handle that (seems like only throttling flips to avoid outstanding flips would)
[We talked about this in person; this is for posterity]
We have mutexes and spinlocks in place to make sure only one flip is queued at once, so checking the ISR should be safe here.
The reason we need to check is that hw could have queued a previous flip, and we may even have completed the first half of it (due to the flip pending interrupt). But until the flip actually completes at vblank time, queuing another one will be "undefined" according to the docs. Turns out in this case "undefined" means hangs and other bad behavior.
Quoted 5 lines
Quoted 2 lines
That said, I think this needs an Ironlake check too, since the bits have moved recently.
status update: taking this one off my todo list, since it needs to be updated for ironlake
Yes, just ignore this one and the gen3 one. The don't seem to be required at least on my 945 for stable page flipping.
Thanks,
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center