From patchwork Fri May 27 19:43:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: akash.goel@intel.com X-Patchwork-Id: 9138909 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EE75D6075A for ; Fri, 27 May 2016 19:32:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF92027CF9 for ; Fri, 27 May 2016 19:32:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2F9028294; Fri, 27 May 2016 19:32:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE8FC27CF9 for ; Fri, 27 May 2016 19:32:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E18FB6ED19; Fri, 27 May 2016 19:32:05 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id 9EC066ED14 for ; Fri, 27 May 2016 19:30:17 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 27 May 2016 12:30:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,375,1459839600"; d="scan'208";a="986117673" Received: from akashgoe-desktop.iind.intel.com ([10.223.82.36]) by orsmga002.jf.intel.com with ESMTP; 27 May 2016 12:30:15 -0700 From: akash.goel@intel.com To: intel-gfx@lists.freedesktop.org Date: Sat, 28 May 2016 01:13:02 +0530 Message-Id: <1464378183-9433-12-git-send-email-akash.goel@intel.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1464378183-9433-1-git-send-email-akash.goel@intel.com> References: <1464378183-9433-1-git-send-email-akash.goel@intel.com> Cc: sourab.gupta@intel.com, Akash Goel Subject: [Intel-gfx] [RFC 11/12] drm/i915: Add sysfs interface to capture the GuC ukernel logs X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Akash Goel 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 --- 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 {