All of lore.kernel.org
 help / color / mirror / Atom feed
From: akash.goel@intel.com
To: intel-gfx@lists.freedesktop.org
Cc: Akash Goel <akash.goel@intel.com>
Subject: [PATCH 05/11] drm/i915: Handle log buffer flush interrupt event from GuC
Date: Mon, 27 Jun 2016 17:46:52 +0530	[thread overview]
Message-ID: <1467029818-3417-6-git-send-email-akash.goel@intel.com> (raw)
In-Reply-To: <1467029818-3417-1-git-send-email-akash.goel@intel.com>

From: Sagar Arun Kamble <sagar.a.kamble@intel.com>

GuC ukernel sends an interrupt to Host to flush the log buffer
and expects Host to correspondingly update the read pointer
information in the state structure, once it has consumed the
log buffer contents by copying them to a file or buffer.
Even if Host couldn't copy the contents, it can still update the
read pointer so that logging state is not disturbed on GuC side.

Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@intel.com>
Signed-off-by: Akash Goel <akash.goel@intel.com>
---
 drivers/gpu/drm/i915/i915_guc_submission.c | 72 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_irq.c            | 19 +++++++-
 drivers/gpu/drm/i915/intel_guc.h           |  1 +
 3 files changed, 91 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
index 8105ddd..b95a510 100644
--- a/drivers/gpu/drm/i915/i915_guc_submission.c
+++ b/drivers/gpu/drm/i915/i915_guc_submission.c
@@ -819,6 +819,65 @@ err:
 	return NULL;
 }
 
+static void* guc_get_write_buffer(struct intel_guc *guc)
+{
+	return NULL;
+}
+
+static void guc_read_update_log_buffer(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_guc *guc = &dev_priv->guc;
+	struct guc_log_buffer_state *log_buffer_state;
+	struct guc_log_buffer_state *log_buffer_copy_state;
+	void *src_ptr, *dst_ptr;
+	int i;
+
+	if (!guc->log_obj)
+		return;
+
+	log_buffer_state = src_ptr =
+		kmap_atomic(i915_gem_object_get_page(guc->log_obj, 0));
+
+	/* Get the pointer to local buffer to store the logs */
+	dst_ptr = log_buffer_copy_state = guc_get_write_buffer(guc);
+	if (log_buffer_copy_state)
+		memcpy(log_buffer_copy_state, log_buffer_state, PAGE_SIZE);
+
+	for (i = 0; i < GUC_MAX_LOG_BUFFER; i++) {
+		/* Update the read pointer in the shared log buffer */
+		log_buffer_state->read_ptr =
+			log_buffer_state->sampled_write_ptr;
+
+		/* Clear the 'flush to file' flag */
+		log_buffer_state->flush_to_file = 0;
+		log_buffer_state++;
+
+		if (!log_buffer_copy_state)
+			continue;
+
+		/* The write pointer could have been updated by the GuC firmware,
+		 * after sending the flush interrupt to Host, for consistency
+		 * set the write pointer value to same value of sampled_write_ptr
+		 * in the snapshot buffer.
+		 */
+		log_buffer_copy_state->write_ptr =
+			log_buffer_copy_state->sampled_write_ptr;
+
+		log_buffer_copy_state++;
+	}
+
+	kunmap_atomic(src_ptr);
+
+	/* Now copy the actual logs */
+	for (i=1; (i < guc->log_obj->base.size / PAGE_SIZE) && dst_ptr; i++) {
+		dst_ptr += PAGE_SIZE;
+		src_ptr = kmap_atomic(i915_gem_object_get_page(guc->log_obj, i));
+		memcpy(dst_ptr, src_ptr, PAGE_SIZE);
+		kunmap_atomic(src_ptr);
+	}
+}
+
 static void guc_create_log(struct intel_guc *guc)
 {
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
@@ -1078,3 +1137,16 @@ int intel_guc_resume(struct drm_device *dev)
 
 	return host2guc_action(guc, data, ARRAY_SIZE(data));
 }
+
+void i915_guc_capture_logs(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_guc *guc = &dev_priv->guc;
+	u32 data[1];
+
+	guc_read_update_log_buffer(dev);
+
+	data[0] = HOST2GUC_ACTION_LOG_BUFFER_FILE_FLUSH_COMPLETE;
+	if (host2guc_action(guc, data, 1))
+		DRM_ERROR("Failed\n");
+}
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 3043e45..bda9093 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1237,6 +1237,7 @@ static void gen9_guc2host_events_work(struct work_struct *work)
 {
 	struct drm_i915_private *dev_priv =
 		container_of(work, struct drm_i915_private, guc.events_work);
+	u32 msg;
 
 	spin_lock_irq(&dev_priv->irq_lock);
 	/* Speed up work cancelation during disabling guc interrupts. */
@@ -1256,7 +1257,23 @@ static void gen9_guc2host_events_work(struct work_struct *work)
 	gen6_enable_pm_irq(dev_priv, GEN9_GUC_TO_HOST_INT_EVENT);
 	spin_unlock_irq(&dev_priv->irq_lock);
 
-	/* TODO: Handle the events for which GuC interrupted host */
+	/* Determine why GuC interrupted host and process */
+	msg = I915_READ(SOFT_SCRATCH(15));
+	if (msg & (GUC2HOST_MSG_CRASH_DUMP_POSTED |
+		   GUC2HOST_MSG_FLUSH_LOG_BUFFER)) {
+		i915_guc_capture_logs(dev_priv->dev);
+
+		/* Clear GuC to Host msg bits that are handled */
+		if (msg & GUC2HOST_MSG_FLUSH_LOG_BUFFER)
+			I915_WRITE(SOFT_SCRATCH(15),
+				I915_READ(SOFT_SCRATCH(15)) &
+				~GUC2HOST_MSG_FLUSH_LOG_BUFFER);
+
+		if (msg & GUC2HOST_MSG_CRASH_DUMP_POSTED)
+			I915_WRITE(SOFT_SCRATCH(15),
+				I915_READ(SOFT_SCRATCH(15)) &
+				~GUC2HOST_MSG_CRASH_DUMP_POSTED);
+	}
 
 	intel_runtime_pm_put(dev_priv);
 }
diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h
index ae787e2..b20e167 100644
--- a/drivers/gpu/drm/i915/intel_guc.h
+++ b/drivers/gpu/drm/i915/intel_guc.h
@@ -168,5 +168,6 @@ int i915_guc_wq_check_space(struct drm_i915_gem_request *rq);
 int i915_guc_submit(struct drm_i915_gem_request *rq);
 void i915_guc_submission_disable(struct drm_i915_private *dev_priv);
 void i915_guc_submission_fini(struct drm_i915_private *dev_priv);
+void i915_guc_capture_logs(struct drm_device *dev);
 
 #endif
-- 
1.9.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-06-27 12:04 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-27 12:16 [PATCH v2 00/11] Support for sustained capturing of GuC firmware logs akash.goel
2016-06-27 12:16 ` [PATCH 01/11] drm/i915: Decouple GuC log setup from verbosity parameter akash.goel
2016-06-27 15:00   ` Tvrtko Ursulin
2016-06-27 15:32     ` Goel, Akash
2016-06-27 15:56       ` Tvrtko Ursulin
2016-06-27 16:25         ` Goel, Akash
2016-06-27 12:16 ` [PATCH 02/11] drm/i915: Add GuC ukernel logging related fields to fw interface file akash.goel
2016-06-27 15:09   ` Tvrtko Ursulin
2016-06-27 12:16 ` [PATCH 03/11] drm/i915: Add low level set of routines for programming PM IER/IIR/IMR register set akash.goel
2016-06-27 15:46   ` Tvrtko Ursulin
2016-06-27 16:35     ` Goel, Akash
2016-06-28  8:35       ` Tvrtko Ursulin
2016-06-28  9:21         ` Goel, Akash
2016-06-27 12:16 ` [PATCH 04/11] drm/i915: Support for GuC interrupts akash.goel
2016-06-28 10:03   ` Tvrtko Ursulin
2016-06-28 11:12     ` Goel, Akash
2016-06-28 13:44       ` Tvrtko Ursulin
2016-07-01  6:16         ` Goel, Akash
2016-07-01  8:47           ` Tvrtko Ursulin
2016-07-01  9:57             ` Goel, Akash
2016-06-27 12:16 ` akash.goel [this message]
2016-06-27 12:16 ` [PATCH 06/11] drm/i915: Add a relay backed debugfs interface for capturing GuC logs akash.goel
2016-06-27 14:23   ` kbuild test robot
2016-06-27 17:50   ` kbuild test robot
2016-06-28  9:47   ` Chris Wilson
2016-06-28 10:01     ` Goel, Akash
2016-06-27 12:16 ` [PATCH 07/11] drm/i915: Forcefully flush GuC log buffer on reset akash.goel
2016-06-27 12:16 ` [PATCH 08/11] drm/i915: Debugfs support for GuC logging control akash.goel
2016-06-27 12:16 ` [PATCH 09/11] drm/i915: New module param to control the size of buffer used for storing GuC firmware logs akash.goel
2016-06-27 13:31   ` Jani Nikula
2016-06-27 14:55     ` Goel, Akash
2016-06-27 12:16 ` [PATCH 10/11] drm/i915: Support to create write combined type vmaps akash.goel
2016-06-28  9:52   ` Chris Wilson
2016-06-28 10:25     ` Goel, Akash
2016-06-28 10:42       ` Chris Wilson
2016-06-27 12:16 ` [PATCH 11/11] drm/i915: Use uncached(WC) mapping for acessing the GuC log buffer akash.goel
2016-06-27 13:46 ` ✗ Ro.CI.BAT: failure for Support for sustained capturing of GuC firmware logs (rev3) Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2016-06-10 13:36 [PATCH 00/11] Support for sustained capturing of GuC firmware logs akash.goel
2016-06-10 13:36 ` [PATCH 05/11] drm/i915: Handle log buffer flush interrupt event from GuC akash.goel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467029818-3417-6-git-send-email-akash.goel@intel.com \
    --to=akash.goel@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.