1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2019 Intel Corporation
6 #ifndef __INTEL_SSEU_H__
7 #define __INTEL_SSEU_H__
9 #include <linux/types.h>
10 #include <linux/kernel.h>
14 struct drm_i915_private;
19 * Maximum number of slices on older platforms. Slices no longer exist
20 * starting on Xe_HP ("gslices," "cslices," etc. are a different concept and
21 * are not expressed through fusing).
23 #define GEN_MAX_HSW_SLICES 3
26 * Maximum number of subslices that can exist within a HSW-style slice. This
27 * is only relevant to pre-Xe_HP platforms (Xe_HP and beyond use the
28 * I915_MAX_SS_FUSE_BITS value below).
30 #define GEN_MAX_SS_PER_HSW_SLICE 8
33 * Maximum number of 32-bit registers used by hardware to express the
34 * enabled/disabled subslices.
36 #define I915_MAX_SS_FUSE_REGS 2
37 #define I915_MAX_SS_FUSE_BITS (I915_MAX_SS_FUSE_REGS * 32)
39 /* Maximum number of EUs that can exist within a subslice or DSS. */
40 #define GEN_MAX_EUS_PER_SS 16
42 #define SSEU_MAX(a, b) ((a) > (b) ? (a) : (b))
44 /* The maximum number of bits needed to express each subslice/DSS independently */
45 #define GEN_SS_MASK_SIZE SSEU_MAX(I915_MAX_SS_FUSE_BITS, \
46 GEN_MAX_HSW_SLICES * GEN_MAX_SS_PER_HSW_SLICE)
48 #define GEN_SSEU_STRIDE(max_entries) DIV_ROUND_UP(max_entries, BITS_PER_BYTE)
49 #define GEN_MAX_SUBSLICE_STRIDE GEN_SSEU_STRIDE(GEN_SS_MASK_SIZE)
50 #define GEN_MAX_EU_STRIDE GEN_SSEU_STRIDE(GEN_MAX_EUS_PER_SS)
52 #define GEN_DSS_PER_GSLICE 4
53 #define GEN_DSS_PER_CSLICE 8
54 #define GEN_DSS_PER_MSLICE 8
56 #define GEN_MAX_GSLICES (I915_MAX_SS_FUSE_BITS / GEN_DSS_PER_GSLICE)
57 #define GEN_MAX_CSLICES (I915_MAX_SS_FUSE_BITS / GEN_DSS_PER_CSLICE)
60 u8 hsw[GEN_MAX_HSW_SLICES];
62 /* Bitmap compatible with linux/bitmap.h; may exceed size of u64 */
63 unsigned long xehp[BITS_TO_LONGS(I915_MAX_SS_FUSE_BITS)];
64 } intel_sseu_ss_mask_t;
66 #define XEHP_BITMAP_BITS(mask) ((int)BITS_PER_TYPE(typeof(mask.xehp)))
68 struct sseu_dev_info {
70 intel_sseu_ss_mask_t subslice_mask;
71 intel_sseu_ss_mask_t geometry_subslice_mask;
72 intel_sseu_ss_mask_t compute_subslice_mask;
74 u16 hsw[GEN_MAX_HSW_SLICES][GEN_MAX_SS_PER_HSW_SLICE];
75 u16 xehp[I915_MAX_SS_FUSE_BITS];
81 /* For each slice, which subslice(s) has(have) 7 EUs (bitfield)? */
87 * For Xe_HP and beyond, the hardware no longer has traditional slices
88 * so we just report the entire DSS pool under a fake "slice 0."
95 u8 max_eus_per_subslice;
99 * Powergating configuration for a particular (context,engine).
104 u8 min_eus_per_subslice;
105 u8 max_eus_per_subslice;
108 static inline struct intel_sseu
109 intel_sseu_from_device_info(const struct sseu_dev_info *sseu)
111 struct intel_sseu value = {
112 .slice_mask = sseu->slice_mask,
113 .subslice_mask = sseu->subslice_mask.hsw[0],
114 .min_eus_per_subslice = sseu->max_eus_per_subslice,
115 .max_eus_per_subslice = sseu->max_eus_per_subslice,
122 intel_sseu_has_subslice(const struct sseu_dev_info *sseu, int slice,
125 if (slice >= sseu->max_slices ||
126 subslice >= sseu->max_subslices)
129 if (sseu->has_xehp_dss)
130 return test_bit(subslice, sseu->subslice_mask.xehp);
132 return sseu->subslice_mask.hsw[slice] & BIT(subslice);
136 * Used to obtain the index of the first DSS. Can start searching from the
137 * beginning of a specific dss group (e.g., gslice, cslice, etc.) if
138 * groupsize and groupnum are non-zero.
140 static inline unsigned int
141 intel_sseu_find_first_xehp_dss(const struct sseu_dev_info *sseu, int groupsize,
144 return find_next_bit(sseu->subslice_mask.xehp,
145 XEHP_BITMAP_BITS(sseu->subslice_mask),
146 groupnum * groupsize);
149 void intel_sseu_set_info(struct sseu_dev_info *sseu, u8 max_slices,
150 u8 max_subslices, u8 max_eus_per_subslice);
153 intel_sseu_subslice_total(const struct sseu_dev_info *sseu);
156 intel_sseu_get_hsw_subslices(const struct sseu_dev_info *sseu, u8 slice);
159 intel_sseu_get_compute_subslices(const struct sseu_dev_info *sseu);
161 void intel_sseu_info_init(struct intel_gt *gt);
163 u32 intel_sseu_make_rpcs(struct intel_gt *gt,
164 const struct intel_sseu *req_sseu);
166 void intel_sseu_dump(const struct sseu_dev_info *sseu, struct drm_printer *p);
167 void intel_sseu_print_topology(struct drm_i915_private *i915,
168 const struct sseu_dev_info *sseu,
169 struct drm_printer *p);
171 u16 intel_slicemask_from_xehp_dssmask(intel_sseu_ss_mask_t dss_mask, int dss_per_slice);
173 int intel_sseu_copy_eumask_to_user(void __user *to,
174 const struct sseu_dev_info *sseu);
175 int intel_sseu_copy_ssmask_to_user(void __user *to,
176 const struct sseu_dev_info *sseu);
178 void intel_sseu_print_ss_info(const char *type,
179 const struct sseu_dev_info *sseu,
182 #endif /* __INTEL_SSEU_H__ */