iris: use the same VM for every context
Now that we have no overlapping memory addresses for different contexts we can go ahead and also share the same VM for every context. This should make VM binding much easier to implement once we have Kernel support for it. v2: We now have engines_ctx, set it there too. v3: Fix indenting (Ken). Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12028>
This commit is contained in:
@@ -300,6 +300,7 @@ iris_create_engines_context(struct iris_context *ice, int priority)
|
||||
}
|
||||
|
||||
iris_hw_context_set_unrecoverable(screen->bufmgr, engines_ctx);
|
||||
iris_hw_context_set_vm_id(screen->bufmgr, engines_ctx);
|
||||
|
||||
free(engines_info);
|
||||
return engines_ctx;
|
||||
|
@@ -226,6 +226,9 @@ struct iris_bufmgr {
|
||||
uint64_t vma_min_align;
|
||||
struct iris_memregion vram, sys;
|
||||
|
||||
/* Used only when use_global_vm is true. */
|
||||
uint32_t global_vm_id;
|
||||
|
||||
int next_screen_id;
|
||||
|
||||
bool has_llc:1;
|
||||
@@ -234,6 +237,7 @@ struct iris_bufmgr {
|
||||
bool has_tiling_uapi:1;
|
||||
bool has_userptr_probe:1;
|
||||
bool bo_reuse:1;
|
||||
bool use_global_vm:1;
|
||||
|
||||
struct intel_aux_map_context *aux_map_ctx;
|
||||
|
||||
@@ -2156,6 +2160,24 @@ iris_hw_context_set_unrecoverable(struct iris_bufmgr *bufmgr,
|
||||
intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &p);
|
||||
}
|
||||
|
||||
void
|
||||
iris_hw_context_set_vm_id(struct iris_bufmgr *bufmgr, uint32_t ctx_id)
|
||||
{
|
||||
if (!bufmgr->use_global_vm)
|
||||
return;
|
||||
|
||||
struct drm_i915_gem_context_param p = {
|
||||
.ctx_id = ctx_id,
|
||||
.param = I915_CONTEXT_PARAM_VM,
|
||||
.value = bufmgr->global_vm_id,
|
||||
};
|
||||
int ret = intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &p);
|
||||
if (ret != 0) {
|
||||
DBG("DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM failed: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
iris_create_hw_context(struct iris_bufmgr *bufmgr)
|
||||
{
|
||||
@@ -2167,6 +2189,7 @@ iris_create_hw_context(struct iris_bufmgr *bufmgr)
|
||||
}
|
||||
|
||||
iris_hw_context_set_unrecoverable(bufmgr, create.ctx_id);
|
||||
iris_hw_context_set_vm_id(bufmgr, create.ctx_id);
|
||||
|
||||
return create.ctx_id;
|
||||
}
|
||||
@@ -2334,6 +2357,23 @@ iris_bufmgr_query_meminfo(struct iris_bufmgr *bufmgr)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
iris_bufmgr_init_global_vm(int fd, struct iris_bufmgr *bufmgr)
|
||||
{
|
||||
struct drm_i915_gem_context_param gcp = {
|
||||
.ctx_id = 0,
|
||||
.param = I915_CONTEXT_PARAM_VM,
|
||||
};
|
||||
|
||||
if (intel_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &gcp)) {
|
||||
bufmgr->use_global_vm = false;
|
||||
bufmgr->global_vm_id = 0;
|
||||
} else {
|
||||
bufmgr->use_global_vm = true;
|
||||
bufmgr->global_vm_id = gcp.value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the GEM buffer manager, which uses the kernel to allocate, map,
|
||||
* and manage map buffer objections.
|
||||
@@ -2366,6 +2406,8 @@ iris_bufmgr_create(struct intel_device_info *devinfo, int fd, bool bo_reuse)
|
||||
simple_mtx_init(&bufmgr->lock, mtx_plain);
|
||||
simple_mtx_init(&bufmgr->bo_deps_lock, mtx_plain);
|
||||
|
||||
iris_bufmgr_init_global_vm(fd, bufmgr);
|
||||
|
||||
list_inithead(&bufmgr->zombie_list);
|
||||
|
||||
bufmgr->has_llc = devinfo->has_llc;
|
||||
|
@@ -484,6 +484,7 @@ int iris_kernel_context_get_priority(struct iris_bufmgr *bufmgr, uint32_t ctx_id
|
||||
|
||||
void iris_hw_context_set_unrecoverable(struct iris_bufmgr *bufmgr,
|
||||
uint32_t ctx_id);
|
||||
void iris_hw_context_set_vm_id(struct iris_bufmgr *bufmgr, uint32_t ctx_id);
|
||||
int iris_hw_context_set_priority(struct iris_bufmgr *bufmgr,
|
||||
uint32_t ctx_id, int priority);
|
||||
|
||||
|
Reference in New Issue
Block a user