dmanv17.c 3.3 KB

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