1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, TX., USA
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 * USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
33 int drm_bo_move_ttm(drm_device_t *dev,
37 drm_bo_mem_reg_t *old_mem,
38 drm_bo_mem_reg_t *new_mem)
40 uint32_t save_flags = old_mem->flags;
41 uint32_t save_mask = old_mem->mask;
44 if (old_mem->mem_type == DRM_BO_MEM_TT) {
51 mutex_lock(&dev->struct_mutex);
52 drm_mm_put_block(old_mem->mm_node);
53 mutex_unlock(&dev->struct_mutex);
54 save_flags |= DRM_BO_FLAG_CACHED;
58 ret = drm_bind_ttm(ttm,
59 new_mem->flags & DRM_BO_FLAG_BIND_CACHED,
60 new_mem->mm_node->start);
64 if (!(new_mem->flags & DRM_BO_FLAG_BIND_CACHED)) {
65 save_flags &= ~DRM_BO_FLAG_CACHED;
71 new_mem->mm_node = NULL;
72 old_mem->mask = save_mask;
73 DRM_MASK_VAL(save_flags, new_mem->flags, DRM_BO_MASK_MEM);