Skip to contentSkip to conversation

drm/i915: Don't clobber crtc->fb when queue_flip fails

PATCH Applied [email protected] 4 participants 5 messages Feb 22, 2013 – Mar 4, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/i915: Don't clobber crtc->fb when queue_flip fails

From: Ville Syrjälä <[email protected]>

Restore crtc->fb to the old framebuffer if queue_flip fails.

While at it, kill the pointless intel_fb temp variable.

v2: Update crtc->fb before queue_flip and restore it back
after a failure.

---
 drivers/gpu/drm/i915/intel_display.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_display.c +4 -7
index ebe9dae..d6aff15 100644
@@ -7288,8 +7288,8 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_framebuffer *intel_fb;
-	struct drm_i915_gem_object *obj;
+	struct drm_framebuffer *old_fb = crtc->fb;
+	struct drm_i915_gem_object *obj = to_intel_framebuffer(fb)->obj;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_unpin_work *work;
 	unsigned long flags;
@@ -7314,8 +7314,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 
 	work->event = event;
 	work->crtc = crtc;
-	intel_fb = to_intel_framebuffer(crtc->fb);
-	work->old_fb_obj = intel_fb->obj;
+	work->old_fb_obj = to_intel_framebuffer(old_fb)->obj;
 	INIT_WORK(&work->work, intel_unpin_work_fn);
 
 	ret = drm_vblank_get(dev, intel_crtc->pipe);
@@ -7335,9 +7334,6 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 	intel_crtc->unpin_work = work;
 	spin_unlock_irqrestore(&dev->event_lock, flags);
 
-	intel_fb = to_intel_framebuffer(fb);
-	obj = intel_fb->obj;
-
 	if (atomic_read(&intel_crtc->unpin_work_count) >= 2)
 		flush_workqueue(dev_priv->wq);
 
@@ -7372,6 +7368,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 
 cleanup_pending:
 	atomic_dec(&intel_crtc->unpin_work_count);
+	crtc->fb = old_fb;
 	drm_gem_object_unreference(&work->old_fb_obj->base);
 	drm_gem_object_unreference(&obj->base);
 	mutex_unlock(&dev->struct_mutex);
Signature · 1 line
1.7.12.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · On Fri, Feb 22, 2013 at 04:53:38PM +0200, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Restore crtc->fb to the old framebuffer if queue_flip fails.

While at it, kill the pointless intel_fb temp variable.

v2: Update crtc->fb before queue_flip and restore it back
after a failure.

Lgtm, either v1 or v2 gets my

(with a slight preference towards v2 for the sake of paranoia) -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#2 lore raw
Quoted 10 lines · Chris Wilson
Quoted 9 lines · On Fri, Feb 22, 2013 at 04:53:38PM +0200, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Restore crtc->fb to the old framebuffer if queue_flip fails.

While at it, kill the pointless intel_fb temp variable.

v2: Update crtc->fb before queue_flip and restore it back
after a failure.

Quoted 6 lines
Quoted 2 lines

Lgtm, either v1 or v2 gets my

(with a slight preference towards v2 for the sake of paranoia)

Picked up for -fixes, thanks for the patch. And can I wish for an i-g-t for this?
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#3 lore raw
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Chris Wilson
Quoted 11 lines · On Fri, Feb 22, 2013 at 04:53:38PM +0200, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Restore crtc->fb to the old framebuffer if queue_flip fails.

While at it, kill the pointless intel_fb temp variable.

v2: Update crtc->fb before queue_flip and restore it back
after a failure.

Quoted 6 lines
Quoted 3 lines

Lgtm, either v1 or v2 gets my

(with a slight preference towards v2 for the sake of paranoia)

Picked up for -fixes, thanks for the patch. And can I wish for an i-g-t for this?

Hmm. I think it's a bit difficult to hit it systematically due to a GPU reset. We need to call queue_flip after a hang was detected but before the reset work has a chance to run.

But after a bit more though we should hit the same bug by trying to flip to a Y-tiled buffer. I'll try to make a test based on that.

Signature · 2 lines
Ville Syrjälä
Intel OTC