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 12/17] Verify execbuf fails with stale PXP context after teardown
Date: Fri, 4 Jun 2021 09:38:50 -0400 [thread overview]
Message-ID: <YLos6gCJTZ7mM6IJ@intel.com> (raw)
In-Reply-To: <20210518103344.2264397-13-alan.previn.teres.alexis@intel.com>
On Tue, May 18, 2021 at 03:33:39AM -0700, Alan Previn wrote:
> Add a subtest to verify that reusing a stale protected context
> in a gem_execbuff after a teardown (triggered by suspend-resume
> cycle) shall fail with -EACCES error.
>
> NOTE: The end-to-end architecture requirement includes that
> any break in the links of the PXP sessions needs to trigger a
> full teardown and the application needs to be made aware of that
> allowing it to re-establish the end-to-end pipeline of buffers,
> contexts and renders again if it chooses to. This stricter
> behavior targets only contexts created with PXP enabled.
>
> Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com>
> ---
> lib/intel_batchbuffer.c | 2 +-
> lib/intel_batchbuffer.h | 3 +
> tests/i915/gem_pxp.c | 135 ++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 139 insertions(+), 1 deletion(-)
>
> diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
> index 23957109..e16ab056 100644
> --- a/lib/intel_batchbuffer.c
> +++ b/lib/intel_batchbuffer.c
> @@ -2536,7 +2536,7 @@ static void update_offsets(struct intel_bb *ibb,
> * Note: In this step execobj for bb is allocated and inserted to the objects
> * array.
> */
> -static int __intel_bb_exec(struct intel_bb *ibb, uint32_t end_offset,
> +int __intel_bb_exec(struct intel_bb *ibb, uint32_t end_offset,
> uint64_t flags, bool sync)
> {
> struct drm_i915_gem_execbuffer2 execbuf;
> diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
> index 389da7b2..b16ae00f 100644
> --- a/lib/intel_batchbuffer.h
> +++ b/lib/intel_batchbuffer.h
> @@ -664,6 +664,9 @@ uint64_t intel_bb_offset_reloc_to_object(struct intel_bb *ibb,
> uint32_t offset,
> uint64_t presumed_offset);
>
> +int __intel_bb_exec(struct intel_bb *ibb, uint32_t end_offset,
> + uint64_t flags, bool sync);
> +
> void intel_bb_dump_cache(struct intel_bb *ibb);
>
> void intel_bb_exec(struct intel_bb *ibb, uint32_t end_offset,
> diff --git a/tests/i915/gem_pxp.c b/tests/i915/gem_pxp.c
> index 10134604..f1ef0a24 100644
> --- a/tests/i915/gem_pxp.c
> +++ b/tests/i915/gem_pxp.c
> @@ -15,6 +15,14 @@ struct powermgt_data {
> bool has_runtime_pm;
> };
>
> +struct simple_exec_assets {
> + uint32_t ctx;
> + uint32_t fencebo;
> + struct intel_buf *fencebuf;
> + struct buf_ops *bops;
> + struct intel_bb *ibb;
> +};
> +
> static bool is_pxp_hw_supported(int i915)
> {
> uint32_t devid = intel_get_drm_devid(i915);
> @@ -646,6 +654,131 @@ static void test_pxp_pwrcycle_teardown_keychange(int i915, struct powermgt_data
> igt_assert_eq(matched_after_keychange, 0);
> }
>
> +#define GFX_OP_PIPE_CONTROL ((3 << 29) | (3 << 27) | (2 << 24))
> +#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_BEFORE 0x1234fed0
> +#define PS_OP_TAG_AFTER 0x5678cbaf
> +
> +static void emit_pipectrl(struct intel_bb *ibb, struct intel_buf *fenceb, bool before)
> +{
> + uint32_t pipe_ctl_flags = 0;
> + uint32_t ps_op_id;
> +
> + intel_bb_out(ibb, GFX_OP_PIPE_CONTROL);
> + intel_bb_out(ibb, pipe_ctl_flags);
> +
> + if (before)
> + ps_op_id = PS_OP_TAG_BEFORE;
> + else
> + ps_op_id = PS_OP_TAG_AFTER;
> +
> + pipe_ctl_flags = (PIPE_CONTROL_FLUSH_ENABLE |
> + PIPE_CONTROL_CS_STALL |
> + PIPE_CONTROL_POST_SYNC_OP);
> + intel_bb_out(ibb, GFX_OP_PIPE_CONTROL | 4);
(side comment: the pipe control len in this patch looks right!)
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> + intel_bb_out(ibb, pipe_ctl_flags);
> + intel_bb_emit_reloc(ibb, fenceb->handle, 0, I915_GEM_DOMAIN_COMMAND, (before?0:8),
> + fenceb->addr.offset);
> + intel_bb_out(ibb, ps_op_id);
> + intel_bb_out(ibb, ps_op_id);
> + intel_bb_out(ibb, MI_NOOP);
> + intel_bb_out(ibb, MI_NOOP);
> +}
> +
> +static void assert_pipectl_storedw_done(int i915, uint32_t bo)
> +{
> + uint32_t *ptr;
> + uint32_t success_mask = 0x0;
> +
> + ptr = gem_mmap__device_coherent(i915, bo, 0, 4096, PROT_READ);
> +
> + if (ptr[0] == PS_OP_TAG_BEFORE && ptr[1] == PS_OP_TAG_BEFORE)
> + success_mask |= 0x1;
> +
> + igt_assert_eq(success_mask, 0x1);
> + igt_assert(gem_munmap(ptr, 4096) == 0);
> +}
> +
> +static int gem_execbuf_flush_store_dw(int i915, struct intel_bb *ibb, uint32_t ctx,
> + struct intel_buf *fence)
> +{
> + int ret;
> +
> + intel_bb_ptr_set(ibb, 0);
> + intel_bb_add_intel_buf(ibb, fence, true);
> + emit_pipectrl(ibb, fence, true);
> + intel_bb_emit_bbe(ibb);
> + ret = __intel_bb_exec(ibb, intel_bb_offset(ibb),
> + I915_EXEC_RENDER | I915_EXEC_NO_RELOC, false);
> + if (ret == 0) {
> + gem_sync(ibb->i915, fence->handle);
> + assert_pipectl_storedw_done(i915, fence->handle);
> + }
> + return ret;
> +}
> +
> +static void prepare_exec_assets(int i915, struct simple_exec_assets *data, bool ctx_pxp,
> + bool buf_pxp)
> +{
> + int ret;
> +
> + if (ctx_pxp)
> + ret = create_ctx_with_params(i915, true, true, true, false, &(data->ctx));
> + else
> + ret = create_ctx_with_params(i915, false, false, false, false, &(data->ctx));
> + igt_assert_eq(ret, 0);
> + igt_assert_eq(get_ctx_protected_param(i915, data->ctx), ctx_pxp);
> + data->ibb = intel_bb_create_with_context(i915, data->ctx, 4096);
> + igt_assert(data->ibb);
> +
> + data->fencebo = alloc_and_fill_dest_buff(i915, buf_pxp, 4096, 0);
> +
> + data->bops = buf_ops_create(i915);
> + igt_assert(data->bops);
> +
> + data->fencebuf = intel_buf_create_using_handle(data->bops, data->fencebo, 256, 4,
> + 32, 0, I915_TILING_NONE, 0);
> + intel_bb_add_intel_buf(data->ibb, data->fencebuf, true);
> +}
> +
> +static void free_exec_assets(int i915, struct simple_exec_assets *data)
> +{
> + intel_bb_destroy(data->ibb);
> + gem_close(i915, data->fencebo);
> + intel_buf_destroy(data->fencebuf);
> + gem_context_destroy(i915, data->ctx);
> + buf_ops_destroy(data->bops);
> +}
> +
> +static void test_pxp_pwrcycle_staleasset_execution(int i915, struct powermgt_data *pm)
> +{
> + int ret;
> + struct simple_exec_assets data = {0};
> +
> + /*
> + * Use normal buffers for testing for invalidation
> + * of protected contexts to ensure kernel is catching
> + * the invalidated context (not buffer)
> + */
> + prepare_exec_assets(i915, &data, true, false);
> + ret = gem_execbuf_flush_store_dw(i915, data.ibb, data.ctx, data.fencebuf);
> + igt_assert(ret == 0);
> +
> + trigger_powermgt_suspend_cycle(i915, pm);
> +
> + ret = gem_execbuf_flush_store_dw(i915, data.ibb, data.ctx, data.fencebuf);
> + igt_assert_f((ret == -EACCES), "Executing stale pxp context didn't fail with -EACCES\n");
> +
> + free_exec_assets(i915, &data);
> +}
> +
> igt_main
> {
> int i915 = -1;
> @@ -735,6 +868,8 @@ igt_main
> igt_describe("Verify suspend-resume teardown management:");
> igt_subtest("verify-pxp-key-change-after-suspend-resume")
> test_pxp_pwrcycle_teardown_keychange(i915, &pm);
> + igt_subtest("verify-pxp-execution-behavior-after-suspend-resume")
> + test_pxp_pwrcycle_staleasset_execution(i915, &pm);
> }
>
> igt_fixture {
> --
> 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
next prev parent reply other threads:[~2021-06-04 13:38 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
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 [this message]
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 12/17] Verify execbuf fails with stale PXP context after teardown 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=YLos6gCJTZ7mM6IJ@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