<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 22, 2016 at 1:34 PM, Daniel Vetter <span dir="ltr"><<a href="mailto:daniel@ffwll.ch" target="_blank">daniel@ffwll.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Nov 08, 2016 at 12:51:48PM +0000, Robert Bragg wrote:<br>
> This v2 patch bumps the command parser version so it can be referenced in<br>
> corresponding i-g-t gem_exec_parse changes.<br>
><br>
> --- >8 ---<br>
<br>
</span>Scissors cut everything below, not everything above, hence next time<br>
around pls switch around your comment and the commit message, as-is not<br>
much left ;-)<br></blockquote><div><br></div><div>Hmm, they cut away what's above and keep what's below in my experience - what command are you seeing the opposite with?<br><br></div><div>I just double checked this with git am --scissors<br><br></div><div>- Robert<br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Fixed up while applying.<br>
-Daniel<br>
<div><div class="h5"><br>
><br>
> Being able to program OACONTROL from a non-privileged batch buffer is<br>
> not sufficient to be able to configure the OA unit. This was originally<br>
> allowed to help enable Mesa to expose OA counters via the<br>
> INTEL_performance_query extension, but the current implementation based<br>
> on programming OACONTROL via a batch buffer isn't able to report useable<br>
> data without a more complete OA unit configuration. Mesa handles the<br>
> possibility that writes to OACONTROL may not be allowed and so only<br>
> advertises the extension after explicitly testing that a write to<br>
> OACONTROL succeeds. Based on this; removing OACONTROL from the whitelist<br>
> should be ok for userspace.<br>
><br>
> Removing this simplifies adding a new kernel api for configuring the OA<br>
> unit without needing to consider the possibility that userspace might<br>
> trample on OACONTROL state which we'd like to start managing within<br>
> the kernel instead. In particular running any Mesa based GL application<br>
> currently results in clearing OACONTROL when initializing which would<br>
> disable the capturing of metrics.<br>
><br>
> v2:<br>
> This bumps the command parser version from 8 to 9, as the change is<br>
> visible to userspace.<br>
><br>
> Signed-off-by: Robert Bragg <<a href="mailto:robert@sixbynine.org">robert@sixbynine.org</a>><br>
> Reviewed-by: Matthew Auld <<a href="mailto:matthew.auld@intel.com">matthew.auld@intel.com</a>><br>
> Reviewed-by: Sourab Gupta <<a href="mailto:sourab.gupta@intel.com">sourab.gupta@intel.com</a>><br>
> ---<br>
> drivers/gpu/drm/i915/i915_cmd_<wbr>parser.c | 42 ++++--------------------------<wbr>----<br>
> 1 file changed, 5 insertions(+), 37 deletions(-)<br>
><br>
> diff --git a/drivers/gpu/drm/i915/i915_<wbr>cmd_parser.c b/drivers/gpu/drm/i915/i915_<wbr>cmd_parser.c<br>
> index c9d2ecd..f5762cd 100644<br>
> --- a/drivers/gpu/drm/i915/i915_<wbr>cmd_parser.c<br>
> +++ b/drivers/gpu/drm/i915/i915_<wbr>cmd_parser.c<br>
> @@ -450,7 +450,6 @@ static const struct drm_i915_reg_descriptor gen7_render_regs[] = {<br>
> REG64(PS_INVOCATION_COUNT),<br>
> REG64(PS_DEPTH_COUNT),<br>
> REG64_IDX(RING_TIMESTAMP, RENDER_RING_BASE),<br>
> - REG32(GEN7_OACONTROL), /* Only allowed for LRI and SRM. See below. */<br>
> REG64(MI_PREDICATE_SRC0),<br>
> REG64(MI_PREDICATE_SRC1),<br>
> REG32(GEN7_3DPRIM_END_OFFSET),<br>
> @@ -1060,8 +1059,7 @@ bool intel_engine_needs_cmd_parser(<wbr>struct intel_engine_cs *engine)<br>
> static bool check_cmd(const struct intel_engine_cs *engine,<br>
> const struct drm_i915_cmd_descriptor *desc,<br>
> const u32 *cmd, u32 length,<br>
> - const bool is_master,<br>
> - bool *oacontrol_set)<br>
> + const bool is_master)<br>
> {<br>
> if (desc->flags & CMD_DESC_SKIP)<br>
> return true;<br>
> @@ -1099,31 +1097,6 @@ static bool check_cmd(const struct intel_engine_cs *engine,<br>
> }<br>
><br>
> /*<br>
> - * OACONTROL requires some special handling for<br>
> - * writes. We want to make sure that any batch which<br>
> - * enables OA also disables it before the end of the<br>
> - * batch. The goal is to prevent one process from<br>
> - * snooping on the perf data from another process. To do<br>
> - * that, we need to check the value that will be written<br>
> - * to the register. Hence, limit OACONTROL writes to<br>
> - * only MI_LOAD_REGISTER_IMM commands.<br>
> - */<br>
> - if (reg_addr == i915_mmio_reg_offset(GEN7_<wbr>OACONTROL)) {<br>
> - if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {<br>
> - DRM_DEBUG_DRIVER("CMD: Rejected LRM to OACONTROL\n");<br>
> - return false;<br>
> - }<br>
> -<br>
> - if (desc->cmd.value == MI_LOAD_REGISTER_REG) {<br>
> - DRM_DEBUG_DRIVER("CMD: Rejected LRR to OACONTROL\n");<br>
> - return false;<br>
> - }<br>
> -<br>
> - if (desc->cmd.value == MI_LOAD_REGISTER_IMM(1))<br>
> - *oacontrol_set = (cmd[offset + 1] != 0);<br>
> - }<br>
> -<br>
> - /*<br>
> * Check the value written to the register against the<br>
> * allowed mask/value pair given in the whitelist entry.<br>
> */<br>
> @@ -1214,7 +1187,6 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,<br>
> u32 *cmd, *batch_end;<br>
> struct drm_i915_cmd_descriptor default_desc = noop_desc;<br>
> const struct drm_i915_cmd_descriptor *desc = &default_desc;<br>
> - bool oacontrol_set = false; /* OACONTROL tracking. See check_cmd() */<br>
> bool needs_clflush_after = false;<br>
> int ret = 0;<br>
><br>
> @@ -1270,8 +1242,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,<br>
> break;<br>
> }<br>
><br>
> - if (!check_cmd(engine, desc, cmd, length, is_master,<br>
> - &oacontrol_set)) {<br>
> + if (!check_cmd(engine, desc, cmd, length, is_master)) {<br>
> ret = -EACCES;<br>
> break;<br>
> }<br>
> @@ -1279,11 +1250,6 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,<br>
> cmd += length;<br>
> }<br>
><br>
> - if (oacontrol_set) {<br>
> - DRM_DEBUG_DRIVER("CMD: batch set OACONTROL but did not clear it\n");<br>
> - ret = -EINVAL;<br>
> - }<br>
> -<br>
> if (cmd >= batch_end) {<br>
> DRM_DEBUG_DRIVER("CMD: Got to the end of the buffer w/o a BBE cmd!\n");<br>
> ret = -EINVAL;<br>
> @@ -1336,6 +1302,8 @@ int i915_cmd_parser_get_version(<wbr>struct drm_i915_private *dev_priv)<br>
> * 8. Don't report cmd_check() failures as EINVAL errors to userspace;<br>
> * rely on the HW to NOOP disallowed commands as it would without<br>
> * the parser enabled.<br>
> + * 9. Don't whitelist or handle oacontrol specially, as ownership<br>
> + * for oacontrol state is moving to i915-perf.<br>
> */<br>
> - return 8;<br>
> + return 9;<br>
> }<br>
> --<br>
> 2.10.1<br>
><br>
</div></div>> ______________________________<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>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Daniel Vetter<br>
Software Engineer, Intel Corporation<br>
<a href="http://blog.ffwll.ch" rel="noreferrer" target="_blank">http://blog.ffwll.ch</a><br>
</font></span></blockquote></div><br></div></div>