intel_device_info.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. /*
  2. * Copyright © 2016 Intel Corporation
  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 (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. * IN THE SOFTWARE.
  22. *
  23. */
  24. #include "i915_drv.h"
  25. void intel_device_info_dump(struct drm_i915_private *dev_priv)
  26. {
  27. const struct intel_device_info *info = &dev_priv->info;
  28. #define PRINT_S(name) "%s"
  29. #define SEP_EMPTY
  30. #define PRINT_FLAG(name) info->name ? #name "," : ""
  31. #define SEP_COMMA ,
  32. DRM_DEBUG_DRIVER("i915 device info: gen=%i, pciid=0x%04x rev=0x%02x flags="
  33. DEV_INFO_FOR_EACH_FLAG(PRINT_S, SEP_EMPTY),
  34. info->gen,
  35. dev_priv->drm.pdev->device,
  36. dev_priv->drm.pdev->revision,
  37. DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_COMMA));
  38. #undef PRINT_S
  39. #undef SEP_EMPTY
  40. #undef PRINT_FLAG
  41. #undef SEP_COMMA
  42. }
  43. static void cherryview_sseu_info_init(struct drm_i915_private *dev_priv)
  44. {
  45. struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu;
  46. u32 fuse, eu_dis;
  47. fuse = I915_READ(CHV_FUSE_GT);
  48. sseu->slice_mask = BIT(0);
  49. if (!(fuse & CHV_FGT_DISABLE_SS0)) {
  50. sseu->subslice_mask |= BIT(0);
  51. eu_dis = fuse & (CHV_FGT_EU_DIS_SS0_R0_MASK |
  52. CHV_FGT_EU_DIS_SS0_R1_MASK);
  53. sseu->eu_total += 8 - hweight32(eu_dis);
  54. }
  55. if (!(fuse & CHV_FGT_DISABLE_SS1)) {
  56. sseu->subslice_mask |= BIT(1);
  57. eu_dis = fuse & (CHV_FGT_EU_DIS_SS1_R0_MASK |
  58. CHV_FGT_EU_DIS_SS1_R1_MASK);
  59. sseu->eu_total += 8 - hweight32(eu_dis);
  60. }
  61. /*
  62. * CHV expected to always have a uniform distribution of EU
  63. * across subslices.
  64. */
  65. sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
  66. sseu->eu_total / sseu_subslice_total(sseu) :
  67. 0;
  68. /*
  69. * CHV supports subslice power gating on devices with more than
  70. * one subslice, and supports EU power gating on devices with
  71. * more than one EU pair per subslice.
  72. */
  73. sseu->has_slice_pg = 0;
  74. sseu->has_subslice_pg = sseu_subslice_total(sseu) > 1;
  75. sseu->has_eu_pg = (sseu->eu_per_subslice > 2);
  76. }
  77. static void gen9_sseu_info_init(struct drm_i915_private *dev_priv)
  78. {
  79. struct intel_device_info *info = mkwrite_device_info(dev_priv);
  80. struct sseu_dev_info *sseu = &info->sseu;
  81. int s_max = 3, ss_max = 4, eu_max = 8;
  82. int s, ss;
  83. u32 fuse2, eu_disable;
  84. u8 eu_mask = 0xff;
  85. fuse2 = I915_READ(GEN8_FUSE2);
  86. sseu->slice_mask = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
  87. /*
  88. * The subslice disable field is global, i.e. it applies
  89. * to each of the enabled slices.
  90. */
  91. sseu->subslice_mask = (1 << ss_max) - 1;
  92. sseu->subslice_mask &= ~((fuse2 & GEN9_F2_SS_DIS_MASK) >>
  93. GEN9_F2_SS_DIS_SHIFT);
  94. /*
  95. * Iterate through enabled slices and subslices to
  96. * count the total enabled EU.
  97. */
  98. for (s = 0; s < s_max; s++) {
  99. if (!(sseu->slice_mask & BIT(s)))
  100. /* skip disabled slice */
  101. continue;
  102. eu_disable = I915_READ(GEN9_EU_DISABLE(s));
  103. for (ss = 0; ss < ss_max; ss++) {
  104. int eu_per_ss;
  105. if (!(sseu->subslice_mask & BIT(ss)))
  106. /* skip disabled subslice */
  107. continue;
  108. eu_per_ss = eu_max - hweight8((eu_disable >> (ss*8)) &
  109. eu_mask);
  110. /*
  111. * Record which subslice(s) has(have) 7 EUs. we
  112. * can tune the hash used to spread work among
  113. * subslices if they are unbalanced.
  114. */
  115. if (eu_per_ss == 7)
  116. sseu->subslice_7eu[s] |= BIT(ss);
  117. sseu->eu_total += eu_per_ss;
  118. }
  119. }
  120. /*
  121. * SKL is expected to always have a uniform distribution
  122. * of EU across subslices with the exception that any one
  123. * EU in any one subslice may be fused off for die
  124. * recovery. BXT is expected to be perfectly uniform in EU
  125. * distribution.
  126. */
  127. sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
  128. DIV_ROUND_UP(sseu->eu_total,
  129. sseu_subslice_total(sseu)) : 0;
  130. /*
  131. * SKL supports slice power gating on devices with more than
  132. * one slice, and supports EU power gating on devices with
  133. * more than one EU pair per subslice. BXT supports subslice
  134. * power gating on devices with more than one subslice, and
  135. * supports EU power gating on devices with more than one EU
  136. * pair per subslice.
  137. */
  138. sseu->has_slice_pg =
  139. (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) &&
  140. hweight8(sseu->slice_mask) > 1;
  141. sseu->has_subslice_pg =
  142. IS_BROXTON(dev_priv) && sseu_subslice_total(sseu) > 1;
  143. sseu->has_eu_pg = sseu->eu_per_subslice > 2;
  144. if (IS_BROXTON(dev_priv)) {
  145. #define IS_SS_DISABLED(ss) (!(sseu->subslice_mask & BIT(ss)))
  146. /*
  147. * There is a HW issue in 2x6 fused down parts that requires
  148. * Pooled EU to be enabled as a WA. The pool configuration
  149. * changes depending upon which subslice is fused down. This
  150. * doesn't affect if the device has all 3 subslices enabled.
  151. */
  152. /* WaEnablePooledEuFor2x6:bxt */
  153. info->has_pooled_eu = ((hweight8(sseu->subslice_mask) == 3) ||
  154. (hweight8(sseu->subslice_mask) == 2 &&
  155. INTEL_REVID(dev_priv) < BXT_REVID_C0));
  156. sseu->min_eu_in_pool = 0;
  157. if (info->has_pooled_eu) {
  158. if (IS_SS_DISABLED(2) || IS_SS_DISABLED(0))
  159. sseu->min_eu_in_pool = 3;
  160. else if (IS_SS_DISABLED(1))
  161. sseu->min_eu_in_pool = 6;
  162. else
  163. sseu->min_eu_in_pool = 9;
  164. }
  165. #undef IS_SS_DISABLED
  166. }
  167. }
  168. static void broadwell_sseu_info_init(struct drm_i915_private *dev_priv)
  169. {
  170. struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu;
  171. const int s_max = 3, ss_max = 3, eu_max = 8;
  172. int s, ss;
  173. u32 fuse2, eu_disable[3]; /* s_max */
  174. fuse2 = I915_READ(GEN8_FUSE2);
  175. sseu->slice_mask = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
  176. /*
  177. * The subslice disable field is global, i.e. it applies
  178. * to each of the enabled slices.
  179. */
  180. sseu->subslice_mask = BIT(ss_max) - 1;
  181. sseu->subslice_mask &= ~((fuse2 & GEN8_F2_SS_DIS_MASK) >>
  182. GEN8_F2_SS_DIS_SHIFT);
  183. eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) & GEN8_EU_DIS0_S0_MASK;
  184. eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >> GEN8_EU_DIS0_S1_SHIFT) |
  185. ((I915_READ(GEN8_EU_DISABLE1) & GEN8_EU_DIS1_S1_MASK) <<
  186. (32 - GEN8_EU_DIS0_S1_SHIFT));
  187. eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >> GEN8_EU_DIS1_S2_SHIFT) |
  188. ((I915_READ(GEN8_EU_DISABLE2) & GEN8_EU_DIS2_S2_MASK) <<
  189. (32 - GEN8_EU_DIS1_S2_SHIFT));
  190. /*
  191. * Iterate through enabled slices and subslices to
  192. * count the total enabled EU.
  193. */
  194. for (s = 0; s < s_max; s++) {
  195. if (!(sseu->slice_mask & BIT(s)))
  196. /* skip disabled slice */
  197. continue;
  198. for (ss = 0; ss < ss_max; ss++) {
  199. u32 n_disabled;
  200. if (!(sseu->subslice_mask & BIT(ss)))
  201. /* skip disabled subslice */
  202. continue;
  203. n_disabled = hweight8(eu_disable[s] >> (ss * eu_max));
  204. /*
  205. * Record which subslices have 7 EUs.
  206. */
  207. if (eu_max - n_disabled == 7)
  208. sseu->subslice_7eu[s] |= 1 << ss;
  209. sseu->eu_total += eu_max - n_disabled;
  210. }
  211. }
  212. /*
  213. * BDW is expected to always have a uniform distribution of EU across
  214. * subslices with the exception that any one EU in any one subslice may
  215. * be fused off for die recovery.
  216. */
  217. sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
  218. DIV_ROUND_UP(sseu->eu_total,
  219. sseu_subslice_total(sseu)) : 0;
  220. /*
  221. * BDW supports slice power gating on devices with more than
  222. * one slice.
  223. */
  224. sseu->has_slice_pg = hweight8(sseu->slice_mask) > 1;
  225. sseu->has_subslice_pg = 0;
  226. sseu->has_eu_pg = 0;
  227. }
  228. /*
  229. * Determine various intel_device_info fields at runtime.
  230. *
  231. * Use it when either:
  232. * - it's judged too laborious to fill n static structures with the limit
  233. * when a simple if statement does the job,
  234. * - run-time checks (eg read fuse/strap registers) are needed.
  235. *
  236. * This function needs to be called:
  237. * - after the MMIO has been setup as we are reading registers,
  238. * - after the PCH has been detected,
  239. * - before the first usage of the fields it can tweak.
  240. */
  241. void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
  242. {
  243. struct intel_device_info *info = mkwrite_device_info(dev_priv);
  244. enum pipe pipe;
  245. /*
  246. * Skylake and Broxton currently don't expose the topmost plane as its
  247. * use is exclusive with the legacy cursor and we only want to expose
  248. * one of those, not both. Until we can safely expose the topmost plane
  249. * as a DRM_PLANE_TYPE_CURSOR with all the features exposed/supported,
  250. * we don't expose the topmost plane at all to prevent ABI breakage
  251. * down the line.
  252. */
  253. if (IS_BROXTON(dev_priv)) {
  254. info->num_sprites[PIPE_A] = 2;
  255. info->num_sprites[PIPE_B] = 2;
  256. info->num_sprites[PIPE_C] = 1;
  257. } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
  258. for_each_pipe(dev_priv, pipe)
  259. info->num_sprites[pipe] = 2;
  260. else
  261. for_each_pipe(dev_priv, pipe)
  262. info->num_sprites[pipe] = 1;
  263. if (i915.disable_display) {
  264. DRM_INFO("Display disabled (module parameter)\n");
  265. info->num_pipes = 0;
  266. } else if (info->num_pipes > 0 &&
  267. (IS_GEN7(dev_priv) || IS_GEN8(dev_priv)) &&
  268. HAS_PCH_SPLIT(dev_priv)) {
  269. u32 fuse_strap = I915_READ(FUSE_STRAP);
  270. u32 sfuse_strap = I915_READ(SFUSE_STRAP);
  271. /*
  272. * SFUSE_STRAP is supposed to have a bit signalling the display
  273. * is fused off. Unfortunately it seems that, at least in
  274. * certain cases, fused off display means that PCH display
  275. * reads don't land anywhere. In that case, we read 0s.
  276. *
  277. * On CPT/PPT, we can detect this case as SFUSE_STRAP_FUSE_LOCK
  278. * should be set when taking over after the firmware.
  279. */
  280. if (fuse_strap & ILK_INTERNAL_DISPLAY_DISABLE ||
  281. sfuse_strap & SFUSE_STRAP_DISPLAY_DISABLED ||
  282. (dev_priv->pch_type == PCH_CPT &&
  283. !(sfuse_strap & SFUSE_STRAP_FUSE_LOCK))) {
  284. DRM_INFO("Display fused off, disabling\n");
  285. info->num_pipes = 0;
  286. } else if (fuse_strap & IVB_PIPE_C_DISABLE) {
  287. DRM_INFO("PipeC fused off\n");
  288. info->num_pipes -= 1;
  289. }
  290. } else if (info->num_pipes > 0 && IS_GEN9(dev_priv)) {
  291. u32 dfsm = I915_READ(SKL_DFSM);
  292. u8 disabled_mask = 0;
  293. bool invalid;
  294. int num_bits;
  295. if (dfsm & SKL_DFSM_PIPE_A_DISABLE)
  296. disabled_mask |= BIT(PIPE_A);
  297. if (dfsm & SKL_DFSM_PIPE_B_DISABLE)
  298. disabled_mask |= BIT(PIPE_B);
  299. if (dfsm & SKL_DFSM_PIPE_C_DISABLE)
  300. disabled_mask |= BIT(PIPE_C);
  301. num_bits = hweight8(disabled_mask);
  302. switch (disabled_mask) {
  303. case BIT(PIPE_A):
  304. case BIT(PIPE_B):
  305. case BIT(PIPE_A) | BIT(PIPE_B):
  306. case BIT(PIPE_A) | BIT(PIPE_C):
  307. invalid = true;
  308. break;
  309. default:
  310. invalid = false;
  311. }
  312. if (num_bits > info->num_pipes || invalid)
  313. DRM_ERROR("invalid pipe fuse configuration: 0x%x\n",
  314. disabled_mask);
  315. else
  316. info->num_pipes -= num_bits;
  317. }
  318. /* Initialize slice/subslice/EU info */
  319. if (IS_CHERRYVIEW(dev_priv))
  320. cherryview_sseu_info_init(dev_priv);
  321. else if (IS_BROADWELL(dev_priv))
  322. broadwell_sseu_info_init(dev_priv);
  323. else if (INTEL_INFO(dev_priv)->gen >= 9)
  324. gen9_sseu_info_init(dev_priv);
  325. info->has_snoop = !info->has_llc;
  326. /* Snooping is broken on BXT A stepping. */
  327. if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1))
  328. info->has_snoop = false;
  329. DRM_DEBUG_DRIVER("slice mask: %04x\n", info->sseu.slice_mask);
  330. DRM_DEBUG_DRIVER("slice total: %u\n", hweight8(info->sseu.slice_mask));
  331. DRM_DEBUG_DRIVER("subslice total: %u\n",
  332. sseu_subslice_total(&info->sseu));
  333. DRM_DEBUG_DRIVER("subslice mask %04x\n", info->sseu.subslice_mask);
  334. DRM_DEBUG_DRIVER("subslice per slice: %u\n",
  335. hweight8(info->sseu.subslice_mask));
  336. DRM_DEBUG_DRIVER("EU total: %u\n", info->sseu.eu_total);
  337. DRM_DEBUG_DRIVER("EU per subslice: %u\n", info->sseu.eu_per_subslice);
  338. DRM_DEBUG_DRIVER("has slice power gating: %s\n",
  339. info->sseu.has_slice_pg ? "y" : "n");
  340. DRM_DEBUG_DRIVER("has subslice power gating: %s\n",
  341. info->sseu.has_subslice_pg ? "y" : "n");
  342. DRM_DEBUG_DRIVER("has EU power gating: %s\n",
  343. info->sseu.has_eu_pg ? "y" : "n");
  344. }