[PATCH 5/9] drm/i915: Enable i915 perf stream for Haswell OA unit

Chris Wilson chris at chris-wilson.co.uk
Wed Apr 20 23:16:16 UTC 2016


On Wed, Apr 20, 2016 at 03:23:10PM +0100, Robert Bragg wrote:
> +static int hsw_enable_metric_set(struct drm_i915_private *dev_priv)
> +{
> +	int ret = i915_oa_select_metric_set_hsw(dev_priv);
> +
> +	if (ret)
> +		return ret;
> +
> +	I915_WRITE(GDT_CHICKEN_BITS, GT_NOA_ENABLE);
> +
> +	/* PRM:
> +	 *
> +	 * OA unit is using “crclk” for its functionality. When trunk
> +	 * level clock gating takes place, OA clock would be gated,
> +	 * unable to count the events from non-render clock domain.
> +	 * Render clock gating must be disabled when OA is enabled to
> +	 * count the events from non-render domain. Unit level clock
> +	 * gating for RCS should also be disabled.
> +	 */
> +	I915_WRITE(GEN7_MISCCPCTL, (I915_READ(GEN7_MISCCPCTL) &
> +				    ~GEN7_DOP_CLOCK_GATE_ENABLE));
> +	I915_WRITE(GEN6_UCGCTL1, (I915_READ(GEN6_UCGCTL1) |
> +				  GEN6_CSUNIT_CLOCK_GATE_DISABLE));
> +
> +	config_oa_regs(dev_priv, dev_priv->perf.oa.mux_regs,
> +		       dev_priv->perf.oa.mux_regs_len);
> +
> +	/* It takes a fairly long time for a new MUX configuration to
> +	 * be be applied after these register writes. This delay
> +	 * duration was derived empirically based on the render_basic
> +	 * config but hopefully it covers the maximum configuration
> +	 * latency...
> +	 */
> +	mdelay(100);

You really want to busy spin for 100ms? msleep() perhaps!

Did you look for some register you can observe the change in when the
mux is reconfigured? Is even reading one of the OA registers enough?

> +	config_oa_regs(dev_priv, dev_priv->perf.oa.b_counter_regs,
> +		       dev_priv->perf.oa.b_counter_regs_len);
> +
> +	return 0;
> +}
> +
> +static void hsw_disable_metric_set(struct drm_i915_private *dev_priv)
> +{
> +	I915_WRITE(GEN6_UCGCTL1, (I915_READ(GEN6_UCGCTL1) &
> +				  ~GEN6_CSUNIT_CLOCK_GATE_DISABLE));
> +	I915_WRITE(GEN7_MISCCPCTL, (I915_READ(GEN7_MISCCPCTL) |
> +				    GEN7_DOP_CLOCK_GATE_ENABLE));
> +
> +	I915_WRITE(GDT_CHICKEN_BITS, (I915_READ(GDT_CHICKEN_BITS) &
> +				      ~GT_NOA_ENABLE));

You didn't preserve any other chicken bits during enable_metric_set.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the dri-devel mailing list