From patchwork Fri Jun 28 22:23:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 2802581 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E2D3ABF4A1 for ; Fri, 28 Jun 2013 22:21:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E0E92028F for ; Fri, 28 Jun 2013 22:21:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 3B84920286 for ; Fri, 28 Jun 2013 22:21:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4175DE6249 for ; Fri, 28 Jun 2013 15:21:41 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from shiva.localdomain (unknown [209.20.75.48]) by gabe.freedesktop.org (Postfix) with ESMTP id E4C51E5C40 for ; Fri, 28 Jun 2013 15:20:33 -0700 (PDT) Received: by shiva.localdomain (Postfix, from userid 99) id 84F4288652; Fri, 28 Jun 2013 22:20:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lundgren.kumite (c-24-21-100-90.hsd1.or.comcast.net [24.21.100.90]) by shiva.localdomain (Postfix) with ESMTPSA id 697F888081; Fri, 28 Jun 2013 22:20:32 +0000 (UTC) From: Ben Widawsky To: Intel GFX Date: Fri, 28 Jun 2013 15:23:33 -0700 Message-Id: <1372458217-2053-3-git-send-email-ben@bwidawsk.net> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1372458217-2053-1-git-send-email-ben@bwidawsk.net> References: <1372458217-2053-1-git-send-email-ben@bwidawsk.net> Cc: Paul Berry , Ben Widawsky Subject: [Intel-gfx] [PATCH 2/6] drm/i915: Debugfs for setting debug_flags X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Virus-Scanned: ClamAV using ClamSMTP The lock in the setter isn't really necessary - however we're doing some more stuff there presently, so just leave it in... Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_debugfs.c | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 4d9d8a1..5d6a020 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -2182,6 +2182,42 @@ DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, i915_cache_sharing_get, i915_cache_sharing_set, "%llu\n"); +static int +i915_debug_flags_get(void *data, u64 *val) +{ + struct drm_device *dev = data; + struct drm_i915_private *dev_priv = dev->dev_private; + + *val = dev_priv->debug_flags; + + return 0; +} + +static int +i915_debug_flags_set(void *data, u64 val) +{ + struct drm_device *dev = data; + struct drm_i915_private *dev_priv = dev->dev_private; + int ret; + + /* FIXME?: Nothing prevents this from working pre GEN6; but don't want + * to touch AGP code. + */ + if (INTEL_INFO(dev)->gen < 6 && val & I915_SCRATCH_FAULTS) + DRM_DEBUG_DRIVER("Tried to set unsupported SCRATCH_FAULTS\n"); + + ret = mutex_lock_interruptible(&dev->struct_mutex); + if (ret) + return ret; + dev_priv->debug_flags = val; + mutex_unlock(&dev_priv->dev->struct_mutex); + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(i915_debug_flag_fops, + i915_debug_flags_get, i915_debug_flags_set, + "%llu\n"); + /* As the drm_debugfs_init() routines are called before dev->dev_private is * allocated we need to hook into the minor for release. */ static int @@ -2366,6 +2402,13 @@ int i915_debugfs_init(struct drm_minor *minor) if (ret) return ret; + ret = i915_debugfs_create(minor->debugfs_root, minor, + "i915_debug_flags", + &i915_debug_flag_fops); + if (ret) + return ret; + + return drm_debugfs_create_files(i915_debugfs_list, I915_DEBUGFS_ENTRIES, minor->debugfs_root, minor); @@ -2393,6 +2436,8 @@ void i915_debugfs_cleanup(struct drm_minor *minor) 1, minor); drm_debugfs_remove_files((struct drm_info_list *) &i915_next_seqno_fops, 1, minor); + drm_debugfs_remove_files((struct drm_info_list *) &i915_debug_flag_fops, + 1, minor); } #endif /* CONFIG_DEBUG_FS */