Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[pandora-kernel.git] / drivers / gpu / drm / vmwgfx / vmwgfx_execbuf.c
index dbd36b8..51d9f9f 100644 (file)
@@ -538,8 +538,11 @@ static void vmw_apply_relocations(struct vmw_sw_context *sw_context)
                reloc = &sw_context->relocs[i];
                validate = &sw_context->val_bufs[reloc->index];
                bo = validate->bo;
-               reloc->location->offset += bo->offset;
-               reloc->location->gmrId = vmw_dmabuf_gmr(bo);
+               if (bo->mem.mem_type == TTM_PL_VRAM) {
+                       reloc->location->offset += bo->offset;
+                       reloc->location->gmrId = SVGA_GMR_FRAMEBUFFER;
+               } else
+                       reloc->location->gmrId = bo->mem.start;
        }
        vmw_free_relocations(sw_context);
 }
@@ -563,25 +566,14 @@ static int vmw_validate_single_buffer(struct vmw_private *dev_priv,
 {
        int ret;
 
-       if (vmw_dmabuf_gmr(bo) != SVGA_GMR_NULL)
-               return 0;
-
-       /**
-        * Put BO in VRAM, only if there is space.
-        */
-
-       ret = ttm_bo_validate(bo, &vmw_vram_sys_placement, true, false, false);
-       if (unlikely(ret == -ERESTARTSYS))
-               return ret;
-
        /**
-        * Otherwise, set it up as GMR.
+        * Put BO in VRAM if there is space, otherwise as a GMR.
+        * If there is no space in VRAM and GMR ids are all used up,
+        * start evicting GMRs to make room. If the DMA buffer can't be
+        * used as a GMR, this will return -ENOMEM.
         */
 
-       if (vmw_dmabuf_gmr(bo) != SVGA_GMR_NULL)
-               return 0;
-
-       ret = vmw_gmr_bind(dev_priv, bo);
+       ret = ttm_bo_validate(bo, &vmw_vram_gmr_placement, true, false, false);
        if (likely(ret == 0 || ret == -ERESTARTSYS))
                return ret;
 
@@ -590,6 +582,7 @@ static int vmw_validate_single_buffer(struct vmw_private *dev_priv,
         * previous contents.
         */
 
+       DRM_INFO("Falling through to VRAM.\n");
        ret = ttm_bo_validate(bo, &vmw_vram_placement, true, false, false);
        return ret;
 }
@@ -644,6 +637,7 @@ int vmw_execbuf_ioctl(struct drm_device *dev, void *data,
        ret = copy_from_user(cmd, user_cmd, arg->command_size);
 
        if (unlikely(ret != 0)) {
+               ret = -EFAULT;
                DRM_ERROR("Failed copying commands.\n");
                goto out_commit;
        }
@@ -669,6 +663,15 @@ int vmw_execbuf_ioctl(struct drm_device *dev, void *data,
                goto out_err;
 
        vmw_apply_relocations(sw_context);
+
+       if (arg->throttle_us) {
+               ret = vmw_wait_lag(dev_priv, &dev_priv->fifo.fence_queue,
+                                  arg->throttle_us);
+
+               if (unlikely(ret != 0))
+                       goto out_err;
+       }
+
        vmw_fifo_commit(dev_priv, arg->command_size);
 
        ret = vmw_fifo_send_fence(dev_priv, &sequence);