nouveau_bo9039.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright 2007 Dave Airlied
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice (including the next
  13. * paragraph) shall be included in all copies or substantial portions of the
  14. * Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. */
  24. /*
  25. * Authors: Dave Airlied <airlied@linux.ie>
  26. * Ben Skeggs <darktama@iinet.net.au>
  27. * Jeremy Kolb <jkolb@brandeis.edu>
  28. */
  29. #include "nouveau_bo.h"
  30. #include "nouveau_dma.h"
  31. #include "nouveau_mem.h"
  32. #include <nvif/push906f.h>
  33. #include <nvhw/class/cl9039.h>
  34. int
  35. nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
  36. struct ttm_resource *old_reg, struct ttm_resource *new_reg)
  37. {
  38. struct nvif_push *push = chan->chan.push;
  39. struct nouveau_mem *mem = nouveau_mem(old_reg);
  40. u64 src_offset = mem->vma[0].addr;
  41. u64 dst_offset = mem->vma[1].addr;
  42. u32 page_count = new_reg->num_pages;
  43. int ret;
  44. page_count = new_reg->num_pages;
  45. while (page_count) {
  46. int line_count = (page_count > 2047) ? 2047 : page_count;
  47. ret = PUSH_WAIT(push, 12);
  48. if (ret)
  49. return ret;
  50. PUSH_MTHD(push, NV9039, OFFSET_OUT_UPPER,
  51. NVVAL(NV9039, OFFSET_OUT_UPPER, VALUE, upper_32_bits(dst_offset)),
  52. OFFSET_OUT, lower_32_bits(dst_offset));
  53. PUSH_MTHD(push, NV9039, OFFSET_IN_UPPER,
  54. NVVAL(NV9039, OFFSET_IN_UPPER, VALUE, upper_32_bits(src_offset)),
  55. OFFSET_IN, lower_32_bits(src_offset),
  56. PITCH_IN, PAGE_SIZE,
  57. PITCH_OUT, PAGE_SIZE,
  58. LINE_LENGTH_IN, PAGE_SIZE,
  59. LINE_COUNT, line_count);
  60. PUSH_MTHD(push, NV9039, LAUNCH_DMA,
  61. NVDEF(NV9039, LAUNCH_DMA, SRC_INLINE, FALSE) |
  62. NVDEF(NV9039, LAUNCH_DMA, SRC_MEMORY_LAYOUT, PITCH) |
  63. NVDEF(NV9039, LAUNCH_DMA, DST_MEMORY_LAYOUT, PITCH) |
  64. NVDEF(NV9039, LAUNCH_DMA, COMPLETION_TYPE, FLUSH_DISABLE) |
  65. NVDEF(NV9039, LAUNCH_DMA, INTERRUPT_TYPE, NONE) |
  66. NVDEF(NV9039, LAUNCH_DMA, SEMAPHORE_STRUCT_SIZE, ONE_WORD));
  67. page_count -= line_count;
  68. src_offset += (PAGE_SIZE * line_count);
  69. dst_offset += (PAGE_SIZE * line_count);
  70. }
  71. return 0;
  72. }
  73. int
  74. nvc0_bo_move_init(struct nouveau_channel *chan, u32 handle)
  75. {
  76. struct nvif_push *push = chan->chan.push;
  77. int ret;
  78. ret = PUSH_WAIT(push, 2);
  79. if (ret)
  80. return ret;
  81. PUSH_MTHD(push, NV9039, SET_OBJECT, handle);
  82. return 0;
  83. }