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@intel.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10015>
This commit is contained in:
Lionel Landwerlin 2021-04-03 13:23:55 +03:00 committed by Marge Bot
parent d7c6a90c26
commit e10c641f00

View file

@ -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)
{