Skip to contentSkip to conversation

drm/i915: Don't die in wait_for_pending_flips

PATCH In review Daniel Vetter 4 participants 6 messages May 19, 2014

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

PATCH 1/1 drm/i915: Don't die in wait_for_pending_flips

We can apperently miss them, but breaking the entire driver hampers testing. So bail out after one minute, our customerary "this is a lost cause" timeout.

References: https://bugs.freedesktop.org/show_bug.cgi?id=78383

---
 drivers/gpu/drm/i915/intel_display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -2
index 0f8f9bcb3012..6eca24d8b282 100644
@@ -3284,8 +3284,9 @@ static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
 
 	WARN_ON(waitqueue_active(&dev_priv->pending_flip_queue));
 
-	wait_event(dev_priv->pending_flip_queue,
-		   !intel_crtc_has_pending_flip(crtc));
+	WARN_ON(wait_event_timeout(dev_priv->pending_flip_queue,
+				   !intel_crtc_has_pending_flip(crtc),
+				   60*HZ) == 0);
 
 	mutex_lock(&dev->struct_mutex);
 	intel_finish_fb(crtc->primary->fb);
Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 16 lines · On Mon, 19 May 2014 16:09:35 +0200 Daniel Vetter <[email protected]> wrote:

We can apperently miss them, but breaking the entire driver hampers testing. So bail out after one minute, our customerary "this is a lost cause" timeout.

References: https://bugs.freedesktop.org/show_bug.cgi?id=78383

---
 drivers/gpu/drm/i915/intel_display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 0f8f9bcb3012..6eca24d8b282 100644
@@ -3284,8 +3284,9 @@ static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
 

drivers/gpu/drm/i915/intel_display.c static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc) · line 3292

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +3 -2
 	WARN_ON(waitqueue_active(&dev_priv->pending_flip_queue));
 
-	wait_event(dev_priv->pending_flip_queue,
-		   !intel_crtc_has_pending_flip(crtc));
+	WARN_ON(wait_event_timeout(dev_priv->pending_flip_queue,
+				   !intel_crtc_has_pending_flip(crtc),
+				   60*HZ) == 0);
 
 	mutex_lock(&dev->struct_mutex);
 	intel_finish_fb(crtc->primary->fb);

Updating our page flip ioctl man page (hah!) with the timeout info would be good, in case people like Mario queue flips for after lunch. :)

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#2 lore raw
Quoted 27 lines · Jesse Barnes
Quoted 24 lines · On Mon, 19 May 2014 16:09:35 +0200 Daniel Vetter <[email protected]> wrote:

We can apperently miss them, but breaking the entire driver hampers testing. So bail out after one minute, our customerary "this is a lost cause" timeout.

References: https://bugs.freedesktop.org/show_bug.cgi?id=78383

---
 drivers/gpu/drm/i915/intel_display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -2
index 0f8f9bcb3012..6eca24d8b282 100644
@@ -3284,8 +3284,9 @@ static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
 
 	WARN_ON(waitqueue_active(&dev_priv->pending_flip_queue));
 
-	wait_event(dev_priv->pending_flip_queue,
-		   !intel_crtc_has_pending_flip(crtc));
+	WARN_ON(wait_event_timeout(dev_priv->pending_flip_queue,
+				   !intel_crtc_has_pending_flip(crtc),
+				   60*HZ) == 0);
 
Quoted 5 lines

drivers/gpu/drm/i915/intel_display.c static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc) · line 3292

Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +0 -0
 	mutex_lock(&dev->struct_mutex);
 	intel_finish_fb(crtc->primary->fb);

Updating our page flip ioctl man page (hah!) with the timeout info would be good, in case people like Mario queue flips for after lunch. :)

We don't do that in the kernel though, we only ever queue flips for the next vblank after rendering completed. Completed rendering we can detect (and have 60s timeouts in other places where the hangcheck isn't guaranteed to be around already), the additional vblank is negligible imo.

Of course if we add support for flip queues in the kernel we might need to cancel outstanding flips properly when we kill the crtc, like we already do for vblank events.

So imo no need to document anything.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Reviewed-by
#3 lore raw
Quoted 39 lines · On Mon, 19 May 2014 17:18:40 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 27 lines · Jesse Barnes
Quoted 24 lines · On Mon, 19 May 2014 16:09:35 +0200 Daniel Vetter <[email protected]> wrote:

We can apperently miss them, but breaking the entire driver hampers testing. So bail out after one minute, our customerary "this is a lost cause" timeout.

References: https://bugs.freedesktop.org/show_bug.cgi?id=78383

---
 drivers/gpu/drm/i915/intel_display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -2
index 0f8f9bcb3012..6eca24d8b282 100644
@@ -3284,8 +3284,9 @@ static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
 
 	WARN_ON(waitqueue_active(&dev_priv->pending_flip_queue));
 
-	wait_event(dev_priv->pending_flip_queue,
-		   !intel_crtc_has_pending_flip(crtc));
+	WARN_ON(wait_event_timeout(dev_priv->pending_flip_queue,
+				   !intel_crtc_has_pending_flip(crtc),
+				   60*HZ) == 0);
 
Quoted 5 lines

drivers/gpu/drm/i915/intel_display.c static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc) · line 3292

Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +0 -0
 	mutex_lock(&dev->struct_mutex);
 	intel_finish_fb(crtc->primary->fb);

