Mesa (main): intel/dev: reuse internal functions to set mask
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Nov 5 10:36:24 UTC 2021
Module: Mesa
Branch: main
Commit: e10c641f009b006cc4d7b5fa70be34abdd75dc0b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e10c641f009b006cc4d7b5fa70be34abdd75dc0b
Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date: Sat Apr 3 13:23:55 2021 +0300
intel/dev: reuse internal functions to set mask
Rather than having 2 paths to set the slice/subslice/eu masks, reuse
the other internal functions. This simplifies finding bugs within this
code :
* If we have i915 query topology support, update_from_topology() is
called.
* If we don't have query topology support but we have getparam for
slice/subslice/EU, we generate a topology data and call
update_from_topology()
* If we have no kernel support to query any kind of topology, we
generate the values return by the kernel for slice/subslice/EU and
call update_from_masks() which in turns calls
update_from_topology()
v2: Fixup typo (Adam)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Francisco Jerez <currojerez at riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10015>
---
src/intel/dev/intel_device_info.c | 71 +++++++++++----------------------------
1 file changed, 20 insertions(+), 51 deletions(-)
diff --git a/src/intel/dev/intel_device_info.c b/src/intel/dev/intel_device_info.c
index b276f357d7d..7bf021fc8e4 100644
--- a/src/intel/dev/intel_device_info.c
+++ b/src/intel/dev/intel_device_info.c
@@ -1015,57 +1015,6 @@ static const struct intel_device_info intel_device_info_sg1 = {
GFX12_DG1_SG1_FEATURES,
};
-static void
-intel_device_info_set_eu_mask(struct intel_device_info *devinfo,
- unsigned slice,
- unsigned subslice,
- unsigned eu_mask)
-{
- unsigned subslice_offset = slice * devinfo->eu_slice_stride +
- subslice * devinfo->eu_subslice_stride;
-
- for (unsigned b_eu = 0; b_eu < devinfo->eu_subslice_stride; b_eu++) {
- devinfo->eu_masks[subslice_offset + b_eu] =
- (((1U << devinfo->num_eu_per_subslice) - 1) >> (b_eu * 8)) & 0xff;
- }
-}
-
-/* Generate slice/subslice/eu masks from number of
- * slices/subslices/eu_per_subslices in the per generation/gt intel_device_info
- * structure.
- *
- * These can be overridden with values reported by the kernel either from
- * getparam SLICE_MASK/SUBSLICE_MASK values or from the kernel version 4.17+
- * through the i915 query uapi.
- */
-static void
-fill_masks(struct intel_device_info *devinfo)
-{
- devinfo->slice_masks = (1U << devinfo->num_slices) - 1;
-
- /* Subslice masks */
- unsigned max_subslices = 0;
- for (int s = 0; s < devinfo->num_slices; s++)
- max_subslices = MAX2(devinfo->num_subslices[s], max_subslices);
- devinfo->subslice_slice_stride = DIV_ROUND_UP(max_subslices, 8);
-
- for (int s = 0; s < devinfo->num_slices; s++) {
- devinfo->subslice_masks[s * devinfo->subslice_slice_stride] =
- (1U << devinfo->num_subslices[s]) - 1;
- }
-
- /* EU masks */
- devinfo->eu_subslice_stride = DIV_ROUND_UP(devinfo->num_eu_per_subslice, 8);
- devinfo->eu_slice_stride = max_subslices * devinfo->eu_subslice_stride;
-
- for (int s = 0; s < devinfo->num_slices; s++) {
- for (int ss = 0; ss < devinfo->num_subslices[s]; ss++) {
- intel_device_info_set_eu_mask(devinfo, s, ss,
- (1U << devinfo->num_eu_per_subslice) - 1);
- }
- }
-}
-
static void
reset_masks(struct intel_device_info *devinfo)
{
@@ -1163,6 +1112,9 @@ update_from_topology(struct intel_device_info *devinfo,
devinfo->num_eu_per_subslice = DIV_ROUND_UP(n_eus, n_subslices);
}
+/* Generate detailed mask from the I915_PARAM_SLICE_MASK,
+ * I915_PARAM_SUBSLICE_MASK & I915_PARAM_EU_TOTAL getparam.
+ */
static bool
update_from_masks(struct intel_device_info *devinfo, uint32_t slice_mask,
uint32_t subslice_mask, uint32_t n_eus)
@@ -1224,6 +1176,23 @@ update_from_masks(struct intel_device_info *devinfo, uint32_t slice_mask,
return true;
}
+/* Generate mask from the device data. */
+static void
+fill_masks(struct intel_device_info *devinfo)
+{
+ /* All of our internal device descriptions assign the same number of
+ * subslices for each slice. Just verify that this is true.
+ */
+ for (int s = 1; s < devinfo->num_slices; s++)
+ assert(devinfo->num_subslices[0] == devinfo->num_subslices[s]);
+
+ update_from_masks(devinfo,
+ (1U << devinfo->num_slices) - 1,
+ (1U << devinfo->num_subslices[0]) - 1,
+ devinfo->num_slices * devinfo->num_subslices[0] *
+ devinfo->num_eu_per_subslice);
+}
+
static bool
getparam(int fd, uint32_t param, int *value)
{
More information about the mesa-commit
mailing list