mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 02:10:11 +01:00
iris: Add gem_create_userptr() to KMD backend
Xe support of userptr will be implemented in the next patch, this is just moving the i915 function to KMD backend. Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Reviewed-by: Marcin Ślusarz <marcin.slusarz@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23817>
This commit is contained in:
parent
0698bc9e5a
commit
b38f7834f5
4 changed files with 39 additions and 26 deletions
|
|
@ -421,10 +421,37 @@ i915_gem_close(struct iris_bufmgr *bufmgr, struct iris_bo *bo)
|
|||
return intel_ioctl(iris_bufmgr_get_fd(bufmgr), DRM_IOCTL_GEM_CLOSE, &close);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
i915_gem_create_userptr(struct iris_bufmgr *bufmgr, void *ptr, uint64_t size)
|
||||
{
|
||||
const struct intel_device_info *devinfo = iris_bufmgr_get_device_info(bufmgr);
|
||||
struct drm_i915_gem_userptr arg = {
|
||||
.user_ptr = (uintptr_t)ptr,
|
||||
.user_size = size,
|
||||
.flags = devinfo->has_userptr_probe ? I915_USERPTR_PROBE : 0,
|
||||
};
|
||||
if (intel_ioctl(iris_bufmgr_get_fd(bufmgr), DRM_IOCTL_I915_GEM_USERPTR, &arg))
|
||||
return 0;
|
||||
|
||||
if (!devinfo->has_userptr_probe) {
|
||||
/* Check the buffer for validity before we try and use it in a batch */
|
||||
if (i915_gem_set_domain(bufmgr, arg.handle, I915_GEM_DOMAIN_CPU, 0)) {
|
||||
struct drm_gem_close close = {
|
||||
.handle = arg.handle,
|
||||
};
|
||||
intel_ioctl(iris_bufmgr_get_fd(bufmgr), DRM_IOCTL_GEM_CLOSE, &close);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return arg.handle;
|
||||
}
|
||||
|
||||
const struct iris_kmd_backend *i915_get_backend(void)
|
||||
{
|
||||
static const struct iris_kmd_backend i915_backend = {
|
||||
.gem_create = i915_gem_create,
|
||||
.gem_create_userptr = i915_gem_create_userptr,
|
||||
.gem_close = i915_gem_close,
|
||||
.bo_madvise = i915_bo_madvise,
|
||||
.bo_set_caching = i915_bo_set_caching,
|
||||
|
|
|
|||
|
|
@ -1067,19 +1067,6 @@ alloc_bo_from_cache(struct iris_bufmgr *bufmgr,
|
|||
return bo;
|
||||
}
|
||||
|
||||
static int
|
||||
i915_gem_set_domain(struct iris_bufmgr *bufmgr, uint32_t handle,
|
||||
uint32_t read_domains, uint32_t write_domains)
|
||||
{
|
||||
struct drm_i915_gem_set_domain sd = {
|
||||
.handle = handle,
|
||||
.read_domains = read_domains,
|
||||
.write_domain = write_domains,
|
||||
};
|
||||
return intel_ioctl(iris_bufmgr_get_fd(bufmgr),
|
||||
DRM_IOCTL_I915_GEM_SET_DOMAIN, &sd);
|
||||
}
|
||||
|
||||
static struct iris_bo *
|
||||
alloc_fresh_bo(struct iris_bufmgr *bufmgr, uint64_t bo_size, unsigned flags)
|
||||
{
|
||||
|
|
@ -1296,20 +1283,9 @@ iris_bo_create_userptr(struct iris_bufmgr *bufmgr, const char *name,
|
|||
if (!bo)
|
||||
return NULL;
|
||||
|
||||
struct drm_i915_gem_userptr arg = {
|
||||
.user_ptr = (uintptr_t)ptr,
|
||||
.user_size = size,
|
||||
.flags = bufmgr->devinfo.has_userptr_probe ? I915_USERPTR_PROBE : 0,
|
||||
};
|
||||
if (intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_USERPTR, &arg))
|
||||
bo->gem_handle = bufmgr->kmd_backend->gem_create_userptr(bufmgr, ptr, size);
|
||||
if (bo->gem_handle == 0)
|
||||
goto err_free;
|
||||
bo->gem_handle = arg.handle;
|
||||
|
||||
if (!bufmgr->devinfo.has_userptr_probe) {
|
||||
/* Check the buffer for validity before we try and use it in a batch */
|
||||
if (i915_gem_set_domain(bufmgr, bo->gem_handle, I915_GEM_DOMAIN_CPU, 0))
|
||||
goto err_close;
|
||||
}
|
||||
|
||||
bo->name = name;
|
||||
bo->size = size;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ struct iris_kmd_backend {
|
|||
const struct intel_memory_class_instance **regions,
|
||||
uint16_t regions_count, uint64_t size,
|
||||
enum iris_heap heap_flags, unsigned alloc_flags);
|
||||
uint32_t (*gem_create_userptr)(struct iris_bufmgr *bufmgr, void *ptr,
|
||||
uint64_t size);
|
||||
int (*gem_close)(struct iris_bufmgr *bufmgr, struct iris_bo *bo);
|
||||
bool (*bo_madvise)(struct iris_bo *bo, enum iris_madvice state);
|
||||
int (*bo_set_caching)(struct iris_bo *bo, bool cached);
|
||||
|
|
|
|||
|
|
@ -436,10 +436,18 @@ xe_gem_close(struct iris_bufmgr *bufmgr, struct iris_bo *bo)
|
|||
return intel_ioctl(iris_bufmgr_get_fd(bufmgr), DRM_IOCTL_GEM_CLOSE, &close);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
xe_gem_create_userptr(struct iris_bufmgr *bufmgr, void *ptr, uint64_t size)
|
||||
{
|
||||
/* We return 0, because Xe doesn't create handles for userptrs. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct iris_kmd_backend *xe_get_backend(void)
|
||||
{
|
||||
static const struct iris_kmd_backend xe_backend = {
|
||||
.gem_create = xe_gem_create,
|
||||
.gem_create_userptr = xe_gem_create_userptr,
|
||||
.gem_close = xe_gem_close,
|
||||
.gem_mmap = xe_gem_mmap,
|
||||
.gem_vm_bind = xe_gem_vm_bind,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue