I've just been talking with Ben about nouveau having some issues since this path, ttm_resource can be subclassed by drivers, and the code below that copies ttm_resources around pretty much seems to destroy that. > + struct ttm_resource *src_mem = &bo->mem; > + struct ttm_resource_manager *src_man = > + ttm_manager_type(bdev, src_mem->mem_type); > + struct ttm_resource src_copy = *src_mem; This here ^^ > + union { > + struct ttm_kmap_iter_tt tt; > + struct ttm_kmap_iter_linear_io io; > + } _dst_iter, _src_iter; > + struct ttm_kmap_iter *dst_iter, *src_iter; > + int ret = 0; > > - /* > - * TTM might be null for moves within the same region. > - */ > - if (ttm) { > + if (ttm && ((ttm->page_flags & TTM_PAGE_FLAG_SWAPPED) || > + dst_man->use_tt)) { > ret = ttm_tt_populate(bdev, ttm, ctx); > if (ret) > - goto out1; > + return ret; > } > > - for (i = 0; i < new_mem->num_pages; ++i) { > - if (old_iomap == NULL) { > - pgprot_t prot = ttm_io_prot(bo, old_mem, PAGE_KERNEL); > - ret = ttm_copy_ttm_io_page(ttm, new_iomap, i, > - prot); > - } else if (new_iomap == NULL) { > - pgprot_t prot = ttm_io_prot(bo, new_mem, PAGE_KERNEL); > - ret = ttm_copy_io_ttm_page(ttm, old_iomap, i, > - prot); > - } else { > - ret = ttm_copy_io_page(new_iomap, old_iomap, i); > - } > - if (ret) > - goto out1; > + dst_iter = ttm_kmap_iter_linear_io_init(&_dst_iter.io, bdev, dst_mem); > + if (PTR_ERR(dst_iter) == -EINVAL && dst_man->use_tt) > + dst_iter = ttm_kmap_iter_tt_init(&_dst_iter.tt, bo->ttm); > + if (IS_ERR(dst_iter)) > + return PTR_ERR(dst_iter); > + > + src_iter = ttm_kmap_iter_linear_io_init(&_src_iter.io, bdev, src_mem); > + if (PTR_ERR(src_iter) == -EINVAL && src_man->use_tt) > + src_iter = ttm_kmap_iter_tt_init(&_src_iter.tt, bo->ttm); > + if (IS_ERR(src_iter)) { > + ret = PTR_ERR(src_iter); > + goto out_src_iter; > } > - mb(); > -out2: > - old_copy = *old_mem; > > - ttm_bo_assign_mem(bo, new_mem); > - > - if (!man->use_tt) > - ttm_bo_tt_destroy(bo); > + ttm_move_memcpy(bo, dst_mem->num_pages, dst_iter, src_iter); > + src_copy = *src_mem; > + ttm_bo_move_sync_cleanup(bo, dst_mem); > > -out1: > - ttm_resource_iounmap(bdev, old_mem, new_iomap); > -out: > - ttm_resource_iounmap(bdev, &old_copy, old_iomap); > + if (!src_iter->ops->maps_tt) > + ttm_kmap_iter_linear_io_fini(&_src_iter.io, bdev, &src_copy); passes a copy into linear_io_fini which calls the driver io_mem_free without the subclass data. Dave.