mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 22:08:26 +02:00
iris: Use the new I915_USERPTR_PROBE API
We need to raise an error when importing a user pointer as a BO if the supplied pointer can't actually be used on the GPU. Previously, we were (ab)using the SET_DOMAIN ioctl for this, but it's not really intended for that purpose, and is going away on discrete. Fortunately, there's a new kernel API for this: the I915_USERPTR_PROBE flag tries to perform basic sanity checking of the supplied pointer so that we can at least reject obvious misuse of this API up front. Use the new API where available. Fall back to SET_DOMAIN if it isn't. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12044>
This commit is contained in:
parent
b8e2214ee5
commit
468c3c83b4
1 changed files with 13 additions and 7 deletions
|
|
@ -210,6 +210,7 @@ struct iris_bufmgr {
|
|||
bool has_local_mem:1;
|
||||
bool has_mmap_offset:1;
|
||||
bool has_tiling_uapi:1;
|
||||
bool has_userptr_probe:1;
|
||||
bool bo_reuse:1;
|
||||
|
||||
struct intel_aux_map_context *aux_map_ctx;
|
||||
|
|
@ -707,18 +708,21 @@ iris_bo_create_userptr(struct iris_bufmgr *bufmgr, const char *name,
|
|||
struct drm_i915_gem_userptr arg = {
|
||||
.user_ptr = (uintptr_t)ptr,
|
||||
.user_size = size,
|
||||
.flags = bufmgr->has_userptr_probe ? I915_USERPTR_PROBE : 0,
|
||||
};
|
||||
if (intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_USERPTR, &arg))
|
||||
goto err_free;
|
||||
bo->gem_handle = arg.handle;
|
||||
|
||||
/* Check the buffer for validity before we try and use it in a batch */
|
||||
struct drm_i915_gem_set_domain sd = {
|
||||
.handle = bo->gem_handle,
|
||||
.read_domains = I915_GEM_DOMAIN_CPU,
|
||||
};
|
||||
if (intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &sd))
|
||||
goto err_close;
|
||||
if (!bufmgr->has_userptr_probe) {
|
||||
/* Check the buffer for validity before we try and use it in a batch */
|
||||
struct drm_i915_gem_set_domain sd = {
|
||||
.handle = bo->gem_handle,
|
||||
.read_domains = I915_GEM_DOMAIN_CPU,
|
||||
};
|
||||
if (intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &sd))
|
||||
goto err_close;
|
||||
}
|
||||
|
||||
bo->name = name;
|
||||
bo->size = size;
|
||||
|
|
@ -1774,6 +1778,8 @@ iris_bufmgr_create(struct intel_device_info *devinfo, int fd, bool bo_reuse)
|
|||
bufmgr->has_tiling_uapi = devinfo->has_tiling_uapi;
|
||||
bufmgr->bo_reuse = bo_reuse;
|
||||
bufmgr->has_mmap_offset = gem_param(fd, I915_PARAM_MMAP_GTT_VERSION) >= 4;
|
||||
bufmgr->has_userptr_probe =
|
||||
gem_param(fd, I915_PARAM_HAS_USERPTR_PROBE) >= 1;
|
||||
iris_bufmgr_query_meminfo(bufmgr);
|
||||
|
||||
STATIC_ASSERT(IRIS_MEMZONE_SHADER_START == 0ull);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue