[RFC 11/12] drm/i915: Add sysfs interface to capture the GuC ukernel logs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Akash Goel <akash.goel@xxxxxxxxx>

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@xxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux