From dd89c6ca65f2f623faf975a772a4483151e52aa6 Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Thu, 7 Oct 2021 17:31:33 -0700 Subject: [PATCH] iris: extract iris_hw_context_set_unrecoverable() We're going to add a second caller. Signed-off-by: Paulo Zanoni Reviewed-by: Jordan Justen Reviewed-by: Kenneth Graunke Part-of: --- src/gallium/drivers/iris/iris_bufmgr.c | 27 ++++++++++++++++---------- src/gallium/drivers/iris/iris_bufmgr.h | 2 ++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index 55a341cf9af..467f24fb5e6 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -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; } diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h index 010ce424313..197b9e93635 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.h +++ b/src/gallium/drivers/iris/iris_bufmgr.h @@ -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);