0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "nouveau_bo.h"
0030 #include "nouveau_dma.h"
0031 #include "nouveau_mem.h"
0032
0033 #include <nvif/push906f.h>
0034
0035 #include <nvhw/class/cl9039.h>
0036
0037 int
0038 nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
0039 struct ttm_resource *old_reg, struct ttm_resource *new_reg)
0040 {
0041 struct nvif_push *push = chan->chan.push;
0042 struct nouveau_mem *mem = nouveau_mem(old_reg);
0043 u64 src_offset = mem->vma[0].addr;
0044 u64 dst_offset = mem->vma[1].addr;
0045 u32 page_count = new_reg->num_pages;
0046 int ret;
0047
0048 page_count = new_reg->num_pages;
0049 while (page_count) {
0050 int line_count = (page_count > 2047) ? 2047 : page_count;
0051
0052 ret = PUSH_WAIT(push, 12);
0053 if (ret)
0054 return ret;
0055
0056 PUSH_MTHD(push, NV9039, OFFSET_OUT_UPPER,
0057 NVVAL(NV9039, OFFSET_OUT_UPPER, VALUE, upper_32_bits(dst_offset)),
0058
0059 OFFSET_OUT, lower_32_bits(dst_offset));
0060
0061 PUSH_MTHD(push, NV9039, OFFSET_IN_UPPER,
0062 NVVAL(NV9039, OFFSET_IN_UPPER, VALUE, upper_32_bits(src_offset)),
0063
0064 OFFSET_IN, lower_32_bits(src_offset),
0065 PITCH_IN, PAGE_SIZE,
0066 PITCH_OUT, PAGE_SIZE,
0067 LINE_LENGTH_IN, PAGE_SIZE,
0068 LINE_COUNT, line_count);
0069
0070 PUSH_MTHD(push, NV9039, LAUNCH_DMA,
0071 NVDEF(NV9039, LAUNCH_DMA, SRC_INLINE, FALSE) |
0072 NVDEF(NV9039, LAUNCH_DMA, SRC_MEMORY_LAYOUT, PITCH) |
0073 NVDEF(NV9039, LAUNCH_DMA, DST_MEMORY_LAYOUT, PITCH) |
0074 NVDEF(NV9039, LAUNCH_DMA, COMPLETION_TYPE, FLUSH_DISABLE) |
0075 NVDEF(NV9039, LAUNCH_DMA, INTERRUPT_TYPE, NONE) |
0076 NVDEF(NV9039, LAUNCH_DMA, SEMAPHORE_STRUCT_SIZE, ONE_WORD));
0077
0078 page_count -= line_count;
0079 src_offset += (PAGE_SIZE * line_count);
0080 dst_offset += (PAGE_SIZE * line_count);
0081 }
0082
0083 return 0;
0084 }
0085
0086 int
0087 nvc0_bo_move_init(struct nouveau_channel *chan, u32 handle)
0088 {
0089 struct nvif_push *push = chan->chan.push;
0090 int ret;
0091
0092 ret = PUSH_WAIT(push, 2);
0093 if (ret)
0094 return ret;
0095
0096 PUSH_MTHD(push, NV9039, SET_OBJECT, handle);
0097 return 0;
0098 }