2 * SPDX-License-Identifier: MIT
4 * Copyright © 2019 Intel Corporation
8 #include "intel_lrc_reg.h"
9 #include "intel_sseu.h"
11 u32 intel_sseu_make_rpcs(struct drm_i915_private *i915,
12 const struct intel_sseu *req_sseu)
14 const struct sseu_dev_info *sseu = &RUNTIME_INFO(i915)->sseu;
15 bool subslice_pg = sseu->has_subslice_pg;
16 struct intel_sseu ctx_sseu;
21 * No explicit RPCS request is needed to ensure full
22 * slice/subslice/EU enablement prior to Gen9.
24 if (INTEL_GEN(i915) < 9)
28 * If i915/perf is active, we want a stable powergating configuration
31 * We could choose full enablement, but on ICL we know there are use
32 * cases which disable slices for functional, apart for performance
33 * reasons. So in this case we select a known stable subset.
35 if (!i915->perf.oa.exclusive_stream) {
38 ctx_sseu = intel_sseu_from_device_info(sseu);
40 if (IS_GEN(i915, 11)) {
42 * We only need subslice count so it doesn't matter
43 * which ones we select - just turn off low bits in the
44 * amount of half of all available subslices per slice.
46 ctx_sseu.subslice_mask =
47 ~(~0 << (hweight8(ctx_sseu.subslice_mask) / 2));
48 ctx_sseu.slice_mask = 0x1;
52 slices = hweight8(ctx_sseu.slice_mask);
53 subslices = hweight8(ctx_sseu.subslice_mask);
56 * Since the SScount bitfield in GEN8_R_PWR_CLK_STATE is only three bits
57 * wide and Icelake has up to eight subslices, specfial programming is
58 * needed in order to correctly enable all subslices.
60 * According to documentation software must consider the configuration
61 * as 2x4x8 and hardware will translate this to 1x8x8.
63 * Furthemore, even though SScount is three bits, maximum documented
64 * value for it is four. From this some rules/restrictions follow:
67 * If enabled subslice count is greater than four, two whole slices must
71 * When more than one slice is enabled, hardware ignores the subslice
74 * From these restrictions it follows that it is not possible to enable
75 * a count of subslices between the SScount maximum of four restriction,
76 * and the maximum available number on a particular SKU. Either all
77 * subslices are enabled, or a count between one and four on the first
80 if (IS_GEN(i915, 11) &&
82 subslices > min_t(u8, 4, hweight8(sseu->subslice_mask[0]) / 2)) {
83 GEM_BUG_ON(subslices & 1);
90 * Starting in Gen9, render power gating can leave
91 * slice/subslice/EU in a partially enabled state. We
92 * must make an explicit request through RPCS for full
95 if (sseu->has_slice_pg) {
96 u32 mask, val = slices;
98 if (INTEL_GEN(i915) >= 11) {
99 mask = GEN11_RPCS_S_CNT_MASK;
100 val <<= GEN11_RPCS_S_CNT_SHIFT;
102 mask = GEN8_RPCS_S_CNT_MASK;
103 val <<= GEN8_RPCS_S_CNT_SHIFT;
106 GEM_BUG_ON(val & ~mask);
109 rpcs |= GEN8_RPCS_ENABLE | GEN8_RPCS_S_CNT_ENABLE | val;
115 val <<= GEN8_RPCS_SS_CNT_SHIFT;
117 GEM_BUG_ON(val & ~GEN8_RPCS_SS_CNT_MASK);
118 val &= GEN8_RPCS_SS_CNT_MASK;
120 rpcs |= GEN8_RPCS_ENABLE | GEN8_RPCS_SS_CNT_ENABLE | val;
123 if (sseu->has_eu_pg) {
126 val = ctx_sseu.min_eus_per_subslice << GEN8_RPCS_EU_MIN_SHIFT;
127 GEM_BUG_ON(val & ~GEN8_RPCS_EU_MIN_MASK);
128 val &= GEN8_RPCS_EU_MIN_MASK;
132 val = ctx_sseu.max_eus_per_subslice << GEN8_RPCS_EU_MAX_SHIFT;
133 GEM_BUG_ON(val & ~GEN8_RPCS_EU_MAX_MASK);
134 val &= GEN8_RPCS_EU_MAX_MASK;
138 rpcs |= GEN8_RPCS_ENABLE;