ctxgm20b.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
  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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. #include "ctxgf100.h"
  23. static void
  24. gm20b_grctx_generate_r406028(struct gf100_gr *gr)
  25. {
  26. struct nvkm_device *device = gr->base.engine.subdev.device;
  27. u32 tpc_per_gpc = 0;
  28. int i;
  29. for (i = 0; i < gr->gpc_nr; i++)
  30. tpc_per_gpc |= gr->tpc_nr[i] << (4 * i);
  31. nvkm_wr32(device, 0x406028, tpc_per_gpc);
  32. nvkm_wr32(device, 0x405870, tpc_per_gpc);
  33. }
  34. static void
  35. gm20b_grctx_generate_main(struct gf100_gr *gr, struct gf100_grctx *info)
  36. {
  37. struct nvkm_device *device = gr->base.engine.subdev.device;
  38. const struct gf100_grctx_func *grctx = gr->func->grctx;
  39. u32 idle_timeout;
  40. int i, tmp;
  41. gf100_gr_mmio(gr, gr->fuc_sw_ctx);
  42. gf100_gr_wait_idle(gr);
  43. idle_timeout = nvkm_mask(device, 0x404154, 0xffffffff, 0x00000000);
  44. grctx->attrib(info);
  45. grctx->unkn(gr);
  46. gm200_grctx_generate_tpcid(gr);
  47. gm20b_grctx_generate_r406028(gr);
  48. gk104_grctx_generate_r418bb8(gr);
  49. for (i = 0; i < 8; i++)
  50. nvkm_wr32(device, 0x4064d0 + (i * 0x04), 0x00000000);
  51. nvkm_wr32(device, 0x405b00, (gr->tpc_total << 8) | gr->gpc_nr);
  52. nvkm_wr32(device, 0x408908, nvkm_rd32(device, 0x410108) | 0x80000000);
  53. for (tmp = 0, i = 0; i < gr->gpc_nr; i++)
  54. tmp |= ((1 << gr->tpc_nr[i]) - 1) << (i * 4);
  55. nvkm_wr32(device, 0x4041c4, tmp);
  56. gm200_grctx_generate_405b60(gr);
  57. gf100_gr_wait_idle(gr);
  58. nvkm_wr32(device, 0x404154, idle_timeout);
  59. gf100_gr_wait_idle(gr);
  60. gf100_gr_mthd(gr, gr->fuc_method);
  61. gf100_gr_wait_idle(gr);
  62. gf100_gr_icmd(gr, gr->fuc_bundle);
  63. grctx->pagepool(info);
  64. grctx->bundle(info);
  65. }
  66. const struct gf100_grctx_func
  67. gm20b_grctx = {
  68. .main = gm20b_grctx_generate_main,
  69. .unkn = gk104_grctx_generate_unkn,
  70. .bundle = gm107_grctx_generate_bundle,
  71. .bundle_size = 0x1800,
  72. .bundle_min_gpm_fifo_depth = 0x182,
  73. .bundle_token_limit = 0x1c0,
  74. .pagepool = gm107_grctx_generate_pagepool,
  75. .pagepool_size = 0x8000,
  76. .attrib = gm107_grctx_generate_attrib,
  77. .attrib_nr_max = 0x600,
  78. .attrib_nr = 0x400,
  79. .alpha_nr_max = 0xc00,
  80. .alpha_nr = 0x800,
  81. };