drm/i915: Add function to determine if a slice has a subslice
authorStuart Summers <stuart.summers@intel.com>
Fri, 23 Aug 2019 16:03:04 +0000 (09:03 -0700)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 23 Aug 2019 18:14:25 +0000 (19:14 +0100)
Add a new function to determine whether a particular slice
has a given subslice.

Signed-off-by: Stuart Summers <stuart.summers@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190823160307.180813-9-stuart.summers@intel.com
drivers/gpu/drm/i915/gt/intel_sseu.h
drivers/gpu/drm/i915/intel_device_info.c

index 73a9064291a2e1e90790a266b63ae7d94790e7c1..7703d75f2da311d25eb66eccaf0be570483c54a5 100644 (file)
@@ -10,6 +10,8 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 
+#include "i915_gem.h"
+
 struct drm_i915_private;
 
 #define GEN_MAX_SLICES         (6) /* CNL upper bound */
@@ -69,6 +71,20 @@ intel_sseu_from_device_info(const struct sseu_dev_info *sseu)
        return value;
 }
 
+static inline bool
+intel_sseu_has_subslice(const struct sseu_dev_info *sseu, int slice,
+                       int subslice)
+{
+       u8 mask;
+       int ss_idx = subslice / BITS_PER_BYTE;
+
+       GEM_BUG_ON(ss_idx >= sseu->ss_stride);
+
+       mask = sseu->subslice_mask[slice * sseu->ss_stride + ss_idx];
+
+       return mask & BIT(subslice % BITS_PER_BYTE);
+}
+
 void intel_sseu_set_info(struct sseu_dev_info *sseu, u8 max_slices,
                         u8 max_subslices, u8 max_eus_per_subslice);
 
index 1a45728ac7126e0822826bf530b3c05ad66d2f5a..c20f74ee5f2271363b39a371e4c1e445793b8fc3 100644 (file)
@@ -210,10 +210,9 @@ static void gen11_sseu_info_init(struct drm_i915_private *dev_priv)
                        intel_sseu_set_subslices(sseu, s, (ss_en >> ss_idx) &
                                                          ss_en_mask);
 
-                       for (ss = 0; ss < sseu->max_subslices; ss++) {
-                               if (sseu->subslice_mask[s] & BIT(ss))
+                       for (ss = 0; ss < sseu->max_subslices; ss++)
+                               if (intel_sseu_has_subslice(sseu, s, ss))
                                        sseu_set_eus(sseu, s, ss, eu_en);
-                       }
                }
        }
        sseu->eu_per_subslice = hweight8(eu_en);
@@ -395,7 +394,7 @@ static void gen9_sseu_info_init(struct drm_i915_private *dev_priv)
                        int eu_per_ss;
                        u8 eu_disabled_mask;
 
-                       if (!(sseu->subslice_mask[s] & BIT(ss)))
+                       if (!intel_sseu_has_subslice(sseu, s, ss))
                                /* skip disabled subslice */
                                continue;
 
@@ -501,7 +500,7 @@ static void broadwell_sseu_info_init(struct drm_i915_private *dev_priv)
                        u8 eu_disabled_mask;
                        u32 n_disabled;
 
-                       if (!(sseu->subslice_mask[s] & BIT(ss)))
+                       if (!intel_sseu_has_subslice(sseu, s, ss))
                                /* skip disabled subslice */
                                continue;