Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Alan Previn <alan.previn.teres.alexis@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t 08/17] Enable protected session cmd in gen12_render_copyfunc
Date: Fri, 4 Jun 2021 09:16:11 -0400	[thread overview]
Message-ID: <YLonm/ledRfwelqV@intel.com> (raw)
In-Reply-To: <20210518103344.2264397-9-alan.previn.teres.alexis@intel.com>

On Tue, May 18, 2021 at 03:33:35AM -0700, Alan Previn wrote:
> 1. In _gen9_render_op, check if the incoming batchbuffer
>    is marked with pxp enabled. If so, insert MI_SET_APPID
>    along with PIPE_CONTROL instructions at the start and
>    end of the rendering operation in the command buffer.
> 
> 2. The two PIPE_CONTROLs will enable protected memory
>    at the start of the batch and disabling protected
>    memory at the end of it. These PIPE_CONTROLs require a
>    Post-Sync operation with a write to memory for hardware
>    to accept.
> 
> 3. In order to satisfy #2, _gen9_render_op uses unused
>    regions of the ibb buffer for the PIPE_CONTROL PostSync
>    write to memory (no different from how other 3d states
>    are being referenced).
> 
> 4. _gen9_render_op shall check the incoming surface
>    buffers for "is_protected" flag and if its set, it
>    will mark the SURFACE_STATE's MOCS field accordingly.
> 
> NOTE: _gen9_render_op needs to program the HW to enable
> the PXP session as part of the rendering batch buffer
> because the HW requires that enabling/disabling protected
> memory access must be programmed in pairs within the same
> "dispatch of rendering commands" to HW.
> 
> Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com>
> ---
>  lib/rendercopy_gen9.c | 72 ++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 65 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/rendercopy_gen9.c b/lib/rendercopy_gen9.c
> index eecf73d3..bfcf311b 100644
> --- a/lib/rendercopy_gen9.c
> +++ b/lib/rendercopy_gen9.c
> @@ -19,7 +19,8 @@
>  #include "intel_bufops.h"
>  #include "intel_batchbuffer.h"
>  #include "intel_io.h"
> -#include "rendercopy.h"
> +#include "igt.h"
> +#include "i915/gem.h"
>  #include "gen9_render.h"
>  #include "intel_reg.h"
>  #include "igt_aux.h"
> @@ -152,6 +153,8 @@ gen8_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst) {
>  		ss->ss0.tiled_mode = 3;
>  
>  	ss->ss1.memory_object_control = I915_MOCS_PTE << 1;
> +	if (intel_buf_pxp(buf))
> +		ss->ss1.memory_object_control |= 1;
>  
>  	if (buf->tiling == I915_TILING_Yf)
>  		ss->ss5.trmode = 1;
> @@ -873,6 +876,53 @@ static void gen8_emit_primitive(struct intel_bb *ibb, uint32_t offset)
>  	intel_bb_out(ibb, 0);	/* index buffer offset, ignored */
>  }
>  
> +#define GFX_OP_PIPE_CONTROL    ((3 << 29) | (3 << 27) | (2 << 24))

there's no len defined here...

