1303bf270SFrançois Tigeot /*
2303bf270SFrançois Tigeot * Copyright © 2016 Intel Corporation
3303bf270SFrançois Tigeot *
4303bf270SFrançois Tigeot * Permission is hereby granted, free of charge, to any person obtaining a
5303bf270SFrançois Tigeot * copy of this software and associated documentation files (the "Software"),
6303bf270SFrançois Tigeot * to deal in the Software without restriction, including without limitation
7303bf270SFrançois Tigeot * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8303bf270SFrançois Tigeot * and/or sell copies of the Software, and to permit persons to whom the
9303bf270SFrançois Tigeot * Software is furnished to do so, subject to the following conditions:
10303bf270SFrançois Tigeot *
11303bf270SFrançois Tigeot * The above copyright notice and this permission notice (including the next
12303bf270SFrançois Tigeot * paragraph) shall be included in all copies or substantial portions of the
13303bf270SFrançois Tigeot * Software.
14303bf270SFrançois Tigeot *
15303bf270SFrançois Tigeot * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16303bf270SFrançois Tigeot * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17303bf270SFrançois Tigeot * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18303bf270SFrançois Tigeot * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19303bf270SFrançois Tigeot * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20303bf270SFrançois Tigeot * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21303bf270SFrançois Tigeot * IN THE SOFTWARE.
22303bf270SFrançois Tigeot *
23303bf270SFrançois Tigeot */
24303bf270SFrançois Tigeot
25303bf270SFrançois Tigeot #include "i915_drv.h"
26303bf270SFrançois Tigeot
27a85cb24fSFrançois Tigeot #define PLATFORM_NAME(x) [INTEL_##x] = #x
28a85cb24fSFrançois Tigeot static const char * const platform_names[] = {
29a85cb24fSFrançois Tigeot PLATFORM_NAME(I830),
30a85cb24fSFrançois Tigeot PLATFORM_NAME(I845G),
31a85cb24fSFrançois Tigeot PLATFORM_NAME(I85X),
32a85cb24fSFrançois Tigeot PLATFORM_NAME(I865G),
33a85cb24fSFrançois Tigeot PLATFORM_NAME(I915G),
34a85cb24fSFrançois Tigeot PLATFORM_NAME(I915GM),
35a85cb24fSFrançois Tigeot PLATFORM_NAME(I945G),
36a85cb24fSFrançois Tigeot PLATFORM_NAME(I945GM),
37a85cb24fSFrançois Tigeot PLATFORM_NAME(G33),
38a85cb24fSFrançois Tigeot PLATFORM_NAME(PINEVIEW),
39a85cb24fSFrançois Tigeot PLATFORM_NAME(I965G),
40a85cb24fSFrançois Tigeot PLATFORM_NAME(I965GM),
41a85cb24fSFrançois Tigeot PLATFORM_NAME(G45),
42a85cb24fSFrançois Tigeot PLATFORM_NAME(GM45),
43a85cb24fSFrançois Tigeot PLATFORM_NAME(IRONLAKE),
44a85cb24fSFrançois Tigeot PLATFORM_NAME(SANDYBRIDGE),
45a85cb24fSFrançois Tigeot PLATFORM_NAME(IVYBRIDGE),
46a85cb24fSFrançois Tigeot PLATFORM_NAME(VALLEYVIEW),
47a85cb24fSFrançois Tigeot PLATFORM_NAME(HASWELL),
48a85cb24fSFrançois Tigeot PLATFORM_NAME(BROADWELL),
49a85cb24fSFrançois Tigeot PLATFORM_NAME(CHERRYVIEW),
50a85cb24fSFrançois Tigeot PLATFORM_NAME(SKYLAKE),
51a85cb24fSFrançois Tigeot PLATFORM_NAME(BROXTON),
52a85cb24fSFrançois Tigeot PLATFORM_NAME(KABYLAKE),
53a85cb24fSFrançois Tigeot PLATFORM_NAME(GEMINILAKE),
54*3f2dd94aSFrançois Tigeot PLATFORM_NAME(COFFEELAKE),
55*3f2dd94aSFrançois Tigeot PLATFORM_NAME(CANNONLAKE),
56a85cb24fSFrançois Tigeot };
57a85cb24fSFrançois Tigeot #undef PLATFORM_NAME
58a85cb24fSFrançois Tigeot
intel_platform_name(enum intel_platform platform)59a85cb24fSFrançois Tigeot const char *intel_platform_name(enum intel_platform platform)
60a85cb24fSFrançois Tigeot {
61a85cb24fSFrançois Tigeot BUILD_BUG_ON(ARRAY_SIZE(platform_names) != INTEL_MAX_PLATFORMS);
62a85cb24fSFrançois Tigeot
63a85cb24fSFrançois Tigeot if (WARN_ON_ONCE(platform >= ARRAY_SIZE(platform_names) ||
64a85cb24fSFrançois Tigeot platform_names[platform] == NULL))
65a85cb24fSFrançois Tigeot return "<unknown>";
66a85cb24fSFrançois Tigeot
67a85cb24fSFrançois Tigeot return platform_names[platform];
68a85cb24fSFrançois Tigeot }
69a85cb24fSFrançois Tigeot
intel_device_info_dump(struct drm_i915_private * dev_priv)70303bf270SFrançois Tigeot void intel_device_info_dump(struct drm_i915_private *dev_priv)
71303bf270SFrançois Tigeot {
72303bf270SFrançois Tigeot const struct intel_device_info *info = &dev_priv->info;
73303bf270SFrançois Tigeot
74a85cb24fSFrançois Tigeot DRM_DEBUG_DRIVER("i915 device info: platform=%s gen=%i pciid=0x%04x rev=0x%02x",
75a85cb24fSFrançois Tigeot intel_platform_name(info->platform),
76303bf270SFrançois Tigeot info->gen,
77303bf270SFrançois Tigeot dev_priv->drm.pdev->device,
781e12ee3bSFrançois Tigeot dev_priv->drm.pdev->revision);
791e12ee3bSFrançois Tigeot #define PRINT_FLAG(name) \
801e12ee3bSFrançois Tigeot DRM_DEBUG_DRIVER("i915 device info: " #name ": %s", yesno(info->name))
811e12ee3bSFrançois Tigeot DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
82303bf270SFrançois Tigeot #undef PRINT_FLAG
83303bf270SFrançois Tigeot }
84303bf270SFrançois Tigeot
gen10_sseu_info_init(struct drm_i915_private * dev_priv)85*3f2dd94aSFrançois Tigeot static void gen10_sseu_info_init(struct drm_i915_private *dev_priv)
86*3f2dd94aSFrançois Tigeot {
87*3f2dd94aSFrançois Tigeot struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu;
88*3f2dd94aSFrançois Tigeot const u32 fuse2 = I915_READ(GEN8_FUSE2);
89*3f2dd94aSFrançois Tigeot
90*3f2dd94aSFrançois Tigeot sseu->slice_mask = (fuse2 & GEN10_F2_S_ENA_MASK) >>
91*3f2dd94aSFrançois Tigeot GEN10_F2_S_ENA_SHIFT;
92*3f2dd94aSFrançois Tigeot sseu->subslice_mask = (1 << 4) - 1;
93*3f2dd94aSFrançois Tigeot sseu->subslice_mask &= ~((fuse2 & GEN10_F2_SS_DIS_MASK) >>
94*3f2dd94aSFrançois Tigeot GEN10_F2_SS_DIS_SHIFT);
95*3f2dd94aSFrançois Tigeot
96*3f2dd94aSFrançois Tigeot sseu->eu_total = hweight32(~I915_READ(GEN8_EU_DISABLE0));
97*3f2dd94aSFrançois Tigeot sseu->eu_total += hweight32(~I915_READ(GEN8_EU_DISABLE1));
98*3f2dd94aSFrançois Tigeot sseu->eu_total += hweight32(~I915_READ(GEN8_EU_DISABLE2));
99*3f2dd94aSFrançois Tigeot sseu->eu_total += hweight8(~(I915_READ(GEN10_EU_DISABLE3) &
100*3f2dd94aSFrançois Tigeot GEN10_EU_DIS_SS_MASK));
101*3f2dd94aSFrançois Tigeot
102*3f2dd94aSFrançois Tigeot /*
103*3f2dd94aSFrançois Tigeot * CNL is expected to always have a uniform distribution
104*3f2dd94aSFrançois Tigeot * of EU across subslices with the exception that any one
105*3f2dd94aSFrançois Tigeot * EU in any one subslice may be fused off for die
106*3f2dd94aSFrançois Tigeot * recovery.
107*3f2dd94aSFrançois Tigeot */
108*3f2dd94aSFrançois Tigeot sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
109*3f2dd94aSFrançois Tigeot DIV_ROUND_UP(sseu->eu_total,
110*3f2dd94aSFrançois Tigeot sseu_subslice_total(sseu)) : 0;
111*3f2dd94aSFrançois Tigeot
112*3f2dd94aSFrançois Tigeot /* No restrictions on Power Gating */
113*3f2dd94aSFrançois Tigeot sseu->has_slice_pg = 1;
114*3f2dd94aSFrançois Tigeot sseu->has_subslice_pg = 1;
115*3f2dd94aSFrançois Tigeot sseu->has_eu_pg = 1;
116*3f2dd94aSFrançois Tigeot }
117*3f2dd94aSFrançois Tigeot
cherryview_sseu_info_init(struct drm_i915_private * dev_priv)118303bf270SFrançois Tigeot static void cherryview_sseu_info_init(struct drm_i915_private *dev_priv)
119303bf270SFrançois Tigeot {
1201e12ee3bSFrançois Tigeot struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu;
121303bf270SFrançois Tigeot u32 fuse, eu_dis;
122303bf270SFrançois Tigeot
123303bf270SFrançois Tigeot fuse = I915_READ(CHV_FUSE_GT);
124303bf270SFrançois Tigeot
1251e12ee3bSFrançois Tigeot sseu->slice_mask = BIT(0);
126303bf270SFrançois Tigeot
127303bf270SFrançois Tigeot if (!(fuse & CHV_FGT_DISABLE_SS0)) {
1281e12ee3bSFrançois Tigeot sseu->subslice_mask |= BIT(0);
129303bf270SFrançois Tigeot eu_dis = fuse & (CHV_FGT_EU_DIS_SS0_R0_MASK |
130303bf270SFrançois Tigeot CHV_FGT_EU_DIS_SS0_R1_MASK);
1311e12ee3bSFrançois Tigeot sseu->eu_total += 8 - hweight32(eu_dis);
132303bf270SFrançois Tigeot }
133303bf270SFrançois Tigeot
134303bf270SFrançois Tigeot if (!(fuse & CHV_FGT_DISABLE_SS1)) {
1351e12ee3bSFrançois Tigeot sseu->subslice_mask |= BIT(1);
136303bf270SFrançois Tigeot eu_dis = fuse & (CHV_FGT_EU_DIS_SS1_R0_MASK |
137303bf270SFrançois Tigeot CHV_FGT_EU_DIS_SS1_R1_MASK);
1381e12ee3bSFrançois Tigeot sseu->eu_total += 8 - hweight32(eu_dis);
139303bf270SFrançois Tigeot }
140303bf270SFrançois Tigeot
141303bf270SFrançois Tigeot /*
142303bf270SFrançois Tigeot * CHV expected to always have a uniform distribution of EU
143303bf270SFrançois Tigeot * across subslices.
144303bf270SFrançois Tigeot */
1451e12ee3bSFrançois Tigeot sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
1461e12ee3bSFrançois Tigeot sseu->eu_total / sseu_subslice_total(sseu) :
147303bf270SFrançois Tigeot 0;
148303bf270SFrançois Tigeot /*
149303bf270SFrançois Tigeot * CHV supports subslice power gating on devices with more than
150303bf270SFrançois Tigeot * one subslice, and supports EU power gating on devices with
151303bf270SFrançois Tigeot * more than one EU pair per subslice.
152303bf270SFrançois Tigeot */
1531e12ee3bSFrançois Tigeot sseu->has_slice_pg = 0;
1541e12ee3bSFrançois Tigeot sseu->has_subslice_pg = sseu_subslice_total(sseu) > 1;
1551e12ee3bSFrançois Tigeot sseu->has_eu_pg = (sseu->eu_per_subslice > 2);
156303bf270SFrançois Tigeot }
157303bf270SFrançois Tigeot
gen9_sseu_info_init(struct drm_i915_private * dev_priv)158303bf270SFrançois Tigeot static void gen9_sseu_info_init(struct drm_i915_private *dev_priv)
159303bf270SFrançois Tigeot {
160303bf270SFrançois Tigeot struct intel_device_info *info = mkwrite_device_info(dev_priv);
1611e12ee3bSFrançois Tigeot struct sseu_dev_info *sseu = &info->sseu;
162303bf270SFrançois Tigeot int s_max = 3, ss_max = 4, eu_max = 8;
163303bf270SFrançois Tigeot int s, ss;
1641e12ee3bSFrançois Tigeot u32 fuse2, eu_disable;
165303bf270SFrançois Tigeot u8 eu_mask = 0xff;
166303bf270SFrançois Tigeot
167303bf270SFrançois Tigeot fuse2 = I915_READ(GEN8_FUSE2);
1681e12ee3bSFrançois Tigeot sseu->slice_mask = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
169303bf270SFrançois Tigeot
170303bf270SFrançois Tigeot /*
171303bf270SFrançois Tigeot * The subslice disable field is global, i.e. it applies
172303bf270SFrançois Tigeot * to each of the enabled slices.
173303bf270SFrançois Tigeot */
1741e12ee3bSFrançois Tigeot sseu->subslice_mask = (1 << ss_max) - 1;
1751e12ee3bSFrançois Tigeot sseu->subslice_mask &= ~((fuse2 & GEN9_F2_SS_DIS_MASK) >>
1761e12ee3bSFrançois Tigeot GEN9_F2_SS_DIS_SHIFT);
177303bf270SFrançois Tigeot
178303bf270SFrançois Tigeot /*
179303bf270SFrançois Tigeot * Iterate through enabled slices and subslices to
180303bf270SFrançois Tigeot * count the total enabled EU.
181303bf270SFrançois Tigeot */
182303bf270SFrançois Tigeot for (s = 0; s < s_max; s++) {
1831e12ee3bSFrançois Tigeot if (!(sseu->slice_mask & BIT(s)))
184303bf270SFrançois Tigeot /* skip disabled slice */
185303bf270SFrançois Tigeot continue;
186303bf270SFrançois Tigeot
187303bf270SFrançois Tigeot eu_disable = I915_READ(GEN9_EU_DISABLE(s));
188303bf270SFrançois Tigeot for (ss = 0; ss < ss_max; ss++) {
189303bf270SFrançois Tigeot int eu_per_ss;
190303bf270SFrançois Tigeot
1911e12ee3bSFrançois Tigeot if (!(sseu->subslice_mask & BIT(ss)))
192303bf270SFrançois Tigeot /* skip disabled subslice */
193303bf270SFrançois Tigeot continue;
194303bf270SFrançois Tigeot
195303bf270SFrançois Tigeot eu_per_ss = eu_max - hweight8((eu_disable >> (ss*8)) &
196303bf270SFrançois Tigeot eu_mask);
197303bf270SFrançois Tigeot
198303bf270SFrançois Tigeot /*
199303bf270SFrançois Tigeot * Record which subslice(s) has(have) 7 EUs. we
200303bf270SFrançois Tigeot * can tune the hash used to spread work among
201303bf270SFrançois Tigeot * subslices if they are unbalanced.
202303bf270SFrançois Tigeot */
203303bf270SFrançois Tigeot if (eu_per_ss == 7)
2041e12ee3bSFrançois Tigeot sseu->subslice_7eu[s] |= BIT(ss);
205303bf270SFrançois Tigeot
2061e12ee3bSFrançois Tigeot sseu->eu_total += eu_per_ss;
207303bf270SFrançois Tigeot }
208303bf270SFrançois Tigeot }
209303bf270SFrançois Tigeot
210303bf270SFrançois Tigeot /*
211303bf270SFrançois Tigeot * SKL is expected to always have a uniform distribution
212303bf270SFrançois Tigeot * of EU across subslices with the exception that any one
213303bf270SFrançois Tigeot * EU in any one subslice may be fused off for die
214303bf270SFrançois Tigeot * recovery. BXT is expected to be perfectly uniform in EU
215303bf270SFrançois Tigeot * distribution.
216303bf270SFrançois Tigeot */
2171e12ee3bSFrançois Tigeot sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
2181e12ee3bSFrançois Tigeot DIV_ROUND_UP(sseu->eu_total,
2191e12ee3bSFrançois Tigeot sseu_subslice_total(sseu)) : 0;
220303bf270SFrançois Tigeot /*
221*3f2dd94aSFrançois Tigeot * SKL+ supports slice power gating on devices with more than
222303bf270SFrançois Tigeot * one slice, and supports EU power gating on devices with
223*3f2dd94aSFrançois Tigeot * more than one EU pair per subslice. BXT+ supports subslice
224303bf270SFrançois Tigeot * power gating on devices with more than one subslice, and
225303bf270SFrançois Tigeot * supports EU power gating on devices with more than one EU
226303bf270SFrançois Tigeot * pair per subslice.
227303bf270SFrançois Tigeot */
2281e12ee3bSFrançois Tigeot sseu->has_slice_pg =
229*3f2dd94aSFrançois Tigeot !IS_GEN9_LP(dev_priv) && hweight8(sseu->slice_mask) > 1;
2301e12ee3bSFrançois Tigeot sseu->has_subslice_pg =
231a85cb24fSFrançois Tigeot IS_GEN9_LP(dev_priv) && sseu_subslice_total(sseu) > 1;
2321e12ee3bSFrançois Tigeot sseu->has_eu_pg = sseu->eu_per_subslice > 2;
233303bf270SFrançois Tigeot
234a85cb24fSFrançois Tigeot if (IS_GEN9_LP(dev_priv)) {
2351e12ee3bSFrançois Tigeot #define IS_SS_DISABLED(ss) (!(sseu->subslice_mask & BIT(ss)))
236a85cb24fSFrançois Tigeot info->has_pooled_eu = hweight8(sseu->subslice_mask) == 3;
237a85cb24fSFrançois Tigeot
238303bf270SFrançois Tigeot /*
239303bf270SFrançois Tigeot * There is a HW issue in 2x6 fused down parts that requires
240303bf270SFrançois Tigeot * Pooled EU to be enabled as a WA. The pool configuration
241303bf270SFrançois Tigeot * changes depending upon which subslice is fused down. This
242303bf270SFrançois Tigeot * doesn't affect if the device has all 3 subslices enabled.
243303bf270SFrançois Tigeot */
244303bf270SFrançois Tigeot /* WaEnablePooledEuFor2x6:bxt */
245a85cb24fSFrançois Tigeot info->has_pooled_eu |= (hweight8(sseu->subslice_mask) == 2 &&
246a85cb24fSFrançois Tigeot IS_BXT_REVID(dev_priv, 0, BXT_REVID_B_LAST));
247303bf270SFrançois Tigeot
2481e12ee3bSFrançois Tigeot sseu->min_eu_in_pool = 0;
249303bf270SFrançois Tigeot if (info->has_pooled_eu) {
2501e12ee3bSFrançois Tigeot if (IS_SS_DISABLED(2) || IS_SS_DISABLED(0))
2511e12ee3bSFrançois Tigeot sseu->min_eu_in_pool = 3;
2521e12ee3bSFrançois Tigeot else if (IS_SS_DISABLED(1))
2531e12ee3bSFrançois Tigeot sseu->min_eu_in_pool = 6;
254303bf270SFrançois Tigeot else
2551e12ee3bSFrançois Tigeot sseu->min_eu_in_pool = 9;
256303bf270SFrançois Tigeot }
257303bf270SFrançois Tigeot #undef IS_SS_DISABLED
258303bf270SFrançois Tigeot }
259303bf270SFrançois Tigeot }
260303bf270SFrançois Tigeot
broadwell_sseu_info_init(struct drm_i915_private * dev_priv)261303bf270SFrançois Tigeot static void broadwell_sseu_info_init(struct drm_i915_private *dev_priv)
262303bf270SFrançois Tigeot {
2631e12ee3bSFrançois Tigeot struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu;
264303bf270SFrançois Tigeot const int s_max = 3, ss_max = 3, eu_max = 8;
265303bf270SFrançois Tigeot int s, ss;
2661e12ee3bSFrançois Tigeot u32 fuse2, eu_disable[3]; /* s_max */
267303bf270SFrançois Tigeot
268303bf270SFrançois Tigeot fuse2 = I915_READ(GEN8_FUSE2);
2691e12ee3bSFrançois Tigeot sseu->slice_mask = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
2701e12ee3bSFrançois Tigeot /*
2711e12ee3bSFrançois Tigeot * The subslice disable field is global, i.e. it applies
2721e12ee3bSFrançois Tigeot * to each of the enabled slices.
2731e12ee3bSFrançois Tigeot */
274a85cb24fSFrançois Tigeot sseu->subslice_mask = GENMASK(ss_max - 1, 0);
2751e12ee3bSFrançois Tigeot sseu->subslice_mask &= ~((fuse2 & GEN8_F2_SS_DIS_MASK) >>
2761e12ee3bSFrançois Tigeot GEN8_F2_SS_DIS_SHIFT);
277303bf270SFrançois Tigeot
278303bf270SFrançois Tigeot eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) & GEN8_EU_DIS0_S0_MASK;
279303bf270SFrançois Tigeot eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >> GEN8_EU_DIS0_S1_SHIFT) |
280303bf270SFrançois Tigeot ((I915_READ(GEN8_EU_DISABLE1) & GEN8_EU_DIS1_S1_MASK) <<
281303bf270SFrançois Tigeot (32 - GEN8_EU_DIS0_S1_SHIFT));
282303bf270SFrançois Tigeot eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >> GEN8_EU_DIS1_S2_SHIFT) |
283303bf270SFrançois Tigeot ((I915_READ(GEN8_EU_DISABLE2) & GEN8_EU_DIS2_S2_MASK) <<
284303bf270SFrançois Tigeot (32 - GEN8_EU_DIS1_S2_SHIFT));
285303bf270SFrançois Tigeot
286303bf270SFrançois Tigeot /*
287303bf270SFrançois Tigeot * Iterate through enabled slices and subslices to
288303bf270SFrançois Tigeot * count the total enabled EU.
289303bf270SFrançois Tigeot */
290303bf270SFrançois Tigeot for (s = 0; s < s_max; s++) {
2911e12ee3bSFrançois Tigeot if (!(sseu->slice_mask & BIT(s)))
292303bf270SFrançois Tigeot /* skip disabled slice */
293303bf270SFrançois Tigeot continue;
294303bf270SFrançois Tigeot
295303bf270SFrançois Tigeot for (ss = 0; ss < ss_max; ss++) {
296303bf270SFrançois Tigeot u32 n_disabled;
297303bf270SFrançois Tigeot
2981e12ee3bSFrançois Tigeot if (!(sseu->subslice_mask & BIT(ss)))
299303bf270SFrançois Tigeot /* skip disabled subslice */
300303bf270SFrançois Tigeot continue;
301303bf270SFrançois Tigeot
302303bf270SFrançois Tigeot n_disabled = hweight8(eu_disable[s] >> (ss * eu_max));
303303bf270SFrançois Tigeot
304303bf270SFrançois Tigeot /*
305303bf270SFrançois Tigeot * Record which subslices have 7 EUs.
306303bf270SFrançois Tigeot */
307303bf270SFrançois Tigeot if (eu_max - n_disabled == 7)
3081e12ee3bSFrançois Tigeot sseu->subslice_7eu[s] |= 1 << ss;
309303bf270SFrançois Tigeot
3101e12ee3bSFrançois Tigeot sseu->eu_total += eu_max - n_disabled;
311303bf270SFrançois Tigeot }
312303bf270SFrançois Tigeot }
313303bf270SFrançois Tigeot
314303bf270SFrançois Tigeot /*
315303bf270SFrançois Tigeot * BDW is expected to always have a uniform distribution of EU across
316303bf270SFrançois Tigeot * subslices with the exception that any one EU in any one subslice may
317303bf270SFrançois Tigeot * be fused off for die recovery.
318303bf270SFrançois Tigeot */
3191e12ee3bSFrançois Tigeot sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
3201e12ee3bSFrançois Tigeot DIV_ROUND_UP(sseu->eu_total,
3211e12ee3bSFrançois Tigeot sseu_subslice_total(sseu)) : 0;
322303bf270SFrançois Tigeot
323303bf270SFrançois Tigeot /*
324303bf270SFrançois Tigeot * BDW supports slice power gating on devices with more than
325303bf270SFrançois Tigeot * one slice.
326303bf270SFrançois Tigeot */
3271e12ee3bSFrançois Tigeot sseu->has_slice_pg = hweight8(sseu->slice_mask) > 1;
3281e12ee3bSFrançois Tigeot sseu->has_subslice_pg = 0;
3291e12ee3bSFrançois Tigeot sseu->has_eu_pg = 0;
330303bf270SFrançois Tigeot }
331303bf270SFrançois Tigeot
332303bf270SFrançois Tigeot /*
333303bf270SFrançois Tigeot * Determine various intel_device_info fields at runtime.
334303bf270SFrançois Tigeot *
335303bf270SFrançois Tigeot * Use it when either:
336303bf270SFrançois Tigeot * - it's judged too laborious to fill n static structures with the limit
337303bf270SFrançois Tigeot * when a simple if statement does the job,
338303bf270SFrançois Tigeot * - run-time checks (eg read fuse/strap registers) are needed.
339303bf270SFrançois Tigeot *
340303bf270SFrançois Tigeot * This function needs to be called:
341303bf270SFrançois Tigeot * - after the MMIO has been setup as we are reading registers,
342303bf270SFrançois Tigeot * - after the PCH has been detected,
343303bf270SFrançois Tigeot * - before the first usage of the fields it can tweak.
344303bf270SFrançois Tigeot */
intel_device_info_runtime_init(struct drm_i915_private * dev_priv)345303bf270SFrançois Tigeot void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
346303bf270SFrançois Tigeot {
347303bf270SFrançois Tigeot struct intel_device_info *info = mkwrite_device_info(dev_priv);
348303bf270SFrançois Tigeot enum i915_pipe pipe;
349303bf270SFrançois Tigeot
350a85cb24fSFrançois Tigeot if (INTEL_GEN(dev_priv) >= 9) {
351a85cb24fSFrançois Tigeot info->num_scalers[PIPE_A] = 2;
352a85cb24fSFrançois Tigeot info->num_scalers[PIPE_B] = 2;
353a85cb24fSFrançois Tigeot info->num_scalers[PIPE_C] = 1;
354a85cb24fSFrançois Tigeot }
355a85cb24fSFrançois Tigeot
356303bf270SFrançois Tigeot /*
357303bf270SFrançois Tigeot * Skylake and Broxton currently don't expose the topmost plane as its
358303bf270SFrançois Tigeot * use is exclusive with the legacy cursor and we only want to expose
359303bf270SFrançois Tigeot * one of those, not both. Until we can safely expose the topmost plane
360303bf270SFrançois Tigeot * as a DRM_PLANE_TYPE_CURSOR with all the features exposed/supported,
361303bf270SFrançois Tigeot * we don't expose the topmost plane at all to prevent ABI breakage
362303bf270SFrançois Tigeot * down the line.
363303bf270SFrançois Tigeot */
364*3f2dd94aSFrançois Tigeot if (IS_GEN10(dev_priv) || IS_GEMINILAKE(dev_priv))
365a85cb24fSFrançois Tigeot for_each_pipe(dev_priv, pipe)
366a85cb24fSFrançois Tigeot info->num_sprites[pipe] = 3;
367a85cb24fSFrançois Tigeot else if (IS_BROXTON(dev_priv)) {
368303bf270SFrançois Tigeot info->num_sprites[PIPE_A] = 2;
369303bf270SFrançois Tigeot info->num_sprites[PIPE_B] = 2;
370303bf270SFrançois Tigeot info->num_sprites[PIPE_C] = 1;
3714be47400SFrançois Tigeot } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
372303bf270SFrançois Tigeot for_each_pipe(dev_priv, pipe)
373303bf270SFrançois Tigeot info->num_sprites[pipe] = 2;
374*3f2dd94aSFrançois Tigeot } else if (INTEL_GEN(dev_priv) >= 5 || IS_G4X(dev_priv)) {
375303bf270SFrançois Tigeot for_each_pipe(dev_priv, pipe)
376303bf270SFrançois Tigeot info->num_sprites[pipe] = 1;
3774be47400SFrançois Tigeot }
378303bf270SFrançois Tigeot
379*3f2dd94aSFrançois Tigeot if (i915_modparams.disable_display) {
380303bf270SFrançois Tigeot DRM_INFO("Display disabled (module parameter)\n");
381303bf270SFrançois Tigeot info->num_pipes = 0;
382303bf270SFrançois Tigeot } else if (info->num_pipes > 0 &&
383303bf270SFrançois Tigeot (IS_GEN7(dev_priv) || IS_GEN8(dev_priv)) &&
384303bf270SFrançois Tigeot HAS_PCH_SPLIT(dev_priv)) {
385303bf270SFrançois Tigeot u32 fuse_strap = I915_READ(FUSE_STRAP);
386303bf270SFrançois Tigeot u32 sfuse_strap = I915_READ(SFUSE_STRAP);
387303bf270SFrançois Tigeot
388303bf270SFrançois Tigeot /*
389303bf270SFrançois Tigeot * SFUSE_STRAP is supposed to have a bit signalling the display
390303bf270SFrançois Tigeot * is fused off. Unfortunately it seems that, at least in
391303bf270SFrançois Tigeot * certain cases, fused off display means that PCH display
392303bf270SFrançois Tigeot * reads don't land anywhere. In that case, we read 0s.
393303bf270SFrançois Tigeot *
394303bf270SFrançois Tigeot * On CPT/PPT, we can detect this case as SFUSE_STRAP_FUSE_LOCK
395303bf270SFrançois Tigeot * should be set when taking over after the firmware.
396303bf270SFrançois Tigeot */
397303bf270SFrançois Tigeot if (fuse_strap & ILK_INTERNAL_DISPLAY_DISABLE ||
398303bf270SFrançois Tigeot sfuse_strap & SFUSE_STRAP_DISPLAY_DISABLED ||
399*3f2dd94aSFrançois Tigeot (HAS_PCH_CPT(dev_priv) &&
400303bf270SFrançois Tigeot !(sfuse_strap & SFUSE_STRAP_FUSE_LOCK))) {
401303bf270SFrançois Tigeot DRM_INFO("Display fused off, disabling\n");
402303bf270SFrançois Tigeot info->num_pipes = 0;
403303bf270SFrançois Tigeot } else if (fuse_strap & IVB_PIPE_C_DISABLE) {
404303bf270SFrançois Tigeot DRM_INFO("PipeC fused off\n");
405303bf270SFrançois Tigeot info->num_pipes -= 1;
406303bf270SFrançois Tigeot }
407303bf270SFrançois Tigeot } else if (info->num_pipes > 0 && IS_GEN9(dev_priv)) {
408303bf270SFrançois Tigeot u32 dfsm = I915_READ(SKL_DFSM);
409303bf270SFrançois Tigeot u8 disabled_mask = 0;
410303bf270SFrançois Tigeot bool invalid;
411303bf270SFrançois Tigeot int num_bits;
412303bf270SFrançois Tigeot
413303bf270SFrançois Tigeot if (dfsm & SKL_DFSM_PIPE_A_DISABLE)
414303bf270SFrançois Tigeot disabled_mask |= BIT(PIPE_A);
415303bf270SFrançois Tigeot if (dfsm & SKL_DFSM_PIPE_B_DISABLE)
416303bf270SFrançois Tigeot disabled_mask |= BIT(PIPE_B);
417303bf270SFrançois Tigeot if (dfsm & SKL_DFSM_PIPE_C_DISABLE)
418303bf270SFrançois Tigeot disabled_mask |= BIT(PIPE_C);
419303bf270SFrançois Tigeot
420303bf270SFrançois Tigeot num_bits = hweight8(disabled_mask);
421303bf270SFrançois Tigeot
422303bf270SFrançois Tigeot switch (disabled_mask) {
423303bf270SFrançois Tigeot case BIT(PIPE_A):
424303bf270SFrançois Tigeot case BIT(PIPE_B):
425303bf270SFrançois Tigeot case BIT(PIPE_A) | BIT(PIPE_B):
426303bf270SFrançois Tigeot case BIT(PIPE_A) | BIT(PIPE_C):
427303bf270SFrançois Tigeot invalid = true;
428303bf270SFrançois Tigeot break;
429303bf270SFrançois Tigeot default:
430303bf270SFrançois Tigeot invalid = false;
431303bf270SFrançois Tigeot }
432303bf270SFrançois Tigeot
433303bf270SFrançois Tigeot if (num_bits > info->num_pipes || invalid)
434303bf270SFrançois Tigeot DRM_ERROR("invalid pipe fuse configuration: 0x%x\n",
435303bf270SFrançois Tigeot disabled_mask);
436303bf270SFrançois Tigeot else
437303bf270SFrançois Tigeot info->num_pipes -= num_bits;
438303bf270SFrançois Tigeot }
439303bf270SFrançois Tigeot
440303bf270SFrançois Tigeot /* Initialize slice/subslice/EU info */
441303bf270SFrançois Tigeot if (IS_CHERRYVIEW(dev_priv))
442303bf270SFrançois Tigeot cherryview_sseu_info_init(dev_priv);
443303bf270SFrançois Tigeot else if (IS_BROADWELL(dev_priv))
444303bf270SFrançois Tigeot broadwell_sseu_info_init(dev_priv);
445*3f2dd94aSFrançois Tigeot else if (INTEL_GEN(dev_priv) == 9)
446303bf270SFrançois Tigeot gen9_sseu_info_init(dev_priv);
447*3f2dd94aSFrançois Tigeot else if (INTEL_GEN(dev_priv) >= 10)
448*3f2dd94aSFrançois Tigeot gen10_sseu_info_init(dev_priv);
449303bf270SFrançois Tigeot
4501e12ee3bSFrançois Tigeot DRM_DEBUG_DRIVER("slice mask: %04x\n", info->sseu.slice_mask);
4511e12ee3bSFrançois Tigeot DRM_DEBUG_DRIVER("slice total: %u\n", hweight8(info->sseu.slice_mask));
4521e12ee3bSFrançois Tigeot DRM_DEBUG_DRIVER("subslice total: %u\n",
4531e12ee3bSFrançois Tigeot sseu_subslice_total(&info->sseu));
4541e12ee3bSFrançois Tigeot DRM_DEBUG_DRIVER("subslice mask %04x\n", info->sseu.subslice_mask);
4551e12ee3bSFrançois Tigeot DRM_DEBUG_DRIVER("subslice per slice: %u\n",
4561e12ee3bSFrançois Tigeot hweight8(info->sseu.subslice_mask));
4571e12ee3bSFrançois Tigeot DRM_DEBUG_DRIVER("EU total: %u\n", info->sseu.eu_total);
4581e12ee3bSFrançois Tigeot DRM_DEBUG_DRIVER("EU per subslice: %u\n", info->sseu.eu_per_subslice);
459303bf270SFrançois Tigeot DRM_DEBUG_DRIVER("has slice power gating: %s\n",
4601e12ee3bSFrançois Tigeot info->sseu.has_slice_pg ? "y" : "n");
461303bf270SFrançois Tigeot DRM_DEBUG_DRIVER("has subslice power gating: %s\n",
4621e12ee3bSFrançois Tigeot info->sseu.has_subslice_pg ? "y" : "n");
463303bf270SFrançois Tigeot DRM_DEBUG_DRIVER("has EU power gating: %s\n",
4641e12ee3bSFrançois Tigeot info->sseu.has_eu_pg ? "y" : "n");
465303bf270SFrançois Tigeot }
466