dmanv10.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright 2012 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. * Authors: Ben Skeggs
  23. */
  24. #include "channv04.h"
  25. #include "regsnv04.h"
  26. #include <core/client.h>
  27. #include <core/gpuobj.h>
  28. #include <subdev/instmem.h>
  29. #include <nvif/class.h>
  30. #include <nvif/unpack.h>
  31. static int
  32. nv10_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
  33. void *data, u32 size, struct nvkm_object **pobject)
  34. {
  35. struct nvkm_object *parent = oclass->parent;
  36. union {
  37. struct nv03_channel_dma_v0 v0;
  38. } *args = data;
  39. struct nv04_fifo *fifo = nv04_fifo(base);
  40. struct nv04_fifo_chan *chan = NULL;
  41. struct nvkm_device *device = fifo->base.engine.subdev.device;
  42. struct nvkm_instmem *imem = device->imem;
  43. int ret;
  44. nvif_ioctl(parent, "create channel dma size %d\n", size);
  45. if (nvif_unpack(args->v0, 0, 0, false)) {
  46. nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx "
  47. "offset %08x\n", args->v0.version,
  48. args->v0.pushbuf, args->v0.offset);
  49. if (!args->v0.pushbuf)
  50. return -EINVAL;
  51. } else
  52. return ret;
  53. if (!(chan = kzalloc(sizeof(*chan), GFP_KERNEL)))
  54. return -ENOMEM;
  55. *pobject = &chan->base.object;
  56. ret = nvkm_fifo_chan_ctor(&nv04_fifo_dma_func, &fifo->base,
  57. 0x1000, 0x1000, false, 0, args->v0.pushbuf,
  58. (1ULL << NVKM_ENGINE_DMAOBJ) |
  59. (1ULL << NVKM_ENGINE_GR) |
  60. (1ULL << NVKM_ENGINE_SW),
  61. 0, 0x800000, 0x10000, oclass, &chan->base);
  62. chan->fifo = fifo;
  63. if (ret)
  64. return ret;
  65. args->v0.chid = chan->base.chid;
  66. chan->ramfc = chan->base.chid * 32;
  67. nvkm_kmap(imem->ramfc);
  68. nvkm_wo32(imem->ramfc, chan->ramfc + 0x00, args->v0.offset);
  69. nvkm_wo32(imem->ramfc, chan->ramfc + 0x04, args->v0.offset);
  70. nvkm_wo32(imem->ramfc, chan->ramfc + 0x0c, chan->base.push->addr >> 4);
  71. nvkm_wo32(imem->ramfc, chan->ramfc + 0x14,
  72. NV_PFIFO_CACHE1_DMA_FETCH_TRIG_128_BYTES |
  73. NV_PFIFO_CACHE1_DMA_FETCH_SIZE_128_BYTES |
  74. #ifdef __BIG_ENDIAN
  75. NV_PFIFO_CACHE1_BIG_ENDIAN |
  76. #endif
  77. NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_8);
  78. nvkm_done(imem->ramfc);
  79. return 0;
  80. }
  81. const struct nvkm_fifo_chan_oclass
  82. nv10_fifo_dma_oclass = {
  83. .base.oclass = NV10_CHANNEL_DMA,
  84. .base.minver = 0,
  85. .base.maxver = 0,
  86. .ctor = nv10_fifo_dma_new,
  87. };