nouveau_bo90b5.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright 2020 Red Hat Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #include "nouveau_bo.h"
  23. #include "nouveau_dma.h"
  24. #include "nouveau_mem.h"
  25. #include <nvif/push906f.h>
  26. /*XXX: Fixup class to be compatible with NVIDIA's, which will allow sharing
  27. * code with KeplerDmaCopyA.
  28. */
  29. int
  30. nvc0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
  31. struct ttm_resource *old_reg, struct ttm_resource *new_reg)
  32. {
  33. struct nouveau_mem *mem = nouveau_mem(old_reg);
  34. struct nvif_push *push = chan->chan.push;
  35. u64 src_offset = mem->vma[0].addr;
  36. u64 dst_offset = mem->vma[1].addr;
  37. u32 page_count = new_reg->num_pages;
  38. int ret;
  39. page_count = new_reg->num_pages;
  40. while (page_count) {
  41. int line_count = (page_count > 8191) ? 8191 : page_count;
  42. ret = PUSH_WAIT(push, 10);
  43. if (ret)
  44. return ret;
  45. PUSH_NVSQ(push, NV90B5, 0x030c, upper_32_bits(src_offset),
  46. 0x0310, lower_32_bits(src_offset),
  47. 0x0314, upper_32_bits(dst_offset),
  48. 0x0318, lower_32_bits(dst_offset),
  49. 0x031c, PAGE_SIZE,
  50. 0x0320, PAGE_SIZE,
  51. 0x0324, PAGE_SIZE,
  52. 0x0328, line_count);
  53. PUSH_NVIM(push, NV90B5, 0x0300, 0x0110);
  54. page_count -= line_count;
  55. src_offset += (PAGE_SIZE * line_count);
  56. dst_offset += (PAGE_SIZE * line_count);
  57. }
  58. return 0;
  59. }