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/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 }