From a3923053779949e1342378c9f7e7e5d243718a75 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Thu, 27 Nov 2014 16:15:21 +0100 Subject: [PATCH] drm/i915: Ignore unclaimed reg errors due to userspace tools Userspace tooling like the reg dumper don't bother with checking power wells and stuff and so cause lots of unclaimed register issues. Which then linger and result in fail in subsequent tests. To figure out whether userspace is doing access abuse the forcewake debugfs file and block any unclaimed register errors while that's open. Also clear any errors when closing it again. v2: git add to make it compile. Oops. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=85890 Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_debugfs.c | 6 ++++++ drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/intel_uncore.c | 15 +++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 7ea3843ca612..c29040c68240 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -4228,6 +4228,8 @@ static int i915_forcewake_open(struct inode *inode, struct file *file) struct drm_device *dev = inode->i_private; struct drm_i915_private *dev_priv = dev->dev_private; + atomic_inc(&dev_priv->uncore.user_access_count); + if (INTEL_INFO(dev)->gen < 6) return 0; @@ -4241,6 +4243,10 @@ static int i915_forcewake_release(struct inode *inode, struct file *file) struct drm_device *dev = inode->i_private; struct drm_i915_private *dev_priv = dev->dev_private; + atomic_dec(&dev_priv->uncore.user_access_count); + + intel_uncore_reset_errors(dev); + if (INTEL_INFO(dev)->gen < 6) return 0; diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 049482f5d9ac..6795d5a86fdf 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -561,6 +561,7 @@ struct intel_uncore { unsigned fifo_count; unsigned forcewake_count; + atomic_t user_access_count; unsigned fw_rendercount; unsigned fw_mediacount; @@ -2411,6 +2412,7 @@ extern void intel_uncore_sanitize(struct drm_device *dev); extern void intel_uncore_early_sanitize(struct drm_device *dev, bool restore_forcewake); extern void intel_uncore_init(struct drm_device *dev); +extern void intel_uncore_reset_errors(struct drm_device *dev); extern void intel_uncore_check_errors(struct drm_device *dev); extern void intel_uncore_fini(struct drm_device *dev); extern void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore); diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c index 46de8d75b4bf..1b2237bb66ff 100644 --- a/drivers/gpu/drm/i915/intel_uncore.c +++ b/drivers/gpu/drm/i915/intel_uncore.c @@ -718,7 +718,8 @@ hsw_unclaimed_reg_debug(struct drm_i915_private *dev_priv, u32 reg, bool read, const char *op = read ? "reading" : "writing to"; const char *when = before ? "before" : "after"; - if (!i915.mmio_debug) + if (!i915.mmio_debug || + atomic_read(&dev_priv->uncore.user_access_count)) return; if (__raw_i915_read32(dev_priv, FPGA_DBG) & FPGA_DBG_RM_NOCLAIM) { @@ -731,7 +732,7 @@ hsw_unclaimed_reg_debug(struct drm_i915_private *dev_priv, u32 reg, bool read, static void hsw_unclaimed_reg_detect(struct drm_i915_private *dev_priv) { - if (i915.mmio_debug) + if (i915.mmio_debug || atomic_read(&dev_priv->uncore.user_access_count)) return; if (__raw_i915_read32(dev_priv, FPGA_DBG) & FPGA_DBG_RM_NOCLAIM) { @@ -1470,6 +1471,16 @@ int intel_gpu_reset(struct drm_device *dev) return -ENODEV; } +void intel_uncore_reset_errors(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + + if (HAS_FPGA_DBG_UNCLAIMED(dev) && + (__raw_i915_read32(dev_priv, FPGA_DBG) & FPGA_DBG_RM_NOCLAIM)) { + __raw_i915_write32(dev_priv, FPGA_DBG, FPGA_DBG_RM_NOCLAIM); + } +} + void intel_uncore_check_errors(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; -- 2.1.1