gpfifonv50.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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/cl506f.h>
  29. #include <nvif/unpack.h>
  30. static int
  31. nv50_fifo_gpfifo_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_gpfifo_v0 v0;
  37. } *args = data;
  38. struct nv50_fifo *fifo = nv50_fifo(base);
  39. struct nv50_fifo_chan *chan;
  40. u64 ioffset, ilength;
  41. int ret = -ENOSYS;
  42. nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
  43. if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
  44. nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
  45. "pushbuf %llx ioffset %016llx "
  46. "ilength %08x\n",
  47. args->v0.version, args->v0.vm, args->v0.pushbuf,
  48. args->v0.ioffset, args->v0.ilength);
  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 = nv50_fifo_chan_ctor(fifo, args->v0.vm, args->v0.pushbuf,
  57. oclass, chan);
  58. if (ret)
  59. return ret;
  60. args->v0.chid = chan->base.chid;
  61. ioffset = args->v0.ioffset;
  62. ilength = order_base_2(args->v0.ilength / 8);
  63. nvkm_kmap(chan->ramfc);
  64. nvkm_wo32(chan->ramfc, 0x3c, 0x403f6078);
  65. nvkm_wo32(chan->ramfc, 0x44, 0x01003fff);
  66. nvkm_wo32(chan->ramfc, 0x48, chan->base.push->node->offset >> 4);
  67. nvkm_wo32(chan->ramfc, 0x50, lower_32_bits(ioffset));
  68. nvkm_wo32(chan->ramfc, 0x54, upper_32_bits(ioffset) | (ilength << 16));
  69. nvkm_wo32(chan->ramfc, 0x60, 0x7fffffff);
  70. nvkm_wo32(chan->ramfc, 0x78, 0x00000000);
  71. nvkm_wo32(chan->ramfc, 0x7c, 0x30000001);
  72. nvkm_wo32(chan->ramfc, 0x80, ((chan->ramht->bits - 9) << 27) |
  73. (4 << 24) /* SEARCH_FULL */ |
  74. (chan->ramht->gpuobj->node->offset >> 4));
  75. nvkm_done(chan->ramfc);
  76. return 0;
  77. }
  78. const struct nvkm_fifo_chan_oclass
  79. nv50_fifo_gpfifo_oclass = {
  80. .base.oclass = NV50_CHANNEL_GPFIFO,
  81. .base.minver = 0,
  82. .base.maxver = 0,
  83. .ctor = nv50_fifo_gpfifo_new,
  84. };