[intel] Handle -EAGAINs correctly in execbuffer.
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Tue, 26 Feb 2008 08:19:27 +0000 (09:19 +0100)
committerThomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Tue, 26 Feb 2008 08:19:27 +0000 (09:19 +0100)
Dont stop on fence creation errors.

src/mesa/drivers/dri/intel/intel_ioctl.c

index c8f70ae47862539157346627b5bfafd323f7355a..66e36102b9d13b1698c403482cbdc602e46abd40 100644 (file)
@@ -155,6 +155,7 @@ intel_exec_ioctl(struct intel_context *intel,
 {
    struct drm_i915_execbuffer execbuf;
    dri_fence *fo;
+   int ret;
 
    assert(intel->locked);
    assert(used);
@@ -179,13 +180,27 @@ intel_exec_ioctl(struct intel_context *intel,
    execbuf.ops_list = (unsigned long)start; // TODO
    execbuf.fence_arg.flags = DRM_FENCE_FLAG_SHAREABLE | DRM_I915_FENCE_FLAG_FLUSHED;
 
-   if (drmCommandWriteRead(intel->driFd, DRM_I915_EXECBUFFER, &execbuf,
-                       sizeof(execbuf))) {
+   do {
+      ret = drmCommandWriteRead(intel->driFd, DRM_I915_EXECBUFFER, &execbuf,
+                               sizeof(execbuf));
+   } while (ret == -EAGAIN);
+
+   if (ret != 0) {
       fprintf(stderr, "DRM_I915_EXECBUFFER: %d\n", -errno);
       UNLOCK_HARDWARE(intel);
       exit(1);
    }
 
+   if (execbuf.fence_arg.error != 0) {
+
+      /*
+       * Fence creation has failed, but the GPU has been
+       * idled by the kernel. Safe to continue.
+       */ 
+
+      *fence = NULL;
+      return;
+   }
 
    fo = intel_ttm_fence_create_from_arg(intel->bufmgr, "fence buffers",
                                        &execbuf.fence_arg);