intel_sseu.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright © 2019 Intel Corporation
  4. */
  5. #ifndef __INTEL_SSEU_H__
  6. #define __INTEL_SSEU_H__
  7. #include <linux/types.h>
  8. #include <linux/kernel.h>
  9. #include "i915_gem.h"
  10. struct drm_i915_private;
  11. struct intel_gt;
  12. struct drm_printer;
  13. /*
  14. * Maximum number of slices on older platforms. Slices no longer exist
  15. * starting on Xe_HP ("gslices," "cslices," etc. are a different concept and
  16. * are not expressed through fusing).
  17. */
  18. #define GEN_MAX_HSW_SLICES 3
  19. /*
  20. * Maximum number of subslices that can exist within a HSW-style slice. This
  21. * is only relevant to pre-Xe_HP platforms (Xe_HP and beyond use the
  22. * I915_MAX_SS_FUSE_BITS value below).
  23. */
  24. #define GEN_MAX_SS_PER_HSW_SLICE 8
  25. /*
  26. * Maximum number of 32-bit registers used by hardware to express the
  27. * enabled/disabled subslices.
  28. */
  29. #define I915_MAX_SS_FUSE_REGS 2
  30. #define I915_MAX_SS_FUSE_BITS (I915_MAX_SS_FUSE_REGS * 32)
  31. /* Maximum number of EUs that can exist within a subslice or DSS. */
  32. #define GEN_MAX_EUS_PER_SS 16
  33. #define SSEU_MAX(a, b) ((a) > (b) ? (a) : (b))
  34. /* The maximum number of bits needed to express each subslice/DSS independently */
  35. #define GEN_SS_MASK_SIZE SSEU_MAX(I915_MAX_SS_FUSE_BITS, \
  36. GEN_MAX_HSW_SLICES * GEN_MAX_SS_PER_HSW_SLICE)
  37. #define GEN_SSEU_STRIDE(max_entries) DIV_ROUND_UP(max_entries, BITS_PER_BYTE)
  38. #define GEN_MAX_SUBSLICE_STRIDE GEN_SSEU_STRIDE(GEN_SS_MASK_SIZE)
  39. #define GEN_MAX_EU_STRIDE GEN_SSEU_STRIDE(GEN_MAX_EUS_PER_SS)
  40. #define GEN_DSS_PER_GSLICE 4
  41. #define GEN_DSS_PER_CSLICE 8
  42. #define GEN_DSS_PER_MSLICE 8
  43. #define GEN_MAX_GSLICES (I915_MAX_SS_FUSE_BITS / GEN_DSS_PER_GSLICE)
  44. #define GEN_MAX_CSLICES (I915_MAX_SS_FUSE_BITS / GEN_DSS_PER_CSLICE)
  45. typedef union {
  46. u8 hsw[GEN_MAX_HSW_SLICES];
  47. /* Bitmap compatible with linux/bitmap.h; may exceed size of u64 */
  48. unsigned long xehp[BITS_TO_LONGS(I915_MAX_SS_FUSE_BITS)];
  49. } intel_sseu_ss_mask_t;
  50. #define XEHP_BITMAP_BITS(mask) ((int)BITS_PER_TYPE(typeof(mask.xehp)))
  51. struct sseu_dev_info {
  52. u8 slice_mask;
  53. intel_sseu_ss_mask_t subslice_mask;
  54. intel_sseu_ss_mask_t geometry_subslice_mask;
  55. intel_sseu_ss_mask_t compute_subslice_mask;
  56. union {
  57. u16 hsw[GEN_MAX_HSW_SLICES][GEN_MAX_SS_PER_HSW_SLICE];
  58. u16 xehp[I915_MAX_SS_FUSE_BITS];
  59. } eu_mask;
  60. u16 eu_total;
  61. u8 eu_per_subslice;
  62. u8 min_eu_in_pool;
  63. /* For each slice, which subslice(s) has(have) 7 EUs (bitfield)? */
  64. u8 subslice_7eu[3];
  65. u8 has_slice_pg:1;
  66. u8 has_subslice_pg:1;
  67. u8 has_eu_pg:1;
  68. /*
  69. * For Xe_HP and beyond, the hardware no longer has traditional slices
  70. * so we just report the entire DSS pool under a fake "slice 0."
  71. */
  72. u8 has_xehp_dss:1;
  73. /* Topology fields */
  74. u8 max_slices;
  75. u8 max_subslices;
  76. u8 max_eus_per_subslice;
  77. };
  78. /*
  79. * Powergating configuration for a particular (context,engine).
  80. */
  81. struct intel_sseu {
  82. u8 slice_mask;
  83. u8 subslice_mask;
  84. u8 min_eus_per_subslice;
  85. u8 max_eus_per_subslice;
  86. };
  87. static inline struct intel_sseu
  88. intel_sseu_from_device_info(const struct sseu_dev_info *sseu)
  89. {
  90. struct intel_sseu value = {
  91. .slice_mask = sseu->slice_mask,
  92. .subslice_mask = sseu->subslice_mask.hsw[0],
  93. .min_eus_per_subslice = sseu->max_eus_per_subslice,
  94. .max_eus_per_subslice = sseu->max_eus_per_subslice,
  95. };
  96. return value;
  97. }
  98. static inline bool
  99. intel_sseu_has_subslice(const struct sseu_dev_info *sseu, int slice,
  100. int subslice)
  101. {
  102. if (slice >= sseu->max_slices ||
  103. subslice >= sseu->max_subslices)
  104. return false;
  105. if (sseu->has_xehp_dss)
  106. return test_bit(subslice, sseu->subslice_mask.xehp);
  107. else
  108. return sseu->subslice_mask.hsw[slice] & BIT(subslice);
  109. }
  110. /*
  111. * Used to obtain the index of the first DSS. Can start searching from the
  112. * beginning of a specific dss group (e.g., gslice, cslice, etc.) if
  113. * groupsize and groupnum are non-zero.
  114. */
  115. static inline unsigned int
  116. intel_sseu_find_first_xehp_dss(const struct sseu_dev_info *sseu, int groupsize,
  117. int groupnum)
  118. {
  119. return find_next_bit(sseu->subslice_mask.xehp,
  120. XEHP_BITMAP_BITS(sseu->subslice_mask),
  121. groupnum * groupsize);
  122. }
  123. void intel_sseu_set_info(struct sseu_dev_info *sseu, u8 max_slices,
  124. u8 max_subslices, u8 max_eus_per_subslice);
  125. unsigned int
  126. intel_sseu_subslice_total(const struct sseu_dev_info *sseu);
  127. unsigned int
  128. intel_sseu_get_hsw_subslices(const struct sseu_dev_info *sseu, u8 slice);
  129. intel_sseu_ss_mask_t
  130. intel_sseu_get_compute_subslices(const struct sseu_dev_info *sseu);
  131. void intel_sseu_info_init(struct intel_gt *gt);
  132. u32 intel_sseu_make_rpcs(struct intel_gt *gt,
  133. const struct intel_sseu *req_sseu);
  134. void intel_sseu_dump(const struct sseu_dev_info *sseu, struct drm_printer *p);
  135. void intel_sseu_print_topology(struct drm_i915_private *i915,
  136. const struct sseu_dev_info *sseu,
  137. struct drm_printer *p);
  138. u16 intel_slicemask_from_xehp_dssmask(intel_sseu_ss_mask_t dss_mask, int dss_per_slice);
  139. int intel_sseu_copy_eumask_to_user(void __user *to,
  140. const struct sseu_dev_info *sseu);
  141. int intel_sseu_copy_ssmask_to_user(void __user *to,
  142. const struct sseu_dev_info *sseu);
  143. void intel_sseu_print_ss_info(const char *type,
  144. const struct sseu_dev_info *sseu,
  145. struct seq_file *m);
  146. #endif /* __INTEL_SSEU_H__ */