Connect INTEL_DEBUG=sync up to cmd/batch ioctls.
authorEric Anholt <eric@anholt.net>
Wed, 11 Oct 2006 19:16:09 +0000 (12:16 -0700)
committerEric Anholt <eric@anholt.net>
Sun, 10 Dec 2006 20:24:46 +0000 (12:24 -0800)
src/mesa/drivers/dri/i965/intel_ioctl.c

index d1f2e3f27ca6e30f5a842c397d3fee077a43e022..d8176c559e548856b44eb68d324f1e8dacd273dd 100644 (file)
 #include "drm.h"
 #include "bufmgr.h"
 
+static int intelWaitIdleLocked( struct intel_context *intel )
+{
+   static int in_wait_idle = 0;
+   unsigned int fence;
+
+   if (!in_wait_idle) {
+      if (INTEL_DEBUG & DEBUG_SYNC) {
+        fprintf(stderr, "waiting for idle\n");
+      }
+
+      in_wait_idle = 1;
+      fence = bmSetFence(intel);
+      intelWaitIrq(intel, fence);
+      in_wait_idle = 0;
+
+      return bmTestFence(intel, fence);
+   } else {
+      return 1;
+   }
+}
 
 int intelEmitIrqLocked( struct intel_context *intel )
 {
@@ -139,7 +159,11 @@ void intel_batch_ioctl( struct intel_context *intel,
         UNLOCK_HARDWARE(intel);
         exit(1);
       }
-   }      
+
+      if (INTEL_DEBUG & DEBUG_SYNC) {
+       intelWaitIdleLocked(intel);
+      }
+   }
 }
 
 void intel_cmd_ioctl( struct intel_context *intel, 
@@ -171,5 +195,9 @@ void intel_cmd_ioctl( struct intel_context *intel,
         UNLOCK_HARDWARE(intel);
         exit(1);
       }
-   }      
+
+      if (INTEL_DEBUG & DEBUG_SYNC) {
+       intelWaitIdleLocked(intel);
+      }
+   }
 }