iris: extract iris_hw_context_set_unrecoverable()

We're going to add a second caller.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12692>
This commit is contained in:
Paulo Zanoni 2021-10-07 17:31:33 -07:00 committed by Jordan Justen
parent e88dcb38a1
commit dd89c6ca65
2 changed files with 19 additions and 10 deletions

View File

@ -2015,16 +2015,10 @@ init_cache_buckets(struct iris_bufmgr *bufmgr, bool local)
}
}
uint32_t
iris_create_hw_context(struct iris_bufmgr *bufmgr)
void
iris_hw_context_set_unrecoverable(struct iris_bufmgr *bufmgr,
uint32_t ctx_id)
{
struct drm_i915_gem_context_create create = { };
int ret = intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create);
if (ret != 0) {
DBG("DRM_IOCTL_I915_GEM_CONTEXT_CREATE failed: %s\n", strerror(errno));
return 0;
}
/* Upon declaring a GPU hang, the kernel will zap the guilty context
* back to the default logical HW state and attempt to continue on to
* our next submitted batchbuffer. However, our render batches assume
@ -2041,11 +2035,24 @@ iris_create_hw_context(struct iris_bufmgr *bufmgr)
* we'll have two lost batches instead of a continual stream of hangs.
*/
struct drm_i915_gem_context_param p = {
.ctx_id = create.ctx_id,
.ctx_id = ctx_id,
.param = I915_CONTEXT_PARAM_RECOVERABLE,
.value = false,
};
intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &p);
}
uint32_t
iris_create_hw_context(struct iris_bufmgr *bufmgr)
{
struct drm_i915_gem_context_create create = { };
int ret = intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create);
if (ret != 0) {
DBG("DRM_IOCTL_I915_GEM_CONTEXT_CREATE failed: %s\n", strerror(errno));
return 0;
}
iris_hw_context_set_unrecoverable(bufmgr, create.ctx_id);
return create.ctx_id;
}

View File

@ -455,6 +455,8 @@ uint32_t iris_clone_hw_context(struct iris_bufmgr *bufmgr, uint32_t ctx_id);
#define IRIS_CONTEXT_MEDIUM_PRIORITY (I915_CONTEXT_DEFAULT_PRIORITY)
#define IRIS_CONTEXT_HIGH_PRIORITY ((I915_CONTEXT_MAX_USER_PRIORITY+1)/2)
void iris_hw_context_set_unrecoverable(struct iris_bufmgr *bufmgr,
uint32_t ctx_id);
int iris_hw_context_set_priority(struct iris_bufmgr *bufmgr,
uint32_t ctx_id, int priority);