ctxgf117.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /*
  2. * Copyright 2013 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 <bskeggs@redhat.com>
  23. */
  24. #include "ctxgf100.h"
  25. #include <subdev/fb.h>
  26. #include <subdev/mc.h>
  27. /*******************************************************************************
  28. * PGRAPH context register lists
  29. ******************************************************************************/
  30. static const struct gf100_gr_init
  31. gf117_grctx_init_ds_0[] = {
  32. { 0x405800, 1, 0x04, 0x0f8000bf },
  33. { 0x405830, 1, 0x04, 0x02180324 },
  34. { 0x405834, 1, 0x04, 0x08000000 },
  35. { 0x405838, 1, 0x04, 0x00000000 },
  36. { 0x405854, 1, 0x04, 0x00000000 },
  37. { 0x405870, 4, 0x04, 0x00000001 },
  38. { 0x405a00, 2, 0x04, 0x00000000 },
  39. { 0x405a18, 1, 0x04, 0x00000000 },
  40. {}
  41. };
  42. static const struct gf100_gr_init
  43. gf117_grctx_init_pd_0[] = {
  44. { 0x406020, 1, 0x04, 0x000103c1 },
  45. { 0x406028, 4, 0x04, 0x00000001 },
  46. { 0x4064a8, 1, 0x04, 0x00000000 },
  47. { 0x4064ac, 1, 0x04, 0x00003fff },
  48. { 0x4064b4, 3, 0x04, 0x00000000 },
  49. { 0x4064c0, 1, 0x04, 0x801a0078 },
  50. { 0x4064c4, 1, 0x04, 0x00c9ffff },
  51. { 0x4064d0, 8, 0x04, 0x00000000 },
  52. {}
  53. };
  54. static const struct gf100_gr_pack
  55. gf117_grctx_pack_hub[] = {
  56. { gf100_grctx_init_main_0 },
  57. { gf119_grctx_init_fe_0 },
  58. { gf100_grctx_init_pri_0 },
  59. { gf100_grctx_init_memfmt_0 },
  60. { gf117_grctx_init_ds_0 },
  61. { gf117_grctx_init_pd_0 },
  62. { gf100_grctx_init_rstr2d_0 },
  63. { gf100_grctx_init_scc_0 },
  64. { gf119_grctx_init_be_0 },
  65. {}
  66. };
  67. static const struct gf100_gr_init
  68. gf117_grctx_init_setup_0[] = {
  69. { 0x418800, 1, 0x04, 0x7006860a },
  70. { 0x418808, 3, 0x04, 0x00000000 },
  71. { 0x418828, 1, 0x04, 0x00008442 },
  72. { 0x418830, 1, 0x04, 0x10000001 },
  73. { 0x4188d8, 1, 0x04, 0x00000008 },
  74. { 0x4188e0, 1, 0x04, 0x01000000 },
  75. { 0x4188e8, 5, 0x04, 0x00000000 },
  76. { 0x4188fc, 1, 0x04, 0x20100018 },
  77. {}
  78. };
  79. static const struct gf100_gr_pack
  80. gf117_grctx_pack_gpc[] = {
  81. { gf100_grctx_init_gpc_unk_0 },
  82. { gf119_grctx_init_prop_0 },
  83. { gf119_grctx_init_gpc_unk_1 },
  84. { gf117_grctx_init_setup_0 },
  85. { gf100_grctx_init_zcull_0 },
  86. { gf119_grctx_init_crstr_0 },
  87. { gf108_grctx_init_gpm_0 },
  88. { gf100_grctx_init_gcc_0 },
  89. {}
  90. };
  91. const struct gf100_gr_init
  92. gf117_grctx_init_pe_0[] = {
  93. { 0x419848, 1, 0x04, 0x00000000 },
  94. { 0x419864, 1, 0x04, 0x00000129 },
  95. { 0x419888, 1, 0x04, 0x00000000 },
  96. {}
  97. };
  98. static const struct gf100_gr_init
  99. gf117_grctx_init_tex_0[] = {
  100. { 0x419a00, 1, 0x04, 0x000001f0 },
  101. { 0x419a04, 1, 0x04, 0x00000001 },
  102. { 0x419a08, 1, 0x04, 0x00000023 },
  103. { 0x419a0c, 1, 0x04, 0x00020000 },
  104. { 0x419a10, 1, 0x04, 0x00000000 },
  105. { 0x419a14, 1, 0x04, 0x00000200 },
  106. { 0x419a1c, 1, 0x04, 0x00008000 },
  107. { 0x419a20, 1, 0x04, 0x00000800 },
  108. { 0x419ac4, 1, 0x04, 0x0017f440 },
  109. {}
  110. };
  111. static const struct gf100_gr_init
  112. gf117_grctx_init_mpc_0[] = {
  113. { 0x419c00, 1, 0x04, 0x0000000a },
  114. { 0x419c04, 1, 0x04, 0x00000006 },
  115. { 0x419c08, 1, 0x04, 0x00000002 },
  116. { 0x419c20, 1, 0x04, 0x00000000 },
  117. { 0x419c24, 1, 0x04, 0x00084210 },
  118. { 0x419c28, 1, 0x04, 0x3efbefbe },
  119. {}
  120. };
  121. static const struct gf100_gr_pack
  122. gf117_grctx_pack_tpc[] = {
  123. { gf117_grctx_init_pe_0 },
  124. { gf117_grctx_init_tex_0 },
  125. { gf117_grctx_init_mpc_0 },
  126. { gf104_grctx_init_l1c_0 },
  127. { gf119_grctx_init_sm_0 },
  128. {}
  129. };
  130. static const struct gf100_gr_init
  131. gf117_grctx_init_pes_0[] = {
  132. { 0x41be24, 1, 0x04, 0x00000002 },
  133. {}
  134. };
  135. static const struct gf100_gr_init
  136. gf117_grctx_init_cbm_0[] = {
  137. { 0x41bec0, 1, 0x04, 0x12180000 },
  138. { 0x41bec4, 1, 0x04, 0x00003fff },
  139. { 0x41bee4, 1, 0x04, 0x03240218 },
  140. {}
  141. };
  142. const struct gf100_gr_init
  143. gf117_grctx_init_wwdx_0[] = {
  144. { 0x41bf00, 1, 0x04, 0x0a418820 },
  145. { 0x41bf04, 1, 0x04, 0x062080e6 },
  146. { 0x41bf08, 1, 0x04, 0x020398a4 },
  147. { 0x41bf0c, 1, 0x04, 0x0e629062 },
  148. { 0x41bf10, 1, 0x04, 0x0a418820 },
  149. { 0x41bf14, 1, 0x04, 0x000000e6 },
  150. { 0x41bfd0, 1, 0x04, 0x00900103 },
  151. { 0x41bfe0, 1, 0x04, 0x00400001 },
  152. { 0x41bfe4, 1, 0x04, 0x00000000 },
  153. {}
  154. };
  155. static const struct gf100_gr_pack
  156. gf117_grctx_pack_ppc[] = {
  157. { gf117_grctx_init_pes_0 },
  158. { gf117_grctx_init_cbm_0 },
  159. { gf117_grctx_init_wwdx_0 },
  160. {}
  161. };
  162. /*******************************************************************************
  163. * PGRAPH context implementation
  164. ******************************************************************************/
  165. void
  166. gf117_grctx_generate_attrib(struct gf100_grctx *info)
  167. {
  168. struct gf100_gr *gr = info->gr;
  169. const struct gf100_grctx_func *grctx = gr->func->grctx;
  170. const u32 alpha = grctx->alpha_nr;
  171. const u32 beta = grctx->attrib_nr;
  172. const u32 size = 0x20 * (grctx->attrib_nr_max + grctx->alpha_nr_max);
  173. const u32 access = NV_MEM_ACCESS_RW;
  174. const int s = 12;
  175. const int b = mmio_vram(info, size * gr->tpc_total, (1 << s), access);
  176. const int timeslice_mode = 1;
  177. const int max_batches = 0xffff;
  178. u32 bo = 0;
  179. u32 ao = bo + grctx->attrib_nr_max * gr->tpc_total;
  180. int gpc, ppc;
  181. mmio_refn(info, 0x418810, 0x80000000, s, b);
  182. mmio_refn(info, 0x419848, 0x10000000, s, b);
  183. mmio_wr32(info, 0x405830, (beta << 16) | alpha);
  184. mmio_wr32(info, 0x4064c4, ((alpha / 4) << 16) | max_batches);
  185. for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
  186. for (ppc = 0; ppc < gr->ppc_nr[gpc]; ppc++) {
  187. const u32 a = alpha * gr->ppc_tpc_nr[gpc][ppc];
  188. const u32 b = beta * gr->ppc_tpc_nr[gpc][ppc];
  189. const u32 t = timeslice_mode;
  190. const u32 o = PPC_UNIT(gpc, ppc, 0);
  191. if (!(gr->ppc_mask[gpc] & (1 << ppc)))
  192. continue;
  193. mmio_skip(info, o + 0xc0, (t << 28) | (b << 16) | ++bo);
  194. mmio_wr32(info, o + 0xc0, (t << 28) | (b << 16) | --bo);
  195. bo += grctx->attrib_nr_max * gr->ppc_tpc_nr[gpc][ppc];
  196. mmio_wr32(info, o + 0xe4, (a << 16) | ao);
  197. ao += grctx->alpha_nr_max * gr->ppc_tpc_nr[gpc][ppc];
  198. }
  199. }
  200. }
  201. static void
  202. gf117_grctx_generate_main(struct gf100_gr *gr, struct gf100_grctx *info)
  203. {
  204. struct nvkm_device *device = gr->base.engine.subdev.device;
  205. const struct gf100_grctx_func *grctx = gr->func->grctx;
  206. u32 idle_timeout;
  207. int i;
  208. nvkm_mc_unk260(device, 0);
  209. gf100_gr_mmio(gr, grctx->hub);
  210. gf100_gr_mmio(gr, grctx->gpc);
  211. gf100_gr_mmio(gr, grctx->zcull);
  212. gf100_gr_mmio(gr, grctx->tpc);
  213. gf100_gr_mmio(gr, grctx->ppc);
  214. idle_timeout = nvkm_mask(device, 0x404154, 0xffffffff, 0x00000000);
  215. grctx->bundle(info);
  216. grctx->pagepool(info);
  217. grctx->attrib(info);
  218. grctx->unkn(gr);
  219. gf100_grctx_generate_tpcid(gr);
  220. gf100_grctx_generate_r406028(gr);
  221. gf100_grctx_generate_r4060a8(gr);
  222. gk104_grctx_generate_r418bb8(gr);
  223. gf100_grctx_generate_r406800(gr);
  224. for (i = 0; i < 8; i++)
  225. nvkm_wr32(device, 0x4064d0 + (i * 0x04), 0x00000000);
  226. gf100_gr_icmd(gr, grctx->icmd);
  227. nvkm_wr32(device, 0x404154, idle_timeout);
  228. gf100_gr_mthd(gr, grctx->mthd);
  229. nvkm_mc_unk260(device, 1);
  230. }
  231. const struct gf100_grctx_func
  232. gf117_grctx = {
  233. .main = gf117_grctx_generate_main,
  234. .unkn = gk104_grctx_generate_unkn,
  235. .hub = gf117_grctx_pack_hub,
  236. .gpc = gf117_grctx_pack_gpc,
  237. .zcull = gf100_grctx_pack_zcull,
  238. .tpc = gf117_grctx_pack_tpc,
  239. .ppc = gf117_grctx_pack_ppc,
  240. .icmd = gf119_grctx_pack_icmd,
  241. .mthd = gf119_grctx_pack_mthd,
  242. .bundle = gf100_grctx_generate_bundle,
  243. .bundle_size = 0x1800,
  244. .pagepool = gf100_grctx_generate_pagepool,
  245. .pagepool_size = 0x8000,
  246. .attrib = gf117_grctx_generate_attrib,
  247. .attrib_nr_max = 0x324,
  248. .attrib_nr = 0x218,
  249. .alpha_nr_max = 0x7ff,
  250. .alpha_nr = 0x324,
  251. };