Commit b5572d31 authored by Chris Wilson's avatar Chris Wilson

drm/i915/selftests: Mark up sole accessor to ctx->vm as being protected

In the selftests, where we are accessing a private ctx from within the
confines of a single test, we know that the ctx->vm pointer is static
and bounded by the lifetime of the test. We can use a simple helper to
provide the RCU annotations to keep sparse happy.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191107221201.30497-1-chris@chris-wilson.co.uk
parent a8c9a7f5
...@@ -26,6 +26,12 @@ ...@@ -26,6 +26,12 @@
#define DW_PER_PAGE (PAGE_SIZE / sizeof(u32)) #define DW_PER_PAGE (PAGE_SIZE / sizeof(u32))
static inline struct i915_address_space *ctx_vm(struct i915_gem_context *ctx)
{
/* single threaded, private ctx */
return rcu_dereference_protected(ctx->vm, true);
}
static int live_nop_switch(void *arg) static int live_nop_switch(void *arg)
{ {
const unsigned int nctx = 1024; const unsigned int nctx = 1024;
...@@ -786,14 +792,15 @@ static int igt_shared_ctx_exec(void *arg) ...@@ -786,14 +792,15 @@ static int igt_shared_ctx_exec(void *arg)
} }
mutex_lock(&ctx->mutex); mutex_lock(&ctx->mutex);
__assign_ppgtt(ctx, parent->vm); __assign_ppgtt(ctx, ctx_vm(parent));
mutex_unlock(&ctx->mutex); mutex_unlock(&ctx->mutex);
ce = i915_gem_context_get_engine(ctx, engine->legacy_idx); ce = i915_gem_context_get_engine(ctx, engine->legacy_idx);
GEM_BUG_ON(IS_ERR(ce)); GEM_BUG_ON(IS_ERR(ce));
if (!obj) { if (!obj) {
obj = create_test_object(parent->vm, file, &objects); obj = create_test_object(ctx_vm(parent),
file, &objects);
if (IS_ERR(obj)) { if (IS_ERR(obj)) {
err = PTR_ERR(obj); err = PTR_ERR(obj);
intel_context_put(ce); intel_context_put(ce);
...@@ -1343,14 +1350,11 @@ static int igt_ctx_readonly(void *arg) ...@@ -1343,14 +1350,11 @@ static int igt_ctx_readonly(void *arg)
goto out_file; goto out_file;
} }
rcu_read_lock(); vm = ctx_vm(ctx) ?: &i915->ggtt.alias->vm;
vm = rcu_dereference(ctx->vm) ?: &i915->ggtt.alias->vm;
if (!vm || !vm->has_read_only) { if (!vm || !vm->has_read_only) {
rcu_read_unlock();
err = 0; err = 0;
goto out_file; goto out_file;
} }
rcu_read_unlock();
ndwords = 0; ndwords = 0;
dw = 0; dw = 0;
...@@ -1380,7 +1384,7 @@ static int igt_ctx_readonly(void *arg) ...@@ -1380,7 +1384,7 @@ static int igt_ctx_readonly(void *arg)
pr_err("Failed to fill dword %lu [%lu/%lu] with gpu (%s) [full-ppgtt? %s], err=%d\n", pr_err("Failed to fill dword %lu [%lu/%lu] with gpu (%s) [full-ppgtt? %s], err=%d\n",
ndwords, dw, max_dwords(obj), ndwords, dw, max_dwords(obj),
ce->engine->name, ce->engine->name,
yesno(!!rcu_access_pointer(ctx->vm)), yesno(!!ctx_vm(ctx)),
err); err);
i915_gem_context_unlock_engines(ctx); i915_gem_context_unlock_engines(ctx);
goto out_file; goto out_file;
...@@ -1698,11 +1702,11 @@ static int igt_vm_isolation(void *arg) ...@@ -1698,11 +1702,11 @@ static int igt_vm_isolation(void *arg)
} }
/* We can only test vm isolation, if the vm are distinct */ /* We can only test vm isolation, if the vm are distinct */
if (ctx_a->vm == ctx_b->vm) if (ctx_vm(ctx_a) == ctx_vm(ctx_b))
goto out_file; goto out_file;
vm_total = ctx_a->vm->total; vm_total = ctx_vm(ctx_a)->total;
GEM_BUG_ON(ctx_b->vm->total != vm_total); GEM_BUG_ON(ctx_vm(ctx_b)->total != vm_total);
vm_total -= I915_GTT_PAGE_SIZE; vm_total -= I915_GTT_PAGE_SIZE;
count = 0; count = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment