<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 5, 2017 at 6:26 PM, Ville Syrjälä <span dir="ltr"><<a href="mailto:ville.syrjala@linux.intel.com" target="_blank">ville.syrjala@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, Apr 05, 2017 at 06:17:36PM +0100, Lionel Landwerlin wrote:<br>
> On 05/04/17 18:06, Ville Syrjälä wrote:<br>
> > On Wed, Apr 05, 2017 at 05:23:19PM +0100, Robert Bragg wrote:<br>
> >> An oa_exponent_to_ns() utility and per-gen timebase constants where<br>
> >> recently removed when updating the tail pointer race condition WA, and<br>
> >> this restores those so we can update the _PROP_OA_EXPONENT validation<br>
> >> done in read_properties_unlocked() to not assume we have a 12.5KHz<br>
> >> timebase as we did for Haswell.<br>
> >><br>
> >> Signed-off-by: Robert Bragg <<a href="mailto:robert@sixbynine.org">robert@sixbynine.org</a>><br>
> >> Cc: Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@linux.intel.com">lionel.g.landwerlin@linux.<wbr>intel.com</a>><br>
> >> ---<br>
> >>   drivers/gpu/drm/i915/i915_drv.<wbr>h  |  1 +<br>
> >>   drivers/gpu/drm/i915/i915_<wbr>perf.c | 21 +++++++++++++++------<br>
> >>   2 files changed, 16 insertions(+), 6 deletions(-)<br>
> >><br>
> >> diff --git a/drivers/gpu/drm/i915/i915_<wbr>drv.h b/drivers/gpu/drm/i915/i915_<wbr>drv.h<br>
> >> index 3a22b6fd0ee6..48b07d706f06 100644<br>
> >> --- a/drivers/gpu/drm/i915/i915_<wbr>drv.h<br>
> >> +++ b/drivers/gpu/drm/i915/i915_<wbr>drv.h<br>
> >> @@ -2463,6 +2463,7 @@ struct drm_i915_private {<br>
> >><br>
> >>                    bool periodic;<br>
> >>                    int period_exponent;<br>
> >> +                  int timestamp_frequency;<br>
> >><br>
> >>                    int metrics_set;<br>
> >><br>
> >> diff --git a/drivers/gpu/drm/i915/i915_<wbr>perf.c b/drivers/gpu/drm/i915/i915_<wbr>perf.c<br>
> >> index 98eb6415b63a..87c0d1ce1b9f 100644<br>
> >> --- a/drivers/gpu/drm/i915/i915_<wbr>perf.c<br>
> >> +++ b/drivers/gpu/drm/i915/i915_<wbr>perf.c<br>
> >> @@ -2549,6 +2549,12 @@ i915_perf_open_ioctl_locked(<wbr>struct drm_i915_private *dev_priv,<br>
> >>    return ret;<br>
> >>   }<br>
> >><br>
> >> +static u64 oa_exponent_to_ns(struct drm_i915_private *dev_priv, int exponent)<br>
> >> +{<br>
> >> +       return div_u64(1000000000ULL * (2ULL << exponent),<br>
> >> +                      dev_priv->perf.oa.timestamp_<wbr>frequency);<br>
> >> +}<br>
> >> +<br>
> >>   /**<br>
> >>    * read_properties_unlocked - validate + copy userspace stream open properties<br>
> >>    * @dev_priv: i915 device instance<br>
> >> @@ -2647,14 +2653,9 @@ static int read_properties_unlocked(<wbr>struct drm_i915_private *dev_priv,<br>
> >>                    /* Theoretically we can program the OA unit to sample<br>
> >>                     * every 160ns but don't allow that by default unless<br>
> >>                     * root.<br>
> >> -                   *<br>
> >> -                   * On Haswell the period is derived from the exponent<br>
> >> -                   * as:<br>
> >> -                   *<br>
> >> -                   *   period = 80ns * 2^(exponent + 1)<br>
> >>                     */<br>
> >>                    BUILD_BUG_ON(sizeof(oa_period) != 8);<br>
> >> -                  oa_period = 80ull * (2ull << value);<br>
> >> +                  oa_period = oa_exponent_to_ns(dev_priv, value);<br>
> >><br>
> >>                    /* This check is primarily to ensure that oa_period <=<br>
> >>                     * UINT32_MAX (before passing to do_div which only<br>
> >> @@ -2910,6 +2911,8 @@ void i915_perf_init(struct drm_i915_private *dev_priv)<br>
> >>            dev_priv->perf.oa.ops.oa_hw_<wbr>tail_read =<br>
> >>                    gen7_oa_hw_tail_read;<br>
> >><br>
> >> +          dev_priv->perf.oa.timestamp_<wbr>frequency = 12500000;<br>
> >> +<br>
> >>            dev_priv->perf.oa.oa_formats = hsw_oa_formats;<br>
> >><br>
> >>            dev_priv->perf.oa.n_builtin_<wbr>sets =<br>
> >> @@ -2923,6 +2926,8 @@ void i915_perf_init(struct drm_i915_private *dev_priv)<br>
> >>             */<br>
> >><br>
> >>            if (IS_GEN8(dev_priv)) {<br>
> >> +                  dev_priv->perf.oa.timestamp_<wbr>frequency = 12500000;<br>
> >> +<br>
> >>                    dev_priv->perf.oa.ctx_<wbr>oactxctrl_offset = 0x120;<br>
> >>                    dev_priv->perf.oa.ctx_flexeu0_<wbr>offset = 0x2ce;<br>
> >>                    dev_priv->perf.oa.gen8_valid_<wbr>ctx_bit = (1<<25);<br>
> >> @@ -2939,6 +2944,8 @@ void i915_perf_init(struct drm_i915_private *dev_priv)<br>
> >>                                    i915_oa_select_metric_set_chv;<br>
> >>                    }<br>
> >>            } else if (IS_GEN9(dev_priv)) {<br>
> >> +                  dev_priv->perf.oa.timestamp_<wbr>frequency = 12000000;<br>
> >> +<br>
> >>                    dev_priv->perf.oa.ctx_<wbr>oactxctrl_offset = 0x128;<br>
> >>                    dev_priv->perf.oa.ctx_flexeu0_<wbr>offset = 0x3de;<br>
> >>                    dev_priv->perf.oa.gen8_valid_<wbr>ctx_bit = (1<<16);<br>
> >> @@ -2959,6 +2966,8 @@ void i915_perf_init(struct drm_i915_private *dev_priv)<br>
> >>                            dev_priv->perf.oa.ops.select_<wbr>metric_set =<br>
> >>                                    i915_oa_select_metric_set_<wbr>sklgt4;<br>
> >>                    } else if (IS_BROXTON(dev_priv)) {<br>
> >> +                          dev_priv->perf.oa.timestamp_<wbr>frequency = 19200123;<br>
> >> +<br>
> > Why isn't this exactly 19.2MHz?<br>
><br>
> It's based off the timestamp base (from documentation) :<br>
><br>
> BDW: 80ns<br>
> SKL: 83.333ns<br>
> BXT: 52.083ns<br>
><br>
> 1000000000 / 19200123 is the closest we can get.<br>
<br>
</div></div>I'm pretty sure the clock is actually 19.2 and the 52.083 is just a<br>
truncated value. Same for the 83.333 where the code does specify<br>
120MHz exactly.<br></blockquote><div><br></div><div>Ah, right, that sounds most likely. I'll update.<br><br></div><div>Thanks,<br></div><div>- Robert<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="im HOEnZb"><br>
><br>
> ><br>
> >>                            dev_priv->perf.oa.n_builtin_<wbr>sets =<br>
> >>                                    i915_oa_n_builtin_metric_sets_<wbr>bxt;<br>
> >>                            dev_priv->perf.oa.ops.select_<wbr>metric_set =<br>
> >> --<br>
> >> 2.12.0<br>
> >><br>
> >> ______________________________<wbr>_________________<br>
> >> Intel-gfx mailing list<br>
> >> <a href="mailto:Intel-gfx@lists.freedesktop.org">Intel-gfx@lists.freedesktop.<wbr>org</a><br>
> >> <a href="https://lists.freedesktop.org/mailman/listinfo/intel-gfx" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/intel-gfx</a><br>
><br>
<br>
</span><div class="HOEnZb"><div class="h5">--<br>
Ville Syrjälä<br>
Intel OTC<br>
</div></div></blockquote></div><br></div></div>