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/cla0b5.h>
0036 
0037 int
0038 nve0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
0039           struct ttm_resource *old_reg, struct ttm_resource *new_reg)
0040 {
0041     struct nouveau_mem *mem = nouveau_mem(old_reg);
0042     struct nvif_push *push = chan->chan.push;
0043     int ret;
0044 
0045     ret = PUSH_WAIT(push, 10);
0046     if (ret)
0047         return ret;
0048 
0049     PUSH_MTHD(push, NVA0B5, OFFSET_IN_UPPER,
0050           NVVAL(NVA0B5, OFFSET_IN_UPPER, UPPER, upper_32_bits(mem->vma[0].addr)),
0051 
0052                 OFFSET_IN_LOWER, lower_32_bits(mem->vma[0].addr),
0053 
0054                 OFFSET_OUT_UPPER,
0055           NVVAL(NVA0B5, OFFSET_OUT_UPPER, UPPER, upper_32_bits(mem->vma[1].addr)),
0056 
0057                 OFFSET_OUT_LOWER, lower_32_bits(mem->vma[1].addr),
0058                 PITCH_IN, PAGE_SIZE,
0059                 PITCH_OUT, PAGE_SIZE,
0060                 LINE_LENGTH_IN, PAGE_SIZE,
0061                 LINE_COUNT, new_reg->num_pages);
0062 
0063     PUSH_IMMD(push, NVA0B5, LAUNCH_DMA,
0064           NVDEF(NVA0B5, LAUNCH_DMA, DATA_TRANSFER_TYPE, NON_PIPELINED) |
0065           NVDEF(NVA0B5, LAUNCH_DMA, FLUSH_ENABLE, TRUE) |
0066           NVDEF(NVA0B5, LAUNCH_DMA, SEMAPHORE_TYPE, NONE) |
0067           NVDEF(NVA0B5, LAUNCH_DMA, INTERRUPT_TYPE, NONE) |
0068           NVDEF(NVA0B5, LAUNCH_DMA, SRC_MEMORY_LAYOUT, PITCH) |
0069           NVDEF(NVA0B5, LAUNCH_DMA, DST_MEMORY_LAYOUT, PITCH) |
0070           NVDEF(NVA0B5, LAUNCH_DMA, MULTI_LINE_ENABLE, TRUE) |
0071           NVDEF(NVA0B5, LAUNCH_DMA, REMAP_ENABLE, FALSE) |
0072           NVDEF(NVA0B5, LAUNCH_DMA, BYPASS_L2, USE_PTE_SETTING) |
0073           NVDEF(NVA0B5, LAUNCH_DMA, SRC_TYPE, VIRTUAL) |
0074           NVDEF(NVA0B5, LAUNCH_DMA, DST_TYPE, VIRTUAL));
0075     return 0;
0076 }
0077 
0078 int
0079 nve0_bo_move_init(struct nouveau_channel *chan, u32 handle)
0080 {
0081     struct nvif_push *push = chan->chan.push;
0082     int ret;
0083 
0084     ret = PUSH_WAIT(push, 2);
0085     if (ret)
0086         return ret;
0087 
0088     PUSH_NVSQ(push, NVA0B5, 0x0000, handle & 0x0000ffff);
0089     return 0;
0090 }