1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#include "nouveau_bo.h"
30#include "nouveau_dma.h"
31#include "nouveau_mem.h"
32
33#include <nvif/push906f.h>
34
35#include <nvhw/class/cl9039.h>
36
37int
38nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
39 struct ttm_resource *old_reg, struct ttm_resource *new_reg)
40{
41 struct nvif_push *push = chan->chan.push;
42 struct nouveau_mem *mem = nouveau_mem(old_reg);
43 u64 src_offset = mem->vma[0].addr;
44 u64 dst_offset = mem->vma[1].addr;
45 u32 page_count = new_reg->num_pages;
46 int ret;
47
48 page_count = new_reg->num_pages;
49 while (page_count) {
50 int line_count = (page_count > 2047) ? 2047 : page_count;
51
52 ret = PUSH_WAIT(push, 12);
53 if (ret)
54 return ret;
55
56 PUSH_MTHD(push, NV9039, OFFSET_OUT_UPPER,
57 NVVAL(NV9039, OFFSET_OUT_UPPER, VALUE, upper_32_bits(dst_offset)),
58
59 OFFSET_OUT, lower_32_bits(dst_offset));
60
61 PUSH_MTHD(push, NV9039, OFFSET_IN_UPPER,
62 NVVAL(NV9039, OFFSET_IN_UPPER, VALUE, upper_32_bits(src_offset)),
63
64 OFFSET_IN, lower_32_bits(src_offset),
65 PITCH_IN, PAGE_SIZE,
66 PITCH_OUT, PAGE_SIZE,
67 LINE_LENGTH_IN, PAGE_SIZE,
68 LINE_COUNT, line_count);
69
70 PUSH_MTHD(push, NV9039, LAUNCH_DMA,
71 NVDEF(NV9039, LAUNCH_DMA, SRC_INLINE, FALSE) |
72 NVDEF(NV9039, LAUNCH_DMA, SRC_MEMORY_LAYOUT, PITCH) |
73 NVDEF(NV9039, LAUNCH_DMA, DST_MEMORY_LAYOUT, PITCH) |
74 NVDEF(NV9039, LAUNCH_DMA, COMPLETION_TYPE, FLUSH_DISABLE) |
75 NVDEF(NV9039, LAUNCH_DMA, INTERRUPT_TYPE, NONE) |
76 NVDEF(NV9039, LAUNCH_DMA, SEMAPHORE_STRUCT_SIZE, ONE_WORD));
77
78 page_count -= line_count;
79 src_offset += (PAGE_SIZE * line_count);
80 dst_offset += (PAGE_SIZE * line_count);
81 }
82
83 return 0;
84}
85
86int
87nvc0_bo_move_init(struct nouveau_channel *chan, u32 handle)
88{
89 struct nvif_push *push = chan->chan.push;
90 int ret;
91
92 ret = PUSH_WAIT(push, 2);
93 if (ret)
94 return ret;
95
96 PUSH_MTHD(push, NV9039, SET_OBJECT, handle);
97 return 0;
98}
99