Updating our page flip ioctl man page (hah!) with the timeout info would be good, in case people like Mario queue flips for after lunch. :)

We don't do that in the kernel though, we only ever queue flips for the next vblank after rendering completed. Completed rendering we can detect (and have 60s timeouts in other places where the hangcheck isn't guaranteed to be around already), the additional vblank is negligible imo.

Quoted 5 lines

Of course if we add support for flip queues in the kernel we might need to cancel outstanding flips properly when we kill the crtc, like we already do for vblank events.

So imo no need to document anything.

Ah right so we'd only be affected here by ridiculous refresh rates... so yeah should be fine.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Reviewed-by
#4 lore raw
Quoted 42 lines · Jesse Barnes
Quoted 39 lines · On Mon, 19 May 2014 17:18:40 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 27 lines · Jesse Barnes
Quoted 24 lines · On Mon, 19 May 2014 16:09:35 +0200 Daniel Vetter <[email protected]> wrote:

We can apperently miss them, but breaking the entire driver hampers testing. So bail out after one minute, our customerary "this is a lost cause" timeout.

References: https://bugs.freedesktop.org/show_bug.cgi?id=78383

---
 drivers/gpu/drm/i915/intel_display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -2
index 0f8f9bcb3012..6eca24d8b282 100644
@@ -3284,8 +3284,9 @@ static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
 
 	WARN_ON(waitqueue_active(&dev_priv->pending_flip_queue));
 
-	wait_event(dev_priv->pending_flip_queue,
-		   !intel_crtc_has_pending_flip(crtc));
+	WARN_ON(wait_event_timeout(dev_priv->pending_flip_queue,
+				   !intel_crtc_has_pending_flip(crtc),
+				   60*HZ) == 0);
 
Quoted 5 lines

drivers/gpu/drm/i915/intel_display.c static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc) · line 3292

Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +0 -0
 	mutex_lock(&dev->struct_mutex);
 	intel_finish_fb(crtc->primary->fb);

Updating our page flip ioctl man page (hah!) with the timeout info would be good, in case people like Mario queue flips for after lunch. :)

We don't do that in the kernel though, we only ever queue flips for the next vblank after rendering completed. Completed rendering we can detect (and have 60s timeouts in other places where the hangcheck isn't guaranteed to be around already), the additional vblank is negligible imo.

Quoted 8 lines
Quoted 5 lines

Of course if we add support for flip queues in the kernel we might need to cancel outstanding flips properly when we kill the crtc, like we already do for vblank events.

So imo no need to document anything.

Ah right so we'd only be affected here by ridiculous refresh rates... so yeah should be fine.

If we are that concerned we could factor those into the timeout, say hangcheck + 10 * frame_interval.

Quoted 1 line

Anyhow, I'd been meaning to do this myself, just kept wondering if perhaps hangcheck was a better place to drive it from.

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#5 lore raw
Quoted 52 lines · Chris Wilson
Quoted 42 lines · Jesse Barnes
Quoted 39 lines · On Mon, 19 May 2014 17:18:40 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 27 lines · Jesse Barnes
Quoted 24 lines · On Mon, 19 May 2014 16:09:35 +0200 Daniel Vetter <[email protected]> wrote:

We can apperently miss them, but breaking the entire driver hampers testing. So bail out after one minute, our customerary "this is a lost cause" timeout.

References: https://bugs.freedesktop.org/show_bug.cgi?id=78383

---
 drivers/gpu/drm/i915/intel_display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -2
index 0f8f9bcb3012..6eca24d8b282 100644
@@ -3284,8 +3284,9 @@ static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
 
 	WARN_ON(waitqueue_active(&dev_priv->pending_flip_queue));
 
-	wait_event(dev_priv->pending_flip_queue,
-		   !intel_crtc_has_pending_flip(crtc));
+	WARN_ON(wait_event_timeout(dev_priv->pending_flip_queue,
+				   !intel_crtc_has_pending_flip(crtc),
+				   60*HZ) == 0);
 
Quoted 5 lines

drivers/gpu/drm/i915/intel_display.c static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc) · line 3292

Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +0 -0
 	mutex_lock(&dev->struct_mutex);
 	intel_finish_fb(crtc->primary->fb);

Updating our page flip ioctl man page (hah!) with the timeout info would be good, in case people like Mario queue flips for after lunch. :)

We don't do that in the kernel though, we only ever queue flips for the next vblank after rendering completed. Completed rendering we can detect (and have 60s timeouts in other places where the hangcheck isn't guaranteed to be around already), the additional vblank is negligible imo.

Quoted 8 lines
Quoted 5 lines

Of course if we add support for flip queues in the kernel we might need to cancel outstanding flips properly when we kill the crtc, like we already do for vblank events.

So imo no need to document anything.

Ah right so we'd only be affected here by ridiculous refresh rates... so yeah should be fine.

Quoted 7 lines

If we are that concerned we could factor those into the timeout, say hangcheck + 10 * frame_interval.

Quoted 1 line

Anyhow, I'd been meaning to do this myself, just kept wondering if perhaps hangcheck was a better place to drive it from.

We still lack the add_request for flips ... And imo there's too many fragile parts in our pageflip sequence to go wrong, so a simple timeout at the very end seems best. Patch pulled in.
-Daniel

Quoted 6 lines

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch