Avoid duplicate calls to drm_ttm_bind in some cases.
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Wed, 12 Mar 2008 09:02:09 +0000 (10:02 +0100)
committerThomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Wed, 12 Mar 2008 09:02:09 +0000 (10:02 +0100)
linux-core/drm_bo.c

index fd3cf9d..51cd175 100644 (file)
@@ -208,36 +208,35 @@ static int drm_bo_handle_move_mem(struct drm_buffer_object *bo,
                        if (ret)
                                goto out_err;
                }
-       }
-
-       if ((bo->mem.mem_type == DRM_BO_MEM_LOCAL) && bo->ttm == NULL) {
-
-               struct drm_bo_mem_reg *old_mem = &bo->mem;
-               uint64_t save_flags = old_mem->flags;
-               uint64_t save_proposed_flags = old_mem->proposed_flags;
-
-               *old_mem = *mem;
-               mem->mm_node = NULL;
-               old_mem->proposed_flags = save_proposed_flags;
-               DRM_FLAG_MASKED(save_flags, mem->flags, DRM_BO_MASK_MEMTYPE);
 
-       } else if (!(old_man->flags & _DRM_FLAG_MEMTYPE_FIXED) &&
-                  !(new_man->flags & _DRM_FLAG_MEMTYPE_FIXED)) {
+               if (bo->mem.mem_type == DRM_BO_MEM_LOCAL) {
+                       
+                       struct drm_bo_mem_reg *old_mem = &bo->mem;
+                       uint64_t save_flags = old_mem->flags;
+                       uint64_t save_proposed_flags = old_mem->proposed_flags;
+                       
+                       *old_mem = *mem;
+                       mem->mm_node = NULL;
+                       old_mem->proposed_flags = save_proposed_flags;
+                       DRM_FLAG_MASKED(save_flags, mem->flags,
+                                       DRM_BO_MASK_MEMTYPE);
+                       goto moved;
+               }
+               
+       }
 
+       if (!(old_man->flags & _DRM_FLAG_MEMTYPE_FIXED) &&
+           !(new_man->flags & _DRM_FLAG_MEMTYPE_FIXED))                
                ret = drm_bo_move_ttm(bo, evict, no_wait, mem);
-
-       } else if (dev->driver->bo_driver->move) {
+       else if (dev->driver->bo_driver->move) 
                ret = dev->driver->bo_driver->move(bo, evict, no_wait, mem);
-
-       } else {
-
+       else
                ret = drm_bo_move_memcpy(bo, evict, no_wait, mem);
 
-       }
-
        if (ret)
                goto out_err;
 
+moved:
        if (old_is_pci || new_is_pci)
                drm_bo_vm_post_move(bo);