Back to home page

OSCL-LXR

 
 

    


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