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