* [PATCH] drm/i915: Squelch WARN for VLV_COUNTER_CONTROL
@ 2017-03-17 12:59 Chris Wilson
2017-03-17 13:04 ` Mika Kuoppala
0 siblings, 1 reply; 2+ messages in thread
From: Chris Wilson @ 2017-03-17 12:59 UTC (permalink / raw)
To: intel-gfx; +Cc: Mika Kuoppala
Before rc6 is initialised (after driver load or resume), the value inside
VLV_COUNTER_CONTROL is undefined so we cannot make an assertion that is
in HIGH_RANGE mode.
Fixes: 6b7f6aa75e38 ("drm/i915: Use coarse grained residency counter with byt")
Testcase: igt/drv_suspend/debugfs-reader
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
---
drivers/gpu/drm/i915/intel_pm.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index d55bf882d1aa..aece0ff88a5d 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -8354,22 +8354,24 @@ void intel_pm_setup(struct drm_i915_private *dev_priv)
static u64 vlv_residency_raw(struct drm_i915_private *dev_priv,
const i915_reg_t reg)
{
- u32 lower, upper, tmp, saved_ctl;
+ u32 lower, upper, tmp;
/* The register accessed do not need forcewake. We borrow
* uncore lock to prevent concurrent access to range reg.
*/
spin_lock_irq(&dev_priv->uncore.lock);
- saved_ctl = I915_READ_FW(VLV_COUNTER_CONTROL);
-
- if (WARN_ON(!(saved_ctl & VLV_COUNT_RANGE_HIGH)))
- I915_WRITE_FW(VLV_COUNTER_CONTROL,
- _MASKED_BIT_ENABLE(VLV_COUNT_RANGE_HIGH));
/* vlv and chv residency counters are 40 bits in width.
* With a control bit, we can choose between upper or lower
* 32bit window into this counter.
+ *
+ * Although we always use the counter in high-range mode elsewhere,
+ * userspace may attempt to read the value before rc6 is initialised,
+ * before we have set the default VLV_COUNTER_CONTROL value. So always
+ * set the high bit to be safe.
*/
+ I915_WRITE_FW(VLV_COUNTER_CONTROL,
+ _MASKED_BIT_ENABLE(VLV_COUNT_RANGE_HIGH));
upper = I915_READ_FW(reg);
do {
tmp = upper;
@@ -8383,6 +8385,11 @@ static u64 vlv_residency_raw(struct drm_i915_private *dev_priv,
upper = I915_READ_FW(reg);
} while (upper != tmp);
+ /* Everywhere else we always use VLV_COUNTER_CONTROL with the
+ * VLV_COUNT_RANGE_HIGH bit set - so it is safe to leave it set
+ * now.
+ */
+
spin_unlock_irq(&dev_priv->uncore.lock);
return lower | (u64)upper << 8;
--
2.11.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/i915: Squelch WARN for VLV_COUNTER_CONTROL
2017-03-17 12:59 [PATCH] drm/i915: Squelch WARN for VLV_COUNTER_CONTROL Chris Wilson
@ 2017-03-17 13:04 ` Mika Kuoppala
0 siblings, 0 replies; 2+ messages in thread
From: Mika Kuoppala @ 2017-03-17 13:04 UTC (permalink / raw)
To: Chris Wilson, intel-gfx
Chris Wilson <chris@chris-wilson.co.uk> writes:
> Before rc6 is initialised (after driver load or resume), the value inside
> VLV_COUNTER_CONTROL is undefined so we cannot make an assertion that is
> in HIGH_RANGE mode.
>
> Fixes: 6b7f6aa75e38 ("drm/i915: Use coarse grained residency counter with byt")
> Testcase: igt/drv_suspend/debugfs-reader
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
> drivers/gpu/drm/i915/intel_pm.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index d55bf882d1aa..aece0ff88a5d 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -8354,22 +8354,24 @@ void intel_pm_setup(struct drm_i915_private *dev_priv)
> static u64 vlv_residency_raw(struct drm_i915_private *dev_priv,
> const i915_reg_t reg)
> {
> - u32 lower, upper, tmp, saved_ctl;
> + u32 lower, upper, tmp;
>
> /* The register accessed do not need forcewake. We borrow
> * uncore lock to prevent concurrent access to range reg.
> */
> spin_lock_irq(&dev_priv->uncore.lock);
> - saved_ctl = I915_READ_FW(VLV_COUNTER_CONTROL);
> -
> - if (WARN_ON(!(saved_ctl & VLV_COUNT_RANGE_HIGH)))
> - I915_WRITE_FW(VLV_COUNTER_CONTROL,
> - _MASKED_BIT_ENABLE(VLV_COUNT_RANGE_HIGH));
>
> /* vlv and chv residency counters are 40 bits in width.
> * With a control bit, we can choose between upper or lower
> * 32bit window into this counter.
> + *
> + * Although we always use the counter in high-range mode elsewhere,
> + * userspace may attempt to read the value before rc6 is initialised,
> + * before we have set the default VLV_COUNTER_CONTROL value. So always
> + * set the high bit to be safe.
> */
> + I915_WRITE_FW(VLV_COUNTER_CONTROL,
> + _MASKED_BIT_ENABLE(VLV_COUNT_RANGE_HIGH));
> upper = I915_READ_FW(reg);
> do {
> tmp = upper;
> @@ -8383,6 +8385,11 @@ static u64 vlv_residency_raw(struct drm_i915_private *dev_priv,
> upper = I915_READ_FW(reg);
> } while (upper != tmp);
>
> + /* Everywhere else we always use VLV_COUNTER_CONTROL with the
> + * VLV_COUNT_RANGE_HIGH bit set - so it is safe to leave it set
> + * now.
> + */
> +
> spin_unlock_irq(&dev_priv->uncore.lock);
>
> return lower | (u64)upper << 8;
> --
> 2.11.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-17 13:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-17 12:59 [PATCH] drm/i915: Squelch WARN for VLV_COUNTER_CONTROL Chris Wilson
2017-03-17 13:04 ` Mika Kuoppala
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.