[igt-dev] [PATCH i-g-t v6 14/16] Ensure RESET_STATS reports invalidated protected context
Alan Previn
alan.previn.teres.alexis at intel.com
Fri Jul 16 09:23:32 UTC 2021
When protected contexts are created but get invalidated
due to PXP session teardown (such as after a suspend-resume
cycle), RESET_STATS ioctl for said context will report it
as I915_CONTEXT_INVALIDATED.
Signed-off-by: Alan Previn <alan.previn.teres.alexis at intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
---
tests/i915/gem_pxp.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/tests/i915/gem_pxp.c b/tests/i915/gem_pxp.c
index 73ec9cd8..d14b085f 100644
--- a/tests/i915/gem_pxp.c
+++ b/tests/i915/gem_pxp.c
@@ -760,6 +760,22 @@ static void free_exec_assets(int i915, struct simple_exec_assets *data)
buf_ops_destroy(data->bops);
}
+static bool is_context_valid(int i915, uint32_t ctx)
+{
+ struct drm_i915_reset_stats rs;
+ int ret;
+
+ memset(&rs, 0, sizeof(rs));
+ rs.ctx_id = ctx;
+ ret = drmIoctl(i915, DRM_IOCTL_I915_GET_RESET_STATS, &rs);
+ igt_assert(ret == 0);
+
+ if (rs.flags & I915_CONTEXT_INVALIDATED)
+ return false;
+
+ return true;
+}
+
static void test_pxp_pwrcycle_staleasset_execution(int i915, struct powermgt_data *pm)
{
int ret;
@@ -791,6 +807,8 @@ static void test_pxp_pwrcycle_staleasset_execution(int i915, struct powermgt_dat
trigger_powermgt_suspend_cycle(i915, pm);
+ igt_assert_f(!is_context_valid(i915, data[0].ctx),
+ "RESET_STATS missed INVAL bit on stale pxp context\n");
ret = gem_execbuf_flush_store_dw(i915, data[0].ibb, data[0].ctx, data[0].fencebuf);
igt_assert_f((ret == -EACCES), "Executing stale pxp context didn't fail with -EACCES\n");
@@ -799,6 +817,8 @@ static void test_pxp_pwrcycle_staleasset_execution(int i915, struct powermgt_dat
* reuse the bo to ensure the kernel is catching the
* invalidated bo (not context)
*/
+ igt_assert_f(!is_context_valid(i915, data[1].ctx),
+ "RESET_STATS missed INVAL bit on stale pxp context\n");
ret = create_ctx_with_params(i915, true, true, true, false, &ctx2);
igt_assert_eq(ret, 0);
igt_assert_eq(get_ctx_protected_param(i915, ctx2), 1);
@@ -809,6 +829,8 @@ static void test_pxp_pwrcycle_staleasset_execution(int i915, struct powermgt_dat
ret = gem_execbuf_flush_store_dw(i915, ibb2, ctx2, data[1].fencebuf);
igt_assert_f((ret == -ENOEXEC), "Executing stale pxp buffer didn't fail with -ENOEXEC\n");
+ igt_assert_f(is_context_valid(i915, data[2].ctx),
+ "RESET_STATS false-hit on opt-out context\n");
ret = gem_execbuf_flush_store_dw(i915, data[2].ibb, data[2].ctx, data[2].fencebuf);
igt_assert_f((ret == 0), "Opt-out-execution with stale pxp buffer didn't succeed\n");
--
2.25.1
More information about the igt-dev
mailing list