intel_device_info.c 12 KB

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