dmanv50.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 "channv50.h"
  25. #include <core/client.h>
  26. #include <core/ramht.h>
  27. #include <nvif/class.h>
  28. #include <nvif/cl506e.h>
  29. #include <nvif/unpack.h>
  30. static int
  31. nv50_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
  32. void *data, u32 size, struct nvkm_object **pobject)
  33. {
  34. struct nvkm_object *parent = oclass->parent;
  35. union {
  36. struct nv50_channel_dma_v0 v0;
  37. } *args = data;
  38. struct nv50_fifo *fifo = nv50_fifo(base);
  39. struct nv50_fifo_chan *chan;
  40. int ret = -ENOSYS;
  41. nvif_ioctl(parent, "create channel dma size %d\n", size);
  42. if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
  43. nvif_ioctl(parent, "create channel dma vers %d vm %llx "
  44. "pushbuf %llx offset %016llx\n",
  45. args->v0.version, args->v0.vm, args->v0.pushbuf,
  46. args->v0.offset);
  47. if (!args->v0.pushbuf)
  48. return -EINVAL;
  49. } else
  50. return ret;
  51. if (!(chan = kzalloc(sizeof(*chan), GFP_KERNEL)))
  52. return -ENOMEM;
  53. *pobject = &chan->base.object;
  54. ret = nv50_fifo_chan_ctor(fifo, args->v0.vm, args->v0.pushbuf,
  55. oclass, chan);
  56. if (ret)
  57. return ret;
  58. args->v0.chid = chan->base.chid;
  59. nvkm_kmap(chan->ramfc);
  60. nvkm_wo32(chan->ramfc, 0x08, lower_32_bits(args->v0.offset));
  61. nvkm_wo32(chan->ramfc, 0x0c, upper_32_bits(args->v0.offset));
  62. nvkm_wo32(chan->ramfc, 0x10, lower_32_bits(args->v0.offset));
  63. nvkm_wo32(chan->ramfc, 0x14, upper_32_bits(args->v0.offset));
  64. nvkm_wo32(chan->ramfc, 0x3c, 0x003f6078);
  65. nvkm_wo32(chan->ramfc, 0x44, 0x01003fff);
  66. nvkm_wo32(chan->ramfc, 0x48, chan->base.push->node->offset >> 4);
  67. nvkm_wo32(chan->ramfc, 0x4c, 0xffffffff);
  68. nvkm_wo32(chan->ramfc, 0x60, 0x7fffffff);
  69. nvkm_wo32(chan->ramfc, 0x78, 0x00000000);
  70. nvkm_wo32(chan->ramfc, 0x7c, 0x30000001);
  71. nvkm_wo32(chan->ramfc, 0x80, ((chan->ramht->bits - 9) << 27) |
  72. (4 << 24) /* SEARCH_FULL */ |
  73. (chan->ramht->gpuobj->node->offset >> 4));
  74. nvkm_done(chan->ramfc);
  75. return 0;
  76. }
  77. const struct nvkm_fifo_chan_oclass
  78. nv50_fifo_dma_oclass = {
  79. .base.oclass = NV50_CHANNEL_DMA,
  80. .base.minver = 0,
  81. .base.maxver = 0,
  82. .ctor = nv50_fifo_dma_new,
  83. };