Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: akash.goel@intel.com
To: intel-gfx@lists.freedesktop.org
Cc: sourab.gupta@intel.com, Akash Goel <akash.goel@intel.com>
Subject: [RFC 07/12] drm/i915: Allocate local buffer to store GuC ukernel logs
Date: Sat, 28 May 2016 01:12:58 +0530	[thread overview]
Message-ID: <1464378183-9433-8-git-send-email-akash.goel@intel.com> (raw)
In-Reply-To: <1464378183-9433-1-git-send-email-akash.goel@intel.com>

From: Akash Goel <akash.goel@intel.com>

If relay framework can't be used for all production kernels,
due to debugfs limitation, then need to have our own local buffer
to store the logs and manage it.
This patch allocates a buffer to store the GuC ukernel logs.
The contents of the GuC log buffer will be copied into local buffer
on every flush interrupt from GuC. The local buffer is allocated a
GEM object and is accessed through the vmalloc mapping.

Signed-off-by: Akash Goel <akash.goel@intel.com>
---
 drivers/gpu/drm/i915/i915_guc_submission.c | 40 +++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_guc.h           |  6 +++++
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
index d6d6ead..26b95e7 100644
--- a/drivers/gpu/drm/i915/i915_guc_submission.c
+++ b/drivers/gpu/drm/i915/i915_guc_submission.c
@@ -963,6 +963,12 @@ static void guc_logging_fini(struct intel_guc *guc)
 {
 #ifdef CONFIG_DEBUG_FS
         guc_remove_log_relay_file(guc);
+#else
+	if (guc->log.buf_obj) {
+		i915_gem_object_unpin_map(guc->log.buf_obj);
+		drm_gem_object_unreference(&guc->log.buf_obj->base);
+		guc->log.buf_obj = NULL;
+	}
 #endif
 }
 
@@ -970,6 +976,38 @@ static void guc_logging_init(struct intel_guc *guc)
 {
 #ifdef CONFIG_DEBUG_FS
 	guc_create_log_relay_file(guc);
+#else
+	struct drm_i915_private *dev_priv = guc_to_i915(guc);
+	struct drm_i915_gem_object *obj;
+	size_t n_subbufs, subbuf_size;
+	void *vaddr;
+
+	spin_lock_init(&guc->log.buf_lock);
+
+	subbuf_size = guc->log_obj->base.size;
+	/* TODO: Decide based on the User's input */
+	n_subbufs = GUC_SCRATCH_LOG_ENTRIES_NR;
+
+	obj = i915_gem_object_create(dev_priv->dev, subbuf_size * n_subbufs);
+	if (IS_ERR(obj))
+		return;
+
+	/* For now permanently pin the pages & create a persistent vmalloc
+	 * mapping of them.
+	 * TODO: Pin/unpin on the fly (to participate in vmap shrinking also),
+	 * once dependency on struct_mutex is obviated.
+	 */
+	vaddr = i915_gem_object_pin_map(obj);
+	if (IS_ERR(vaddr)) {
+		drm_gem_object_unreference(&obj->base);
+		return;
+	}
+
+	guc->log.buf_obj = obj;
+
+	/* Enable the flush interrupt, we have a buffer to store GuC logs */
+	if (i915.guc_log_level >= 0)
+		gen8_enable_guc_interrupts(dev_priv->dev);
 #endif
 }
 
@@ -1224,7 +1262,7 @@ int intel_guc_resume(struct drm_device *dev)
 	if (guc->guc_fw.guc_fw_load_status != GUC_FIRMWARE_SUCCESS)
 		return 0;
 
-	if (i915.guc_log_level >= 0 && guc->log_relay_chan)
+	if (i915.guc_log_level >= 0 && (guc->log_relay_chan || guc->log.buf_obj))
 		gen8_enable_guc_interrupts(dev);
 
 	ctx = dev_priv->kernel_context;
diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h
index bf61925..9e6ce2d 100644
--- a/drivers/gpu/drm/i915/intel_guc.h
+++ b/drivers/gpu/drm/i915/intel_guc.h
@@ -121,11 +121,17 @@ struct intel_guc_fw {
 	uint32_t ucode_offset;
 };
 
+struct intel_guc_log {
+	struct drm_i915_gem_object *buf_obj;
+	spinlock_t buf_lock;
+};
+
 struct intel_guc {
 	struct intel_guc_fw guc_fw;
 	uint32_t log_flags;
 	struct drm_i915_gem_object *log_obj;
 	struct rchan *log_relay_chan;
+	struct intel_guc_log log;
 	/*
 	 * work, interrupts_enabled are protected by dev_priv->irq_lock
 	 */
-- 
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-05-27 19:30 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-27 19:42 [RFC 00/12] Support for sustained capturing of GuC firmware logs akash.goel
2016-05-27 19:42 ` [RFC 01/12] drm/i915: Decouple GuC log setup from verbosity parameter akash.goel
2016-05-27 19:42 ` [RFC 02/12] drm/i915: Add GuC ukernel logging related fields to fw interface file akash.goel
2016-05-27 19:42 ` [RFC 03/12] drm/i915: Support for GuC interrupts akash.goel
2016-05-27 19:43   ` Chris Wilson
2016-05-28  8:46     ` Goel, Akash
2016-05-27 19:56   ` Chris Wilson
2016-05-28  9:22     ` Goel, Akash
2016-05-28 12:13       ` Chris Wilson
2016-05-28 13:45         ` Goel, Akash
2016-05-28 14:35           ` Chris Wilson
2016-05-28 17:33             ` Goel, Akash
2016-05-27 19:42 ` [RFC 04/12] drm/i915: Handle log buffer flush interrupt event from GuC akash.goel
2016-05-27 19:42 ` [RFC 05/12] drm/i915: Add a relay backed debugfs interface for capturing GuC logs akash.goel
2016-05-27 19:42 ` [RFC 06/12] drm/i915: Store GuC ukernel logs in the relay buffer akash.goel
2016-05-27 19:42 ` akash.goel [this message]
2016-05-27 19:42 ` [RFC 08/12] drm/i915: Store GuC ukernel logs in the local buffer akash.goel
2016-05-27 19:43 ` [RFC 09/12] drm/i915: Add a char device file interface to capture GuC ukernel logs akash.goel
2016-05-27 19:48   ` Chris Wilson
2016-05-28  8:51     ` Goel, Akash
2016-05-27 19:43 ` [RFC 10/12] drm/i915: Support to capture GuC logs by multiple clients via device file iface akash.goel
2016-05-27 19:43 ` [RFC 11/12] drm/i915: Add sysfs interface to capture the GuC ukernel logs akash.goel
2016-05-27 19:43 ` [RFC 12/12] drm/i915: Forcefully flush GuC log buffer on reset akash.goel
2016-05-28  6:09 ` ✗ Ro.CI.BAT: failure for Support for sustained capturing of GuC firmware logs Patchwork
2016-06-02 10:16 ` [RFC 00/12] " Daniel Vetter
2016-06-02 10:21   ` Johannes Berg
2016-06-03  7:15     ` Daniel Vetter
2016-06-03 10:14       ` Goel, Akash
2016-06-03 10:20         ` Chris Wilson
2016-06-08  8:30           ` Daniel Vetter

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=1464378183-9433-8-git-send-email-akash.goel@intel.com \
    --to=akash.goel@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=sourab.gupta@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox