<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 20, 2016 at 10:11 PM, Chris Wilson <span dir="ltr"><<a href="mailto:chris@chris-wilson.co.uk" target="_blank">chris@chris-wilson.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5">On Wed, Apr 20, 2016 at 03:23:10PM +0100, Robert Bragg wrote:<br>
> +static void gen7_update_oacontrol_locked(struct drm_i915_private *dev_priv)<br>
> +{<br>
> +     assert_spin_locked(&dev_priv->perf.hook_lock);<br>
> +<br>
> +     if (dev_priv->perf.oa.exclusive_stream->enabled) {<br>
> +             unsigned long ctx_id = 0;<br>
> +<br>
> +             if (dev_priv->perf.oa.exclusive_stream->ctx)<br>
> +                     ctx_id = dev_priv->perf.oa.specific_ctx_id;<br>
> +<br>
> +             if (dev_priv->perf.oa.exclusive_stream->ctx == NULL || ctx_id) {<br>
> +                     bool periodic = dev_priv->perf.oa.periodic;<br>
> +                     u32 period_exponent = dev_priv->perf.oa.period_exponent;<br>
> +                     u32 report_format = dev_priv->perf.oa.oa_buffer.format;<br>
> +<br>
> +                     I915_WRITE(GEN7_OACONTROL,<br>
> +                                (ctx_id & GEN7_OACONTROL_CTX_MASK) |<br>
> +                                (period_exponent <<<br>
> +                                 GEN7_OACONTROL_TIMER_PERIOD_SHIFT) |<br>
> +                                (periodic ?<br>
> +                                 GEN7_OACONTROL_TIMER_ENABLE : 0) |<br>
> +                                (report_format <<<br>
> +                                 GEN7_OACONTROL_FORMAT_SHIFT) |<br>
> +                                (ctx_id ?<br>
> +                                 GEN7_OACONTROL_PER_CTX_ENABLE : 0) |<br>
> +                                GEN7_OACONTROL_ENABLE);<br>
<br>
</div></div>So this works by only recording when the OACONTROL context address<br>
matches the CCID. <br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Rather than hooking into switch context and checking every batch whether<br>
you have the exclusive context in case it changed address, you could<br>
just pin the exclusive context when told by the user to bind perf to<br>
that context. Then it will also have the same address until oa is<br>
finished (and releases it vma pin).<br></blockquote><div><br></div><div>Yeah, this was the approach I first went with when the driver was perf based, though we ended up deciding to got with hooking into pinning and updating the OA state in the end.<br><br></div><div>E.g. for reference: <a href="https://lists.freedesktop.org/archives/intel-gfx/2014-November/055385.html">https://lists.freedesktop.org/archives/intel-gfx/2014-November/055385.html</a> (wow, sad face after seeing how long I've been kicking this stuff)<br><br></div>I'd prefer to stick with this approach now, unless you see a big problem with it.<br><br></div><div class="gmail_quote">Regards,<br></div><div class="gmail_quote">- Robert<br></div><div class="gmail_quote"><div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class=""><font color="#888888">-Chris<br>
<br>
--<br>
Chris Wilson, Intel Open Source Technology Centre<br>
</font></span></blockquote></div><br></div></div>