Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2020 Red Hat Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  */
0022 #include "nouveau_bo.h"
0023 #include "nouveau_dma.h"
0024 #include "nouveau_mem.h"
0025 
0026 #include <nvif/push906f.h>
0027 
0028 /*XXX: Fixup class to be compatible with NVIDIA's, which will allow sharing
0029  *     code with KeplerDmaCopyA.
0030  */
0031 
0032 int
0033 nvc0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
0034           struct ttm_resource *old_reg, struct ttm_resource *new_reg)
0035 {
0036     struct nouveau_mem *mem = nouveau_mem(old_reg);
0037     struct nvif_push *push = chan->chan.push;
0038     u64 src_offset = mem->vma[0].addr;
0039     u64 dst_offset = mem->vma[1].addr;
0040     u32 page_count = new_reg->num_pages;
0041     int ret;
0042 
0043     page_count = new_reg->num_pages;
0044     while (page_count) {
0045         int line_count = (page_count > 8191) ? 8191 : page_count;
0046 
0047         ret = PUSH_WAIT(push, 10);
0048         if (ret)
0049             return ret;
0050 
0051         PUSH_NVSQ(push, NV90B5, 0x030c, upper_32_bits(src_offset),
0052                     0x0310, lower_32_bits(src_offset),
0053                     0x0314, upper_32_bits(dst_offset),
0054                     0x0318, lower_32_bits(dst_offset),
0055                     0x031c, PAGE_SIZE,
0056                     0x0320, PAGE_SIZE,
0057                     0x0324, PAGE_SIZE,
0058                     0x0328, line_count);
0059         PUSH_NVIM(push, NV90B5, 0x0300, 0x0110);
0060 
0061         page_count -= line_count;
0062         src_offset += (PAGE_SIZE * line_count);
0063         dst_offset += (PAGE_SIZE * line_count);
0064     }
0065 
0066     return 0;
0067 }