intel_device_info.c 12 KB

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