2 * Copyright 2007 Dave Airlied
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
25 * Authors: Dave Airlied <airlied@linux.ie>
26 * Ben Skeggs <darktama@iinet.net.au>
27 * Jeremy Kolb <jkolb@brandeis.edu>
29 #include "nouveau_bo.h"
30 #include "nouveau_dma.h"
31 #include "nouveau_mem.h"
34 nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
35 struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
37 struct nouveau_mem *mem = nouveau_mem(old_reg);
38 u64 src_offset = mem->vma[0].addr;
39 u64 dst_offset = mem->vma[1].addr;
40 u32 page_count = new_reg->num_pages;
43 page_count = new_reg->num_pages;
45 int line_count = (page_count > 2047) ? 2047 : page_count;
47 ret = RING_SPACE(chan, 12);
51 BEGIN_NVC0(chan, NvSubCopy, 0x0238, 2);
52 OUT_RING (chan, upper_32_bits(dst_offset));
53 OUT_RING (chan, lower_32_bits(dst_offset));
54 BEGIN_NVC0(chan, NvSubCopy, 0x030c, 6);
55 OUT_RING (chan, upper_32_bits(src_offset));
56 OUT_RING (chan, lower_32_bits(src_offset));
57 OUT_RING (chan, PAGE_SIZE); /* src_pitch */
58 OUT_RING (chan, PAGE_SIZE); /* dst_pitch */
59 OUT_RING (chan, PAGE_SIZE); /* line_length */
60 OUT_RING (chan, line_count);
61 BEGIN_NVC0(chan, NvSubCopy, 0x0300, 1);
62 OUT_RING (chan, 0x00100110);
64 page_count -= line_count;
65 src_offset += (PAGE_SIZE * line_count);
66 dst_offset += (PAGE_SIZE * line_count);
73 nvc0_bo_move_init(struct nouveau_channel *chan, u32 handle)
75 int ret = RING_SPACE(chan, 2);
77 BEGIN_NVC0(chan, NvSubCopy, 0x0000, 1);
78 OUT_RING (chan, handle);