[igt-dev] [PATCH i-g-t 15/17] Ensure RESET_STAT reports invalidated protected context
Alan Previn
alan.previn.teres.alexis at intel.com
Sat May 15 23:01:40 UTC 2021
When protected contexts are created but get invalidated
due to PXP session teardown (such as after a suspend-resume
cycle), RESET_STAT ioctl for said context will report it
as I915_CONTEXT_INVALIDATED.
Signed-off-by: Alan Previn <alan.previn.teres.alexis at intel.com>
---
tests/i915/gem_pxp.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/tests/i915/gem_pxp.c b/tests/i915/gem_pxp.c
index e5f3f2f0..dc89eac2 100644
--- a/tests/i915/gem_pxp.c
+++ b/tests/i915/gem_pxp.c
@@ -783,6 +783,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;
@@ -814,6 +830,7 @@ 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 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), "Execution with stale pxp context didnt fail with -EACCES\n");
@@ -822,6 +839,7 @@ 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 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);
@@ -832,6 +850,7 @@ 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), "Execution with stale pxp buffer didnt 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 didnt succeed\n");
--
2.25.1
More information about the igt-dev
mailing list