<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0 ContentPasted1 ContentPasted2 ContentPasted3">
> On 2023-05-01 at 22:19:21 -0700, fei.yang@intel.com wrote:
<div class="ContentPasted0">>> From: Fei Yang <fei.yang@intel.com></div>
<div class="ContentPasted0">>></div>
<div class="ContentPasted0">>> Gem_create uAPI has been extended with capability of setting PAT index.</div>
<div class="ContentPasted0">>> Add a test case to exercise this new extension.</div>
<div class="ContentPasted0">>></div>
<div class="ContentPasted0">>> Signed-off-by: Fei Yang <fei.yang@intel.com></div>
<div class="ContentPasted0">>> ---</div>
<div class="ContentPasted0">>> include/drm-uapi/i915_drm.h | 33 ++++++++++++++++++++++++++++</div>
<div class="ContentPasted0">></div>
<div class="ContentPasted0">> Please use lib/i915/i915_drm_local.h</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Updated in v3, https://patchwork.freedesktop.org/series/117695/</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">> until this land in drm-tip ./include/uapi/drm/i915_drm.h</div>
<div class="ContentPasted0">></div>
<div class="ContentPasted0">> After it will land there send separate patch to sync uapi.</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Will do.</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">> Regards,</div>
<div class="ContentPasted0">> Kamil</div>
<div class="ContentPasted0">></div>
<div class="ContentPasted0">>> tests/i915/gem_create.c | 44 +++++++++++++++++++++++++++++++++++++</div>
<div class="ContentPasted0">>> 2 files changed, 77 insertions(+)</div>
<div class="ContentPasted0">>></div>
<div class="ContentPasted0">>> diff --git a/include/drm-uapi/i915_drm.h b/include/drm-uapi/i915_drm.h</div>
<div class="ContentPasted0">>> index a0876ee4..1fdaa372 100644</div>
<div class="ContentPasted0">>> --- a/include/drm-uapi/i915_drm.h</div>
<div class="ContentPasted0">>> +++ b/include/drm-uapi/i915_drm.h</div>
<div class="ContentPasted0">>> @@ -3499,6 +3499,7 @@ struct drm_i915_gem_create_ext {</div>
<div class="ContentPasted0">>> */</div>
<div class="ContentPasted0">>> #define I915_GEM_CREATE_EXT_MEMORY_REGIONS 0</div>
<div class="ContentPasted0">>> #define I915_GEM_CREATE_EXT_PROTECTED_CONTENT 1</div>
<div class="ContentPasted0">>> +#define I915_GEM_CREATE_EXT_SET_PAT 2</div>
<div class="ContentPasted0">>> __u64 extensions;</div>
<div class="ContentPasted0">>> };</div>
<div class="ContentPasted0">>></div>
<div class="ContentPasted0">>> @@ -3616,6 +3617,38 @@ struct drm_i915_gem_create_ext_protected_content {</div>
<div class="ContentPasted0">>> /* ID of the protected content session managed by i915 when PXP is active */</div>
<div class="ContentPasted0">>> #define I915_PROTECTED_CONTENT_DEFAULT_SESSION 0xf</div>
>>
<div class="ContentPasted1">>> +/**</div>
<div class="ContentPasted1">>> + * struct drm_i915_gem_create_ext_set_pat - The</div>
<div class="ContentPasted1">>> + * I915_GEM_CREATE_EXT_SET_PAT extension.</div>
<div class="ContentPasted1">>> + *</div>
<div class="ContentPasted1">>> + * If this extension is provided, the specified caching policy (PAT index) is</div>
<div class="ContentPasted1">>> + * applied to the buffer object.</div>
<div class="ContentPasted1">>> + *</div>
<div class="ContentPasted1">>> + * Below is an example on how to create an object with specific caching policy:</div>
<div class="ContentPasted1">>> + *</div>
<div class="ContentPasted1">>> + * .. code-block:: C</div>
<div class="ContentPasted1">>> + *</div>
<div class="ContentPasted1">>> + * struct drm_i915_gem_create_ext_set_pat set_pat_ext = {</div>
<div class="ContentPasted1">>> + * .base = { .name = I915_GEM_CREATE_EXT_SET_PAT },</div>
<div class="ContentPasted1">>> + * .pat_index = 0,</div>
<div class="ContentPasted1">>> + * };</div>
<div class="ContentPasted1">>> + * struct drm_i915_gem_create_ext create_ext = {</div>
<div class="ContentPasted1">>> + * .size = PAGE_SIZE,</div>
<div class="ContentPasted1">>> + * .extensions = (uintptr_t)&set_pat_ext,</div>
<div class="ContentPasted1">>> + * };</div>
<div class="ContentPasted1">>> + *</div>
<div class="ContentPasted1">>> + * int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext);</div>
<div class="ContentPasted1">>> + * if (err) ...</div>
<div class="ContentPasted1">>> + */</div>
<div class="ContentPasted1">>> +struct drm_i915_gem_create_ext_set_pat {</div>
<div class="ContentPasted1">>> + /** @base: Extension link. See struct i915_user_extension. */</div>
<div class="ContentPasted1">>> + struct i915_user_extension base;</div>
<div class="ContentPasted1">>> + /** @pat_index: PAT index to be set */</div>
<div class="ContentPasted1">>> + __u32 pat_index;</div>
<div class="ContentPasted1">>> + /** @rsvd: reserved for future use */</div>
<div class="ContentPasted1">>> + __u32 rsvd;</div>
<div class="ContentPasted1">>> +};</div>
<div class="ContentPasted1">>> +</div>
<div class="ContentPasted1">>> #if defined(__cplusplus)</div>
<div class="ContentPasted1">>> }</div>
<div class="ContentPasted1">>> #endif</div>
<div class="ContentPasted1">>> diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c</div>
<div class="ContentPasted1">>> index c719ab6c..20c71afb 100644</div>
<div class="ContentPasted1">>> --- a/tests/i915/gem_create.c</div>
<div class="ContentPasted1">>> +++ b/tests/i915/gem_create.c</div>
<div class="ContentPasted1">>> @@ -537,6 +537,45 @@ static void create_ext_placement_each(int fd)</div>
>> free(regions);
<div class="ContentPasted2">>> }</div>
<div class="ContentPasted2">>></div>
<div class="ContentPasted2">>> +static void create_ext_set_pat(int fd)</div>
<div class="ContentPasted2">>> +{</div>
<div class="ContentPasted2">>> + struct drm_i915_gem_create_ext_set_pat setparam_pat = {</div>
<div class="ContentPasted2">>> + .base = { .name = I915_GEM_CREATE_EXT_SET_PAT },</div>
<div class="ContentPasted2">>> + .pat_index = 0,</div>
<div class="ContentPasted2">>> + };</div>
<div class="ContentPasted2">>> + struct drm_i915_gem_create_ext_set_pat setparam_inv_pat = {</div>
<div class="ContentPasted2">>> + .base = { .name = I915_GEM_CREATE_EXT_SET_PAT },</div>
<div class="ContentPasted2">>> + .pat_index = 65,</div>
<div class="ContentPasted2">>> + };</div>
<div class="ContentPasted2">>> + struct drm_i915_gem_caching arg;</div>
<div class="ContentPasted2">>> + uint64_t size;</div>
<div class="ContentPasted2">>> + uint32_t handle;</div>
<div class="ContentPasted2">>> + int ret;</div>
<div class="ContentPasted2">>> +</div>
<div class="ContentPasted2">>> + size = PAGE_SIZE;</div>
<div class="ContentPasted2">>> +</div>
<div class="ContentPasted2">>> + ret = __gem_create_ext(fd, &size, 0, &handle, &setparam_pat.base);</div>
<div class="ContentPasted2">>> +</div>
<div class="ContentPasted2">>> + /* Returning -EFAULT indicates set_pat extension is not supported */</div>
<div class="ContentPasted2">>> + if (ret == -EFAULT)</div>
<div class="ContentPasted2">>> + igt_info("I915_GEM_CREATE_EXT_SET_PAT is not supported\n");</div>
<div class="ContentPasted2">>> + igt_assert(ret == 0);</div>
<div class="ContentPasted2">>> +</div>
<div class="ContentPasted2">>> + /* {set|get}_caching ioctl should fail for objects created with set_pat */</div>
<div class="ContentPasted2">>> + igt_assert(__gem_set_caching(fd, handle, 1) == -EOPNOTSUPP);</div>
<div class="ContentPasted2">>> +</div>
<div class="ContentPasted2">>> + memset(&arg, 0, sizeof(arg));</div>
<div class="ContentPasted2">>> + arg.handle = handle;</div>
<div class="ContentPasted2">>> + igt_assert(ioctl(fd, DRM_IOCTL_I915_GEM_GET_CACHING, &arg) < 0 &&</div>
<div class="ContentPasted2">>> + errno == EOPNOTSUPP);</div>
<div class="ContentPasted2">>> +</div>
<div class="ContentPasted2">>> + /* gem_create should fail with -EINVAL if invalid pat index specified */</div>
<div class="ContentPasted2">>> + igt_assert_eq(__gem_create_ext(fd, &size, 0, &handle, &setparam_inv_pat.base),</div>
<div class="ContentPasted2">>> + -EINVAL);</div>
<div class="ContentPasted2">>> +</div>
<div class="ContentPasted2">>> + gem_close(fd, handle);</div>
<div class="ContentPasted2">>> +}</div>
>> +
<div class="ContentPasted3">>> static bool supports_needs_cpu_access(int fd)</div>
<div class="ContentPasted3">>> {</div>
<div class="ContentPasted3">>> struct drm_i915_gem_memory_class_instance regions[] = {</div>
<div class="ContentPasted3">>> @@ -897,6 +936,11 @@ igt_main</div>
<div class="ContentPasted3">>> igt_subtest("create-ext-placement-all")</div>
<div class="ContentPasted3">>> create_ext_placement_all(fd);</div>
<div class="ContentPasted3">>></div>
<div class="ContentPasted3">>> + igt_describe("Create objects with specific cache setting"</div>
<div class="ContentPasted3">>> + " create-ext.");</div>
<div class="ContentPasted3">>> + igt_subtest("create-ext-set-pat")</div>
<div class="ContentPasted3">>> + create_ext_set_pat(fd);</div>
<div class="ContentPasted3">>> +</div>
<div class="ContentPasted3">>> igt_describe("Verify the basic functionally and expected ABI contract around I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS");</div>
<div class="ContentPasted3">>> igt_subtest("create-ext-cpu-access-sanity-check") {</div>
<div class="ContentPasted3">>> igt_require(supports_needs_cpu_access(fd));</div>
<div class="ContentPasted3">>> --</div>
<div class="ContentPasted3">>> 2.25.1</div>
<br>
</div>
</body>
</html>