nvc0_fence.c 2.8 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 "nouveau_drv.h"
  25. #include "nouveau_dma.h"
  26. #include "nouveau_fence.h"
  27. #include "nv50_display.h"
  28. #include <nvif/push906f.h>
  29. #include <nvhw/class/cl906f.h>
  30. static int
  31. nvc0_fence_emit32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
  32. {
  33. struct nvif_push *push = chan->chan.push;
  34. int ret = PUSH_WAIT(push, 6);
  35. if (ret == 0) {
  36. PUSH_MTHD(push, NV906F, SEMAPHOREA,
  37. NVVAL(NV906F, SEMAPHOREA, OFFSET_UPPER, upper_32_bits(virtual)),
  38. SEMAPHOREB, lower_32_bits(virtual),
  39. SEMAPHOREC, sequence,
  40. SEMAPHORED,
  41. NVDEF(NV906F, SEMAPHORED, OPERATION, RELEASE) |
  42. NVDEF(NV906F, SEMAPHORED, RELEASE_WFI, EN) |
  43. NVDEF(NV906F, SEMAPHORED, RELEASE_SIZE, 16BYTE),
  44. NON_STALL_INTERRUPT, 0);
  45. PUSH_KICK(push);
  46. }
  47. return ret;
  48. }
  49. static int
  50. nvc0_fence_sync32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
  51. {
  52. struct nvif_push *push = chan->chan.push;
  53. int ret = PUSH_WAIT(push, 5);
  54. if (ret == 0) {
  55. PUSH_MTHD(push, NV906F, SEMAPHOREA,
  56. NVVAL(NV906F, SEMAPHOREA, OFFSET_UPPER, upper_32_bits(virtual)),
  57. SEMAPHOREB, lower_32_bits(virtual),
  58. SEMAPHOREC, sequence,
  59. SEMAPHORED,
  60. NVDEF(NV906F, SEMAPHORED, OPERATION, ACQ_GEQ) |
  61. NVDEF(NV906F, SEMAPHORED, ACQUIRE_SWITCH, ENABLED));
  62. PUSH_KICK(push);
  63. }
  64. return ret;
  65. }
  66. static int
  67. nvc0_fence_context_new(struct nouveau_channel *chan)
  68. {
  69. int ret = nv84_fence_context_new(chan);
  70. if (ret == 0) {
  71. struct nv84_fence_chan *fctx = chan->fence;
  72. fctx->base.emit32 = nvc0_fence_emit32;
  73. fctx->base.sync32 = nvc0_fence_sync32;
  74. }
  75. return ret;
  76. }
  77. int
  78. nvc0_fence_create(struct nouveau_drm *drm)
  79. {
  80. int ret = nv84_fence_create(drm);
  81. if (ret == 0) {
  82. struct nv84_fence_priv *priv = drm->fence;
  83. priv->base.context_new = nvc0_fence_context_new;
  84. }
  85. return ret;
  86. }