More verbose error reporting in some cases.
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Mon, 18 Sep 2006 14:02:33 +0000 (16:02 +0200)
committerThomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Mon, 18 Sep 2006 14:02:33 +0000 (16:02 +0200)
Add a buffer object waitIdle user-space function.
Fix some names and minor glitches.

libdrm/xf86drm.c
libdrm/xf86mm.h
linux-core/drm_fence.c

index 2df74d1..606f098 100644 (file)
@@ -2407,6 +2407,10 @@ int drmFenceWait(int fd, unsigned flags, drmFence *fence, unsigned flush_type)
     drm_fence_arg_t arg;
     int ret;
 
+    if (flush_type == 0) {
+       flush_type = fence->type;
+    }
+
     if (!(fence->flags & DRM_FENCE_FLAG_SHAREABLE)) {
        if ((flush_type & fence->signaled) == flush_type) {
            return 0;
@@ -2964,8 +2968,36 @@ int drmBOInfo(int fd, drmBO *buf)
     drmBOCopyReply(rep, buf);
     return 0;
 }
+
+int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint)
+{
+    drm_bo_arg_t arg;
+    drm_bo_arg_request_t *req = &arg.d.req;
+    drm_bo_arg_reply_t *rep = &arg.d.rep;
+    int ret = 0;
+
+    if ((buf->flags & DRM_BO_FLAG_SHAREABLE) ||
+       (buf->replyFlags & DRM_BO_REP_BUSY)) {
+       arg.handled = 0;
+       req->handle = buf->handle;
+       req->op = drm_bo_wait_idle;
+       req->hint = hint;
+       arg.next = 0;
+
+       ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
+    
+       if (ret) 
+           return ret;
+       if (!arg.handled)
+           return -EFAULT;
+       if (rep->ret)
+           return rep->ret;
+       drmBOCopyReply(rep, buf);
+    }
+    return 0;
+}
        
-int drmBufBusy(int fd, drmBO *buf, int *busy)
+int drmBOBusy(int fd, drmBO *buf, int *busy)
 {
     if (!(buf->flags & DRM_BO_FLAG_SHAREABLE) &&
        !(buf->replyFlags & DRM_BO_REP_BUSY)) {
index 4cb37e2..a62aef4 100644 (file)
@@ -202,7 +202,7 @@ extern int drmBOValidate(int fd, drmBO *buf, unsigned flags, unsigned mask,
                         unsigned hint);
 extern int drmBOFence(int fd, drmBO *buf, unsigned flags, unsigned fenceHandle);
 extern int drmBOInfo(int fd, drmBO *buf);
-extern int drmBufBusy(int fd, drmBO *buf, int *busy);
+extern int drmBOBusy(int fd, drmBO *buf, int *busy);
 
 
 extern int drmAddValidateItem(drmBOList *list, drmBO *buf, unsigned flags, 
@@ -210,7 +210,7 @@ extern int drmAddValidateItem(drmBOList *list, drmBO *buf, unsigned flags,
                       int *newItem);
 extern int drmBOValidateList(int fd, drmBOList *list);
 extern int drmBOFenceList(int fd, drmBOList *list, unsigned fenceHandle);
-
+extern int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint);
 
 /*
  * Initialization functions.
index 5d051d4..41fe62a 100644 (file)
@@ -207,7 +207,8 @@ int drm_fence_object_flush(drm_device_t * dev,
        unsigned long flags;
 
        if (type & ~fence->type) {
-               DRM_ERROR("Flush trying to extend fence type\n");
+               DRM_ERROR("Flush trying to extend fence type, "
+                          "0x%x, 0x%x\n", type, fence->type);
                return -EINVAL;
        }
 
@@ -269,7 +270,8 @@ int drm_fence_object_wait(drm_device_t * dev, drm_fence_object_t * fence,
        int signaled;
 
        if (mask & ~fence->type) {
-               DRM_ERROR("Wait trying to extend fence type\n");
+               DRM_ERROR("Wait trying to extend fence type"
+                         " 0x%08x 0x%08x\n", mask, fence->type);
                return -EINVAL;
        }