intel_device_info.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  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 <drm/drm_print.h>
  25. #include "intel_device_info.h"
  26. #include "i915_drv.h"
  27. #define PLATFORM_NAME(x) [INTEL_##x] = #x
  28. static const char * const platform_names[] = {
  29. PLATFORM_NAME(I830),
  30. PLATFORM_NAME(I845G),
  31. PLATFORM_NAME(I85X),
  32. PLATFORM_NAME(I865G),
  33. PLATFORM_NAME(I915G),
  34. PLATFORM_NAME(I915GM),
  35. PLATFORM_NAME(I945G),
  36. PLATFORM_NAME(I945GM),
  37. PLATFORM_NAME(G33),
  38. PLATFORM_NAME(PINEVIEW),
  39. PLATFORM_NAME(I965G),
  40. PLATFORM_NAME(I965GM),
  41. PLATFORM_NAME(G45),
  42. PLATFORM_NAME(GM45),
  43. PLATFORM_NAME(IRONLAKE),
  44. PLATFORM_NAME(SANDYBRIDGE),
  45. PLATFORM_NAME(IVYBRIDGE),
  46. PLATFORM_NAME(VALLEYVIEW),
  47. PLATFORM_NAME(HASWELL),
  48. PLATFORM_NAME(BROADWELL),
  49. PLATFORM_NAME(CHERRYVIEW),
  50. PLATFORM_NAME(SKYLAKE),
  51. PLATFORM_NAME(BROXTON),
  52. PLATFORM_NAME(KABYLAKE),
  53. PLATFORM_NAME(GEMINILAKE),
  54. PLATFORM_NAME(COFFEELAKE),
  55. PLATFORM_NAME(CANNONLAKE),
  56. PLATFORM_NAME(ICELAKE),
  57. };
  58. #undef PLATFORM_NAME
  59. const char *intel_platform_name(enum intel_platform platform)
  60. {
  61. BUILD_BUG_ON(ARRAY_SIZE(platform_names) != INTEL_MAX_PLATFORMS);
  62. if (WARN_ON_ONCE(platform >= ARRAY_SIZE(platform_names) ||
  63. platform_names[platform] == NULL))
  64. return "<unknown>";
  65. return platform_names[platform];
  66. }
  67. void intel_device_info_dump_flags(const struct intel_device_info *info,
  68. struct drm_printer *p)
  69. {
  70. #define PRINT_FLAG(name) drm_printf(p, "%s: %s\n", #name, yesno(info->name));
  71. DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
  72. #undef PRINT_FLAG
  73. }
  74. static void sseu_dump(const struct sseu_dev_info *sseu, struct drm_printer *p)
  75. {
  76. int s;
  77. drm_printf(p, "slice mask: %04x\n", sseu->slice_mask);
  78. drm_printf(p, "slice total: %u\n", hweight8(sseu->slice_mask));
  79. drm_printf(p, "subslice total: %u\n", sseu_subslice_total(sseu));
  80. for (s = 0; s < ARRAY_SIZE(sseu->subslice_mask); s++) {
  81. drm_printf(p, "slice%d %u subslices mask=%04x\n",
  82. s, hweight8(sseu->subslice_mask[s]),
  83. sseu->subslice_mask[s]);
  84. }
  85. drm_printf(p, "EU total: %u\n", sseu->eu_total);
  86. drm_printf(p, "EU per subslice: %u\n", sseu->eu_per_subslice);
  87. drm_printf(p, "has slice power gating: %s\n",
  88. yesno(sseu->has_slice_pg));
  89. drm_printf(p, "has subslice power gating: %s\n",
  90. yesno(sseu->has_subslice_pg));
  91. drm_printf(p, "has EU power gating: %s\n", yesno(sseu->has_eu_pg));
  92. }
  93. void intel_device_info_dump_runtime(const struct intel_device_info *info,
  94. struct drm_printer *p)
  95. {
  96. sseu_dump(&info->sseu, p);
  97. drm_printf(p, "CS timestamp frequency: %u kHz\n",
  98. info->cs_timestamp_frequency_khz);
  99. }
  100. void intel_device_info_dump(const struct intel_device_info *info,
  101. struct drm_printer *p)
  102. {
  103. struct drm_i915_private *dev_priv =
  104. container_of(info, struct drm_i915_private, info);
  105. drm_printf(p, "pciid=0x%04x rev=0x%02x platform=%s gen=%i\n",
  106. INTEL_DEVID(dev_priv),
  107. INTEL_REVID(dev_priv),
  108. intel_platform_name(info->platform),
  109. info->gen);
  110. intel_device_info_dump_flags(info, p);
  111. }
  112. void intel_device_info_dump_topology(const struct sseu_dev_info *sseu,
  113. struct drm_printer *p)
  114. {
  115. int s, ss;
  116. if (sseu->max_slices == 0) {
  117. drm_printf(p, "Unavailable\n");
  118. return;
  119. }
  120. for (s = 0; s < sseu->max_slices; s++) {
  121. drm_printf(p, "slice%d: %u subslice(s) (0x%hhx):\n",
  122. s, hweight8(sseu->subslice_mask[s]),
  123. sseu->subslice_mask[s]);
  124. for (ss = 0; ss < sseu->max_subslices; ss++) {
  125. u16 enabled_eus = sseu_get_eus(sseu, s, ss);
  126. drm_printf(p, "\tsubslice%d: %u EUs (0x%hx)\n",
  127. ss, hweight16(enabled_eus), enabled_eus);
  128. }
  129. }
  130. }
  131. static u16 compute_eu_total(const struct sseu_dev_info *sseu)
  132. {
  133. u16 i, total = 0;
  134. for (i = 0; i < ARRAY_SIZE(sseu->eu_mask); i++)
  135. total += hweight8(sseu->eu_mask[i]);
  136. return total;
  137. }
  138. static void gen10_sseu_info_init(struct drm_i915_private *dev_priv)
  139. {
  140. struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu;
  141. const u32 fuse2 = I915_READ(GEN8_FUSE2);
  142. int s, ss;
  143. const int eu_mask = 0xff;
  144. u32 subslice_mask, eu_en;
  145. sseu->slice_mask = (fuse2 & GEN10_F2_S_ENA_MASK) >>
  146. GEN10_F2_S_ENA_SHIFT;
  147. sseu->max_slices = 6;
  148. sseu->max_subslices = 4;
  149. sseu->max_eus_per_subslice = 8;
  150. subslice_mask = (1 << 4) - 1;
  151. subslice_mask &= ~((fuse2 & GEN10_F2_SS_DIS_MASK) >>
  152. GEN10_F2_SS_DIS_SHIFT);
  153. /*
  154. * Slice0 can have up to 3 subslices, but there are only 2 in
  155. * slice1/2.
  156. */
  157. sseu->subslice_mask[0] = subslice_mask;
  158. for (s = 1; s < sseu->max_slices; s++)
  159. sseu->subslice_mask[s] = subslice_mask & 0x3;
  160. /* Slice0 */
  161. eu_en = ~I915_READ(GEN8_EU_DISABLE0);
  162. for (ss = 0; ss < sseu->max_subslices; ss++)
  163. sseu_set_eus(sseu, 0, ss, (eu_en >> (8 * ss)) & eu_mask);
  164. /* Slice1 */
  165. sseu_set_eus(sseu, 1, 0, (eu_en >> 24) & eu_mask);
  166. eu_en = ~I915_READ(GEN8_EU_DISABLE1);
  167. sseu_set_eus(sseu, 1, 1, eu_en & eu_mask);
  168. /* Slice2 */
  169. sseu_set_eus(sseu, 2, 0, (eu_en >> 8) & eu_mask);
  170. sseu_set_eus(sseu, 2, 1, (eu_en >> 16) & eu_mask);
  171. /* Slice3 */
  172. sseu_set_eus(sseu, 3, 0, (eu_en >> 24) & eu_mask);
  173. eu_en = ~I915_READ(GEN8_EU_DISABLE2);
  174. sseu_set_eus(sseu, 3, 1, eu_en & eu_mask);
  175. /* Slice4 */
  176. sseu_set_eus(sseu, 4, 0, (eu_en >> 8) & eu_mask);
  177. sseu_set_eus(sseu, 4, 1, (eu_en >> 16) & eu_mask);
  178. /* Slice5 */
  179. sseu_set_eus(sseu, 5, 0, (eu_en >> 24) & eu_mask);
  180. eu_en = ~I915_READ(GEN10_EU_DISABLE3);
  181. sseu_set_eus(sseu, 5, 1, eu_en & eu_mask);
  182. /* Do a second pass where we mark the subslices disabled if all their
  183. * eus are off.
  184. */
  185. for (s = 0; s < sseu->max_slices; s++) {
  186. for (ss = 0; ss < sseu->max_subslices; ss++) {
  187. if (sseu_get_eus(sseu, s, ss) == 0)
  188. sseu->subslice_mask[s] &= ~BIT(ss);
  189. }
  190. }
  191. sseu->eu_total = compute_eu_total(sseu);
  192. /*
  193. * CNL is expected to always have a uniform distribution
  194. * of EU across subslices with the exception that any one
  195. * EU in any one subslice may be fused off for die
  196. * recovery.
  197. */
  198. sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
  199. DIV_ROUND_UP(sseu->eu_total,
  200. sseu_subslice_total(sseu)) : 0;
  201. /* No restrictions on Power Gating */
  202. sseu->has_slice_pg = 1;
  203. sseu->has_subslice_pg = 1;
  204. sseu->has_eu_pg = 1;
  205. }
  206. static void cherryview_sseu_info_init(struct drm_i915_private *dev_priv)
  207. {
  208. struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu;
  209. u32 fuse;
  210. fuse = I915_READ(CHV_FUSE_GT);
  211. sseu->slice_mask = BIT(0);
  212. sseu->max_slices = 1;
  213. sseu->max_subslices = 2;
  214. sseu->max_eus_per_subslice = 8;
  215. if (!(fuse & CHV_FGT_DISABLE_SS0)) {
  216. u8 disabled_mask =
  217. ((fuse & CHV_FGT_EU_DIS_SS0_R0_MASK) >>
  218. CHV_FGT_EU_DIS_SS0_R0_SHIFT) |
  219. (((fuse & CHV_FGT_EU_DIS_SS0_R1_MASK) >>
  220. CHV_FGT_EU_DIS_SS0_R1_SHIFT) << 4);
  221. sseu->subslice_mask[0] |= BIT(0);
  222. sseu_set_eus(sseu, 0, 0, ~disabled_mask);
  223. }
  224. if (!(fuse & CHV_FGT_DISABLE_SS1)) {
  225. u8 disabled_mask =
  226. ((fuse & CHV_FGT_EU_DIS_SS1_R0_MASK) >>
  227. CHV_FGT_EU_DIS_SS1_R0_SHIFT) |
  228. (((fuse & CHV_FGT_EU_DIS_SS1_R1_MASK) >>
  229. CHV_FGT_EU_DIS_SS1_R1_SHIFT) << 4);
  230. sseu->subslice_mask[0] |= BIT(1);
  231. sseu_set_eus(sseu, 0, 1, ~disabled_mask);
  232. }
  233. sseu->eu_total = compute_eu_total(sseu);
  234. /*
  235. * CHV expected to always have a uniform distribution of EU
  236. * across subslices.
  237. */
  238. sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
  239. sseu->eu_total / sseu_subslice_total(sseu) :
  240. 0;
  241. /*
  242. * CHV supports subslice power gating on devices with more than
  243. * one subslice, and supports EU power gating on devices with
  244. * more than one EU pair per subslice.
  245. */
  246. sseu->has_slice_pg = 0;
  247. sseu->has_subslice_pg = sseu_subslice_total(sseu) > 1;
  248. sseu->has_eu_pg = (sseu->eu_per_subslice > 2);
  249. }
  250. static void gen9_sseu_info_init(struct drm_i915_private *dev_priv)
  251. {
  252. struct intel_device_info *info = mkwrite_device_info(dev_priv);
  253. struct sseu_dev_info *sseu = &info->sseu;
  254. int s, ss;
  255. u32 fuse2, eu_disable, subslice_mask;
  256. const u8 eu_mask = 0xff;
  257. fuse2 = I915_READ(GEN8_FUSE2);
  258. sseu->slice_mask = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
  259. /* BXT has a single slice and at most 3 subslices. */
  260. sseu->max_slices = IS_GEN9_LP(dev_priv) ? 1 : 3;
  261. sseu->max_subslices = IS_GEN9_LP(dev_priv) ? 3 : 4;
  262. sseu->max_eus_per_subslice = 8;
  263. /*
  264. * The subslice disable field is global, i.e. it applies
  265. * to each of the enabled slices.
  266. */
  267. subslice_mask = (1 << sseu->max_subslices) - 1;
  268. subslice_mask &= ~((fuse2 & GEN9_F2_SS_DIS_MASK) >>
  269. GEN9_F2_SS_DIS_SHIFT);
  270. /*
  271. * Iterate through enabled slices and subslices to
  272. * count the total enabled EU.
  273. */
  274. for (s = 0; s < sseu->max_slices; s++) {
  275. if (!(sseu->slice_mask & BIT(s)))
  276. /* skip disabled slice */
  277. continue;
  278. sseu->subslice_mask[s] = subslice_mask;
  279. eu_disable = I915_READ(GEN9_EU_DISABLE(s));
  280. for (ss = 0; ss < sseu->max_subslices; ss++) {
  281. int eu_per_ss;
  282. u8 eu_disabled_mask;
  283. if (!(sseu->subslice_mask[s] & BIT(ss)))
  284. /* skip disabled subslice */
  285. continue;
  286. eu_disabled_mask = (eu_disable >> (ss * 8)) & eu_mask;
  287. sseu_set_eus(sseu, s, ss, ~eu_disabled_mask);
  288. eu_per_ss = sseu->max_eus_per_subslice -
  289. hweight8(eu_disabled_mask);
  290. /*
  291. * Record which subslice(s) has(have) 7 EUs. we
  292. * can tune the hash used to spread work among
  293. * subslices if they are unbalanced.
  294. */
  295. if (eu_per_ss == 7)
  296. sseu->subslice_7eu[s] |= BIT(ss);
  297. }
  298. }
  299. sseu->eu_total = compute_eu_total(sseu);
  300. /*
  301. * SKL is expected to always have a uniform distribution
  302. * of EU across subslices with the exception that any one
  303. * EU in any one subslice may be fused off for die
  304. * recovery. BXT is expected to be perfectly uniform in EU
  305. * distribution.
  306. */
  307. sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
  308. DIV_ROUND_UP(sseu->eu_total,
  309. sseu_subslice_total(sseu)) : 0;
  310. /*
  311. * SKL+ supports slice power gating on devices with more than
  312. * one slice, and supports EU power gating on devices with
  313. * more than one EU pair per subslice. BXT+ supports subslice
  314. * power gating on devices with more than one subslice, and
  315. * supports EU power gating on devices with more than one EU
  316. * pair per subslice.
  317. */
  318. sseu->has_slice_pg =
  319. !IS_GEN9_LP(dev_priv) && hweight8(sseu->slice_mask) > 1;
  320. sseu->has_subslice_pg =
  321. IS_GEN9_LP(dev_priv) && sseu_subslice_total(sseu) > 1;
  322. sseu->has_eu_pg = sseu->eu_per_subslice > 2;
  323. if (IS_GEN9_LP(dev_priv)) {
  324. #define IS_SS_DISABLED(ss) (!(sseu->subslice_mask[0] & BIT(ss)))
  325. info->has_pooled_eu = hweight8(sseu->subslice_mask[0]) == 3;
  326. sseu->min_eu_in_pool = 0;
  327. if (info->has_pooled_eu) {
  328. if (IS_SS_DISABLED(2) || IS_SS_DISABLED(0))
  329. sseu->min_eu_in_pool = 3;
  330. else if (IS_SS_DISABLED(1))
  331. sseu->min_eu_in_pool = 6;
  332. else
  333. sseu->min_eu_in_pool = 9;
  334. }
  335. #undef IS_SS_DISABLED
  336. }
  337. }
  338. static void broadwell_sseu_info_init(struct drm_i915_private *dev_priv)
  339. {
  340. struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu;
  341. int s, ss;
  342. u32 fuse2, subslice_mask, eu_disable[3]; /* s_max */
  343. fuse2 = I915_READ(GEN8_FUSE2);
  344. sseu->slice_mask = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
  345. sseu->max_slices = 3;
  346. sseu->max_subslices = 3;
  347. sseu->max_eus_per_subslice = 8;
  348. /*
  349. * The subslice disable field is global, i.e. it applies
  350. * to each of the enabled slices.
  351. */
  352. subslice_mask = GENMASK(sseu->max_subslices - 1, 0);
  353. subslice_mask &= ~((fuse2 & GEN8_F2_SS_DIS_MASK) >>
  354. GEN8_F2_SS_DIS_SHIFT);
  355. eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) & GEN8_EU_DIS0_S0_MASK;
  356. eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >> GEN8_EU_DIS0_S1_SHIFT) |
  357. ((I915_READ(GEN8_EU_DISABLE1) & GEN8_EU_DIS1_S1_MASK) <<
  358. (32 - GEN8_EU_DIS0_S1_SHIFT));
  359. eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >> GEN8_EU_DIS1_S2_SHIFT) |
  360. ((I915_READ(GEN8_EU_DISABLE2) & GEN8_EU_DIS2_S2_MASK) <<
  361. (32 - GEN8_EU_DIS1_S2_SHIFT));
  362. /*
  363. * Iterate through enabled slices and subslices to
  364. * count the total enabled EU.
  365. */
  366. for (s = 0; s < sseu->max_slices; s++) {
  367. if (!(sseu->slice_mask & BIT(s)))
  368. /* skip disabled slice */
  369. continue;
  370. sseu->subslice_mask[s] = subslice_mask;
  371. for (ss = 0; ss < sseu->max_subslices; ss++) {
  372. u8 eu_disabled_mask;
  373. u32 n_disabled;
  374. if (!(sseu->subslice_mask[ss] & BIT(ss)))
  375. /* skip disabled subslice */
  376. continue;
  377. eu_disabled_mask =
  378. eu_disable[s] >> (ss * sseu->max_eus_per_subslice);
  379. sseu_set_eus(sseu, s, ss, ~eu_disabled_mask);
  380. n_disabled = hweight8(eu_disabled_mask);
  381. /*
  382. * Record which subslices have 7 EUs.
  383. */
  384. if (sseu->max_eus_per_subslice - n_disabled == 7)
  385. sseu->subslice_7eu[s] |= 1 << ss;
  386. }
  387. }
  388. sseu->eu_total = compute_eu_total(sseu);
  389. /*
  390. * BDW is expected to always have a uniform distribution of EU across
  391. * subslices with the exception that any one EU in any one subslice may
  392. * be fused off for die recovery.
  393. */
  394. sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
  395. DIV_ROUND_UP(sseu->eu_total,
  396. sseu_subslice_total(sseu)) : 0;
  397. /*
  398. * BDW supports slice power gating on devices with more than
  399. * one slice.
  400. */
  401. sseu->has_slice_pg = hweight8(sseu->slice_mask) > 1;
  402. sseu->has_subslice_pg = 0;
  403. sseu->has_eu_pg = 0;
  404. }
  405. static void haswell_sseu_info_init(struct drm_i915_private *dev_priv)
  406. {
  407. struct intel_device_info *info = mkwrite_device_info(dev_priv);
  408. struct sseu_dev_info *sseu = &info->sseu;
  409. u32 fuse1;
  410. int s, ss;
  411. /*
  412. * There isn't a register to tell us how many slices/subslices. We
  413. * work off the PCI-ids here.
  414. */
  415. switch (info->gt) {
  416. default:
  417. MISSING_CASE(info->gt);
  418. /* fall through */
  419. case 1:
  420. sseu->slice_mask = BIT(0);
  421. sseu->subslice_mask[0] = BIT(0);
  422. break;
  423. case 2:
  424. sseu->slice_mask = BIT(0);
  425. sseu->subslice_mask[0] = BIT(0) | BIT(1);
  426. break;
  427. case 3:
  428. sseu->slice_mask = BIT(0) | BIT(1);
  429. sseu->subslice_mask[0] = BIT(0) | BIT(1);
  430. sseu->subslice_mask[1] = BIT(0) | BIT(1);
  431. break;
  432. }
  433. sseu->max_slices = hweight8(sseu->slice_mask);
  434. sseu->max_subslices = hweight8(sseu->subslice_mask[0]);
  435. fuse1 = I915_READ(HSW_PAVP_FUSE1);
  436. switch ((fuse1 & HSW_F1_EU_DIS_MASK) >> HSW_F1_EU_DIS_SHIFT) {
  437. default:
  438. MISSING_CASE((fuse1 & HSW_F1_EU_DIS_MASK) >>
  439. HSW_F1_EU_DIS_SHIFT);
  440. /* fall through */
  441. case HSW_F1_EU_DIS_10EUS:
  442. sseu->eu_per_subslice = 10;
  443. break;
  444. case HSW_F1_EU_DIS_8EUS:
  445. sseu->eu_per_subslice = 8;
  446. break;
  447. case HSW_F1_EU_DIS_6EUS:
  448. sseu->eu_per_subslice = 6;
  449. break;
  450. }
  451. sseu->max_eus_per_subslice = sseu->eu_per_subslice;
  452. for (s = 0; s < sseu->max_slices; s++) {
  453. for (ss = 0; ss < sseu->max_subslices; ss++) {
  454. sseu_set_eus(sseu, s, ss,
  455. (1UL << sseu->eu_per_subslice) - 1);
  456. }
  457. }
  458. sseu->eu_total = compute_eu_total(sseu);
  459. /* No powergating for you. */
  460. sseu->has_slice_pg = 0;
  461. sseu->has_subslice_pg = 0;
  462. sseu->has_eu_pg = 0;
  463. }
  464. static u32 read_reference_ts_freq(struct drm_i915_private *dev_priv)
  465. {
  466. u32 ts_override = I915_READ(GEN9_TIMESTAMP_OVERRIDE);
  467. u32 base_freq, frac_freq;
  468. base_freq = ((ts_override & GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DIVIDER_MASK) >>
  469. GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DIVIDER_SHIFT) + 1;
  470. base_freq *= 1000;
  471. frac_freq = ((ts_override &
  472. GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DENOMINATOR_MASK) >>
  473. GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DENOMINATOR_SHIFT);
  474. frac_freq = 1000 / (frac_freq + 1);
  475. return base_freq + frac_freq;
  476. }
  477. static u32 read_timestamp_frequency(struct drm_i915_private *dev_priv)
  478. {
  479. u32 f12_5_mhz = 12500;
  480. u32 f19_2_mhz = 19200;
  481. u32 f24_mhz = 24000;
  482. if (INTEL_GEN(dev_priv) <= 4) {
  483. /* PRMs say:
  484. *
  485. * "The value in this register increments once every 16
  486. * hclks." (through the “Clocking Configuration”
  487. * (“CLKCFG”) MCHBAR register)
  488. */
  489. return dev_priv->rawclk_freq / 16;
  490. } else if (INTEL_GEN(dev_priv) <= 8) {
  491. /* PRMs say:
  492. *
  493. * "The PCU TSC counts 10ns increments; this timestamp
  494. * reflects bits 38:3 of the TSC (i.e. 80ns granularity,
  495. * rolling over every 1.5 hours).
  496. */
  497. return f12_5_mhz;
  498. } else if (INTEL_GEN(dev_priv) <= 9) {
  499. u32 ctc_reg = I915_READ(CTC_MODE);
  500. u32 freq = 0;
  501. if ((ctc_reg & CTC_SOURCE_PARAMETER_MASK) == CTC_SOURCE_DIVIDE_LOGIC) {
  502. freq = read_reference_ts_freq(dev_priv);
  503. } else {
  504. freq = IS_GEN9_LP(dev_priv) ? f19_2_mhz : f24_mhz;
  505. /* Now figure out how the command stream's timestamp
  506. * register increments from this frequency (it might
  507. * increment only every few clock cycle).
  508. */
  509. freq >>= 3 - ((ctc_reg & CTC_SHIFT_PARAMETER_MASK) >>
  510. CTC_SHIFT_PARAMETER_SHIFT);
  511. }
  512. return freq;
  513. } else if (INTEL_GEN(dev_priv) <= 10) {
  514. u32 ctc_reg = I915_READ(CTC_MODE);
  515. u32 freq = 0;
  516. u32 rpm_config_reg = 0;
  517. /* First figure out the reference frequency. There are 2 ways
  518. * we can compute the frequency, either through the
  519. * TIMESTAMP_OVERRIDE register or through RPM_CONFIG. CTC_MODE
  520. * tells us which one we should use.
  521. */
  522. if ((ctc_reg & CTC_SOURCE_PARAMETER_MASK) == CTC_SOURCE_DIVIDE_LOGIC) {
  523. freq = read_reference_ts_freq(dev_priv);
  524. } else {
  525. u32 crystal_clock;
  526. rpm_config_reg = I915_READ(RPM_CONFIG0);
  527. crystal_clock = (rpm_config_reg &
  528. GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK) >>
  529. GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT;
  530. switch (crystal_clock) {
  531. case GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_19_2_MHZ:
  532. freq = f19_2_mhz;
  533. break;
  534. case GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ:
  535. freq = f24_mhz;
  536. break;
  537. }
  538. /* Now figure out how the command stream's timestamp
  539. * register increments from this frequency (it might
  540. * increment only every few clock cycle).
  541. */
  542. freq >>= 3 - ((rpm_config_reg &
  543. GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_MASK) >>
  544. GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_SHIFT);
  545. }
  546. return freq;
  547. }
  548. MISSING_CASE("Unknown gen, unable to read command streamer timestamp frequency\n");
  549. return 0;
  550. }
  551. /**
  552. * intel_device_info_runtime_init - initialize runtime info
  553. * @info: intel device info struct
  554. *
  555. * Determine various intel_device_info fields at runtime.
  556. *
  557. * Use it when either:
  558. * - it's judged too laborious to fill n static structures with the limit
  559. * when a simple if statement does the job,
  560. * - run-time checks (eg read fuse/strap registers) are needed.
  561. *
  562. * This function needs to be called:
  563. * - after the MMIO has been setup as we are reading registers,
  564. * - after the PCH has been detected,
  565. * - before the first usage of the fields it can tweak.
  566. */
  567. void intel_device_info_runtime_init(struct intel_device_info *info)
  568. {
  569. struct drm_i915_private *dev_priv =
  570. container_of(info, struct drm_i915_private, info);
  571. enum pipe pipe;
  572. if (INTEL_GEN(dev_priv) >= 10) {
  573. for_each_pipe(dev_priv, pipe)
  574. info->num_scalers[pipe] = 2;
  575. } else if (INTEL_GEN(dev_priv) == 9) {
  576. info->num_scalers[PIPE_A] = 2;
  577. info->num_scalers[PIPE_B] = 2;
  578. info->num_scalers[PIPE_C] = 1;
  579. }
  580. BUILD_BUG_ON(I915_NUM_ENGINES >
  581. sizeof(intel_ring_mask_t) * BITS_PER_BYTE);
  582. /*
  583. * Skylake and Broxton currently don't expose the topmost plane as its
  584. * use is exclusive with the legacy cursor and we only want to expose
  585. * one of those, not both. Until we can safely expose the topmost plane
  586. * as a DRM_PLANE_TYPE_CURSOR with all the features exposed/supported,
  587. * we don't expose the topmost plane at all to prevent ABI breakage
  588. * down the line.
  589. */
  590. if (IS_GEN10(dev_priv) || IS_GEMINILAKE(dev_priv))
  591. for_each_pipe(dev_priv, pipe)
  592. info->num_sprites[pipe] = 3;
  593. else if (IS_BROXTON(dev_priv)) {
  594. info->num_sprites[PIPE_A] = 2;
  595. info->num_sprites[PIPE_B] = 2;
  596. info->num_sprites[PIPE_C] = 1;
  597. } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
  598. for_each_pipe(dev_priv, pipe)
  599. info->num_sprites[pipe] = 2;
  600. } else if (INTEL_GEN(dev_priv) >= 5 || IS_G4X(dev_priv)) {
  601. for_each_pipe(dev_priv, pipe)
  602. info->num_sprites[pipe] = 1;
  603. }
  604. if (i915_modparams.disable_display) {
  605. DRM_INFO("Display disabled (module parameter)\n");
  606. info->num_pipes = 0;
  607. } else if (info->num_pipes > 0 &&
  608. (IS_GEN7(dev_priv) || IS_GEN8(dev_priv)) &&
  609. HAS_PCH_SPLIT(dev_priv)) {
  610. u32 fuse_strap = I915_READ(FUSE_STRAP);
  611. u32 sfuse_strap = I915_READ(SFUSE_STRAP);
  612. /*
  613. * SFUSE_STRAP is supposed to have a bit signalling the display
  614. * is fused off. Unfortunately it seems that, at least in
  615. * certain cases, fused off display means that PCH display
  616. * reads don't land anywhere. In that case, we read 0s.
  617. *
  618. * On CPT/PPT, we can detect this case as SFUSE_STRAP_FUSE_LOCK
  619. * should be set when taking over after the firmware.
  620. */
  621. if (fuse_strap & ILK_INTERNAL_DISPLAY_DISABLE ||
  622. sfuse_strap & SFUSE_STRAP_DISPLAY_DISABLED ||
  623. (HAS_PCH_CPT(dev_priv) &&
  624. !(sfuse_strap & SFUSE_STRAP_FUSE_LOCK))) {
  625. DRM_INFO("Display fused off, disabling\n");
  626. info->num_pipes = 0;
  627. } else if (fuse_strap & IVB_PIPE_C_DISABLE) {
  628. DRM_INFO("PipeC fused off\n");
  629. info->num_pipes -= 1;
  630. }
  631. } else if (info->num_pipes > 0 && IS_GEN9(dev_priv)) {
  632. u32 dfsm = I915_READ(SKL_DFSM);
  633. u8 disabled_mask = 0;
  634. bool invalid;
  635. int num_bits;
  636. if (dfsm & SKL_DFSM_PIPE_A_DISABLE)
  637. disabled_mask |= BIT(PIPE_A);
  638. if (dfsm & SKL_DFSM_PIPE_B_DISABLE)
  639. disabled_mask |= BIT(PIPE_B);
  640. if (dfsm & SKL_DFSM_PIPE_C_DISABLE)
  641. disabled_mask |= BIT(PIPE_C);
  642. num_bits = hweight8(disabled_mask);
  643. switch (disabled_mask) {
  644. case BIT(PIPE_A):
  645. case BIT(PIPE_B):
  646. case BIT(PIPE_A) | BIT(PIPE_B):
  647. case BIT(PIPE_A) | BIT(PIPE_C):
  648. invalid = true;
  649. break;
  650. default:
  651. invalid = false;
  652. }
  653. if (num_bits > info->num_pipes || invalid)
  654. DRM_ERROR("invalid pipe fuse configuration: 0x%x\n",
  655. disabled_mask);
  656. else
  657. info->num_pipes -= num_bits;
  658. }
  659. /* Initialize slice/subslice/EU info */
  660. if (IS_HASWELL(dev_priv))
  661. haswell_sseu_info_init(dev_priv);
  662. else if (IS_CHERRYVIEW(dev_priv))
  663. cherryview_sseu_info_init(dev_priv);
  664. else if (IS_BROADWELL(dev_priv))
  665. broadwell_sseu_info_init(dev_priv);
  666. else if (INTEL_GEN(dev_priv) == 9)
  667. gen9_sseu_info_init(dev_priv);
  668. else if (INTEL_GEN(dev_priv) >= 10)
  669. gen10_sseu_info_init(dev_priv);
  670. /* Initialize command stream timestamp frequency */
  671. info->cs_timestamp_frequency_khz = read_timestamp_frequency(dev_priv);
  672. }
  673. void intel_driver_caps_print(const struct intel_driver_caps *caps,
  674. struct drm_printer *p)
  675. {
  676. drm_printf(p, "scheduler: %x\n", caps->scheduler);
  677. }