Skip to contentSkip to conversation

batchbuffers failing to execute

PATCH New Eric Anholt 3 participants 5 messages Feb 20, 2012

lore
Share & tools
lore
#0 lore raw

I think I've got a concrete test here for something I've been trying to track down for a while now: it appears that when the GPU is too busy, batches get dropped and sometimes the GPU hangs.

This really became clear when I was testing a patch for citybench to "improve" the swap throttling -- a broken version that I submitted caused no throttling to occur at all. The app, which renders a predefined set of frames as fast as possible, would now frequently stutter in the middle. The results were insanely fast (40-60% better!). But it didn't make sense for there to be a stutter if the set of frames rendered is predefined.

So, I wrote this little patch series to try to test my guess that my batches were getting dropped. The plan is: Emit a dword write every (render) batch, and after a while go look and see if they all landed. Corresponding to the stutters is:

Mesa: Initializing x86-64 optimizations
batch 42 didn't report: 0xd0d0d0d0 instead of 0x0000002a batch 43 didn't report: 0xd0d0d0d0 instead of 0x0000002b batch 44 didn't report: 0xd0d0d0d0 instead of 0x0000002c batch 45 didn't report: 0xd0d0d0d0 instead of 0x0000002d batch 46 didn't report: 0xd0d0d0d0 instead of 0x0000002e batch 47 didn't report: 0xd0d0d0d0 instead of 0x0000002f batch 48 didn't report: 0xd0d0d0d0 instead of 0x00000030 batch 49 didn't report: 0xd0d0d0d0 instead of 0x00000031 batch 50 didn't report: 0xd0d0d0d0 instead of 0x00000032 batch 51 didn't report: 0xd0d0d0d0 instead of 0x00000033 batch 52 didn't report: 0xd0d0d0d0 instead of 0x00000034 batch 53 didn't report: 0xd0d0d0d0 instead of 0x00000035 shutting up

The cool thing is apparently I don't need citybench, either. This paste came from vblank_mode=0 glxgears fullscreened on my 1600x900 panel (default size doesn't reproduce the failure).

This is gen7, danvet's kernel de67cba65944f26c0f147035bd62e30c5f456b96 rebased on top of cherry-picks of the 4 ivb workaround patches. A revert of a71d8d94525e8fd855c0466fb586ae1cb008f3a2 doesn't help.

I've also run this on a test libdrm that returns NULL pointers on map failure and asserts that exec and pwrite don't return errors.

#1 lore raw

PATCH 1/2 Try to ensure that batches emitted actually complete.

---
 src/mesa/drivers/dri/i965/brw_state_upload.c   |    2 +
 src/mesa/drivers/dri/intel/intel_batchbuffer.c |   73 ++++++++++++++++++++++++
 src/mesa/drivers/dri/intel/intel_batchbuffer.h |    2 +
 3 files changed, 77 insertions(+), 0 deletions(-)
src/mesa/drivers/dri/i965/brw_state_upload.c +2 -0
index f5e6fdc..4655e75 100644
@@ -435,6 +435,8 @@ void brw_upload_state(struct brw_context *brw)
    int i;
    static int dirty_count = 0;
 
+   record_batch(intel);
+
    state->mesa |= brw->intel.NewGLState;
    brw->intel.NewGLState = 0;
 
src/mesa/drivers/dri/intel/intel_batchbuffer.c +73 -0

94 lines not on this page · raw message

src/mesa/drivers/dri/intel/intel_batchbuffer.h +2 -0
index 751ec99..c36fd0b 100644
@@ -132,6 +132,8 @@ intel_batchbuffer_advance(struct intel_context *intel)
 
 void intel_batchbuffer_cached_advance(struct intel_context *intel);
 
+void record_batch(struct intel_context *intel);
+
 /* Here are the crusty old macros, to be removed:
  */
 #define BATCH_LOCALS
Signature · 1 line
1.7.9
#2 lore raw

PATCH 2/2 intel: Disable swap throttling entirely.

In reply to Eric Anholt

This reveals some major breakage in the kernel.

---
 src/mesa/drivers/dri/intel/intel_context.c |   22 ----------------------
 1 files changed, 0 insertions(+), 22 deletions(-)
src/mesa/drivers/dri/intel/intel_context.c +0 -22
index 377bcbc..573346da23 100644
@@ -411,28 +411,6 @@ intel_prepare_render(struct intel_context *intel)
     */
    if (intel->is_front_buffer_rendering)
       intel->front_buffer_dirty = true;
-
-   /* Wait for the swapbuffers before the one we just emitted, so we
-    * don't get too many swaps outstanding for apps that are GPU-heavy
-    * but not CPU-heavy.
-    *
-    * We're using intelDRI2Flush (called from the loader before
-    * swapbuffer) and glFlush (for front buffer rendering) as the
-    * indicator that a frame is done and then throttle when we get
-    * here as we prepare to render the next frame.  At this point for
-    * round trips for swap/copy and getting new buffers are done and
-    * we'll spend less time waiting on the GPU.
-    *
-    * Unfortunately, we don't have a handle to the batch containing
-    * the swap, and getting our hands on that doesn't seem worth it,
-    * so we just us the first batch we emitted after the last swap.
-    */
-   if (intel->need_throttle && intel->first_post_swapbuffers_batch) {
-      drm_intel_bo_wait_rendering(intel->first_post_swapbuffers_batch);
-      drm_intel_bo_unreference(intel->first_post_swapbuffers_batch);
-      intel->first_post_swapbuffers_batch = NULL;
-      intel->need_throttle = false;
-   }
 }
 
 static void
Signature · 1 line
1.7.9
#3 lore raw
In reply to Eric Anholt
Quoted 3 lines · Eric Anholt

This is gen7, danvet's kernel de67cba65944f26c0f147035bd62e30c5f456b96 rebased on top of cherry-picks of the 4 ivb workaround patches. A revert of a71d8d94525e8fd855c0466fb586ae1cb008f3a2 doesn't help.

You need the bug fix that was meant to be applied before that patch id:[email protected].

See also https://bugs.freedesktop.org/show_bug.cgi?id=45492
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#4 lore raw
Quoted 9 lines · Chris Wilson
Quoted 3 lines · Eric Anholt

This is gen7, danvet's kernel de67cba65944f26c0f147035bd62e30c5f456b96 rebased on top of cherry-picks of the 4 ivb workaround patches. A revert of a71d8d94525e8fd855c0466fb586ae1cb008f3a2 doesn't help.

You need the bug fix that was meant to be applied before that patch id:[email protected].

See also https://bugs.freedesktop.org/show_bug.cgi?id=45492

Meh, stupid me somehow got the idea that we'd check the new request->tail before the b0rked autoreport_head and hence merging just the new code for -next would fix this desaster without merging in -fixes. Otherwise I'd been slightly more clear in my -next announcement ...

/me hides in shame
-Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48