i915_small_bar.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /**
  2. * struct __drm_i915_memory_region_info - Describes one region as known to the
  3. * driver.
  4. *
  5. * Note this is using both struct drm_i915_query_item and struct drm_i915_query.
  6. * For this new query we are adding the new query id DRM_I915_QUERY_MEMORY_REGIONS
  7. * at &drm_i915_query_item.query_id.
  8. */
  9. struct __drm_i915_memory_region_info {
  10. /** @region: The class:instance pair encoding */
  11. struct drm_i915_gem_memory_class_instance region;
  12. /** @rsvd0: MBZ */
  13. __u32 rsvd0;
  14. /**
  15. * @probed_size: Memory probed by the driver
  16. *
  17. * Note that it should not be possible to ever encounter a zero value
  18. * here, also note that no current region type will ever return -1 here.
  19. * Although for future region types, this might be a possibility. The
  20. * same applies to the other size fields.
  21. */
  22. __u64 probed_size;
  23. /**
  24. * @unallocated_size: Estimate of memory remaining
  25. *
  26. * Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable accounting.
  27. * Without this (or if this is an older kernel) the value here will
  28. * always equal the @probed_size. Note this is only currently tracked
  29. * for I915_MEMORY_CLASS_DEVICE regions (for other types the value here
  30. * will always equal the @probed_size).
  31. */
  32. __u64 unallocated_size;
  33. union {
  34. /** @rsvd1: MBZ */
  35. __u64 rsvd1[8];
  36. struct {
  37. /**
  38. * @probed_cpu_visible_size: Memory probed by the driver
  39. * that is CPU accessible.
  40. *
  41. * This will be always be <= @probed_size, and the
  42. * remainder (if there is any) will not be CPU
  43. * accessible.
  44. *
  45. * On systems without small BAR, the @probed_size will
  46. * always equal the @probed_cpu_visible_size, since all
  47. * of it will be CPU accessible.
  48. *
  49. * Note this is only tracked for
  50. * I915_MEMORY_CLASS_DEVICE regions (for other types the
  51. * value here will always equal the @probed_size).
  52. *
  53. * Note that if the value returned here is zero, then
  54. * this must be an old kernel which lacks the relevant
  55. * small-bar uAPI support (including
  56. * I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS), but on
  57. * such systems we should never actually end up with a
  58. * small BAR configuration, assuming we are able to load
  59. * the kernel module. Hence it should be safe to treat
  60. * this the same as when @probed_cpu_visible_size ==
  61. * @probed_size.
  62. */
  63. __u64 probed_cpu_visible_size;
  64. /**
  65. * @unallocated_cpu_visible_size: Estimate of CPU
  66. * visible memory remaining
  67. *
  68. * Note this is only tracked for
  69. * I915_MEMORY_CLASS_DEVICE regions (for other types the
  70. * value here will always equal the
  71. * @probed_cpu_visible_size).
  72. *
  73. * Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable
  74. * accounting. Without this the value here will always
  75. * equal the @probed_cpu_visible_size. Note this is only
  76. * currently tracked for I915_MEMORY_CLASS_DEVICE
  77. * regions (for other types the value here will also
  78. * always equal the @probed_cpu_visible_size).
  79. *
  80. * If this is an older kernel the value here will be
  81. * zero, see also @probed_cpu_visible_size.
  82. */
  83. __u64 unallocated_cpu_visible_size;
  84. };
  85. };
  86. };
  87. /**
  88. * struct __drm_i915_gem_create_ext - Existing gem_create behaviour, with added
  89. * extension support using struct i915_user_extension.
  90. *
  91. * Note that new buffer flags should be added here, at least for the stuff that
  92. * is immutable. Previously we would have two ioctls, one to create the object
  93. * with gem_create, and another to apply various parameters, however this
  94. * creates some ambiguity for the params which are considered immutable. Also in
  95. * general we're phasing out the various SET/GET ioctls.
  96. */
  97. struct __drm_i915_gem_create_ext {
  98. /**
  99. * @size: Requested size for the object.
  100. *
  101. * The (page-aligned) allocated size for the object will be returned.
  102. *
  103. * Note that for some devices we have might have further minimum
  104. * page-size restrictions (larger than 4K), like for device local-memory.
  105. * However in general the final size here should always reflect any
  106. * rounding up, if for example using the I915_GEM_CREATE_EXT_MEMORY_REGIONS
  107. * extension to place the object in device local-memory. The kernel will
  108. * always select the largest minimum page-size for the set of possible
  109. * placements as the value to use when rounding up the @size.
  110. */
  111. __u64 size;
  112. /**
  113. * @handle: Returned handle for the object.
  114. *
  115. * Object handles are nonzero.
  116. */
  117. __u32 handle;
  118. /**
  119. * @flags: Optional flags.
  120. *
  121. * Supported values:
  122. *
  123. * I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS - Signal to the kernel that
  124. * the object will need to be accessed via the CPU.
  125. *
  126. * Only valid when placing objects in I915_MEMORY_CLASS_DEVICE, and only
  127. * strictly required on configurations where some subset of the device
  128. * memory is directly visible/mappable through the CPU (which we also
  129. * call small BAR), like on some DG2+ systems. Note that this is quite
  130. * undesirable, but due to various factors like the client CPU, BIOS etc
  131. * it's something we can expect to see in the wild. See
  132. * &__drm_i915_memory_region_info.probed_cpu_visible_size for how to
  133. * determine if this system applies.
  134. *
  135. * Note that one of the placements MUST be I915_MEMORY_CLASS_SYSTEM, to
  136. * ensure the kernel can always spill the allocation to system memory,
  137. * if the object can't be allocated in the mappable part of
  138. * I915_MEMORY_CLASS_DEVICE.
  139. *
  140. * Also note that since the kernel only supports flat-CCS on objects
  141. * that can *only* be placed in I915_MEMORY_CLASS_DEVICE, we therefore
  142. * don't support I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS together with
  143. * flat-CCS.
  144. *
  145. * Without this hint, the kernel will assume that non-mappable
  146. * I915_MEMORY_CLASS_DEVICE is preferred for this object. Note that the
  147. * kernel can still migrate the object to the mappable part, as a last
  148. * resort, if userspace ever CPU faults this object, but this might be
  149. * expensive, and so ideally should be avoided.
  150. *
  151. * On older kernels which lack the relevant small-bar uAPI support (see
  152. * also &__drm_i915_memory_region_info.probed_cpu_visible_size),
  153. * usage of the flag will result in an error, but it should NEVER be
  154. * possible to end up with a small BAR configuration, assuming we can
  155. * also successfully load the i915 kernel module. In such cases the
  156. * entire I915_MEMORY_CLASS_DEVICE region will be CPU accessible, and as
  157. * such there are zero restrictions on where the object can be placed.
  158. */
  159. #define I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS (1 << 0)
  160. __u32 flags;
  161. /**
  162. * @extensions: The chain of extensions to apply to this object.
  163. *
  164. * This will be useful in the future when we need to support several
  165. * different extensions, and we need to apply more than one when
  166. * creating the object. See struct i915_user_extension.
  167. *
  168. * If we don't supply any extensions then we get the same old gem_create
  169. * behaviour.
  170. *
  171. * For I915_GEM_CREATE_EXT_MEMORY_REGIONS usage see
  172. * struct drm_i915_gem_create_ext_memory_regions.
  173. *
  174. * For I915_GEM_CREATE_EXT_PROTECTED_CONTENT usage see
  175. * struct drm_i915_gem_create_ext_protected_content.
  176. */
  177. #define I915_GEM_CREATE_EXT_MEMORY_REGIONS 0
  178. #define I915_GEM_CREATE_EXT_PROTECTED_CONTENT 1
  179. __u64 extensions;
  180. };