> +#define PIPE_CONTROL_CS_STALL	            (1 << 20)
> +#define PIPE_CONTROL_RENDER_TARGET_FLUSH    (1 << 12)
> +#define PIPE_CONTROL_FLUSH_ENABLE           (1 << 7)
> +#define PIPE_CONTROL_DATA_CACHE_INVALIDATE  (1 << 5)
> +#define PIPE_CONTROL_PROTECTEDPATH_DISABLE  (1 << 27)
> +#define PIPE_CONTROL_PROTECTEDPATH_ENABLE   (1 << 22)
> +#define PIPE_CONTROL_POST_SYNC_OP           (1 << 14)
> +#define PIPE_CONTROL_POST_SYNC_OP_STORE_DW_IDX (1 << 21)
> +#define PS_OP_TAG_START                     0x1234fed0
> +#define PS_OP_TAG_END                       0x5678cbaf
> +static void gen12_emit_pxp_state(struct intel_bb *ibb, bool enable,
> +		 uint32_t pxp_write_op_offset)
> +{
> +	uint32_t pipe_ctl_flags;
> +	uint32_t set_app_id, ps_op_id;
> +
> +	if (enable) {
> +		pipe_ctl_flags = PIPE_CONTROL_FLUSH_ENABLE;
> +		intel_bb_out(ibb, GFX_OP_PIPE_CONTROL);

... so, I believe this one should be GFX_OP_PIPE_CONTROL | 1

(len - 2) = (3 - 2) = 1

> +		intel_bb_out(ibb, pipe_ctl_flags);
> +
> +		set_app_id =  MI_SET_APPID |
> +			      APPTYPE(intel_bb_pxp_apptype(ibb)) |
> +			      APPID(intel_bb_pxp_appid(ibb));
> +		intel_bb_out(ibb, set_app_id);
> +
> +		pipe_ctl_flags = PIPE_CONTROL_PROTECTEDPATH_ENABLE;
> +		ps_op_id = PS_OP_TAG_START;
> +	} else {
> +		pipe_ctl_flags = PIPE_CONTROL_PROTECTEDPATH_DISABLE;
> +		ps_op_id = PS_OP_TAG_END;
> +	}
> +
> +	pipe_ctl_flags |= (PIPE_CONTROL_CS_STALL |
> +			   PIPE_CONTROL_RENDER_TARGET_FLUSH |
> +			   PIPE_CONTROL_DATA_CACHE_INVALIDATE |
> +			   PIPE_CONTROL_POST_SYNC_OP);
> +	intel_bb_out(ibb, GFX_OP_PIPE_CONTROL | 4);

and this one should be GFX_OP_PIPE_CONTROL | 2

(len - 2) = (4 - 2) = 2

but to be honest, I always get lost and confused with these pipe_control len...
specially looking IGT tests, many of them don't make sense to me.

However I see, at least, some inconsistency here between these 2 pipe_control
emissions. What am I missing?

> +	intel_bb_out(ibb, pipe_ctl_flags);
> +	intel_bb_emit_reloc(ibb, ibb->handle, 0, I915_GEM_DOMAIN_COMMAND,
> +			    (enable ? pxp_write_op_offset : (pxp_write_op_offset+8)),
> +			    ibb->batch_offset);
> +	intel_bb_out(ibb, ps_op_id);
> +	intel_bb_out(ibb, ps_op_id);
> +}
> +
>  /* The general rule is if it's named gen6 it is directly copied from
>   * gen6_render_copyfunc.
>   *
> @@ -922,6 +972,7 @@ void _gen9_render_op(struct intel_bb *ibb,
>  	uint32_t vertex_buffer;
>  	uint32_t aux_pgtable_state;
>  	bool fast_clear = !src;
> +	uint32_t pxp_scratch_offset;
>  
>  	if (!fast_clear)
>  		igt_assert(src->bpp == dst->bpp);
> @@ -950,8 +1001,12 @@ void _gen9_render_op(struct intel_bb *ibb,
>  	aux_pgtable_state = gen12_create_aux_pgtable_state(ibb, aux_pgtable_buf);
>  
>  	/* TODO: there is other state which isn't setup */
> +	pxp_scratch_offset = intel_bb_offset(ibb);
>  	intel_bb_ptr_set(ibb, 0);
>  
> +	if (intel_bb_pxp_enabled(ibb))
> +		gen12_emit_pxp_state(ibb, true, pxp_scratch_offset);
> +
>  	/* Start emitting the commands. The order roughly follows the mesa blorp
>  	 * order */
>  	intel_bb_out(ibb, G4X_PIPELINE_SELECT | PIPELINE_SELECT_3D |
> @@ -963,13 +1018,12 @@ void _gen9_render_op(struct intel_bb *ibb,
>  		for (int i = 0; i < 4; i++) {
>  			intel_bb_out(ibb, MI_STORE_DWORD_IMM);
>  			intel_bb_emit_reloc(ibb, dst->handle,
> -					    I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
> -                                            dst->cc.offset + i*sizeof(float),
> -					    dst->addr.offset);
> +					I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
> +					dst->cc.offset + i*sizeof(float),
> +					dst->addr.offset);
>  			intel_bb_out(ibb, *(uint32_t*)&clear_color[i]);
> -               }
> -       }
> -
> +		}
> +	}
>  
>  	gen8_emit_sip(ibb);
>  
> @@ -1023,10 +1077,14 @@ void _gen9_render_op(struct intel_bb *ibb,
>  	gen8_emit_vf_topology(ibb);
>  	gen8_emit_primitive(ibb, vertex_buffer);
>  
> +	if (intel_bb_pxp_enabled(ibb))
> +		gen12_emit_pxp_state(ibb, false, pxp_scratch_offset);
> +
>  	intel_bb_emit_bbe(ibb);
>  	intel_bb_exec(ibb, intel_bb_offset(ibb),
>  		      I915_EXEC_RENDER | I915_EXEC_NO_RELOC, false);
>  	dump_batch(ibb);
> +
>  	intel_bb_reset(ibb, false);
>  }
>  
> -- 
> 2.25.1
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2021-06-04 13:16 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 10:33 [igt-dev] [PATCH i-g-t 00/17] Introduce PXP Test Alan Previn
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 01/17] Sync i915_drm.h UAPI from kernel Alan Previn
2021-06-02 20:07   ` Rodrigo Vivi
2021-06-03  0:15     ` Teres Alexis, Alan Previn
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 02/17] Add PXP UAPI support in i915_drm.h Alan Previn
2021-06-02 20:10   ` Rodrigo Vivi
2021-06-03  0:50     ` Teres Alexis, Alan Previn
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 03/17] Update IOCTL wrapper with DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT Alan Previn
2021-06-02 20:10   ` Rodrigo Vivi
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 04/17] Add basic PXP testing of buffer and context alloc Alan Previn
2021-06-02 20:23   ` Rodrigo Vivi
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 05/17] Perform a regular 3d copy as a control checkpoint Alan Previn
2021-06-02 21:37   ` Rodrigo Vivi
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 06/17] Add PXP attribute support in batchbuffer and buffer_ops libs Alan Previn
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 07/17] Add MI_SET_APPID instruction definition Alan Previn
2021-06-02 21:40   ` Rodrigo Vivi
2021-06-03  0:54     ` Teres Alexis, Alan Previn
2021-06-03 15:06       ` Rodrigo Vivi
2021-06-03  8:52   ` Michal Wajdeczko
2021-06-03 15:22     ` Teres Alexis, Alan Previn
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 08/17] Enable protected session cmd in gen12_render_copyfunc Alan Previn
2021-06-04 13:16   ` Rodrigo Vivi [this message]
2021-06-10 17:36     ` Teres Alexis, Alan Previn
2021-06-10 19:55       ` Rodrigo Vivi
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 09/17] Add subtest to copy raw source to protected dest Alan Previn
2021-06-04 13:22   ` Rodrigo Vivi
2021-06-05  1:30     ` Teres Alexis, Alan Previn
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 10/17] Add test where both src and dest are protected Alan Previn
2021-06-04 13:31   ` Rodrigo Vivi
2021-06-05  1:38     ` Teres Alexis, Alan Previn
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 11/17] Verify PXP teardown occurred through suspend-resume Alan Previn
2021-06-03 21:40   ` Rodrigo Vivi
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 12/17] Verify execbuf fails with stale PXP context after teardown Alan Previn
2021-06-04 13:38   ` Rodrigo Vivi
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 13/17] Verify execbuf fails with stale PXP buffer " Alan Previn
2021-06-03 21:41   ` Rodrigo Vivi
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 14/17] Verify execbuf ok with stale prot-buff and regular context Alan Previn
2021-06-04 13:56   ` Rodrigo Vivi
2021-06-05  0:27     ` Teres Alexis, Alan Previn
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 15/17] Ensure RESET_STATS reports invalidated protected context Alan Previn
2021-06-03 21:43   ` Rodrigo Vivi
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 16/17] Verify protected surfaces are dma buffer sharable Alan Previn
2021-06-04 14:18   ` Rodrigo Vivi
2021-06-05  0:45     ` Teres Alexis, Alan Previn
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 17/17] tests/i915_pxp: CRC validation for display tests Alan Previn
2021-06-04 14:40   ` Rodrigo Vivi
2021-06-05  1:07     ` Teres Alexis, Alan Previn
2021-06-10 13:00       ` Shankar, Uma
2021-06-10 14:17         ` Rodrigo Vivi
2021-05-18 11:30 ` [igt-dev] ✓ Fi.CI.BAT: success for Introduce PXP Test (rev5) Patchwork
2021-05-18 18:19 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2021-06-02 21:44   ` Rodrigo Vivi
2021-06-03 18:09     ` Teres Alexis, Alan Previn
2021-06-03 18:13       ` Rodrigo Vivi
  -- strict thread matches above, loose matches on Subject: below --
2021-05-15 23:01 [igt-dev] [PATCH i-g-t 00/17] Introduce PXP Test Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 08/17] Enable protected session cmd in gen12_render_copyfunc Alan Previn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YLonm/ledRfwelqV@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=alan.previn.teres.alexis@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox