Skip to content

Commit 5bb6164

Browse files
ickledanvet
authored andcommitted
drm/i915: Flush the pending flips on the CRTC before modification
This was meant to be the purpose of the intel_crtc_wait_for_pending_flips() function which is called whilst preparing the CRTC for a modeset or before disabling. However, as Ville Syrjala pointed out, we set the pending flip notification on the old framebuffer that is no longer attached to the CRTC by the time we come to flush the pending operations. Instead, we can simply wait on the pending unpin work to be finished on this CRTC, knowning that the hardware has therefore finished modifying the registers, before proceeding with our direct access. Fixes i-g-t/flip_test on non-pch platforms. pch platforms simply schedule the flip immediately when the pipe is disabled, leading to other funny issues. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: stable@vger.kernel.org [danvet: Added i-g-t note and cc: stable] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent ac82ea2 commit 5bb6164

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

drivers/gpu/drm/i915/intel_display.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,13 +2806,34 @@ static void ironlake_fdi_disable(struct drm_crtc *crtc)
28062806
udelay(100);
28072807
}
28082808

2809+
static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc)
2810+
{
2811+
struct drm_device *dev = crtc->dev;
2812+
struct drm_i915_private *dev_priv = dev->dev_private;
2813+
unsigned long flags;
2814+
bool pending;
2815+
2816+
if (atomic_read(&dev_priv->mm.wedged))
2817+
return false;
2818+
2819+
spin_lock_irqsave(&dev->event_lock, flags);
2820+
pending = to_intel_crtc(crtc)->unpin_work != NULL;
2821+
spin_unlock_irqrestore(&dev->event_lock, flags);
2822+
2823+
return pending;
2824+
}
2825+
28092826
static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
28102827
{
28112828
struct drm_device *dev = crtc->dev;
2829+
struct drm_i915_private *dev_priv = dev->dev_private;
28122830

28132831
if (crtc->fb == NULL)
28142832
return;
28152833

2834+
wait_event(dev_priv->pending_flip_queue,
2835+
!intel_crtc_has_pending_flip(crtc));
2836+
28162837
mutex_lock(&dev->struct_mutex);
28172838
intel_finish_fb(crtc->fb);
28182839
mutex_unlock(&dev->struct_mutex);
@@ -6217,9 +6238,8 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
62176238

62186239
atomic_clear_mask(1 << intel_crtc->plane,
62196240
&obj->pending_flip.counter);
6220-
if (atomic_read(&obj->pending_flip) == 0)
6221-
wake_up(&dev_priv->pending_flip_queue);
62226241

6242+
wake_up(&dev_priv->pending_flip_queue);
62236243
schedule_work(&work->work);
62246244

62256245
trace_i915_flip_complete(intel_crtc->plane, work->pending_flip_obj);

0 commit comments

Comments
 (0)