gk104.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 "priv.h"
  25. #include <core/enum.h>
  26. #include <nvif/class.h>
  27. static const struct nvkm_enum
  28. gk104_ce_launcherr_report[] = {
  29. { 0x0, "NO_ERR" },
  30. { 0x1, "2D_LAYER_EXCEEDS_DEPTH" },
  31. { 0x2, "INVALID_ARGUMENT" },
  32. { 0x3, "MEM2MEM_RECT_OUT_OF_BOUNDS" },
  33. { 0x4, "SRC_LINE_EXCEEDS_PITCH" },
  34. { 0x5, "SRC_LINE_EXCEEDS_NEG_PITCH" },
  35. { 0x6, "DST_LINE_EXCEEDS_PITCH" },
  36. { 0x7, "DST_LINE_EXCEEDS_NEG_PITCH" },
  37. { 0x8, "BAD_SRC_PIXEL_COMP_REF" },
  38. { 0x9, "INVALID_VALUE" },
  39. { 0xa, "UNUSED_FIELD" },
  40. { 0xb, "INVALID_OPERATION" },
  41. {}
  42. };
  43. static void
  44. gk104_ce_intr_launcherr(struct nvkm_engine *ce, const u32 base)
  45. {
  46. struct nvkm_subdev *subdev = &ce->subdev;
  47. struct nvkm_device *device = subdev->device;
  48. u32 stat = nvkm_rd32(device, 0x104f14 + base);
  49. const struct nvkm_enum *en =
  50. nvkm_enum_find(gk104_ce_launcherr_report, stat & 0x0000000f);
  51. nvkm_warn(subdev, "LAUNCHERR %08x [%s]\n", stat, en ? en->name : "");
  52. nvkm_wr32(device, 0x104f14 + base, 0x00000000);
  53. }
  54. void
  55. gk104_ce_intr(struct nvkm_engine *ce)
  56. {
  57. const u32 base = (ce->subdev.index - NVKM_ENGINE_CE0) * 0x1000;
  58. struct nvkm_subdev *subdev = &ce->subdev;
  59. struct nvkm_device *device = subdev->device;
  60. u32 mask = nvkm_rd32(device, 0x104904 + base);
  61. u32 intr = nvkm_rd32(device, 0x104908 + base) & mask;
  62. if (intr & 0x00000001) {
  63. nvkm_warn(subdev, "BLOCKPIPE\n");
  64. nvkm_wr32(device, 0x104908 + base, 0x00000001);
  65. intr &= ~0x00000001;
  66. }
  67. if (intr & 0x00000002) {
  68. nvkm_warn(subdev, "NONBLOCKPIPE\n");
  69. nvkm_wr32(device, 0x104908 + base, 0x00000002);
  70. intr &= ~0x00000002;
  71. }
  72. if (intr & 0x00000004) {
  73. gk104_ce_intr_launcherr(ce, base);
  74. nvkm_wr32(device, 0x104908 + base, 0x00000004);
  75. intr &= ~0x00000004;
  76. }
  77. if (intr) {
  78. nvkm_warn(subdev, "intr %08x\n", intr);
  79. nvkm_wr32(device, 0x104908 + base, intr);
  80. }
  81. }
  82. static const struct nvkm_engine_func
  83. gk104_ce = {
  84. .intr = gk104_ce_intr,
  85. .sclass = {
  86. { -1, -1, KEPLER_DMA_COPY_A },
  87. {}
  88. }
  89. };
  90. int
  91. gk104_ce_new(struct nvkm_device *device, int index,
  92. struct nvkm_engine **pengine)
  93. {
  94. return nvkm_engine_new_(&gk104_ce, device, index, true, pengine);
  95. }