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 <ben at bwidawsk.net> --- 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 */ -- 1.8.3.1