@@ -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);
@@ -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 {