History

drm/i915: Allow user to set cache at BO creation

To comply with the design that buffer objects shall have immutable cache setting through out their life cycle, {set, get}_caching ioctl's are no longer supported from MTL onward. With that change caching policy can only be set at object creation time. The current code applies a default (platform dependent) cache setting for all objects. However this is not optimal for performance tuning. The patch extends the existing gem_create uAPI to let user set PAT index for the object at creation time. The new extension is platform independent, so UMD's can switch to using this extension for older platforms as well, while {set, get}_caching are still supported on these legacy paltforms for compatibility reason. However, since PAT index was not clearly defined for platforms prior to GEN12 (TGL), so we are limiting this externsion to GEN12+ platforms only. See ext_set_pat() in for the implementation details. The documentation related to the PAT/MOCS tables is currently available for Tiger Lake here: https://www.intel.com/content/www/us/en/docs/graphics-for-linux/developer-reference/1-0/tiger-lake.html The documentation for other platforms is currently being updated. BSpec: 45101 Mesa support has been submitted in this merge request: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22878 The media driver supprt has bin submitted in this merge request: https://github.com/intel/media-driver/pull/1680 The IGT test related to this change is igt@gem_create@create-ext-set-pat

Fei Yang committed 3 years ago

Commit 81b1b591 parent 1b842f73 files · +87 −0Browse files

Showing the changes to include/uapi (1 of 3 files). Show all

Unified · Split

include/uapi/drm/i915_drm.h+41−0
@@ -3680,9 +3680,13 @@ struct drm_i915_gem_create_ext { · 3679 unmodified lines
3680 *3680 *
3681 * For I915_GEM_CREATE_EXT_PROTECTED_CONTENT usage see3681 * For I915_GEM_CREATE_EXT_PROTECTED_CONTENT usage see
3682 * struct drm_i915_gem_create_ext_protected_content.3682 * struct drm_i915_gem_create_ext_protected_content.
3683 *
3684 * For I915_GEM_CREATE_EXT_SET_PAT usage see
3685 * struct drm_i915_gem_create_ext_set_pat.
3683 */3686 */
3684#define I915_GEM_CREATE_EXT_MEMORY_REGIONS 03687#define I915_GEM_CREATE_EXT_MEMORY_REGIONS 0
3685#define I915_GEM_CREATE_EXT_PROTECTED_CONTENT 13688#define I915_GEM_CREATE_EXT_PROTECTED_CONTENT 1
3689#define I915_GEM_CREATE_EXT_SET_PAT 2
3686 __u64 extensions;3690 __u64 extensions;
3687};3691};
3688 3692
@@ -3797,6 +3801,43 @@ struct drm_i915_gem_create_ext_protected_content { · 108 unmodified lines
3797 __u32 flags;3801 __u32 flags;
3798};3802};
3799 3803
3804/**
3805 * struct drm_i915_gem_create_ext_set_pat - The
3806 * I915_GEM_CREATE_EXT_SET_PAT extension.
3807 *
3808 * If this extension is provided, the specified caching policy (PAT index) is
3809 * applied to the buffer object.
3810 *
3811 * Below is an example on how to create an object with specific caching policy:
3812 *
3813 * .. code-block:: C
3814 *
3815 * struct drm_i915_gem_create_ext_set_pat set_pat_ext = {
3816 * .base = { .name = I915_GEM_CREATE_EXT_SET_PAT },
3817 * .pat_index = 0,
3818 * };
3819 * struct drm_i915_gem_create_ext create_ext = {
3820 * .size = PAGE_SIZE,
3821 * .extensions = (uintptr_t)&set_pat_ext,
3822 * };
3823 *
3824 * int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext);
3825 * if (err) ...
3826 */
3827struct drm_i915_gem_create_ext_set_pat {
3828 /** @base: Extension link. See struct i915_user_extension. */
3829 struct i915_user_extension base;
3830 /**
3831 * @pat_index: PAT index to be set
3832 * PAT index is a bit field in Page Table Entry to control caching
3833 * behaviors for GPU accesses. The definition of PAT index is
3834 * platform dependent and can be found in hardware specifications,
3835 */
3836 __u32 pat_index;
3837 /** @rsvd: reserved for future use */
3838 __u32 rsvd;
3839};
3840
3800/* ID of the protected content session managed by i915 when PXP is active */3841/* ID of the protected content session managed by i915 when PXP is active */
3801#define I915_PROTECTED_CONTENT_DEFAULT_SESSION 0xf3842#define I915_PROTECTED_CONTENT_DEFAULT_SESSION 0xf
3802 3843

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t