Make intel_{batch,exec}_ioctl return an error code so we can recover better.
authorEric Anholt <eric@anholt.net>
Mon, 5 May 2008 20:40:50 +0000 (13:40 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 5 May 2008 20:40:50 +0000 (13:40 -0700)
src/mesa/drivers/dri/intel/intel_batchbuffer.c
src/mesa/drivers/dri/intel/intel_ioctl.c
src/mesa/drivers/dri/intel/intel_ioctl.h

index 683d06a5526988c3acc88707880bee2f68c71510..a95abd9ec9d7c3f3b9934aa5152c19aeac2bca3e 100644 (file)
@@ -125,6 +125,7 @@ do_flush_locked(struct intel_batchbuffer *batch,
                GLuint used, GLboolean allow_unlock)
 {
    struct intel_context *intel = batch->intel;
+   int ret = 0;
 
    dri_bo_unmap(batch->buf);
 
@@ -142,18 +143,18 @@ do_flush_locked(struct intel_batchbuffer *batch,
         struct drm_i915_gem_execbuffer *execbuf;
 
         execbuf = dri_process_relocs(batch->buf);
-        intel_exec_ioctl(batch->intel,
-                         used,
-                         batch->cliprect_mode != LOOP_CLIPRECTS,
-                         allow_unlock,
-                         execbuf);
+        ret = intel_exec_ioctl(batch->intel,
+                               used,
+                               batch->cliprect_mode != LOOP_CLIPRECTS,
+                               allow_unlock,
+                               execbuf);
       } else {
         dri_process_relocs(batch->buf);
-        intel_batch_ioctl(batch->intel,
-                          batch->buf->offset,
-                          used,
-                          batch->cliprect_mode != LOOP_CLIPRECTS,
-                          allow_unlock);
+        ret = intel_batch_ioctl(batch->intel,
+                                batch->buf->offset,
+                                used,
+                                batch->cliprect_mode != LOOP_CLIPRECTS,
+                                allow_unlock);
       }
    }
 
@@ -182,6 +183,10 @@ do_flush_locked(struct intel_batchbuffer *batch,
         intel->vtbl.debug_batch(intel);
    }
 
+   if (ret != 0) {
+      UNLOCK_HARDWARE(intel);
+      exit(1);
+   }
    intel->vtbl.new_batch(intel);
 }
 
index 317ff2c440ff79a2113ed896b5ec29cff8b6dca3..591548ae85be7843f2043852cc181c0f47705e94 100644 (file)
@@ -106,7 +106,7 @@ intelWaitIrq(struct intel_context *intel, int seq)
 }
 
 
-void
+int
 intel_batch_ioctl(struct intel_context *intel,
                   GLuint start_offset,
                   GLuint used,
@@ -115,7 +115,7 @@ intel_batch_ioctl(struct intel_context *intel,
    struct drm_i915_batchbuffer batch;
 
    if (intel->no_hw)
-      return;
+      return 0;
 
    assert(intel->locked);
    assert(used);
@@ -144,12 +144,13 @@ intel_batch_ioctl(struct intel_context *intel,
    if (drmCommandWrite(intel->driFd, DRM_I915_BATCHBUFFER, &batch,
                        sizeof(batch))) {
       fprintf(stderr, "DRM_I915_BATCHBUFFER: %d\n", -errno);
-      UNLOCK_HARDWARE(intel);
-      exit(1);
+      return -errno;
    }
+
+   return 0;
 }
 
-void
+int
 intel_exec_ioctl(struct intel_context *intel,
                 GLuint used,
                 GLboolean ignore_cliprects, GLboolean allow_unlock,
@@ -161,7 +162,7 @@ intel_exec_ioctl(struct intel_context *intel,
    assert(used);
 
    if (intel->no_hw)
-      return;
+      return 0;
 
    execbuf->batch_start_offset = 0;
    execbuf->batch_len = used;
@@ -177,7 +178,8 @@ intel_exec_ioctl(struct intel_context *intel,
 
    if (ret != 0) {
       fprintf(stderr, "DRM_I915_GEM_EXECBUFFER: %d\n", -errno);
-      UNLOCK_HARDWARE(intel);
-      exit(1);
+      return -errno;
    }
+
+   return 0;
 }
index 52b0ab61021e2b57116f0da2cab70c4955c6fb22..526e38358cc83509f9409bdb1496aff20af54e07 100644 (file)
 void intelWaitIrq( struct intel_context *intel, int seq );
 int intelEmitIrqLocked( struct intel_context *intel );
 
-void intel_batch_ioctl( struct intel_context *intel, 
-                       GLuint start_offset,
-                       GLuint used,
-                       GLboolean ignore_cliprects,
-                       GLboolean allow_unlock );
-void intel_exec_ioctl(struct intel_context *intel,
+int intel_batch_ioctl(struct intel_context *intel,
+                     GLuint start_offset,
                      GLuint used,
-                     GLboolean ignore_cliprects, GLboolean allow_unlock,
-                     struct drm_i915_gem_execbuffer *execbuf);
+                     GLboolean ignore_cliprects,
+                     GLboolean allow_unlock);
+int intel_exec_ioctl(struct intel_context *intel,
+                    GLuint used,
+                    GLboolean ignore_cliprects, GLboolean allow_unlock,
+                    struct drm_i915_gem_execbuffer *execbuf);
 
 #endif