Path: blob/master/Documentation/gpu/rfc/i915_small_bar.h
26295 views
/**1* struct __drm_i915_memory_region_info - Describes one region as known to the2* driver.3*4* Note this is using both struct drm_i915_query_item and struct drm_i915_query.5* For this new query we are adding the new query id DRM_I915_QUERY_MEMORY_REGIONS6* at &drm_i915_query_item.query_id.7*/8struct __drm_i915_memory_region_info {9/** @region: The class:instance pair encoding */10struct drm_i915_gem_memory_class_instance region;1112/** @rsvd0: MBZ */13__u32 rsvd0;1415/**16* @probed_size: Memory probed by the driver17*18* Note that it should not be possible to ever encounter a zero value19* here, also note that no current region type will ever return -1 here.20* Although for future region types, this might be a possibility. The21* same applies to the other size fields.22*/23__u64 probed_size;2425/**26* @unallocated_size: Estimate of memory remaining27*28* Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable accounting.29* Without this (or if this is an older kernel) the value here will30* always equal the @probed_size. Note this is only currently tracked31* for I915_MEMORY_CLASS_DEVICE regions (for other types the value here32* will always equal the @probed_size).33*/34__u64 unallocated_size;3536union {37/** @rsvd1: MBZ */38__u64 rsvd1[8];39struct {40/**41* @probed_cpu_visible_size: Memory probed by the driver42* that is CPU accessible.43*44* This will be always be <= @probed_size, and the45* remainder (if there is any) will not be CPU46* accessible.47*48* On systems without small BAR, the @probed_size will49* always equal the @probed_cpu_visible_size, since all50* of it will be CPU accessible.51*52* Note this is only tracked for53* I915_MEMORY_CLASS_DEVICE regions (for other types the54* value here will always equal the @probed_size).55*56* Note that if the value returned here is zero, then57* this must be an old kernel which lacks the relevant58* small-bar uAPI support (including59* I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS), but on60* such systems we should never actually end up with a61* small BAR configuration, assuming we are able to load62* the kernel module. Hence it should be safe to treat63* this the same as when @probed_cpu_visible_size ==64* @probed_size.65*/66__u64 probed_cpu_visible_size;6768/**69* @unallocated_cpu_visible_size: Estimate of CPU70* visible memory remaining71*72* Note this is only tracked for73* I915_MEMORY_CLASS_DEVICE regions (for other types the74* value here will always equal the75* @probed_cpu_visible_size).76*77* Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable78* accounting. Without this the value here will always79* equal the @probed_cpu_visible_size. Note this is only80* currently tracked for I915_MEMORY_CLASS_DEVICE81* regions (for other types the value here will also82* always equal the @probed_cpu_visible_size).83*84* If this is an older kernel the value here will be85* zero, see also @probed_cpu_visible_size.86*/87__u64 unallocated_cpu_visible_size;88};89};90};9192/**93* struct __drm_i915_gem_create_ext - Existing gem_create behaviour, with added94* extension support using struct i915_user_extension.95*96* Note that new buffer flags should be added here, at least for the stuff that97* is immutable. Previously we would have two ioctls, one to create the object98* with gem_create, and another to apply various parameters, however this99* creates some ambiguity for the params which are considered immutable. Also in100* general we're phasing out the various SET/GET ioctls.101*/102struct __drm_i915_gem_create_ext {103/**104* @size: Requested size for the object.105*106* The (page-aligned) allocated size for the object will be returned.107*108* Note that for some devices we have might have further minimum109* page-size restrictions (larger than 4K), like for device local-memory.110* However in general the final size here should always reflect any111* rounding up, if for example using the I915_GEM_CREATE_EXT_MEMORY_REGIONS112* extension to place the object in device local-memory. The kernel will113* always select the largest minimum page-size for the set of possible114* placements as the value to use when rounding up the @size.115*/116__u64 size;117118/**119* @handle: Returned handle for the object.120*121* Object handles are nonzero.122*/123__u32 handle;124125/**126* @flags: Optional flags.127*128* Supported values:129*130* I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS - Signal to the kernel that131* the object will need to be accessed via the CPU.132*133* Only valid when placing objects in I915_MEMORY_CLASS_DEVICE, and only134* strictly required on configurations where some subset of the device135* memory is directly visible/mappable through the CPU (which we also136* call small BAR), like on some DG2+ systems. Note that this is quite137* undesirable, but due to various factors like the client CPU, BIOS etc138* it's something we can expect to see in the wild. See139* &__drm_i915_memory_region_info.probed_cpu_visible_size for how to140* determine if this system applies.141*142* Note that one of the placements MUST be I915_MEMORY_CLASS_SYSTEM, to143* ensure the kernel can always spill the allocation to system memory,144* if the object can't be allocated in the mappable part of145* I915_MEMORY_CLASS_DEVICE.146*147* Also note that since the kernel only supports flat-CCS on objects148* that can *only* be placed in I915_MEMORY_CLASS_DEVICE, we therefore149* don't support I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS together with150* flat-CCS.151*152* Without this hint, the kernel will assume that non-mappable153* I915_MEMORY_CLASS_DEVICE is preferred for this object. Note that the154* kernel can still migrate the object to the mappable part, as a last155* resort, if userspace ever CPU faults this object, but this might be156* expensive, and so ideally should be avoided.157*158* On older kernels which lack the relevant small-bar uAPI support (see159* also &__drm_i915_memory_region_info.probed_cpu_visible_size),160* usage of the flag will result in an error, but it should NEVER be161* possible to end up with a small BAR configuration, assuming we can162* also successfully load the i915 kernel module. In such cases the163* entire I915_MEMORY_CLASS_DEVICE region will be CPU accessible, and as164* such there are zero restrictions on where the object can be placed.165*/166#define I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS (1 << 0)167__u32 flags;168169/**170* @extensions: The chain of extensions to apply to this object.171*172* This will be useful in the future when we need to support several173* different extensions, and we need to apply more than one when174* creating the object. See struct i915_user_extension.175*176* If we don't supply any extensions then we get the same old gem_create177* behaviour.178*179* For I915_GEM_CREATE_EXT_MEMORY_REGIONS usage see180* struct drm_i915_gem_create_ext_memory_regions.181*182* For I915_GEM_CREATE_EXT_PROTECTED_CONTENT usage see183* struct drm_i915_gem_create_ext_protected_content.184*/185#define I915_GEM_CREATE_EXT_MEMORY_REGIONS 0186#define I915_GEM_CREATE_EXT_PROTECTED_CONTENT 1187__u64 extensions;188};189190191