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 11/12] drm/i915: Add sysfs interface to capture the GuC ukernel logs
Date: Sat, 28 May 2016 01:13:02 +0530	[thread overview]
Message-ID: <1464378183-9433-12-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>

This patch adds support to pull GuC logs stored in the local buffer
through a sysfs interface '/sys/class/drm/card0/guc_log'.
The implementation is on the lines of '/proc/kmsg' and sysfs will be
one of the client just like other clients pulling the logs via
'/dev/dri/guc_log' interface.

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

diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
index 02507bf..77d43cd 100644
--- a/drivers/gpu/drm/i915/i915_sysfs.c
+++ b/drivers/gpu/drm/i915/i915_sysfs.c
@@ -590,6 +590,40 @@ static struct bin_attribute error_state_attr = {
 	.write = error_state_write,
 };
 
+static ssize_t guc_log_data_read(struct file *filp, struct kobject *kobj,
+				struct bin_attribute *attr, char *buf,
+				loff_t off, size_t count)
+{
+	struct device *kdev = kobj_to_dev(kobj);
+	struct drm_minor *minor = dev_to_drm_minor(kdev);
+	struct drm_device *dev = minor->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_guc *guc = &dev_priv->guc;
+	struct intel_guc_log_client *log_client = &guc->log.sysfs_client;
+	int ret;
+
+	if (!guc->log_obj || !guc->log.buf_obj)
+		return -ENODEV;
+
+	spin_lock_irq(&guc->log.buf_lock);
+
+	log_client->scratch_buf = buf;
+	log_client->guc = guc;
+	ret = i915_guc_read_logs(log_client, count, filp->f_flags);
+	log_client->scratch_buf = NULL;
+
+	spin_unlock_irq(&guc->log.buf_lock);
+
+	return ret;
+}
+
+static struct bin_attribute guc_log_attr = {
+	.attr.name = "guc_log",
+	.attr.mode = S_IRUSR,
+	.size = 0,
+	.read = guc_log_data_read,
+};
+
 void i915_setup_sysfs(struct drm_device *dev)
 {
 	int ret;
@@ -639,10 +673,16 @@ void i915_setup_sysfs(struct drm_device *dev)
 				    &error_state_attr);
 	if (ret)
 		DRM_ERROR("error_state sysfs setup failed\n");
+
+	ret = sysfs_create_bin_file(&dev->primary->kdev->kobj,
+				    &guc_log_attr);
+	if (ret)
+		DRM_ERROR("guc_log sysfs setup failed\n");
 }
 
 void i915_teardown_sysfs(struct drm_device *dev)
 {
+	sysfs_remove_bin_file(&dev->primary->kdev->kobj, &guc_log_attr);
 	sysfs_remove_bin_file(&dev->primary->kdev->kobj, &error_state_attr);
 	if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
 		sysfs_remove_files(&dev->primary->kdev->kobj, vlv_attrs);
diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h
index 985fb4b..5bb44b5 100644
--- a/drivers/gpu/drm/i915/intel_guc.h
+++ b/drivers/gpu/drm/i915/intel_guc.h
@@ -136,6 +136,8 @@ struct intel_guc_log {
 	uint64_t next_seq;
 	/* For Userspace clients to pull logs via /dev/dri/guc_log */
 	struct miscdevice misc_dev;
+	/* For getting logs via /sys/class/drm/card0/guc_log iface */
+	struct intel_guc_log_client sysfs_client;
 };
 
 struct intel_guc {
-- 
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 ` [RFC 07/12] drm/i915: Allocate local buffer to store GuC ukernel logs akash.goel
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 ` akash.goel [this message]
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-12-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