diff mbox

[RFC,05/12] drm/i915: Capture the renderstate batchbuffer

Message ID 1509127275-22121-6-git-send-email-oscar.mateo@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

oscar.mateo@intel.com Oct. 27, 2017, 6:01 p.m. UTC
It can be useful if it's in play at the time of the crash,
and I will be needing it in AubCrash.

Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Cc: Chris Wilson <chris@chris-wsilon.co.uk>
---
 drivers/gpu/drm/i915/i915_drv.h              |  3 ++-
 drivers/gpu/drm/i915/i915_gem_render_state.c | 11 +++++++++++
 drivers/gpu/drm/i915/i915_gem_render_state.h |  1 +
 drivers/gpu/drm/i915/i915_gpu_error.c        | 13 +++++++++++++
 4 files changed, 27 insertions(+), 1 deletion(-)

Comments

Chris Wilson Oct. 27, 2017, 6:17 p.m. UTC | #1
Quoting Oscar Mateo (2017-10-27 19:01:08)
> It can be useful if it's in play at the time of the crash,
> and I will be needing it in AubCrash.

Ambiguous pronoun.

Just add it to the error-state unconditionally. Active is used very
loosely here.
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index f64871b..23d746b 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -996,7 +996,8 @@  struct i915_gpu_state {
 			int page_count;
 			int unused;
 			u32 *pages[0];
-		} *ringbuffer, *batchbuffer, *wa_batchbuffer, *ctx, *hws_page;
+		} *ringbuffer, *batchbuffer, *wa_batchbuffer,
+		  *renderstate, *ctx, *hws_page;
 
 		struct drm_i915_error_object **user_bo;
 		long user_bo_count;
diff --git a/drivers/gpu/drm/i915/i915_gem_render_state.c b/drivers/gpu/drm/i915/i915_gem_render_state.c
index 3703dc9..47454fb 100644
--- a/drivers/gpu/drm/i915/i915_gem_render_state.c
+++ b/drivers/gpu/drm/i915/i915_gem_render_state.c
@@ -266,6 +266,17 @@  int i915_gem_render_state_emit(struct drm_i915_gem_request *req)
 	return ret;
 }
 
+struct i915_vma *i915_gem_render_state_get(struct intel_engine_cs *engine)
+{
+	struct intel_render_state *so;
+
+	so = engine->render_state;
+	if (!so)
+		return NULL;
+
+	return so->vma;
+}
+
 void i915_gem_render_state_fini(struct intel_engine_cs *engine)
 {
 	struct intel_render_state *so;
diff --git a/drivers/gpu/drm/i915/i915_gem_render_state.h b/drivers/gpu/drm/i915/i915_gem_render_state.h
index 8748184..c760cf9 100644
--- a/drivers/gpu/drm/i915/i915_gem_render_state.h
+++ b/drivers/gpu/drm/i915/i915_gem_render_state.h
@@ -28,6 +28,7 @@ 
 
 int i915_gem_render_state_init(struct intel_engine_cs *engine);
 int i915_gem_render_state_emit(struct drm_i915_gem_request *req);
+struct i915_vma *i915_gem_render_state_get(struct intel_engine_cs *engine);
 void i915_gem_render_state_fini(struct intel_engine_cs *engine);
 
 #endif /* _I915_GEM_RENDER_STATE_H_ */
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index befd17c..a14aa29 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -755,6 +755,9 @@  int i915_error_state_to_str(struct drm_i915_error_state_buf *m,
 				"HW context", ee->ctx);
 
 		print_error_obj(m, dev_priv->engine[i],
+				"Renderstate", ee->renderstate);
+
+		print_error_obj(m, dev_priv->engine[i],
 				"WA context", ee->wa_ctx);
 
 		print_error_obj(m, dev_priv->engine[i],
@@ -850,6 +853,7 @@  void __i915_gpu_state_free(struct kref *error_ref)
 		i915_error_object_free(ee->hws_page);
 		i915_error_object_free(ee->ctx);
 		i915_error_object_free(ee->wa_ctx);
+		i915_error_object_free(ee->renderstate);
 
 		kfree(ee->requests);
 		if (!IS_ERR_OR_NULL(ee->waiters))
@@ -1434,6 +1438,7 @@  static void i915_gem_record_rings(struct drm_i915_private *dev_priv,
 		request = i915_gem_find_active_request(engine);
 		if (request) {
 			struct intel_ring *ring;
+			struct i915_vma *renderstate_vma;
 
 			ee->vm = request->ctx->ppgtt ?
 				&request->ctx->ppgtt->base : &ggtt->base;
@@ -1454,6 +1459,14 @@  static void i915_gem_record_rings(struct drm_i915_private *dev_priv,
 
 			request_record_user_bo(request, ee);
 
+			renderstate_vma = i915_gem_render_state_get(engine);
+			if (renderstate_vma &&
+			    i915_vma_is_active(renderstate_vma)) {
+				ee->renderstate =
+					i915_error_object_create(dev_priv,
+								 renderstate_vma);
+			}
+
 			ee->ctx =
 				i915_error_object_create(dev_priv,
 							 request->ctx->engine[i].state);