drm/i915: Consolidate unclaimed reg detection
Subsystems (2)
PATCH 1/4 drm/i915: Consolidate unclaimed reg detection
Access the unclaimed reg detection register through
one helper which also does cleanup. Note that we now access the register only if the platform has the actual non claimed access bit. This prevents needlessly reading the register with older gens when debug_mmio > 0.
--- drivers/gpu/drm/i915/intel_uncore.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/intel_uncore.c +22 -12
@@ -334,13 +334,30 @@ static void intel_uncore_ellc_detect(struct drm_device *dev) } } +static bool +unclaimed_reg_access (struct drm_i915_private *dev_priv) +{ +u32 dbg; + +if (!HAS_FPGA_DBG_UNCLAIMED (dev_priv)) +return false; + + dbg =__raw_i915_read32 (dev_priv,FPGA_DBG ); +if (likely (!(dbg &FPGA_DBG_RM_NOCLAIM ))) +return false; + +__raw_i915_write32 (dev_priv,FPGA_DBG ,FPGA_DBG_RM_NOCLAIM ); + +return true; +} +static void __intel_uncore_early_sanitize (struct drm_device *dev,bool restore_forcewake) {struct drm_i915_private *dev_priv = dev->dev_private; -if (HAS_FPGA_DBG_UNCLAIMED (dev)) -__raw_i915_write32 (dev_priv,FPGA_DBG ,FPGA_DBG_RM_NOCLAIM ); +/* clear out unclaimed reg detection bit */ +unclaimed_reg_access (dev_priv);/* clear out old GT FIFO errors */ if (IS_GEN6 (dev) ||IS_GEN7 (dev))
@@ -601,10 +618,9 @@ hsw_unclaimed_reg_debug(struct drm_i915_private *dev_priv,if (!i915.mmio_debug)return ; -if (__raw_i915_read32 (dev_priv,FPGA_DBG ) &FPGA_DBG_RM_NOCLAIM ) { +if (unclaimed_reg_access (dev_priv)) {WARN (1 ,"Unclaimed register detected %s %s register 0x%x\n" , when, op,i915_mmio_reg_offset (reg)); -__raw_i915_write32 (dev_priv,FPGA_DBG ,FPGA_DBG_RM_NOCLAIM ); i915.mmio_debug--;/* Only report the first N failures */ } }
@@ -617,11 +633,10 @@ hsw_unclaimed_reg_detect(struct drm_i915_private *dev_priv)if (i915.mmio_debug || !mmio_debug_once)return ; -if (__raw_i915_read32 (dev_priv,FPGA_DBG ) &FPGA_DBG_RM_NOCLAIM ) { +if (unclaimed_reg_access (dev_priv)) {DRM_DEBUG ("Unclaimed register detected, " "enabling oneshot unclaimed register reporting. " "Please use i915.mmio_debug=N for more information.\n" ); -__raw_i915_write32 (dev_priv,FPGA_DBG ,FPGA_DBG_RM_NOCLAIM ); i915.mmio_debug = mmio_debug_once--; } }
@@ -1589,11 +1604,6 @@ bool intel_has_gpu_reset(struct drm_device *dev)void intel_uncore_check_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 )) { +if (unclaimed_reg_access (to_i915 (dev)))DRM_ERROR ("Unclaimed register before interrupt\n" ); -__raw_i915_write32 (dev_priv,FPGA_DBG ,FPGA_DBG_RM_NOCLAIM ); - } }
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/4 drm/i915: Introduce intel_uncore_unclaimed_access
Currently interrupt code is the only place checking for the unclaimed register access prior to actual register macros using the same functionality. Rename the function and make it return bool so that the possible error message context is clear in the caller side. The motivation is to allow usage of unclaimed detection on arbitrary places.
--- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_irq.c | 3 ++- drivers/gpu/drm/i915/intel_uncore.c | 5 ++--- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -2725,7 +2725,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_check_errors (struct drm_device *dev); +extern bool intel_uncore_unclaimed_access (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);const char *intel_uncore_forcewake_domain_to_str (const enum forcewake_domain_id id);
drivers/gpu/drm/i915/i915_irq.c +2 -1
@@ -2167,7 +2167,8 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)/* We get interrupts on unclaimed registers, so check for this before we * do any I915_{READ,WRITE}. */ -intel_uncore_check_errors (dev); +if (intel_uncore_unclaimed_access (dev)) +DRM_ERROR ("Unclaimed register before interrupt\n" );/* disable master interrupt before clearing iir */ de_ier =I915_READ (DEIER );
drivers/gpu/drm/i915/intel_uncore.c +2 -3
@@ -1602,8 +1602,7 @@ bool intel_has_gpu_reset(struct drm_device *dev)return intel_get_gpu_reset (dev) !=NULL ; } -void intel_uncore_check_errors (struct drm_device *dev) +bool intel_uncore_unclaimed_access (struct drm_device *dev) { -if (unclaimed_reg_access (to_i915 (dev))) -DRM_ERROR ("Unclaimed register before interrupt\n" ); +return unclaimed_reg_access (to_i915 (dev)); }
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/4] drm/i915: Introduce intel_uncore_unclaimed_access
Quoted 32 lines · Mika Kuoppala
Currently interrupt code is the only place checking for the unclaimed register access prior to actual register macros using the same functionality. Rename the function and make it return bool so that the possible error message context is clear in the caller side. The motivation is to allow usage of unclaimed detection on arbitrary places.
Signed-off-by Mika Kuoppala <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_irq.c | 3 ++- drivers/gpu/drm/i915/intel_uncore.c | 5 ++--- 3 files changed, 5 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-1@@ -2725,7 +2725,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_check_errors (struct drm_device *dev); +extern bool intel_uncore_unclaimed_access (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);const char *intel_uncore_forcewake_domain_to_str (const enum forcewake_domain_id id);drivers/gpu/drm/i915/i915_irq.c +0
-0
drivers/gpu/drm/i915/i915_irq.c static irqreturn_t ironlake_irq_handler(int irq, void *arg) · line 2171
Quoted 6 lines
drivers/gpu/drm/i915/i915_irq.c +2
-1@@ -2167,7 +2167,8 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)/* We get interrupts on unclaimed registers, so check for this before we * do any I915_{READ,WRITE}. */ -intel_uncore_check_errors (dev); +if (intel_uncore_unclaimed_access (dev)) +DRM_ERROR ("Unclaimed register before interrupt\n" );
This reminds me that having this error message is spectacularly unhelpful. Could I persuade you to adopt
it's been on the list a few times. With your new framework it may make sense to move it about. For instance, doing the check every interrupt is not great.
Quoted 7 lines
drivers/gpu/drm/i915/i915_irq.c +0
-0/* disable master interrupt before clearing iir */ de_ier =I915_READ (DEIER );drivers/gpu/drm/i915/intel_uncore.c +0
-0
drivers/gpu/drm/i915/intel_uncore.c bool intel_has_gpu_reset(struct drm_device *dev) · line 1608
Quoted 10 lines
drivers/gpu/drm/i915/intel_uncore.c +2
-3@@ -1602,8 +1602,7 @@ bool intel_has_gpu_reset(struct drm_device *dev)return intel_get_gpu_reset (dev) !=NULL ; } -void intel_uncore_check_errors (struct drm_device *dev) +bool intel_uncore_unclaimed_access (struct drm_device *dev) { -if (unclaimed_reg_access (to_i915 (dev))) -DRM_ERROR ("Unclaimed register before interrupt\n" ); +return unclaimed_reg_access (to_i915 (dev)); }
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 drm/i915: Detect and clear unclaimed access on resume
In reply to Mika KuoppalaIf something, the usual suspect being bios, access hw behind our back, dont let it slide into situation where normal register access will detect this and spit out a warn on into dmesg. On some bdw bioses this happens during igt/bat run always and as there is not much we can do about it, its better just to detect and flush this explicitly on resume and only print a debug message.
Testcase: igt/pm_rpm/basic-rte
--- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +5 -0
@@ -1477,6 +1477,9 @@ static int intel_runtime_suspend(struct device *device)cancel_delayed_work_sync (&dev_priv->gpu_error.hangcheck_work);intel_uncore_forcewake_reset (dev, false); +if (intel_uncore_unclaimed_access (dev)) +DRM_ERROR ("Unclaimed access detected prior suspending\n" ); + dev_priv->pm.suspended = true;/*
@@ -1522,6 +1525,8 @@ static int intel_runtime_resume(struct device *device)intel_opregion_notify_adapter (dev,PCI_D0 ); dev_priv->pm.suspended = false; +if (intel_uncore_unclaimed_access (dev)) +DRM_DEBUG_KMS ("Unclaimed access during suspend, bios?\n" );intel_guc_resume (dev);
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Detect and clear unclaimed access on resume
Quoted 32 lines · Mika Kuoppala
If something, the usual suspect being bios, access hw behind our back, dont let it slide into situation where normal register access will detect this and spit out a warn on into dmesg. On some bdw bioses this happens during igt/bat run always and as there is not much we can do about it, its better just to detect and flush this explicitly on resume and only print a debug message.
Testcase: igt/pm_rpm/basic-rte
Cc Chris Wilson <[email protected]>Cc Paulo Zanoni <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/i915/i915_drv.c +3
-0@@ -1477,6 +1477,9 @@ static int intel_runtime_suspend(struct device *device)cancel_delayed_work_sync (&dev_priv->gpu_error.hangcheck_work);intel_uncore_forcewake_reset (dev, false); +if (intel_uncore_unclaimed_access (dev)) +DRM_ERROR ("Unclaimed access detected prior suspending\n" ); + dev_priv->pm.suspended = true;/*
drivers/gpu/drm/i915/i915_drv.c static int intel_runtime_resume(struct device *device) · line 1529
Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.c +2
-0@@ -1522,6 +1525,8 @@ static int intel_runtime_resume(struct device *device)intel_opregion_notify_adapter (dev,PCI_D0 ); dev_priv->pm.suspended = false; +if (intel_uncore_unclaimed_access (dev)) +DRM_DEBUG_KMS ("Unclaimed access during suspend, bios?\n" );
DRM_DEBUG_DRIVER(), is this not modesetting related.
Other than that, looks like a good idea. Now I just need to see some patches to see what intel_uncore_unclaimed_access() does... -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 drm/i915: Detect and clear unclaimed access on resume
If something, the usual suspect being bios, access hw behind our back, dont let it slide into situation where normal register access will detect this and spit out a warn on into dmesg. On some bdw bioses this happens during igt/bat run always and as there is not much we can do about it, its better just to detect and flush this explicitly on resume and only print a debug message.
v2: use DRM_DEBUG_DRIVER (Chris)
Testcase: igt/pm_rpm/basic-rte
--- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +5 -0
@@ -1477,6 +1477,9 @@ static int intel_runtime_suspend(struct device *device)cancel_delayed_work_sync (&dev_priv->gpu_error.hangcheck_work);intel_uncore_forcewake_reset (dev, false); +if (intel_uncore_unclaimed_access (dev)) +DRM_ERROR ("Unclaimed access detected prior suspending\n" ); + dev_priv->pm.suspended = true;/*
@@ -1522,6 +1525,8 @@ static int intel_runtime_resume(struct device *device)intel_opregion_notify_adapter (dev,PCI_D0 ); dev_priv->pm.suspended = false; +if (intel_uncore_unclaimed_access (dev)) +DRM_DEBUG_DRIVER ("Unclaimed access during suspend, bios?\n" );intel_guc_resume (dev);
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Detect and clear unclaimed access on resume
Quoted 24 lines · Mika Kuoppala
If something, the usual suspect being bios, access hw behind our back, dont let it slide into situation where normal register access will detect this and spit out a warn on into dmesg. On some bdw bioses this happens during igt/bat run always and as there is not much we can do about it, its better just to detect and flush this explicitly on resume and only print a debug message.
v2: use
DRM_DEBUG_DRIVER(Chris)Testcase: igt/pm_rpm/basic-rte
Cc Chris Wilson <[email protected]>Cc Paulo Zanoni <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/i915/i915_drv.c +0
-0
drivers/gpu/drm/i915/i915_drv.c static int intel_runtime_suspend(struct device *device) · line 1481
Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.c +2
-0@@ -1477,6 +1477,9 @@ static int intel_runtime_suspend(struct device *device)cancel_delayed_work_sync (&dev_priv->gpu_error.hangcheck_work);intel_uncore_forcewake_reset (dev, false); +if (intel_uncore_unclaimed_access (dev)) +DRM_ERROR ("Unclaimed access detected prior suspending\n" );
s/prior/prior to/
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 drm/i915: Check unclaimed access per forcewake domain get/put
In reply to Mika KuoppalaWe do unclaimed register access check in non mmio_debug mode once per write. This adds probability of finding the exact sequence where we did the bad access, but also adds burden to each write.
As we have mmio_debug available for more fine grained analysis, give up some accuracy for the benefit of performance in normal case. Do this by doing the unclaimed reg check only once when forcewake domains are get.
--- drivers/gpu/drm/i915/intel_uncore.c | 39 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/intel_uncore.c +19 -20
@@ -351,6 +351,22 @@ unclaimed_reg_access(struct drm_i915_private *dev_priv)return true; } +static void +unclaimed_access_detect_oneshot (struct drm_i915_private *dev_priv) +{ +static bool mmio_debug_once = true; + +if (i915.mmio_debug || !mmio_debug_once) +return ; + +if (unclaimed_reg_access (dev_priv)) { +DRM_DEBUG ("Unclaimed register detected, " +"enabling oneshot unclaimed register reporting. " +"Please use i915.mmio_debug=N for more information.\n" ); + i915.mmio_debug = mmio_debug_once--; + } +} +static void __intel_uncore_early_sanitize (struct drm_device *dev,bool restore_forcewake) {
@@ -403,8 +419,10 @@ static void __intel_uncore_forcewake_get(struct drm_i915_private *dev_priv, fw_domains &= ~(1 << id); } -if (fw_domains) +if (fw_domains) { dev_priv->uncore.funcs.force_wake_get (dev_priv, fw_domains); +unclaimed_access_detect_oneshot (dev_priv); + } }/**
@@ -625,22 +643,6 @@ hsw_unclaimed_reg_debug(struct drm_i915_private *dev_priv, } } -static void -hsw_unclaimed_reg_detect (struct drm_i915_private *dev_priv) -{ -static bool mmio_debug_once = true; - -if (i915.mmio_debug || !mmio_debug_once) -return ; - -if (unclaimed_reg_access (dev_priv)) { -DRM_DEBUG ("Unclaimed register detected, " -"enabling oneshot unclaimed register reporting. " -"Please use i915.mmio_debug=N for more information.\n" ); - i915.mmio_debug = mmio_debug_once--; - } -} -#define GEN2_READ_HEADER (x) \ u##x val = 0; \ assert_device_not_suspended(dev_priv);
@@ -920,7 +922,6 @@ hsw_write##x(struct drm_i915_private *dev_priv, i915_reg_t reg, u##x val, bool tgen6_gt_check_fifodbg (dev_priv); \ } \hsw_unclaimed_reg_debug (dev_priv, reg, false, false); \ -hsw_unclaimed_reg_detect (dev_priv); \GEN6_WRITE_FOOTER ; \ }
@@ -955,7 +956,6 @@ gen8_write##x(struct drm_i915_private *dev_priv, i915_reg_t reg, u##x val, bool__force_wake_get (dev_priv,FORCEWAKE_RENDER ); \ __raw_i915_write##x(dev_priv, reg, val); \ hsw_unclaimed_reg_debug(dev_priv, reg, false, false); \ - hsw_unclaimed_reg_detect(dev_priv); \ GEN6_WRITE_FOOTER; \ }
@@ -1025,7 +1025,6 @@ gen9_write##x(struct drm_i915_private *dev_priv, i915_reg_t reg, u##x val, \__force_wake_get (dev_priv, fw_engine); \ __raw_i915_write##x(dev_priv, reg, val); \ hsw_unclaimed_reg_debug(dev_priv, reg, false, false); \ - hsw_unclaimed_reg_detect(dev_priv); \ GEN6_WRITE_FOOTER; \ }
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/4] drm/i915: Check unclaimed access per forcewake domain get/put
Quoted 9 lines · Mika Kuoppala
We do unclaimed register access check in non
mmio_debugmode once per write. This adds probability of finding the exact sequence where we did the bad access, but also adds burden to each write.As we have
mmio_debugavailable for more fine grained analysis, give up some accuracy for the benefit of performance in normal case. Do this by doing the unclaimed reg check only once when forcewake domains are get.
Still far too often in the normal case.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 18 lines · Mika Kuoppala
Access the unclaimed reg detection register through
one helper which also does cleanup. Note that we now access the register only if the platform has the actual non claimed access bit. This prevents needlessly reading the register with older gens whendebug_mmio> 0.Cc Chris Wilson <[email protected]>Cc Paulo Zanoni <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>--- drivers/gpu/drm/i915/intel_uncore.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)drivers/gpu/drm/i915/intel_uncore.c +0
-0
drivers/gpu/drm/i915/intel_uncore.c static void intel_uncore_ellc_detect(struct drm_device *dev) · line 338
Quoted 5 lines
drivers/gpu/drm/i915/intel_uncore.c +2
-0@@ -334,13 +334,30 @@ static void intel_uncore_ellc_detect(struct drm_device *dev) } } +static bool +unclaimed_reg_access (struct drm_i915_private *dev_priv)
check_unclaimed_mmio() otherwise the verb here is "access" and the function says "access this register in an unclaimed manner". Or perhaps detect_unclaimed_mmio() would be closer to surrounding usage. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx