Back to home page

OSCL-LXR

 
 

    


0001 /**
0002  * struct __drm_i915_memory_region_info - Describes one region as known to the
0003  * driver.
0004  *
0005  * Note this is using both struct drm_i915_query_item and struct drm_i915_query.
0006  * For this new query we are adding the new query id DRM_I915_QUERY_MEMORY_REGIONS
0007  * at &drm_i915_query_item.query_id.
0008  */
0009 struct __drm_i915_memory_region_info {
0010     /** @region: The class:instance pair encoding */
0011     struct drm_i915_gem_memory_class_instance region;
0012 
0013     /** @rsvd0: MBZ */
0014     __u32 rsvd0;
0015 
0016     /**
0017      * @probed_size: Memory probed by the driver
0018      *
0019      * Note that it should not be possible to ever encounter a zero value
0020      * here, also note that no current region type will ever return -1 here.
0021      * Although for future region types, this might be a possibility. The
0022      * same applies to the other size fields.
0023      */
0024     __u64 probed_size;
0025 
0026     /**
0027      * @unallocated_size: Estimate of memory remaining
0028      *
0029      * Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable accounting.
0030      * Without this (or if this is an older kernel) the value here will
0031      * always equal the @probed_size. Note this is only currently tracked
0032      * for I915_MEMORY_CLASS_DEVICE regions (for other types the value here
0033      * will always equal the @probed_size).
0034      */
0035     __u64 unallocated_size;
0036 
0037     union {
0038         /** @rsvd1: MBZ */
0039         __u64 rsvd1[8];
0040         struct {
0041             /**
0042              * @probed_cpu_visible_size: Memory probed by the driver
0043              * that is CPU accessible.
0044              *
0045              * This will be always be <= @probed_size, and the
0046              * remainder (if there is any) will not be CPU
0047              * accessible.
0048              *
0049              * On systems without small BAR, the @probed_size will
0050              * always equal the @probed_cpu_visible_size, since all
0051              * of it will be CPU accessible.
0052              *
0053              * Note this is only tracked for
0054              * I915_MEMORY_CLASS_DEVICE regions (for other types the
0055              * value here will always equal the @probed_size).
0056              *
0057              * Note that if the value returned here is zero, then
0058              * this must be an old kernel which lacks the relevant
0059              * small-bar uAPI support (including
0060              * I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS), but on
0061              * such systems we should never actually end up with a
0062              * small BAR configuration, assuming we are able to load
0063              * the kernel module. Hence it should be safe to treat
0064              * this the same as when @probed_cpu_visible_size ==
0065              * @probed_size.
0066              */
0067             __u64 probed_cpu_visible_size;
0068 
0069             /**
0070              * @unallocated_cpu_visible_size: Estimate of CPU
0071              * visible memory remaining
0072              *
0073              * Note this is only tracked for
0074              * I915_MEMORY_CLASS_DEVICE regions (for other types the
0075              * value here will always equal the
0076              * @probed_cpu_visible_size).
0077              *
0078              * Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable
0079              * accounting.  Without this the value here will always
0080              * equal the @probed_cpu_visible_size. Note this is only
0081              * currently tracked for I915_MEMORY_CLASS_DEVICE
0082              * regions (for other types the value here will also
0083              * always equal the @probed_cpu_visible_size).
0084              *
0085              * If this is an older kernel the value here will be
0086              * zero, see also @probed_cpu_visible_size.
0087              */
0088             __u64 unallocated_cpu_visible_size;
0089         };
0090     };
0091 };
0092 
0093 /**
0094  * struct __drm_i915_gem_create_ext - Existing gem_create behaviour, with added
0095  * extension support using struct i915_user_extension.
0096  *
0097  * Note that new buffer flags should be added here, at least for the stuff that
0098  * is immutable. Previously we would have two ioctls, one to create the object
0099  * with gem_create, and another to apply various parameters, however this
0100  * creates some ambiguity for the params which are considered immutable. Also in
0101  * general we're phasing out the various SET/GET ioctls.
0102  */
0103 struct __drm_i915_gem_create_ext {
0104     /**
0105      * @size: Requested size for the object.
0106      *
0107      * The (page-aligned) allocated size for the object will be returned.
0108      *
0109      * Note that for some devices we have might have further minimum
0110      * page-size restrictions (larger than 4K), like for device local-memory.
0111      * However in general the final size here should always reflect any
0112      * rounding up, if for example using the I915_GEM_CREATE_EXT_MEMORY_REGIONS
0113      * extension to place the object in device local-memory. The kernel will
0114      * always select the largest minimum page-size for the set of possible
0115      * placements as the value to use when rounding up the @size.
0116      */
0117     __u64 size;
0118 
0119     /**
0120      * @handle: Returned handle for the object.
0121      *
0122      * Object handles are nonzero.
0123      */
0124     __u32 handle;
0125 
0126     /**
0127      * @flags: Optional flags.
0128      *
0129      * Supported values:
0130      *
0131      * I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS - Signal to the kernel that
0132      * the object will need to be accessed via the CPU.
0133      *
0134      * Only valid when placing objects in I915_MEMORY_CLASS_DEVICE, and only
0135      * strictly required on configurations where some subset of the device
0136      * memory is directly visible/mappable through the CPU (which we also
0137      * call small BAR), like on some DG2+ systems. Note that this is quite
0138      * undesirable, but due to various factors like the client CPU, BIOS etc
0139      * it's something we can expect to see in the wild. See
0140      * &__drm_i915_memory_region_info.probed_cpu_visible_size for how to
0141      * determine if this system applies.
0142      *
0143      * Note that one of the placements MUST be I915_MEMORY_CLASS_SYSTEM, to
0144      * ensure the kernel can always spill the allocation to system memory,
0145      * if the object can't be allocated in the mappable part of
0146      * I915_MEMORY_CLASS_DEVICE.
0147      *
0148      * Also note that since the kernel only supports flat-CCS on objects
0149      * that can *only* be placed in I915_MEMORY_CLASS_DEVICE, we therefore
0150      * don't support I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS together with
0151      * flat-CCS.
0152      *
0153      * Without this hint, the kernel will assume that non-mappable
0154      * I915_MEMORY_CLASS_DEVICE is preferred for this object. Note that the
0155      * kernel can still migrate the object to the mappable part, as a last
0156      * resort, if userspace ever CPU faults this object, but this might be
0157      * expensive, and so ideally should be avoided.
0158      *
0159      * On older kernels which lack the relevant small-bar uAPI support (see
0160      * also &__drm_i915_memory_region_info.probed_cpu_visible_size),
0161      * usage of the flag will result in an error, but it should NEVER be
0162      * possible to end up with a small BAR configuration, assuming we can
0163      * also successfully load the i915 kernel module. In such cases the
0164      * entire I915_MEMORY_CLASS_DEVICE region will be CPU accessible, and as
0165      * such there are zero restrictions on where the object can be placed.
0166      */
0167 #define I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS (1 << 0)
0168     __u32 flags;
0169 
0170     /**
0171      * @extensions: The chain of extensions to apply to this object.
0172      *
0173      * This will be useful in the future when we need to support several
0174      * different extensions, and we need to apply more than one when
0175      * creating the object. See struct i915_user_extension.
0176      *
0177      * If we don't supply any extensions then we get the same old gem_create
0178      * behaviour.
0179      *
0180      * For I915_GEM_CREATE_EXT_MEMORY_REGIONS usage see
0181      * struct drm_i915_gem_create_ext_memory_regions.
0182      *
0183      * For I915_GEM_CREATE_EXT_PROTECTED_CONTENT usage see
0184      * struct drm_i915_gem_create_ext_protected_content.
0185      */
0186 #define I915_GEM_CREATE_EXT_MEMORY_REGIONS 0
0187 #define I915_GEM_CREATE_EXT_PROTECTED_CONTENT 1
0188     __u64 extensions;
0189 };