intel_step.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. // SPDX-License-Identifier: MIT
  2. /*
  3. * Copyright © 2020,2021 Intel Corporation
  4. */
  5. #include "i915_drv.h"
  6. #include "intel_step.h"
  7. /*
  8. * Some platforms have unusual ways of mapping PCI revision ID to GT/display
  9. * steppings. E.g., in some cases a higher PCI revision may translate to a
  10. * lower stepping of the GT and/or display IP. This file provides lookup
  11. * tables to map the PCI revision into a standard set of stepping values that
  12. * can be compared numerically.
  13. *
  14. * Also note that some revisions/steppings may have been set aside as
  15. * placeholders but never materialized in real hardware; in those cases there
  16. * may be jumps in the revision IDs or stepping values in the tables below.
  17. */
  18. /*
  19. * Some platforms always have the same stepping value for GT and display;
  20. * use a macro to define these to make it easier to identify the platforms
  21. * where the two steppings can deviate.
  22. */
  23. #define COMMON_STEP(x) .graphics_step = STEP_##x, .media_step = STEP_##x
  24. static const struct intel_step_info skl_revids[] = {
  25. [0x6] = { COMMON_STEP(G0) },
  26. [0x7] = { COMMON_STEP(H0) },
  27. [0x9] = { COMMON_STEP(J0) },
  28. [0xA] = { COMMON_STEP(I1) },
  29. };
  30. static const struct intel_step_info kbl_revids[] = {
  31. [1] = { COMMON_STEP(B0) },
  32. [2] = { COMMON_STEP(C0) },
  33. [3] = { COMMON_STEP(D0) },
  34. [4] = { COMMON_STEP(F0) },
  35. [5] = { COMMON_STEP(C0) },
  36. [6] = { COMMON_STEP(D1) },
  37. [7] = { COMMON_STEP(G0) },
  38. };
  39. static const struct intel_step_info bxt_revids[] = {
  40. [0xA] = { COMMON_STEP(C0) },
  41. [0xB] = { COMMON_STEP(C0) },
  42. [0xC] = { COMMON_STEP(D0) },
  43. [0xD] = { COMMON_STEP(E0) },
  44. };
  45. static const struct intel_step_info glk_revids[] = {
  46. [3] = { COMMON_STEP(B0) },
  47. };
  48. static const struct intel_step_info icl_revids[] = {
  49. [7] = { COMMON_STEP(D0) },
  50. };
  51. static const struct intel_step_info jsl_ehl_revids[] = {
  52. [0] = { COMMON_STEP(A0) },
  53. [1] = { COMMON_STEP(B0) },
  54. };
  55. static const struct intel_step_info tgl_uy_revids[] = {
  56. [0] = { COMMON_STEP(A0) },
  57. [1] = { COMMON_STEP(B0) },
  58. [2] = { COMMON_STEP(B1) },
  59. [3] = { COMMON_STEP(C0) },
  60. };
  61. /* Same GT stepping between tgl_uy_revids and tgl_revids don't mean the same HW */
  62. static const struct intel_step_info tgl_revids[] = {
  63. [0] = { COMMON_STEP(A0) },
  64. [1] = { COMMON_STEP(B0) },
  65. };
  66. static const struct intel_step_info rkl_revids[] = {
  67. [0] = { COMMON_STEP(A0) },
  68. [1] = { COMMON_STEP(B0) },
  69. [4] = { COMMON_STEP(C0) },
  70. };
  71. static const struct intel_step_info dg1_revids[] = {
  72. [0] = { COMMON_STEP(A0) },
  73. [1] = { COMMON_STEP(B0) },
  74. };
  75. static const struct intel_step_info adls_revids[] = {
  76. [0x0] = { COMMON_STEP(A0) },
  77. [0x1] = { COMMON_STEP(A0) },
  78. [0x4] = { COMMON_STEP(B0) },
  79. [0x8] = { COMMON_STEP(C0) },
  80. [0xC] = { COMMON_STEP(D0) },
  81. };
  82. static const struct intel_step_info adlp_revids[] = {
  83. [0x0] = { COMMON_STEP(A0) },
  84. [0x4] = { COMMON_STEP(B0) },
  85. [0x8] = { COMMON_STEP(C0) },
  86. [0xC] = { COMMON_STEP(C0) },
  87. };
  88. static const struct intel_step_info dg2_g10_revid_step_tbl[] = {
  89. [0x0] = { COMMON_STEP(A0) },
  90. [0x1] = { COMMON_STEP(A1) },
  91. [0x4] = { COMMON_STEP(B0) },
  92. [0x8] = { COMMON_STEP(C0) },
  93. };
  94. static const struct intel_step_info dg2_g11_revid_step_tbl[] = {
  95. [0x0] = { COMMON_STEP(A0) },
  96. [0x4] = { COMMON_STEP(B0) },
  97. [0x5] = { COMMON_STEP(B1) },
  98. };
  99. static const struct intel_step_info dg2_g12_revid_step_tbl[] = {
  100. [0x0] = { COMMON_STEP(A0) },
  101. [0x1] = { COMMON_STEP(A1) },
  102. };
  103. static const struct intel_step_info adls_rpls_revids[] = {
  104. [0x4] = { COMMON_STEP(D0) },
  105. [0xC] = { COMMON_STEP(D0) },
  106. };
  107. static const struct intel_step_info adlp_rplp_revids[] = {
  108. [0x4] = { COMMON_STEP(C0) },
  109. };
  110. static const struct intel_step_info adlp_n_revids[] = {
  111. [0x0] = { COMMON_STEP(A0) },
  112. };
  113. static u8 gmd_to_intel_step(struct drm_i915_private *i915,
  114. struct intel_ip_version *gmd)
  115. {
  116. u8 step = gmd->step + STEP_A0;
  117. if (step >= STEP_FUTURE) {
  118. drm_dbg(&i915->drm, "Using future steppings\n");
  119. return STEP_FUTURE;
  120. }
  121. return step;
  122. }
  123. void intel_step_init(struct drm_i915_private *i915)
  124. {
  125. const struct intel_step_info *revids = NULL;
  126. int size = 0;
  127. int revid = INTEL_REVID(i915);
  128. struct intel_step_info step = {};
  129. if (HAS_GMD_ID(i915)) {
  130. step.graphics_step = gmd_to_intel_step(i915,
  131. &RUNTIME_INFO(i915)->graphics.ip);
  132. step.media_step = gmd_to_intel_step(i915,
  133. &RUNTIME_INFO(i915)->media.ip);
  134. RUNTIME_INFO(i915)->step = step;
  135. return;
  136. }
  137. if (IS_DG2_G10(i915)) {
  138. revids = dg2_g10_revid_step_tbl;
  139. size = ARRAY_SIZE(dg2_g10_revid_step_tbl);
  140. } else if (IS_DG2_G11(i915)) {
  141. revids = dg2_g11_revid_step_tbl;
  142. size = ARRAY_SIZE(dg2_g11_revid_step_tbl);
  143. } else if (IS_DG2_G12(i915)) {
  144. revids = dg2_g12_revid_step_tbl;
  145. size = ARRAY_SIZE(dg2_g12_revid_step_tbl);
  146. } else if (IS_ALDERLAKE_P_N(i915)) {
  147. revids = adlp_n_revids;
  148. size = ARRAY_SIZE(adlp_n_revids);
  149. } else if (IS_RAPTORLAKE_P(i915)) {
  150. revids = adlp_rplp_revids;
  151. size = ARRAY_SIZE(adlp_rplp_revids);
  152. } else if (IS_ALDERLAKE_P(i915)) {
  153. revids = adlp_revids;
  154. size = ARRAY_SIZE(adlp_revids);
  155. } else if (IS_RAPTORLAKE_S(i915)) {
  156. revids = adls_rpls_revids;
  157. size = ARRAY_SIZE(adls_rpls_revids);
  158. } else if (IS_ALDERLAKE_S(i915)) {
  159. revids = adls_revids;
  160. size = ARRAY_SIZE(adls_revids);
  161. } else if (IS_DG1(i915)) {
  162. revids = dg1_revids;
  163. size = ARRAY_SIZE(dg1_revids);
  164. } else if (IS_ROCKETLAKE(i915)) {
  165. revids = rkl_revids;
  166. size = ARRAY_SIZE(rkl_revids);
  167. } else if (IS_TIGERLAKE_UY(i915)) {
  168. revids = tgl_uy_revids;
  169. size = ARRAY_SIZE(tgl_uy_revids);
  170. } else if (IS_TIGERLAKE(i915)) {
  171. revids = tgl_revids;
  172. size = ARRAY_SIZE(tgl_revids);
  173. } else if (IS_JASPERLAKE(i915) || IS_ELKHARTLAKE(i915)) {
  174. revids = jsl_ehl_revids;
  175. size = ARRAY_SIZE(jsl_ehl_revids);
  176. } else if (IS_ICELAKE(i915)) {
  177. revids = icl_revids;
  178. size = ARRAY_SIZE(icl_revids);
  179. } else if (IS_GEMINILAKE(i915)) {
  180. revids = glk_revids;
  181. size = ARRAY_SIZE(glk_revids);
  182. } else if (IS_BROXTON(i915)) {
  183. revids = bxt_revids;
  184. size = ARRAY_SIZE(bxt_revids);
  185. } else if (IS_KABYLAKE(i915)) {
  186. revids = kbl_revids;
  187. size = ARRAY_SIZE(kbl_revids);
  188. } else if (IS_SKYLAKE(i915)) {
  189. revids = skl_revids;
  190. size = ARRAY_SIZE(skl_revids);
  191. }
  192. /* Not using the stepping scheme for the platform yet. */
  193. if (!revids)
  194. return;
  195. if (revid < size && revids[revid].graphics_step != STEP_NONE) {
  196. step = revids[revid];
  197. } else {
  198. drm_warn(&i915->drm, "Unknown revid 0x%02x\n", revid);
  199. /*
  200. * If we hit a gap in the revid array, use the information for
  201. * the next revid.
  202. *
  203. * This may be wrong in all sorts of ways, especially if the
  204. * steppings in the array are not monotonically increasing, but
  205. * it's better than defaulting to 0.
  206. */
  207. while (revid < size && revids[revid].graphics_step == STEP_NONE)
  208. revid++;
  209. if (revid < size) {
  210. drm_dbg(&i915->drm, "Using steppings for revid 0x%02x\n",
  211. revid);
  212. step = revids[revid];
  213. } else {
  214. drm_dbg(&i915->drm, "Using future steppings\n");
  215. step.graphics_step = STEP_FUTURE;
  216. }
  217. }
  218. if (drm_WARN_ON(&i915->drm, step.graphics_step == STEP_NONE))
  219. return;
  220. RUNTIME_INFO(i915)->step = step;
  221. }
  222. #define STEP_NAME_CASE(name) \
  223. case STEP_##name: \
  224. return #name;
  225. const char *intel_step_name(enum intel_step step)
  226. {
  227. switch (step) {
  228. STEP_NAME_LIST(STEP_NAME_CASE);
  229. default:
  230. return "**";
  231. }
  232. }