Stop depending on context mutation (v3)
Subsystems (2)
cover Stop depending on context mutation (v3)
I'm trying to clean up some of our uAPI technical debt in i915. One of the biggest areas we have right now is context mutability. There's no good reason why things like the set of engines or the VM should be able to be changed on the fly and no "real" userspace actually relies on this functionality. It does, however, make for a good excuse for tests and lots of bug reports as things like swapping out the set of engines under load break randomly. The solution here is to stop allowing that behavior and simplify the i915 internals.
In particular, we'd like to remove the following from the i915 API:
1. I915_CONTEXT_CLONE_*. These are only used by IGT and have never been used by any "real" userspace.
2. Changing the VM or set of engines via SETPARAM after they've been "used" by an execbuf or similar. This would effectively make those parameters create params rather than mutable state. We can't drop setparam entirely for those because media does use it but we can enforce some rules.
3. Unused (by non-IGT userspace) GETPARAM for things like engines.
As much as we'd love to do that, we have a bit of a problem in IGT. The way we handle multi-engine testing today relies heavily on this soon-to-be- deprecated functionality. In particular, the standard flow is usually something like this:
static void run_test1(int fd, uint32_t engine)
{
igt_spin_t *spin;
ctx = = gem_context_clone_with_engines(fd, 0);
__igt_spin_new(fd, ctx, .engine = engine);
/* do some testing with ctx */
igt_spin_free(fd, spin);
gem_destroy_context(fd, ctx);
}
igt_main
{
struct intel_execution_engine2 *e;
/* Usual fixture code */
__for_each_physical_engine(fd, e)
run_test1(fd, e->flags);
__for_each_physical_engine(fd, e)
run_test2(fd, e->flags);
}Let's walk through what this does:
1. __for_each_physical_engine calls intel_init_engine_list() which resets the set of engines on ctx0 to the full set of engines available as per the engine query. On older kernels/hardware where we don't have the engines query, it leaves the set alone.
2. intel_init_engine_list() also returns a set of engines for iteration and __for_each_physical_engine() sets up a for loop to walk the set.
3. gem_context_clone_with_engines() creates a new context using I915_CONTEXT_CONTEXT_CLONE_ENGINES (not used by anything other than IGT) to ask that the newly created context has the same set of engines as ctx0. Remember we changed that at the start of loop iteration!
4. When the context is passed to __igt_spin_new(), it calls gem_context_lookup_engine which does a GETPARAM to introspet the set of engines on the context and figure out the engine class.
If you've been keeping track, this trivial and extremely common example uses every single one of these soon-to-be-deprecated APIs even though the test author may be completely obvious to it. It also means that getting rid of IGT's use of them is going to require some fairly deep surgery.
The approach proposed and partially implemented here is to add a new wrapper struct intel_ctx_t which wraps a GEM context handle as well as the full set of parameters used to create it, represented by intel_ctx_cfg_t. We can then use the context anywhere we would regularly use a context, we just have to do ctx->id. If we want to clone it, we can do so by re-using the create parameters by calling intel_ctx_create(fd, &old_ctx->cfg);
Along with the above rework (which got long, sorry) I've got a few other patches in here which delete tests which exist expressly to test APIs that are on the chopping block.
v2 (Jason Ekstrand):
- Better documentation
- Two more patches at the end to clean up query APIs even more
v3 (Jason Ekstrand):
- Improved intel_ctx interface
- More tests converted to intel_ctx_t
- Misc. bug fixes
--Jason
Jason Ekstrand (89):
tests/i915: Drop gem_ctx_ringsize tests/i915/gem_exec_balancer: Drop the ringsize subtest tests/i915/gem_exec_endless: Stop setting the ring size tests/i915/gem_ctx_param: Drop the zeromap subtests tests/i915: Drop gem_ctx_clone
docs: Add gem_engine_topology.h to the docs lib/i915/gem_engine_topology: Expose the __query_engines helper (v2) lib/i915/gem_context: Add gem_context_create_ext helpers
lib: Add an intel_ctx wrapper struct and helpers (v4) lib/i915/gem_engine_topology: Rework query_engine_list() lib/i915/gem_engine_topology: Factor out static engine listing lib/i915/gem_engine_topology: Add an iterator which doesn't munge
contexts (v2)
lib/i915/gem_engine_topology: Add an iterator for intel_ctx_t (v2) tests/i915/gem_exec_basic: Convert to intel_ctx_t lib/dummyload: Better document igt_spin_factory lib/dummyload: Rename igt_spin_factory::ctx to ctx_id lib/dummyload: Support intel_ctx_t tests/i915/gem_exec_fence: Move the engine data into
inter_engine_context
tests/i915/gem_exec_fence: Convert to intel_ctx_t tests/i915/gem_exec_schedule: Convert to intel_ctx_t tests/i915/perf_pmu: Convert to intel_ctx_t tests/i915/gem_exec_nop: Convert to intel_ctx_t tests/i915/gem_exec_reloc: Convert to intel_ctx_t tests/i915/gem_busy: Convert to intel_ctx_t tests/i915/gem_ctx_isolation: Convert to intel_ctx_t tests/i915/gem_exec_async: Convert to intel_ctx_t tests/i915/sysfs_clients: Convert to intel_ctx_t tests/i915/gem_exec_fair: Convert to intel_ctx_t tests/i915/gem_spin_batch: Convert to intel_ctx_t tests/i915/gem_exec_store: Convert to intel_ctx_t tests/amdgpu/amd_prime: Convert to intel_ctx_t tests/i915/i915_hangman: Convert to intel_ctx_t tests/i915/gem_ringfill: Convert to intel_ctx_t tests/prime_busy: Convert to intel_ctx_t
tests/prime_vgem: Convert to intel_ctx_t tests/gem_exec_whisper: Convert to intel_ctx_t tests/i915/gem_ctx_exec: Stop cloning contexts in close_race tests/i915/gem_ctx_exec: Convert to intel_ctx_t tests/i915/gem_exec_suspend: Convert to intel_ctx_t tests/i915/gem_sync: Convert to intel_ctx_t tests/i915/gem_userptr_blits: Convert to intel_ctx_t tests/i915/gem_wait: Convert to intel_ctx_t tests/i915/gem_request_retire: Convert to intel_ctx_t tests/i915/gem_ctx_shared: Convert to intel_ctx_t tests/i915/gem_ctx_shared: Stop cloning contexts tests/i915/gem_create: Convert to intel_ctx_t tests/i915/gem_ctx_switch: Convert to intel_ctx_t tests/i915/gem_exec_parallel: Convert to intel_ctx_t tests/i915/gem_exec_latency: Convert to intel_ctx_t tests/i915/gem_watchdog: Convert to intel_ctx_t tests/i915/gem_shrink: Convert to intel_ctx_t tests/i915/gem_exec_params: Convert to intel_ctx_t tests/i915/gem_exec_gttfill: Convert to intel_ctx_t tests/i915/gem_exec_capture: Convert to intel_ctx_t tests/i915/gem_exec_create: Convert to intel_ctx_t tests/i915/gem_exec_await: Convert to intel_ctx_t tests/i915/gem_ctx_persistence: Drop the clone subtest tests/i915/gem_ctx_persistence: Drop the engine replace subtests tests/i915/gem_ctx_persistence: Convert to intel_ctx_t tests/i915/module_load: Convert to intel_ctx_t tests/i915/pm_rc6_residency: Convert to intel_ctx_t tests/i915/gem_cs_tlb: Convert to intel_ctx_t tests/core_hotplug: Convert to intel_ctx_t tests/i915/gem_exec_balancer: Stop cloning engines tests/i915/gem_exec_balancer: Don't reset engines on a context tests/i915/gem_exec_balancer: Stop munging ctx0 engines tests/i915/gem_exec_balancer: Drop bonded tests lib/intel_ctx: Add load balancing support tests/i915/gem_exec_balancer: Convert to intel_ctx_t tests/i915/gem_exec_endless: Stop munging ctx0 engines lib/i915: Use for_each_physical_ring for submission tests tests/i915/gem_ctx_engines: Rework execute-one* tests/i915/gem_ctx_engines: Use better engine iteration tests/i915/gem_ctx_engines: Drop the idempotent subtest tests/i915/gem_ctx_create: Convert benchmarks to intel_ctx_t tests/i915/gem_vm_create: Delete destroy racing tests tests/i915/gem_vm_create: Use intel_ctx_t in the execbuf test tests/i915/sysfs: Convert to intel_ctx_t tests/i915/gem_workarounds: Convert to intel_ctx_t lib/i915/gem_context: Delete all the context clone/copy stuff tests/i915/gem_ctx_engines: Delete the libapi subtest lib/igt_dummyload: Stop supporting ALL_ENGINES without an intel_ctx_t lib/i915/gem_engine_topology: Delete the old physical engine iterators tests/i915/gem_mmap_gtt: Convert to intel_ctx_t igt/dummyload: Require an intel_ctx_t for POLL_RUN and !ALL_ENGINES lib/i915: Rework engine API availability checks (v2) lib/intel_bb: Remove intel_bb_assign_vm and tests tests/i915/gem_ctx_param: Stop setting VMs on old contexts tests/i915/gen9_exec_parse: Convert to intel_ctx_t
.../igt-gpu-tools/igt-gpu-tools-docs.xml | 2 + lib/i915/gem_context.c | 261 ++---- lib/i915/gem_context.h | 21 +- lib/i915/gem_engine_topology.c | 277 +++--- lib/i915/gem_engine_topology.h | 78 +- lib/i915/gem_submission.c | 13 +- lib/igt_dummyload.c | 25 +- lib/igt_dummyload.h | 28 +- lib/igt_gt.c | 2 +- lib/intel_batchbuffer.c | 52 - lib/intel_batchbuffer.h | 3 - lib/intel_ctx.c | 327 +++++++ lib/intel_ctx.h | 79 ++ lib/meson.build | 1 + tests/amdgpu/amd_prime.c | 10 +- tests/core_hotunplug.c | 6 +- tests/i915/api_intel_bb.c | 104 -- tests/i915/gem_busy.c | 77 +- tests/i915/gem_create.c | 14 +- tests/i915/gem_cs_tlb.c | 10 +- tests/i915/gem_ctx_clone.c | 450 --------- tests/i915/gem_ctx_create.c | 76 +- tests/i915/gem_ctx_engines.c | 276 +----- tests/i915/gem_ctx_exec.c | 54 +- tests/i915/gem_ctx_isolation.c | 112 +-- tests/i915/gem_ctx_param.c | 47 +- tests/i915/gem_ctx_persistence.c | 457 +++------ tests/i915/gem_ctx_ringsize.c | 345 ------- tests/i915/gem_ctx_shared.c | 335 ++++--- tests/i915/gem_ctx_switch.c | 115 ++- tests/i915/gem_eio.c | 2 +- tests/i915/gem_exec_async.c | 32 +- tests/i915/gem_exec_await.c | 20 +- tests/i915/gem_exec_balancer.c | 887 ++++-------------- tests/i915/gem_exec_basic.c | 7 +- tests/i915/gem_exec_capture.c | 30 +- tests/i915/gem_exec_create.c | 9 +- tests/i915/gem_exec_endless.c | 14 +- tests/i915/gem_exec_fair.c | 112 ++- tests/i915/gem_exec_fence.c | 302 +++--- tests/i915/gem_exec_gttfill.c | 15 +- tests/i915/gem_exec_latency.c | 118 +-- tests/i915/gem_exec_nop.c | 156 +-- tests/i915/gem_exec_parallel.c | 29 +- tests/i915/gem_exec_params.c | 4 +- tests/i915/gem_exec_reloc.c | 102 +- tests/i915/gem_exec_schedule.c | 887 +++++++++--------- tests/i915/gem_exec_store.c | 36 +- tests/i915/gem_exec_suspend.c | 52 +- tests/i915/gem_exec_whisper.c | 83 +- tests/i915/gem_mmap_gtt.c | 18 +- tests/i915/gem_request_retire.c | 17 +- tests/i915/gem_ringfill.c | 48 +- tests/i915/gem_shrink.c | 37 +- tests/i915/gem_spin_batch.c | 79 +- tests/i915/gem_sync.c | 159 ++-- tests/i915/gem_userptr_blits.c | 25 +- tests/i915/gem_vm_create.c | 125 +-- tests/i915/gem_wait.c | 20 +- tests/i915/gem_watchdog.c | 167 +--- tests/i915/gem_workarounds.c | 11 +- tests/i915/gen9_exec_parse.c | 106 +-- tests/i915/i915_hangman.c | 37 +- tests/i915/i915_module_load.c | 7 +- tests/i915/i915_pm_rc6_residency.c | 7 +- tests/i915/i915_query.c | 17 +- tests/i915/perf_pmu.c | 226 +++-- tests/i915/sysfs_clients.c | 87 +- tests/i915/sysfs_heartbeat_interval.c | 40 +- tests/i915/sysfs_preempt_timeout.c | 39 +- tests/i915/sysfs_timeslice_duration.c | 51 +- tests/meson.build | 2 - tests/prime_busy.c | 19 +- tests/prime_vgem.c | 35 +- 74 files changed, 3374 insertions(+), 4559 deletions(-) create mode 100644 lib/intel_ctx.c create mode 100644 lib/intel_ctx.h delete mode 100644 tests/i915/gem_ctx_clone.c delete mode 100644 tests/i915/gem_ctx_ringsize.c
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 1/89 tests/i915: Drop gem_ctx_ringsize
I915_CONTEXT_PARAM_RINGSIZE is being removed from upstream i915 because it's never been used by any userspace other than IGT.
--- tests/i915/gem_ctx_ringsize.c | 345 ---------------------------------- tests/meson.build | 1 - 2 files changed, 346 deletions(-) delete mode 100644 tests/i915/gem_ctx_ringsize.c
tests/i915/gem_ctx_ringsize.c deleted +0 -345
@@ -1,345 +0,0 @@ -/* -* Copyright © 2019 Intel Corporation -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -* IN THE SOFTWARE. -*/ - -#include <errno.h> -#include <fcntl.h> -#include <inttypes.h> -#include <math.h> -#include <signal.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <unistd.h> - -#include "drmtest.h" -#include "i915/gem.h" -#include "i915/gem_context.h" -#include "i915/gem_engine_topology.h" -#include "ioctl_wrappers.h" /* gem_wait()! */ -#include "sw_sync.h" - -static bool has_ringsize (int i915) -{ -struct drm_i915_gem_context_param p = { - .param =I915_CONTEXT_PARAM_RINGSIZE , - }; - -return __gem_context_get_param (i915, &p) ==0 ; -} - -static void test_idempotent (int i915) -{ -struct drm_i915_gem_context_param p = { - .param =I915_CONTEXT_PARAM_RINGSIZE , - }; -uint32_t saved; - -/* -* Simple test to verify that we are able to read back the same -* value as we set. -*/ - -gem_context_get_param (i915, &p); - saved = p.value; - -for (uint32_t x =1 <<12 ; x <=128 <<12 ; x <<=1 ) { - p.value = x; -gem_context_set_param (i915, &p); -gem_context_get_param (i915, &p); -igt_assert_eq_u32 (p.value, x); - } - - p.value = saved; -gem_context_set_param (i915, &p); -} - -static void test_invalid (int i915) -{ -struct drm_i915_gem_context_param p = { - .param =I915_CONTEXT_PARAM_RINGSIZE , - }; -uint64_t invalid[] = { -0 ,1 ,4095 ,4097 ,8191 ,8193 , -/* upper limit may be HW dependent, atm it is 512KiB */ - (512 <<10 ) -1 , (512 <<10 ) +1 , --1 ,-1u - }; -uint32_t saved; - -/* -* The HW only accepts certain aligned values and so we reject -* any invalid sizes specified by the user. -* -* Currently, the HW only accepts 4KiB - 512KiB in 4K increments, -* and is unlikely to ever accept smaller. -*/ - -gem_context_get_param (i915, &p); - saved = p.value; - -for (int i =0 ; i <ARRAY_SIZE (invalid); i++) { - p.value = invalid[i]; -igt_assert_eq (__gem_context_set_param (i915, &p), -EINVAL ); -gem_context_get_param (i915, &p); -igt_assert_eq_u64 (p.value, saved); - } -} - -static int create_ext_ioctl (int i915, -struct drm_i915_gem_context_create_ext *arg) -{ -int err; - - err =0 ; -if (igt_ioctl (i915,DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT , arg)) { - err = -errno; -igt_assume (err); - } - - errno =0 ; -return err; -} - -static void test_create (int i915) -{ -struct drm_i915_gem_context_create_ext_setparam p = { - .base = { - .name =I915_CONTEXT_CREATE_EXT_SETPARAM , - .next_extension =0 ,/* end of chain */ - }, - .param = { - .param =I915_CONTEXT_PARAM_RINGSIZE , - .value =512 <<10 , - } - }; -struct drm_i915_gem_context_create_ext create = { - .flags =I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS , - .extensions =to_user_pointer (&p), - }; - -/* -* Check that the ringsize parameter is used during context constuction. -*/ - -igt_assert_eq (create_ext_ioctl (i915, &create),0 ); - - p.param.ctx_id = create.ctx_id; - p.param.value =0 ; -gem_context_get_param (i915, &p.param); -igt_assert_eq (p.param.value,512 <<10 ); - -gem_context_destroy (i915, create.ctx_id); -} - -static void test_clone (int i915) -{ -struct drm_i915_gem_context_create_ext_setparam p = { - .base = { - .name =I915_CONTEXT_CREATE_EXT_SETPARAM , - .next_extension =0 ,/* end of chain */ - }, - .param = { - .param =I915_CONTEXT_PARAM_RINGSIZE , - .value =512 <<10 , - } - }; -struct drm_i915_gem_context_create_ext create = { - .flags =I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS , - .extensions =to_user_pointer (&p), - }; - -/* -* Check that the ringsize is copied across during context cloning. -*/ - -igt_assert_eq (create_ext_ioctl (i915, &create),0 ); - - p.param.ctx_id =gem_context_clone (i915, create.ctx_id, -I915_CONTEXT_CLONE_ENGINES ,0 ); -igt_assert_neq (p.param.ctx_id, create.ctx_id); -gem_context_destroy (i915, create.ctx_id); - - p.param.value =0 ; -gem_context_get_param (i915, &p.param); -igt_assert_eq (p.param.value,512 <<10 ); - -gem_context_destroy (i915, p.param.ctx_id); -} - -static int __execbuf (int i915,struct drm_i915_gem_execbuffer2 *execbuf) -{ -int err; - - err =0 ; -if (ioctl (i915,DRM_IOCTL_I915_GEM_EXECBUFFER2 , execbuf)) { - err = -errno; -igt_assume (err); - } - - errno =0 ; -return err; -} - -#define IDLE (1 << 0) -#define PLUG (1 << 1) - -static void sighandler (int sig) -{ -} - -static unsigned int -measure_inflight (int i915,unsigned int engine,int timeout,unsigned int flags) -{ -IGT_CORK_FENCE (cork); -unsigned int count; -igt_spin_t *spin; -int fence; -int err; - -fcntl (i915,F_SETFL ,fcntl (i915,F_GETFL ) |O_NONBLOCK ); -signal (SIGALRM , sighandler); -alarm (timeout); - - fence =igt_cork_plug (&cork, i915); - spin = igt_spin_new(i915, - .engine = engine, - .fence = fence, - .flags = (flags &PLUG ) ?IGT_SPIN_FENCE_IN :0 ); -for (count =1 ; (err =__execbuf (i915, &spin->execbuf)) ==0 ; count++) - ; -igt_debugfs_dump (i915,"i915_engine_info" ); -igt_assert_eq (err, -EWOULDBLOCK ); -close (fence); - -alarm (0 ); -signal (SIGALRM ,SIG_DFL ); -fcntl (i915,F_SETFL ,fcntl (i915,F_GETFL ) & ~O_NONBLOCK ); - -igt_spin_free (i915, spin); -igt_cork_unplug (&cork); - -return count; -} - -static void test_resize (int i915, -const struct intel_execution_engine2 *e, -void *data) -#define as_pointer(x) (void *)(uintptr_t)(x) -{ -struct drm_i915_gem_context_param p = { - .param =I915_CONTEXT_PARAM_RINGSIZE , - }; -unsigned long flags = (uintptr_t )data; -unsigned int prev[2 ] = {}; -uint64_t elapsed; -uint32_t saved; - -/* -* The ringsize directly affects the number of batches we can have -* inflight -- when we run out of room in the ring, the client is -* blocked (or if O_NONBLOCK is specified, -EWOULDBLOCK is reported). -* The kernel throttles the client when they enter the last 4KiB page, -* so as we double the size of the ring, we nearly double the number -* of requests we can fit as 2^n-1: i.e 0, 1, 3, 7, 15, 31 pages. -*/ - -gem_context_get_param (i915, &p); - saved = p.value; - -/* XXX disable hangchecking? */ - elapsed =0 ; -gem_quiescent_gpu (i915); -for (p.value =1 <<12 ; p.value <=128 <<12 ; p.value <<=1 ) { -struct timespec tv = {}; -unsigned int count; - -gem_context_set_param (i915, &p); - -igt_nsec_elapsed (&tv); - count =measure_inflight (i915, - e->flags, -1 +4 *ceil (elapsed*1e-9 ), - flags); - elapsed =igt_nsec_elapsed (&tv); - -igt_info ("%s: %6llx -> %'6d\n" , e->name, p.value, count); -igt_assert (count >3 * (prev[1 ] - prev[0 ]) /4 + prev[1 ]); -if (flags &IDLE ) -gem_quiescent_gpu (i915); - - prev[0 ] = prev[1 ]; - prev[1 ] = count; - } -gem_quiescent_gpu (i915); - - p.value = saved; -gem_context_set_param (i915, &p); -} - -static void gem_test_each_engine (int i915,const char *name, -void (*fn)(int i915, -const struct intel_execution_engine2 *e, -void *data), -void *data) -{ -const struct intel_execution_engine2 *e; - -igt_subtest_with_dynamic (name) { -__for_each_physical_engine (i915, e) { - igt_dynamic_f("%s", e->name) -fn (i915, e, data); - } - } -} - -igt_main -{ -int i915; - - igt_fixture { - i915 =drm_open_driver (DRIVER_INTEL ); -igt_require_gem (i915); - -igt_require (has_ringsize (i915)); - } - - igt_subtest("idempotent") -test_idempotent (i915); - - igt_subtest("invalid") -test_invalid (i915); - - igt_subtest("create") -test_create (i915); - igt_subtest("clone") -test_clone (i915); - -gem_test_each_engine (i915,"idle" , test_resize,as_pointer (IDLE )); -gem_test_each_engine (i915,"active" , test_resize,0 ); -gem_test_each_engine (i915,"plugged" , test_resize,as_pointer (PLUG )); - -/* XXX ctx->engines[]? Clone (above) should be enough */ - - igt_fixture { -close (i915); - } -}
tests/meson.build +0 -1
@@ -132,7 +132,6 @@ i915_progs = [ 'gem_ctx_isolation', 'gem_ctx_param', 'gem_ctx_persistence', - 'gem_ctx_ringsize', 'gem_ctx_shared', 'gem_ctx_switch', 'gem_evict_alignment',
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 2/89 tests/i915/gem_exec_balancer: Drop the ringsize subtest
In reply to Jason EkstrandI915_CONTEXT_PARAM_RINGSIZE is being removed from upstream i915 because it's never been used by any userspace other than IGT.
--- tests/i915/gem_exec_balancer.c | 81 ---------------------------------- 1 file changed, 81 deletions(-)
tests/i915/gem_exec_balancer.c +0 -81
@@ -2551,84 +2551,6 @@ next:gem_quiescent_gpu (i915); } -static void sighandler (int sig) -{ -} - -static unsigned int measure_inflight (int i915,uint32_t ctx,int timeout) -{ -igt_spin_t *spin =igt_spin_new (i915, ctx); -unsigned int count; -int err; - -fcntl (i915,F_SETFL ,fcntl (i915,F_GETFL ) |O_NONBLOCK ); -signal (SIGALRM , sighandler); -alarm (timeout); - -for (count =1 ; (err =__execbuf (i915, &spin->execbuf)) ==0 ; count++) - ; -igt_assert_eq (err, -EWOULDBLOCK ); - -alarm (0 ); -signal (SIGALRM ,SIG_DFL ); -fcntl (i915,F_SETFL ,fcntl (i915,F_GETFL ) & ~O_NONBLOCK ); - -igt_spin_free (i915, spin); - -return count; -} - -static void __resize (int i915,uint32_t ctx) -{ -struct drm_i915_gem_context_param p = { - .ctx_id = ctx, - .param =I915_CONTEXT_PARAM_RINGSIZE , - }; -unsigned int prev[2 ] = {}; -uint64_t elapsed; - - elapsed =0 ; -gem_quiescent_gpu (i915); -for (p.value =1 <<12 ; p.value <=128 <<12 ; p.value <<=1 ) { -struct timespec tv = {}; -unsigned int count; - -gem_context_set_param (i915, &p); - -igt_nsec_elapsed (&tv); - count =measure_inflight (i915, ctx,1 +4 *ceil (elapsed*1e-9 )); - elapsed =igt_nsec_elapsed (&tv); - -igt_info ("%6llx -> %'6d\n" , p.value, count); -igt_assert (count >3 * (prev[1 ] - prev[0 ]) /4 + prev[1 ]); - - prev[0 ] = prev[1 ]; - prev[1 ] = count; - } -gem_quiescent_gpu (i915); -} - -static void ringsz (int i915) -{ -for (int class =0 ; class <32 ; class++) { -struct i915_engine_class_instance *ci; -unsigned int count; -uint32_t ctx; - - ci =list_engines (i915,1u << class, &count); -if (!ci || count <2 ) - goto next; - - ctx =load_balancer_create (i915, ci, count); -__resize (i915, ctx); -gem_context_destroy (i915, ctx); -next: -free (ci); - } - -gem_quiescent_gpu (i915); -} -static void ping (int i915,uint32_t ctx,unsigned int engine) {struct drm_i915_gem_exec_object2 obj = {
@@ -3304,9 +3226,6 @@ igt_main igt_subtest("fairslice")fairslice (i915); - igt_subtest("ringsize") -ringsz (i915); - igt_subtest("nop")nop (i915);
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 3/89 tests/i915/gem_exec_endless: Stop setting the ring size
In reply to Jason EkstrandI915_CONTEXT_PARAM_RINGSIZE is being removed from upstream i915 because it's never been used by any userspace other than IGT.
--- tests/i915/gem_exec_endless.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
tests/i915/gem_exec_endless.c +1 -11
@@ -67,16 +67,6 @@ static unsigned int offset_in_page(void *addr)static uint32_t __supervisor_create_context (int i915,const struct intel_execution_engine2 *e) { -struct drm_i915_gem_context_create_ext_setparam p_ring = { - { - .name =I915_CONTEXT_CREATE_EXT_SETPARAM , - .next_extension =0 - }, - { - .param =I915_CONTEXT_PARAM_RINGSIZE , - .value =4096 , - }, - }; I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, 2) = { .engines = { { e->class, e->instance },
@@ -86,7 +76,7 @@ static uint32_t __supervisor_create_context(int i915,struct drm_i915_gem_context_create_ext_setparam p_engines = { { .name =I915_CONTEXT_CREATE_EXT_SETPARAM , - .next_extension =to_user_pointer (&p_ring) + .next_extension =0 , }, { .param =I915_CONTEXT_PARAM_ENGINES ,
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 4/89 tests/i915/gem_ctx_param: Drop the zeromap subtests
In reply to Jason EkstrandThe idea behind this param is to support OpenCL drivers with relocations because OpenCL reserves 0x0 for NULL and, if we placed memory there, it would confuse CL kernels. It was originally sent out as part of a patch series including libdrm [1] and Beignet [2] support. However, the libdrm and Beignet patches never landed in their respective upstream projects so this API has never been used. It's never been used in Mesa or any other driver, either.
This means that these IGT tests are the only userspace for NO_ZEROMAP which has ever really existed. Let's drop them and drop support from i915 as well.
[1]: https://lists.freedesktop.org/archives/intel-gfx/2015-May/067030.html
[2]: https://lists.freedesktop.org/archives/intel-gfx/2015-May/067031.html
--- tests/i915/gem_ctx_param.c | 33 --------------------------------- 1 file changed, 33 deletions(-)
tests/i915/gem_ctx_param.c +0 -33
@@ -335,39 +335,6 @@ igt_maingem_context_set_param (fd, &arg); } - arg.param =I915_CONTEXT_PARAM_NO_ZEROMAP ; - -igt_describe ("Validates context set param ioctl in non root mode with param " -"set to no zeromap" ); - igt_subtest("non-root-set-no-zeromap") { - igt_fork(child, 1) { -igt_drop_root (); - - arg.ctx_id = ctx; -gem_context_get_param (fd, &arg); - arg.value--; -gem_context_set_param (fd, &arg); - } - -igt_waitchildren (); - } - -igt_describe ("Tests the context set param ioctl with no zeromap enabled in root mode" ); - igt_subtest("root-set-no-zeromap-enabled") { - arg.ctx_id = ctx; -gem_context_get_param (fd, &arg); - arg.value =1 ; -gem_context_set_param (fd, &arg); - } - -igt_describe ("Tests the context set param ioctl with no zeromap disabled in root mode" ); - igt_subtest("root-set-no-zeromap-disabled") { - arg.ctx_id = ctx; -gem_context_get_param (fd, &arg); - arg.value =0 ; -gem_context_set_param (fd, &arg); - } -igt_describe ("Tests that multiple contexts can share the same VMA" ); igt_subtest("vm")test_vm (fd);
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 5/89 tests/i915: Drop gem_ctx_clone
In reply to Jason EkstrandWe're going to be deleting the CONTEXT_CLONE API since IGT is the only userspace to ever use it.
--- tests/i915/gem_ctx_clone.c | 450 ------------------------------------- tests/meson.build | 1 - 2 files changed, 451 deletions(-) delete mode 100644 tests/i915/gem_ctx_clone.c
tests/i915/gem_ctx_clone.c deleted +0 -450
@@ -1,450 +0,0 @@ -/* -* Copyright © 2019 Intel Corporation -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -* IN THE SOFTWARE. -*/ - -#include "i915/gem.h" -#include "i915/gem_vm.h" -#include "i915_drm.h" -#include "igt.h" -#include "igt_gt.h" - -static int ctx_create_ioctl (int i915,struct drm_i915_gem_context_create_ext *arg) -{ -int err; - - err =0 ; -if (igt_ioctl (i915,DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT , arg)) { - err = -errno; -igt_assume (err); - } - - errno =0 ; -return err; -} - -static void invalid_clone (int i915) -{ -struct drm_i915_gem_context_create_ext_clone ext = { - { .name =I915_CONTEXT_CREATE_EXT_CLONE }, - }; -struct drm_i915_gem_context_create_ext create = { - .flags =I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS , - .extensions =to_user_pointer (&ext), - }; - -igt_assert_eq (ctx_create_ioctl (i915, &create),0 ); -gem_context_destroy (i915, create.ctx_id); - - ext.flags =-1 ;/* Hopefully we won't run out of flags */ -igt_assert_eq (ctx_create_ioctl (i915, &create), -EINVAL ); - ext.flags =0 ; - - ext.base.next_extension =-1 ; -igt_assert_eq (ctx_create_ioctl (i915, &create), -EFAULT ); - ext.base.next_extension =to_user_pointer (&ext); -igt_assert_eq (ctx_create_ioctl (i915, &create), -E2BIG ); - ext.base.next_extension =0 ; - - ext.clone_id =-1 ; -igt_assert_eq (ctx_create_ioctl (i915, &create), -ENOENT ); - ext.clone_id =0 ; -} - -static void clone_flags (int i915) -{ -struct drm_i915_gem_context_create_ext_setparam set = { - { .name =I915_CONTEXT_CREATE_EXT_SETPARAM }, - { .param =I915_CONTEXT_PARAM_RECOVERABLE }, - }; -struct drm_i915_gem_context_create_ext_clone ext = { - { .name =I915_CONTEXT_CREATE_EXT_CLONE }, - .flags =I915_CONTEXT_CLONE_FLAGS , - }; -struct drm_i915_gem_context_create_ext create = { - .flags =I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS , - .extensions =to_user_pointer (&ext), - }; -int expected; - - set.param.value =1 ;/* default is recoverable */ -igt_require (__gem_context_set_param (i915, &set.param) ==0 ); - -for (int pass =0 ; pass <2 ; pass++) {/* cloning default, then child */ -igt_debug ("Cloning %d\n" , ext.clone_id); -igt_assert_eq (ctx_create_ioctl (i915, &create),0 ); - - set.param.ctx_id = ext.clone_id; -gem_context_get_param (i915, &set.param); - expected = set.param.value; - - set.param.ctx_id = create.ctx_id; -gem_context_get_param (i915, &set.param); - -igt_assert_eq_u64 (set.param.param, -I915_CONTEXT_PARAM_RECOVERABLE ); -igt_assert_eq ((int )set.param.value, expected); - -gem_context_destroy (i915, create.ctx_id); - - expected = set.param.value =0 ; - set.param.ctx_id = ext.clone_id; -gem_context_set_param (i915, &set.param); - -igt_assert_eq (ctx_create_ioctl (i915, &create),0 ); - - set.param.ctx_id = create.ctx_id; -gem_context_get_param (i915, &set.param); - -igt_assert_eq_u64 (set.param.param, -I915_CONTEXT_PARAM_RECOVERABLE ); -igt_assert_eq ((int )set.param.value, expected); - -gem_context_destroy (i915, create.ctx_id); - -/* clone but then reset priority to default... */ - set.param.ctx_id =0 ; - set.param.value =1 ; - ext.base.next_extension =to_user_pointer (&set); -igt_assert_eq (ctx_create_ioctl (i915, &create),0 ); - ext.base.next_extension =0 ; - -/* then new context should have updated priority... */ - set.param.ctx_id = create.ctx_id; -gem_context_get_param (i915, &set.param); -igt_assert_eq_u64 (set.param.value,1 ); - -/* but original context should have default priority */ - set.param.ctx_id = ext.clone_id; -gem_context_get_param (i915, &set.param); -igt_assert_eq_u64 (set.param.value,0 ); - -gem_context_destroy (i915, create.ctx_id); - ext.clone_id =gem_context_create (i915); - } - -gem_context_destroy (i915, ext.clone_id); -} - -static void clone_engines (int i915) -{ -struct drm_i915_gem_context_create_ext_setparam set = { - { .name =I915_CONTEXT_CREATE_EXT_SETPARAM }, - { .param =I915_CONTEXT_PARAM_ENGINES }, - }; -struct drm_i915_gem_context_create_ext_clone ext = { - { .name =I915_CONTEXT_CREATE_EXT_CLONE }, - .flags =I915_CONTEXT_CLONE_ENGINES , - }; -struct drm_i915_gem_context_create_ext create = { - .flags =I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS , - .extensions =to_user_pointer (&ext), - }; -I915_DEFINE_CONTEXT_PARAM_ENGINES (expected,64 ); -I915_DEFINE_CONTEXT_PARAM_ENGINES (engines,64 ); -uint64_t ex_size; - -memset (&expected,0 ,sizeof (expected)); -memset (&engines,0 ,sizeof (engines)); - -igt_require (__gem_context_set_param (i915, &set.param) ==0 ); - -for (int pass =0 ; pass <2 ; pass++) {/* cloning default, then child */ -igt_debug ("Cloning %d\n" , ext.clone_id); -igt_assert_eq (ctx_create_ioctl (i915, &create),0 ); - -/* Check that we cloned the engine map */ - set.param.ctx_id = ext.clone_id; - set.param.size =sizeof (expected); - set.param.value =to_user_pointer (&expected); -gem_context_get_param (i915, &set.param); - ex_size = set.param.size; - - set.param.ctx_id = create.ctx_id; - set.param.size =sizeof (engines); - set.param.value =to_user_pointer (&engines); -gem_context_get_param (i915, &set.param); - -igt_assert_eq_u64 (set.param.param,I915_CONTEXT_PARAM_ENGINES ); -igt_assert_eq_u64 (set.param.size, ex_size); -igt_assert (!memcmp (&engines, &expected, ex_size)); - -gem_context_destroy (i915, create.ctx_id); - -/* Check that the clone will replace an earlier set */ - expected.engines[0 ].engine_class = -I915_ENGINE_CLASS_INVALID ; - expected.engines[0 ].engine_instance = -I915_ENGINE_CLASS_INVALID_NONE ; - ex_size = (sizeof (struct i915_context_param_engines ) + -sizeof (expected.engines[0 ])); - - set.param.ctx_id = ext.clone_id; - set.param.size = ex_size; - set.param.value =to_user_pointer (&expected); -gem_context_set_param (i915, &set.param); - -igt_assert_eq (ctx_create_ioctl (i915, &create),0 ); - - set.param.ctx_id = create.ctx_id; - set.param.size =sizeof (engines); - set.param.value =to_user_pointer (&engines); -gem_context_get_param (i915, &set.param); - -igt_assert_eq_u64 (set.param.size, ex_size); -igt_assert (!memcmp (&engines, &expected, ex_size)); - -gem_context_destroy (i915, create.ctx_id); - -/* clone but then reset engines to default */ - set.param.ctx_id =0 ; - set.param.size =0 ; - set.param.value =0 ; - ext.base.next_extension =to_user_pointer (&set); - -igt_assert_eq (ctx_create_ioctl (i915, &create),0 ); - ext.base.next_extension =0 ; - - set.param.ctx_id = create.ctx_id; - set.param.size =sizeof (engines); - set.param.value =to_user_pointer (&engines); -gem_context_get_param (i915, &set.param); -igt_assert_eq_u64 (set.param.size,0 ); - -gem_context_destroy (i915, create.ctx_id); - -/* And check we ignore the flag */ - ext.flags =0 ; -igt_assert_eq (ctx_create_ioctl (i915, &create),0 ); - ext.flags =I915_CONTEXT_CLONE_ENGINES ; - - set.param.ctx_id = create.ctx_id; - set.param.size =sizeof (engines); - set.param.value =to_user_pointer (&engines); -gem_context_get_param (i915, &set.param); -igt_assert_eq_u64 (set.param.size,0 ); - - ext.clone_id =gem_context_create (i915); - } - -gem_context_destroy (i915, ext.clone_id); -} - -static void clone_scheduler (int i915) -{ -struct drm_i915_gem_context_create_ext_setparam set = { - { .name =I915_CONTEXT_CREATE_EXT_SETPARAM }, - { .param =I915_CONTEXT_PARAM_PRIORITY }, - }; -struct drm_i915_gem_context_create_ext_clone ext = { - { .name =I915_CONTEXT_CREATE_EXT_CLONE }, - .flags =I915_CONTEXT_CLONE_SCHEDATTR , - }; -struct drm_i915_gem_context_create_ext create = { - .flags =I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS , - .extensions =to_user_pointer (&ext), - }; -int expected; - -igt_require (__gem_context_set_param (i915, &set.param) ==0 ); - -for (int pass =0 ; pass <2 ; pass++) {/* cloning default, then child */ -igt_debug ("Cloning %d\n" , ext.clone_id); -igt_assert_eq (ctx_create_ioctl (i915, &create),0 ); - - set.param.ctx_id = ext.clone_id; -gem_context_get_param (i915, &set.param); - expected = set.param.value; - - set.param.ctx_id = create.ctx_id; -gem_context_get_param (i915, &set.param); - -igt_assert_eq_u64 (set.param.param,I915_CONTEXT_PARAM_PRIORITY ); -igt_assert_eq ((int )set.param.value, expected); - -gem_context_destroy (i915, create.ctx_id); - - expected = set.param.value =1 ; - set.param.ctx_id = ext.clone_id; -gem_context_set_param (i915, &set.param); - -igt_assert_eq (ctx_create_ioctl (i915, &create),0 ); - - set.param.ctx_id = create.ctx_id; -gem_context_get_param (i915, &set.param); - -igt_assert_eq_u64 (set.param.param,I915_CONTEXT_PARAM_PRIORITY ); -igt_assert_eq ((int )set.param.value, expected); - -gem_context_destroy (i915, create.ctx_id); - -/* clone but then reset priority to default */ - set.param.ctx_id =0 ; - set.param.value =0 ; - ext.base.next_extension =to_user_pointer (&set); -igt_assert_eq (ctx_create_ioctl (i915, &create),0 ); - ext.base.next_extension =0 ; - - set.param.ctx_id = create.ctx_id; -gem_context_get_param (i915, &set.param); -igt_assert_eq_u64 (set.param.value,0 ); - - set.param.ctx_id = ext.clone_id; -gem_context_get_param (i915, &set.param); -igt_assert_eq_u64 (set.param.value,1 ); - -gem_context_destroy (i915, create.ctx_id); - ext.clone_id =gem_context_create (i915); - } - -gem_context_destroy (i915, ext.clone_id); -} - -static uint32_t __batch_create (int i915,uint32_t offset) -{ -const uint32_t bbe =MI_BATCH_BUFFER_END ; -uint32_t handle; - - handle =gem_create (i915,ALIGN (offset +4 ,4096 )); -gem_write (i915, handle, offset, &bbe,sizeof (bbe)); - -return handle; -} - -static uint32_t batch_create (int i915) -{ -return __batch_create (i915,0 ); -} - -static void check_same_vm (int i915,uint32_t ctx_a,uint32_t ctx_b) -{ -struct drm_i915_gem_exec_object2 batch = { - .handle =batch_create (i915), - }; -struct drm_i915_gem_execbuffer2 eb = { - .buffers_ptr =to_user_pointer (&batch), - .buffer_count =1 , - }; - -/* First verify that we try to use "softpinning" by default */ - batch.offset =48 <<20 ; - eb.rsvd1 = ctx_a; -gem_execbuf (i915, &eb); -igt_assert_eq_u64 (batch.offset,48 <<20 ); - -/* An already active VMA will try to keep its offset */ - batch.offset =0 ; - eb.rsvd1 = ctx_b; -gem_execbuf (i915, &eb); -igt_assert_eq_u64 (batch.offset,48 <<20 ); - -gem_sync (i915, batch.handle); -gem_close (i915, batch.handle); - -gem_quiescent_gpu (i915);/* evict the vma */ -} - -static void clone_vm (int i915) -{ -struct drm_i915_gem_context_param set = { - .param =I915_CONTEXT_PARAM_VM , - }; -struct drm_i915_gem_context_create_ext_clone ext = { - { .name =I915_CONTEXT_CREATE_EXT_CLONE }, - .flags =I915_CONTEXT_CLONE_VM , - }; -struct drm_i915_gem_context_create_ext create = { - .flags =I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS , - .extensions =to_user_pointer (&ext), - }; -uint32_t vm_id[2 ]; - -igt_require (__gem_context_set_param (i915, &set) == -ENOENT ); - -/* Scrub the VM for our tests */ - i915 =gem_reopen_driver (i915); - - set.ctx_id =gem_context_create (i915); -gem_context_get_param (i915, &set); - vm_id[0 ] = set.value; -gem_context_destroy (i915, set.ctx_id); - - vm_id[1 ] =gem_vm_create (i915); - -for (int pass =0 ; pass <2 ; pass++) {/* cloning default, then child */ -igt_debug ("Cloning %d\n" , ext.clone_id); - -igt_assert_eq (ctx_create_ioctl (i915, &create),0 ); -check_same_vm (i915, ext.clone_id, create.ctx_id); -gem_context_destroy (i915, create.ctx_id); - - set.value = vm_id[pass]; - set.ctx_id = ext.clone_id; -gem_context_set_param (i915, &set); - -igt_assert_eq (ctx_create_ioctl (i915, &create),0 ); -check_same_vm (i915, ext.clone_id, create.ctx_id); -gem_context_destroy (i915, create.ctx_id); - - ext.clone_id =gem_context_create (i915); - } - -gem_context_destroy (i915, ext.clone_id); - -for (int i =0 ; i <ARRAY_SIZE (vm_id); i++) -gem_vm_destroy (i915, vm_id[i]); - -close (i915); -} - -igt_main -{ -int i915 =-1 ; - - igt_fixture { - i915 =drm_open_driver (DRIVER_INTEL ); -igt_require_gem (i915); -gem_require_contexts (i915); - -igt_require (gem_has_context_clone (i915)); -igt_fork_hang_detector (i915); - } - - igt_subtest("invalid") -invalid_clone (i915); - - igt_subtest("engines") -clone_engines (i915); - - igt_subtest("flags") -clone_flags (i915); - - igt_subtest("scheduler") -clone_scheduler (i915); - - igt_subtest("vm") -clone_vm (i915); - - igt_fixture { -igt_stop_hang_detector (); -close (i915); - } -}
tests/meson.build +0 -1
@@ -125,7 +125,6 @@ i915_progs = [ 'gem_concurrent_blit', 'gem_cs_tlb', 'gem_ctx_bad_destroy', - 'gem_ctx_clone', 'gem_ctx_create', 'gem_ctx_engines', 'gem_ctx_exec',
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 6/89 docs: Add gem_engine_topology.h to the docs
In reply to Jason EkstrandAlso, document a couple things while we're here. It's nowhere close to everything but it's more than nothing.
--- .../igt-gpu-tools/igt-gpu-tools-docs.xml | 1 + lib/i915/gem_engine_topology.c | 16 ++++++++++++++++ lib/i915/gem_engine_topology.h | 15 +++++++++++++++ 3 files changed, 32 insertions(+)
docs/reference/igt-gpu-tools/igt-gpu-tools-docs.xml +1 -0
@@ -55,6 +55,7 @@ <chapter> <title>igt/i915 API Reference</title> <xi:include href="xml/gem_context.xml"/> + <xi:include href="xml/gem_engine_topology.xml"/> <xi:include href="xml/gem_scheduler.xml"/> <xi:include href="xml/gem_submission.xml"/> </chapter>
lib/i915/gem_engine_topology.c +16 -0
@@ -32,6 +32,14 @@#include "ioctl_wrappers.h" #include "i915/gem_engine_topology.h" +/** +* SECTION:gem_engine_topology +* @short_description: Helpers for dealing engine topology +* @title: GEM Engine Topology +* +* This helper library contains functions used for querying and dealing +* with engines in GEM contexts. +*/ /* * Limit what we support for simplicity due limitation in how much we
@@ -276,6 +284,14 @@ int gem_context_lookup_engine(int fd, uint64_t engine, uint32_t ctx_id,return 0 ; } +/** +* gem_has_engine_topology: +* @fd: open i915 drm file descriptor +* +* Queries whether the engine topology API is supported or not. +* +* Returns: Engine topology API availability. +*/ bool gem_has_engine_topology (int fd) {struct drm_i915_gem_context_param param = {
lib/i915/gem_engine_topology.h +15 -0
@@ -29,6 +29,15 @@#define GEM_MAX_ENGINES I915_EXEC_RING_MASK + 1 +/** +* intel_engine_data: +* @nengines: Number of engines +* @n: Current engine index +* @current_engine: Current engine +* @engines: List of all engines +* +* This struct acts as an interator for walking over a set of engines. +*/ struct intel_engine_data {uint32_t nengines;uint32_t n;
@@ -58,6 +67,12 @@ bool gem_engine_is_equal(const struct intel_execution_engine2 *e1,struct intel_execution_engine2 gem_eb_flags_to_engine (unsigned int flags); +/** +* __for_each_static_engine: +* @e__: struct intel_execution_engine2 iterator +* +* Iterates over each of the statically defined (legacy) engines. +*/ #define __for_each_static_engine (e__) \ for ((e__) = intel_execution_engines2; (e__)->name[0]; (e__)++)
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 06/89] docs: Add gem_engine_topology.h to the docs
Quoted 2 lines · Jason Ekstrand
Also, document a couple things while we're here. It's nowhere close to everything but it's more than nothing.
LGTM and generates docs properly:
--
Zbigniew
Quoted 92 lines
--- .../igt-gpu-tools/igt-gpu-tools-docs.xml | 1 + lib/i915/gem_engine_topology.c | 16 ++++++++++++++++ lib/i915/gem_engine_topology.h | 15 +++++++++++++++ 3 files changed, 32 insertions(+)docs/reference/igt-gpu-tools/igt-gpu-tools-docs.xml +1
-0@@ -55,6 +55,7 @@ <chapter> <title>igt/i915 API Reference</title> <xi:include href="xml/gem_context.xml"/> + <xi:include href="xml/gem_engine_topology.xml"/> <xi:include href="xml/gem_scheduler.xml"/> <xi:include href="xml/gem_submission.xml"/> </chapter>lib/i915/gem_engine_topology.c +16
-0@@ -32,6 +32,14 @@#include "ioctl_wrappers.h" #include "i915/gem_engine_topology.h" +/** +* SECTION:gem_engine_topology +* @short_description: Helpers for dealing engine topology +* @title: GEM Engine Topology +* +* This helper library contains functions used for querying and dealing +* with engines in GEM contexts. +*/ /* * Limit what we support for simplicity due limitation in how much we @@ -276,6 +284,14 @@ int gem_context_lookup_engine(int fd, uint64_t engine, uint32_t ctx_id,return 0 ; } +/** +* gem_has_engine_topology: +* @fd: open i915 drm file descriptor +* +* Queries whether the engine topology API is supported or not. +* +* Returns: Engine topology API availability. +*/ bool gem_has_engine_topology (int fd) {struct drm_i915_gem_context_param param = {lib/i915/gem_engine_topology.h +15
-0@@ -29,6 +29,15 @@#define GEM_MAX_ENGINES I915_EXEC_RING_MASK + 1 +/** +* intel_engine_data: +* @nengines: Number of engines +* @n: Current engine index +* @current_engine: Current engine +* @engines: List of all engines +* +* This struct acts as an interator for walking over a set of engines. +*/ struct intel_engine_data {uint32_t nengines;uint32_t n;@@ -58,6 +67,12 @@ bool gem_engine_is_equal(const struct intel_execution_engine2 *e1,struct intel_execution_engine2 gem_eb_flags_to_engine (unsigned int flags); +/** +* __for_each_static_engine: +* @e__: struct intel_execution_engine2 iterator +* +* Iterates over each of the statically defined (legacy) engines. +*/ #define __for_each_static_engine (e__) \ for ((e__) = intel_execution_engines2; (e__)->name[0]; (e__)++)Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 7/89 lib/i915/gem_engine_topology: Expose the __query_engines helper (v2)
In reply to Jason Ekstrandv2 (Jason Ekstrand):
- Add docs
--- lib/i915/gem_engine_topology.c | 28 +++++++++++++++++++--------- lib/i915/gem_engine_topology.h | 4 ++++ 2 files changed, 23 insertions(+), 9 deletions(-)
lib/i915/gem_engine_topology.c +19 -9
@@ -70,14 +70,17 @@ static int __gem_query(int fd, struct drm_i915_query *q)return err; } -static void gem_query (int fd,struct drm_i915_query *q) -{ -igt_assert_eq (__gem_query (fd, q),0 ); -} - -static void query_engines (int fd, -struct drm_i915_query_engine_info *query_engines, -int length) +/** +* __gem_query_engines: +* @fd: open i915 drm file descriptor +* @query_engines: Returned engine query info +* @length: Size of query_engines, including room for the engines array +* +* Queries the set of engines available on this device. +*/ +int __gem_query_engines (int fd, +struct drm_i915_query_engine_info *query_engines, +int length) {struct drm_i915_query_item item = { };struct drm_i915_query query = { };
@@ -89,7 +92,14 @@ static void query_engines(int fd, item.data_ptr =to_user_pointer (query_engines); -gem_query (fd, &query); +return __gem_query (fd, &query); +} + +static void query_engines (int fd, +struct drm_i915_query_engine_info *query_engines, +int length) +{ +igt_assert_eq (__gem_query_engines (fd, query_engines, length),0 ); } static void ctx_map_engines(int fd, struct intel_engine_data *ed,
lib/i915/gem_engine_topology.h +4 -0
@@ -29,6 +29,10 @@#define GEM_MAX_ENGINES I915_EXEC_RING_MASK + 1 +int __gem_query_engines (int fd, +struct drm_i915_query_engine_info *query_engines, +int length); +/** * intel_engine_data: * @nengines: Number of engines
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 8/89 lib/i915/gem_context: Add gem_context_create_ext helpers
In reply to Jason Ekstrand--- lib/i915/gem_context.c | 56 ++++++++++++++++++++++++++++++++++++++++++ lib/i915/gem_context.h | 3 +++ 2 files changed, 59 insertions(+)
lib/i915/gem_context.c +56 -0
@@ -107,6 +107,40 @@ int __gem_context_create(int fd, uint32_t *ctx_id)return err; } +/** +* __gem_context_create_ext: +* @fd: open i915 drm file descriptor +* @flags: context create flags +* @extensions: first extension struct, or 0 for no extensions +* @ctx_id: on success, the context ID is written here +* +* Creates a new GEM context with flags and extensions. If no flags or +* extensions are required, it's the same as __gem_context_create and works +* on older kernels. +*/ +int __gem_context_create_ext (int fd,uint32_t flags,uint64_t extensions, +uint32_t *ctx_id) +{ +struct drm_i915_gem_context_create_ext ctx_create; +int err =0 ; + +if (!flags && !extensions) +return __gem_context_create (fd, ctx_id); + +memset (&ctx_create,0 ,sizeof (ctx_create)); + ctx_create.flags = flags; +if (extensions) { + ctx_create.flags |=I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS ; + ctx_create.extensions = extensions; + } + + err =create_ext_ioctl (fd, &ctx_create); +if (!err) + *ctx_id = ctx_create.ctx_id; + +return err; +} +/** * gem_context_create: * @fd: open i915 drm file descriptor
@@ -127,6 +161,28 @@ uint32_t gem_context_create(int fd)return ctx_id; } +/** +* gem_context_create_ext: +* @fd: open i915 drm file descriptor +* @flags: context create flags +* @extensions: first extension struct, or 0 for no extensions +* +* Creates a new GEM context with flags and extensions. If no flags or +* extensions are required, it's the same as gem_context_create and works +* on older kernels. +* +* Returns: The id of the allocated context. +*/ +uint32_t gem_context_create_ext (int fd,uint32_t flags,uint64_t extensions) +{ +uint32_t ctx_id; + +igt_assert_eq (__gem_context_create_ext (fd, flags, extensions, &ctx_id),0 ); +igt_assert (ctx_id !=0 ); + +return ctx_id; +} +int __gem_context_destroy (int fd,uint32_t ctx_id) {struct drm_i915_gem_context_destroy destroy = { ctx_id };
lib/i915/gem_context.h +3 -0
@@ -30,7 +30,10 @@struct drm_i915_gem_context_param ;uint32_t gem_context_create (int fd); +uint32_t gem_context_create_ext (int fd,uint32_t flags,uint64_t extensions);int __gem_context_create (int fd,uint32_t *ctx_id); +int __gem_context_create_ext (int fd,uint32_t flags,uint64_t extensions, +uint32_t *ctx_id);void gem_context_destroy (int fd,uint32_t ctx_id);int __gem_context_destroy (int fd,uint32_t ctx_id);
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 9/89 lib: Add an intel_ctx wrapper struct and helpers (v4)
In reply to Jason EkstrandWe're trying to clean up some of our technical debt in the i915 API. In particular, context mutability and unnecessary getparam(). There's quite a bit of the introspection stuff that's not used by any userspace other than IGT. Most drivers don't care about fetching the set of engines, for instance, because they don't forget about what set of engines they asked for int the first place.
Unfortunately, IGT relies heavily on context introspection for just about everything when it comes to multi-engine testing. It also likes to use ctx0 as temporary storage for whatever the current test config is. While effective at keeping IGC simple in some ways, this means we're making heavy use of context mutability. Also, passing data around with in tests isn't really what contexts are for.
This patch adds a new intel_ctx_t struct which wraps a context and remembers the full context configuration. This will provide similar ease-of-use without having use ctx0 as temporary storage.
v2 (Jason Ekstrand):
- Make all intel_ctx_t's const
v3 (Jason Ekstrand):
- Fix up the docs so they build properly
v4 (Jason Ekstrand):
- Add an intel_ctx_create_for_engine helper
--- .../igt-gpu-tools/igt-gpu-tools-docs.xml | 1 + lib/intel_ctx.c | 272 ++++++++++++++++++ lib/intel_ctx.h | 75 +++++ lib/meson.build | 1 + 4 files changed, 349 insertions(+) create mode 100644 lib/intel_ctx.c create mode 100644 lib/intel_ctx.h
docs/reference/igt-gpu-tools/igt-gpu-tools-docs.xml +1 -0
@@ -58,6 +58,7 @@ <xi:include href="xml/gem_engine_topology.xml"/> <xi:include href="xml/gem_scheduler.xml"/> <xi:include href="xml/gem_submission.xml"/> + <xi:include href="xml/intel_ctx.xml"/> </chapter> <xi:include href="xml/igt_test_programs.xml"/>
lib/intel_ctx.c new file +272 -0
272 lines not on this page · raw message
lib/intel_ctx.h new file +75 -0
75 lines not on this page · raw message
lib/meson.build +1 -0
@@ -42,6 +42,7 @@ lib_sources = [ 'intel_batchbuffer.c', 'intel_bufops.c', 'intel_chipset.c', + 'intel_ctx.c', 'intel_device_info.c', 'intel_os.c', 'intel_mmio.c',
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 09/89] lib: Add an intel_ctx wrapper struct and helpers (v4)
Quoted 67 lines · Jason Ekstrand
We're trying to clean up some of our technical debt in the i915 API. In particular, context mutability and unnecessary
getparam(). There's quite a bit of the introspection stuff that's not used by any userspace other than IGT. Most drivers don't care about fetching the set of engines, for instance, because they don't forget about what set of engines they asked for int the first place.Unfortunately, IGT relies heavily on context introspection for just about everything when it comes to multi-engine testing. It also likes to use ctx0 as temporary storage for whatever the current test config is. While effective at keeping IGC simple in some ways, this means we're making heavy use of context mutability. Also, passing data around with in tests isn't really what contexts are for.
This patch adds a new
intel_ctx_tstruct which wraps a context and remembers the full context configuration. This will provide similar ease-of-use without having use ctx0 as temporary storage.v2 (Jason Ekstrand):
- Make all intel_ctx_t's constv3 (Jason Ekstrand):
- Fix up the docs so they build properlyv4 (Jason Ekstrand):
- Add anintel_ctx_create_for_enginehelperSigned-off-by Jason Ekstrand <[email protected]>--- .../igt-gpu-tools/igt-gpu-tools-docs.xml | 1 + lib/intel_ctx.c | 272 ++++++++++++++++++ lib/intel_ctx.h | 75 +++++ lib/meson.build | 1 + 4 files changed, 349 insertions(+) create mode 100644 lib/intel_ctx.c create mode 100644 lib/intel_ctx.hdocs/reference/igt-gpu-tools/igt-gpu-tools-docs.xml +1
-0@@ -58,6 +58,7 @@ <xi:include href="xml/gem_engine_topology.xml"/> <xi:include href="xml/gem_scheduler.xml"/> <xi:include href="xml/gem_submission.xml"/> + <xi:include href="xml/intel_ctx.xml"/> </chapter> <xi:include href="xml/igt_test_programs.xml"/>lib/intel_ctx.c new file +12
-0@@ -0,0 +1,272 @@ +/* +* Copyright © 2021 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the
lib/intel_ctx.c line 22
Quoted 10 lines
lib/intel_ctx.c new file +10
-0+* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/
We likely should use SPDX here.
Quoted 44 lines
lib/intel_ctx.c new file +44
-0+ +#include <stddef.h> + +#include "intel_ctx.h" +#include "ioctl_wrappers.h" +#include "i915/gem_engine_topology.h" + +/** +* SECTION:intel_ctx +* @short_description: Wrapper structs for dealing with contexts +* @title: Intel Context Wrapper +* +* This helper library contains a couple of wrapper structs for easier +* dealing with GEM contexts. This includes a context configuration struct +* which represents important context construction parameters and a context +* struct which contains the context ID and its configuration. This makes +* it easier to pass around a context without loosing the context create +* information. +*/ + +static void +add_user_ext (uint64_t *root_ext_u64,struct i915_user_extension *ext) +{ + ext->next_extension = *root_ext_u64; + *root_ext_u64 =to_user_pointer (ext); +} + +static size_t sizeof_param_engines (int count) +{ + return offsetof(struct i915_context_param_engines, engines[count]); +} + +#define SIZEOF_QUERY offsetof(struct drm_i915_query_engine_info, \ + engines[GEM_MAX_ENGINES]) + +/** +* intel_ctx_cfg_all_physical: +* @fd: open i915 drm file descriptor +* +* Returns an intel_ctx_cfg_t containing all physical engines. On kernels +* without the engines API, a default context configuration will be +* returned. +*/ +intel_ctx_cfg_t intel_ctx_cfg_all_physical (int fd)
lib/intel_ctx.c line 76
Quoted 10 lines
lib/intel_ctx.c new file +10
-0+{ +uint8_t buff[SIZEOF_QUERY ] = { }; +struct drm_i915_query_engine_info *qei = (void *) buff; +intel_ctx_cfg_t cfg = {}; +int i; + +if (__gem_query_engines (fd, qei,SIZEOF_QUERY ) ==0 ) { + cfg.num_engines = qei->num_engines; +for (i =0 ; i < qei->num_engines; i++) + cfg.engines[i] = qei->engines[i].engine;
So we loose flags and capabilities here. I've walked through the code and caps are related to HEVC decoding and SFC. I don't think we will have some embedded test h265 stream soon in IGT so this is likely not a problem. Some doubts comes with SFC because we already have copyfunc which is using VEBOX engine. I'm not sure how much effort do we need to scale / convert using SFC in this pipeline and do we really need to test this in IGT. If you think we need only engine class/instance I got no objections here.
Quoted 68 lines
lib/intel_ctx.c new file +68
-0+ } + +return cfg; +} + +/** +* intel_ctx_cfg_for_engine: +* @class: engine class +* @inst: engine instance +* +* Returns an intel_ctx_cfg_t containing exactly one engine. +*/ +intel_ctx_cfg_t intel_ctx_cfg_for_engine (unsigned int class,unsigned int inst) +{ +return (intel_ctx_cfg_t ) { + .num_engines =1 , + .engines = { + { .engine_class = class, .engine_instance = inst }, + }, + }; +} + +static int +__context_create_cfg (int fd,const intel_ctx_cfg_t *cfg,uint32_t *ctx_id) +{ +uint64_t ext_root =0 ; +I915_DEFINE_CONTEXT_PARAM_ENGINES (engines,GEM_MAX_ENGINES ); +struct drm_i915_gem_context_create_ext_setparam engines_param, vm_param; +uint32_t i; + +if (cfg->vm) { + vm_param = (struct drm_i915_gem_context_create_ext_setparam ) { + .base = { + .name =I915_CONTEXT_CREATE_EXT_SETPARAM , + }, + .param = { + .param =I915_CONTEXT_PARAM_VM , + .value = cfg->vm, + }, + }; +add_user_ext (&ext_root, &vm_param.base); + } + +if (cfg->num_engines) { +memset (&engines,0 ,sizeof (engines)); +for (i =0 ; i < cfg->num_engines; i++) + engines.engines[i] = cfg->engines[i]; + + engines_param = (struct drm_i915_gem_context_create_ext_setparam ) { + .base = { + .name =I915_CONTEXT_CREATE_EXT_SETPARAM , + }, + .param = { + .param =I915_CONTEXT_PARAM_ENGINES , + .size =sizeof_param_engines (cfg->num_engines), + .value =to_user_pointer (&engines), + }, + }; +add_user_ext (&ext_root, &engines_param.base); + } + +return __gem_context_create_ext (fd, cfg->flags, ext_root, ctx_id); +} + +/** +* __intel_ctx_create: +* @fd: open i915 drm file descriptor +* @cfg: configuration for the created context
lib/intel_ctx.c line 154
Quoted 10 lines
lib/intel_ctx.c new file +10
-0+* @out_ctx: on success, the new intel_ctx_t pointer is written here +* +* Like intel_ctx_create but returns an error instead of asserting. +*/ +int __intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg, +const intel_ctx_t **out_ctx) +{ +uint32_t ctx_id; +intel_ctx_t *ctx; +int err;
This is public and wouldn't assume cfg won't be NULL here. I would just add igt_assert() to avoid surprises.
Quoted 87 lines
lib/intel_ctx.c new file +87
-0+ +if (cfg) + err =__context_create_cfg (fd, cfg, &ctx_id); +else + err =__gem_context_create (fd, &ctx_id); +if (err) +return err; + + ctx =calloc (1 ,sizeof (*ctx)); +igt_assert (ctx); + + ctx->id = ctx_id; +if (cfg) + ctx->cfg = *cfg; + + *out_ctx = ctx; +return 0 ; +} + +/** +* intel_ctx_create: +* @fd: open i915 drm file descriptor +* @cfg: configuration for the created context +* +* Creates a new intel_ctx_t with the given config +*/ +const intel_ctx_t *intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg) +{ +const intel_ctx_t *ctx; +int err; + + err =__intel_ctx_create (fd, cfg, &ctx); +igt_assert_eq (err,0 ); + +return ctx; +} + +static const intel_ctx_t __intel_ctx_0 = {}; + +/** +* intel_ctx_0: +* @fd: open i915 drm file descriptor +* +* Returns an intel_ctx_t representing the default context. +*/ +const intel_ctx_t *intel_ctx_0 (int fd) +{ + (void )fd; +return &__intel_ctx_0; +} + +/** +* intel_ctx_create_for_engine: +* @fd: open i915 drm file descriptor +* @class: engine class +* @inst: engine instance +* +* Returns an intel_ctx_t containing the specified engine. +*/ +const intel_ctx_t * +intel_ctx_create_for_engine (int fd,unsigned int class,unsigned int inst) +{ +intel_ctx_cfg_t cfg =intel_ctx_cfg_for_engine (class, inst); +return intel_ctx_create (fd, &cfg); +} + +/** +* intel_ctx_create_all_physical: +* @fd: open i915 drm file descriptor +* +* Creates an intel_ctx_t containing all physical engines. On kernels +* without the engines API, the created context will be the same as +* intel_ctx_0() except that it will be a new GEM context. On kernels or +* hardware which do not support contexts, it is the same as intel_ctx_0(). +*/ +const intel_ctx_t *intel_ctx_create_all_physical (int fd) +{ +intel_ctx_cfg_t cfg; + +if (!gem_has_contexts (fd)) +return intel_ctx_0 (fd); + + cfg =intel_ctx_cfg_all_physical (fd); +return intel_ctx_create (fd, &cfg); +} + +/**
lib/intel_ctx.c line 251
Quoted 10 lines
lib/intel_ctx.c new file +10
-0+* intel_ctx_destroy: +* @fd: open i915 drm file descriptor +* @ctx: context to destroy, or NULL +* +* Destroys an intel_ctx_t. +*/ +void intel_ctx_destroy (int fd,const intel_ctx_t *ctx) +{ +if (!ctx || ctx->id ==0 ) +return ;
Shouldn't we assert here instead of silence quit on !ctx?
Quoted 39 lines
lib/intel_ctx.c new file +21
-0+ +gem_context_destroy (fd, ctx->id); +free ((void *)ctx); +} + +/** +* intel_ctx_engine_class: +* @ctx: an intel_ctx_t +* @engine: an engine specifier +* +* Returns the class for the given engine. +*/ +unsigned int intel_ctx_engine_class (const intel_ctx_t *ctx,unsigned int engine) +{ +if (ctx->cfg.num_engines) { +igt_assert (engine < ctx->cfg.num_engines); +return ctx->cfg.engines[engine].engine_class; + }else { +return gem_execbuf_flags_to_engine_class (engine); + } +}lib/intel_ctx.h new file +12
-0@@ -0,0 +1,75 @@ +/* +* Copyright © 2021 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the
lib/intel_ctx.h line 22
Quoted 10 lines
lib/intel_ctx.h new file +10
-0+* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/
Use SPDX.
--
Zbigniew
Quoted 72 lines
lib/intel_ctx.h new file +53
-0+ +#ifndef INTEL_CTX_H +#define INTEL_CTX_H + +#include "igt_core.h" + +#include "i915_drm.h" + +#define GEM_MAX_ENGINES I915_EXEC_RING_MASK + 1 + +/** +* intel_ctx_cfg_t: +* @flags: Context create flags +* @vm: VM to inherit or 0 for using a per-context VM +* @num_engines: Number of client-specified engines or 0 for legacy mode +* @engines: Client-specified engines +* +* Represents the full configuration of an intel_ctx. +*/ +typedef struct intel_ctx_cfg { +uint32_t flags; +uint32_t vm; +unsigned int num_engines; +struct i915_engine_class_instance engines[GEM_MAX_ENGINES ]; +}intel_ctx_cfg_t ; + +intel_ctx_cfg_t intel_ctx_cfg_for_engine (unsigned int class,unsigned int inst); +intel_ctx_cfg_t intel_ctx_cfg_all_physical (int fd); + +/** +* intel_ctx_t: +* @id: the context id/handle +* @cfg: the config used to create this context +* +* Represents the full configuration of an intel_ctx. +*/ +typedef struct intel_ctx { +uint32_t id; +intel_ctx_cfg_t cfg; +}intel_ctx_t ; + +int __intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg, +const intel_ctx_t **out_ctx); +const intel_ctx_t *intel_ctx_create (int i915,const intel_ctx_cfg_t *cfg); +const intel_ctx_t *intel_ctx_0 (int fd); +const intel_ctx_t *intel_ctx_create_for_engine (int fd,unsigned int class, +unsigned int inst); +const intel_ctx_t *intel_ctx_create_all_physical (int fd); +void intel_ctx_destroy (int fd,const intel_ctx_t *ctx); + +unsigned int intel_ctx_engine_class (const intel_ctx_t *ctx,unsigned int engine); + +#endif lib/meson.build +1
-0@@ -42,6 +42,7 @@ lib_sources = [ 'intel_batchbuffer.c', 'intel_bufops.c', 'intel_chipset.c', + 'intel_ctx.c', 'intel_device_info.c', 'intel_os.c', 'intel_mmio.c',Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 09/89] lib: Add an intel_ctx wrapper struct and helpers (v4)
Quoted 219 lines · Zbigniew Kempczyński
Quoted 67 lines · Jason Ekstrand
We're trying to clean up some of our technical debt in the i915 API. In particular, context mutability and unnecessary
getparam(). There's quite a bit of the introspection stuff that's not used by any userspace other than IGT. Most drivers don't care about fetching the set of engines, for instance, because they don't forget about what set of engines they asked for int the first place.Unfortunately, IGT relies heavily on context introspection for just about everything when it comes to multi-engine testing. It also likes to use ctx0 as temporary storage for whatever the current test config is. While effective at keeping IGC simple in some ways, this means we're making heavy use of context mutability. Also, passing data around with in tests isn't really what contexts are for.
This patch adds a new
intel_ctx_tstruct which wraps a context and remembers the full context configuration. This will provide similar ease-of-use without having use ctx0 as temporary storage.v2 (Jason Ekstrand):
- Make all intel_ctx_t's constv3 (Jason Ekstrand):
- Fix up the docs so they build properlyv4 (Jason Ekstrand):
- Add anintel_ctx_create_for_enginehelperSigned-off-by Jason Ekstrand <[email protected]>--- .../igt-gpu-tools/igt-gpu-tools-docs.xml | 1 + lib/intel_ctx.c | 272 ++++++++++++++++++ lib/intel_ctx.h | 75 +++++ lib/meson.build | 1 + 4 files changed, 349 insertions(+) create mode 100644 lib/intel_ctx.c create mode 100644 lib/intel_ctx.hdocs/reference/igt-gpu-tools/igt-gpu-tools-docs.xml +1
-0@@ -58,6 +58,7 @@ <xi:include href="xml/gem_engine_topology.xml"/> <xi:include href="xml/gem_scheduler.xml"/> <xi:include href="xml/gem_submission.xml"/> + <xi:include href="xml/intel_ctx.xml"/> </chapter> <xi:include href="xml/igt_test_programs.xml"/>lib/intel_ctx.c new file +12
-0@@ -0,0 +1,272 @@ +/* +* Copyright © 2021 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the lib/intel_ctx.c line 22
Quoted 10 lines
lib/intel_ctx.c new file +10
-0+* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ We likely should use SPDX here.
Quoted 44 lines
lib/intel_ctx.c new file +44
-0+ +#include <stddef.h> + +#include "intel_ctx.h" +#include "ioctl_wrappers.h" +#include "i915/gem_engine_topology.h" + +/** +* SECTION:intel_ctx +* @short_description: Wrapper structs for dealing with contexts +* @title: Intel Context Wrapper +* +* This helper library contains a couple of wrapper structs for easier +* dealing with GEM contexts. This includes a context configuration struct +* which represents important context construction parameters and a context +* struct which contains the context ID and its configuration. This makes +* it easier to pass around a context without loosing the context create +* information. +*/ + +static void +add_user_ext (uint64_t *root_ext_u64,struct i915_user_extension *ext) +{ + ext->next_extension = *root_ext_u64; + *root_ext_u64 =to_user_pointer (ext); +} + +static size_t sizeof_param_engines (int count) +{ + return offsetof(struct i915_context_param_engines, engines[count]); +} + +#define SIZEOF_QUERY offsetof(struct drm_i915_query_engine_info, \ + engines[GEM_MAX_ENGINES]) + +/** +* intel_ctx_cfg_all_physical: +* @fd: open i915 drm file descriptor +* +* Returns an intel_ctx_cfg_t containing all physical engines. On kernels +* without the engines API, a default context configuration will be +* returned. +*/ +intel_ctx_cfg_t intel_ctx_cfg_all_physical (int fd)lib/intel_ctx.c line 76
Quoted 10 lines
lib/intel_ctx.c new file +10
-0+{ +uint8_t buff[SIZEOF_QUERY ] = { }; +struct drm_i915_query_engine_info *qei = (void *) buff; +intel_ctx_cfg_t cfg = {}; +int i; + +if (__gem_query_engines (fd, qei,SIZEOF_QUERY ) ==0 ) { + cfg.num_engines = qei->num_engines; +for (i =0 ; i < qei->num_engines; i++) + cfg.engines[i] = qei->engines[i].engine;So we loose flags and capabilities here. I've walked through the code and caps are related to HEVC decoding and SFC. I don't think we will have some embedded test h265 stream soon in IGT so this is likely not a problem. Some doubts comes with SFC because we already have copyfunc which is using VEBOX engine. I'm not sure how much effort do we need to scale / convert using SFC in this pipeline and do we really need to test this in IGT. If you think we need only engine class/instance I got no objections here.
Quoted 73 lines
lib/intel_ctx.c new file +73
-0+ } + +return cfg; +} + +/** +* intel_ctx_cfg_for_engine: +* @class: engine class +* @inst: engine instance +* +* Returns an intel_ctx_cfg_t containing exactly one engine. +*/ +intel_ctx_cfg_t intel_ctx_cfg_for_engine (unsigned int class,unsigned int inst) +{ +return (intel_ctx_cfg_t ) { + .num_engines =1 , + .engines = { + { .engine_class = class, .engine_instance = inst }, + }, + }; +} + +static int +__context_create_cfg (int fd,const intel_ctx_cfg_t *cfg,uint32_t *ctx_id) +{ +uint64_t ext_root =0 ; +I915_DEFINE_CONTEXT_PARAM_ENGINES (engines,GEM_MAX_ENGINES ); +struct drm_i915_gem_context_create_ext_setparam engines_param, vm_param; +uint32_t i; + +if (cfg->vm) { + vm_param = (struct drm_i915_gem_context_create_ext_setparam ) { + .base = { + .name =I915_CONTEXT_CREATE_EXT_SETPARAM , + }, + .param = { + .param =I915_CONTEXT_PARAM_VM , + .value = cfg->vm, + }, + }; +add_user_ext (&ext_root, &vm_param.base); + } + +if (cfg->num_engines) { +memset (&engines,0 ,sizeof (engines)); +for (i =0 ; i < cfg->num_engines; i++) + engines.engines[i] = cfg->engines[i]; + + engines_param = (struct drm_i915_gem_context_create_ext_setparam ) { + .base = { + .name =I915_CONTEXT_CREATE_EXT_SETPARAM , + }, + .param = { + .param =I915_CONTEXT_PARAM_ENGINES , + .size =sizeof_param_engines (cfg->num_engines), + .value =to_user_pointer (&engines), + }, + }; +add_user_ext (&ext_root, &engines_param.base); + } + +return __gem_context_create_ext (fd, cfg->flags, ext_root, ctx_id); +} + +/** +* __intel_ctx_create: +* @fd: open i915 drm file descriptor +* @cfg: configuration for the created context +* @out_ctx: on success, the new intel_ctx_t pointer is written here +* +* Like intel_ctx_create but returns an error instead of asserting. +*/ +int __intel_ctx_create(int fd, const intel_ctx_cfg_t *cfg,
Quoted 8 lines
lib/intel_ctx.c line 154
Quoted 5 lines
lib/intel_ctx.c new file +5
-0+ const intel_ctx_t **out_ctx) +{ +uint32_t ctx_id; +intel_ctx_t *ctx; +int err;This is public and wouldn't assume cfg won't be NULL here. I would just add
igt_assert()to avoid surprises.
Not sure what you mean. The intention is that intel_ctx_create(NULL) gives you a default context; the same as if you zero-initialized the config. There are a bunch of cases where this short-hand is really useful. Maybe I should document that.
Quoted 91 lines
Quoted 91 lines
lib/intel_ctx.c new file +91
-0+ +if (cfg) + err =__context_create_cfg (fd, cfg, &ctx_id); +else + err =__gem_context_create (fd, &ctx_id); +if (err) +return err; + + ctx =calloc (1 ,sizeof (*ctx)); +igt_assert (ctx); + + ctx->id = ctx_id; +if (cfg) + ctx->cfg = *cfg; + + *out_ctx = ctx; +return 0 ; +} + +/** +* intel_ctx_create: +* @fd: open i915 drm file descriptor +* @cfg: configuration for the created context +* +* Creates a new intel_ctx_t with the given config +*/ +const intel_ctx_t *intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg) +{ +const intel_ctx_t *ctx; +int err; + + err =__intel_ctx_create (fd, cfg, &ctx); +igt_assert_eq (err,0 ); + +return ctx; +} + +static const intel_ctx_t __intel_ctx_0 = {}; + +/** +* intel_ctx_0: +* @fd: open i915 drm file descriptor +* +* Returns an intel_ctx_t representing the default context. +*/ +const intel_ctx_t *intel_ctx_0 (int fd) +{ + (void )fd; +return &__intel_ctx_0; +} + +/** +* intel_ctx_create_for_engine: +* @fd: open i915 drm file descriptor +* @class: engine class +* @inst: engine instance +* +* Returns an intel_ctx_t containing the specified engine. +*/ +const intel_ctx_t * +intel_ctx_create_for_engine (int fd,unsigned int class,unsigned int inst) +{ +intel_ctx_cfg_t cfg =intel_ctx_cfg_for_engine (class, inst); +return intel_ctx_create (fd, &cfg); +} + +/** +* intel_ctx_create_all_physical: +* @fd: open i915 drm file descriptor +* +* Creates an intel_ctx_t containing all physical engines. On kernels +* without the engines API, the created context will be the same as +* intel_ctx_0() except that it will be a new GEM context. On kernels or +* hardware which do not support contexts, it is the same as intel_ctx_0(). +*/ +const intel_ctx_t *intel_ctx_create_all_physical (int fd) +{ +intel_ctx_cfg_t cfg; + +if (!gem_has_contexts (fd)) +return intel_ctx_0 (fd); + + cfg =intel_ctx_cfg_all_physical (fd); +return intel_ctx_create (fd, &cfg); +} + +/** +* intel_ctx_destroy: +* @fd: open i915 drm file descriptor +* @ctx: context to destroy, or NULL +*
Quoted 8 lines
lib/intel_ctx.c line 251
Quoted 6 lines
lib/intel_ctx.c new file +6
-0+* Destroys an intel_ctx_t. +*/ +void intel_ctx_destroy (int fd,const intel_ctx_t *ctx) +{ +if (!ctx || ctx->id ==0 ) +return ;Shouldn't we assert here instead of silence quit on !ctx?
We can. There are some cases where it's nice to have the free() semantics of noop-on-NULL but I could go either way. I can change it if you'd like; it'll mean changing a few tests, though.
--Jason
Quoted 123 lines
Quoted 39 lines
lib/intel_ctx.c new file +21
-0+ +gem_context_destroy (fd, ctx->id); +free ((void *)ctx); +} + +/** +* intel_ctx_engine_class: +* @ctx: an intel_ctx_t +* @engine: an engine specifier +* +* Returns the class for the given engine. +*/ +unsigned int intel_ctx_engine_class (const intel_ctx_t *ctx,unsigned int engine) +{ +if (ctx->cfg.num_engines) { +igt_assert (engine < ctx->cfg.num_engines); +return ctx->cfg.engines[engine].engine_class; + }else { +return gem_execbuf_flags_to_engine_class (engine); + } +}lib/intel_ctx.h new file +12
-0@@ -0,0 +1,75 @@ +/* +* Copyright © 2021 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the lib/intel_ctx.h line 22
Quoted 10 lines
lib/intel_ctx.h new file +10
-0+* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ Use SPDX.
--
ZbigniewQuoted 68 lines
lib/intel_ctx.h new file +53
-0+ +#ifndef INTEL_CTX_H +#define INTEL_CTX_H + +#include "igt_core.h" + +#include "i915_drm.h" + +#define GEM_MAX_ENGINES I915_EXEC_RING_MASK + 1 + +/** +* intel_ctx_cfg_t: +* @flags: Context create flags +* @vm: VM to inherit or 0 for using a per-context VM +* @num_engines: Number of client-specified engines or 0 for legacy mode +* @engines: Client-specified engines +* +* Represents the full configuration of an intel_ctx. +*/ +typedef struct intel_ctx_cfg { +uint32_t flags; +uint32_t vm; +unsigned int num_engines; +struct i915_engine_class_instance engines[GEM_MAX_ENGINES ]; +}intel_ctx_cfg_t ; + +intel_ctx_cfg_t intel_ctx_cfg_for_engine (unsigned int class,unsigned int inst); +intel_ctx_cfg_t intel_ctx_cfg_all_physical (int fd); + +/** +* intel_ctx_t: +* @id: the context id/handle +* @cfg: the config used to create this context +* +* Represents the full configuration of an intel_ctx. +*/ +typedef struct intel_ctx { +uint32_t id; +intel_ctx_cfg_t cfg; +}intel_ctx_t ; + +int __intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg, +const intel_ctx_t **out_ctx); +const intel_ctx_t *intel_ctx_create (int i915,const intel_ctx_cfg_t *cfg); +const intel_ctx_t *intel_ctx_0 (int fd); +const intel_ctx_t *intel_ctx_create_for_engine (int fd,unsigned int class, +unsigned int inst); +const intel_ctx_t *intel_ctx_create_all_physical (int fd); +void intel_ctx_destroy (int fd,const intel_ctx_t *ctx); + +unsigned int intel_ctx_engine_class (const intel_ctx_t *ctx,unsigned int engine); + +#endif lib/meson.build +1
-1@@ -42,6 +42,7 @@ lib_sources = [ 'intel_batchbuffer.c', 'intel_bufops.c', 'intel_chipset.c', + 'intel_ctx.c', 'intel_device_info.c', 'intel_os.c', 'intel_mmio.c', --2.31.1
Quoted 4 lines
Quoted 4 lines
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 09/89] lib: Add an intel_ctx wrapper struct and helpers (v4)
In reply to Jason EkstrandQuoted 249 lines · Jason Ekstrand
We're trying to clean up some of our technical debt in the i915 API. In particular, context mutability and unnecessary
getparam(). There's quite a bit of the introspection stuff that's not used by any userspace other than IGT. Most drivers don't care about fetching the set of engines, for instance, because they don't forget about what set of engines they asked for int the first place.Unfortunately, IGT relies heavily on context introspection for just about everything when it comes to multi-engine testing. It also likes to use ctx0 as temporary storage for whatever the current test config is. While effective at keeping IGC simple in some ways, this means we're making heavy use of context mutability. Also, passing data around with in tests isn't really what contexts are for.
This patch adds a new
intel_ctx_tstruct which wraps a context and remembers the full context configuration. This will provide similar ease-of-use without having use ctx0 as temporary storage.v2 (Jason Ekstrand):
- Make all intel_ctx_t's constv3 (Jason Ekstrand):
- Fix up the docs so they build properlyv4 (Jason Ekstrand):
- Add anintel_ctx_create_for_enginehelperSigned-off-by Jason Ekstrand <[email protected]>--- .../igt-gpu-tools/igt-gpu-tools-docs.xml | 1 + lib/intel_ctx.c | 272 ++++++++++++++++++ lib/intel_ctx.h | 75 +++++ lib/meson.build | 1 + 4 files changed, 349 insertions(+) create mode 100644 lib/intel_ctx.c create mode 100644 lib/intel_ctx.hdocs/reference/igt-gpu-tools/igt-gpu-tools-docs.xml +1
-0@@ -58,6 +58,7 @@ <xi:include href="xml/gem_engine_topology.xml"/> <xi:include href="xml/gem_scheduler.xml"/> <xi:include href="xml/gem_submission.xml"/> + <xi:include href="xml/intel_ctx.xml"/> </chapter> <xi:include href="xml/igt_test_programs.xml"/>lib/intel_ctx.c new file +194
-0@@ -0,0 +1,272 @@ +/* +* Copyright © 2021 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#include <stddef.h> + +#include "intel_ctx.h" +#include "ioctl_wrappers.h" +#include "i915/gem_engine_topology.h" + +/** +* SECTION:intel_ctx +* @short_description: Wrapper structs for dealing with contexts +* @title: Intel Context Wrapper +* +* This helper library contains a couple of wrapper structs for easier +* dealing with GEM contexts. This includes a context configuration struct +* which represents important context construction parameters and a context +* struct which contains the context ID and its configuration. This makes +* it easier to pass around a context without loosing the context create +* information. +*/ + +static void +add_user_ext (uint64_t *root_ext_u64,struct i915_user_extension *ext) +{ + ext->next_extension = *root_ext_u64; + *root_ext_u64 =to_user_pointer (ext); +} + +static size_t sizeof_param_engines (int count) +{ + return offsetof(struct i915_context_param_engines, engines[count]); +} + +#define SIZEOF_QUERY offsetof(struct drm_i915_query_engine_info, \ + engines[GEM_MAX_ENGINES]) + +/** +* intel_ctx_cfg_all_physical: +* @fd: open i915 drm file descriptor +* +* Returns an intel_ctx_cfg_t containing all physical engines. On kernels +* without the engines API, a default context configuration will be +* returned. +*/ +intel_ctx_cfg_t intel_ctx_cfg_all_physical (int fd) +{ +uint8_t buff[SIZEOF_QUERY ] = { }; +struct drm_i915_query_engine_info *qei = (void *) buff; +intel_ctx_cfg_t cfg = {}; +int i; + +if (__gem_query_engines (fd, qei,SIZEOF_QUERY ) ==0 ) { + cfg.num_engines = qei->num_engines; +for (i =0 ; i < qei->num_engines; i++) + cfg.engines[i] = qei->engines[i].engine; + } + +return cfg; +} + +/** +* intel_ctx_cfg_for_engine: +* @class: engine class +* @inst: engine instance +* +* Returns an intel_ctx_cfg_t containing exactly one engine. +*/ +intel_ctx_cfg_t intel_ctx_cfg_for_engine (unsigned int class,unsigned int inst) +{ +return (intel_ctx_cfg_t ) { + .num_engines =1 , + .engines = { + { .engine_class = class, .engine_instance = inst }, + }, + }; +} + +static int +__context_create_cfg (int fd,const intel_ctx_cfg_t *cfg,uint32_t *ctx_id) +{ +uint64_t ext_root =0 ; +I915_DEFINE_CONTEXT_PARAM_ENGINES (engines,GEM_MAX_ENGINES ); +struct drm_i915_gem_context_create_ext_setparam engines_param, vm_param; +uint32_t i; + +if (cfg->vm) { + vm_param = (struct drm_i915_gem_context_create_ext_setparam ) { + .base = { + .name =I915_CONTEXT_CREATE_EXT_SETPARAM , + }, + .param = { + .param =I915_CONTEXT_PARAM_VM , + .value = cfg->vm, + }, + }; +add_user_ext (&ext_root, &vm_param.base); + } + +if (cfg->num_engines) { +memset (&engines,0 ,sizeof (engines)); +for (i =0 ; i < cfg->num_engines; i++) + engines.engines[i] = cfg->engines[i]; + + engines_param = (struct drm_i915_gem_context_create_ext_setparam ) { + .base = { + .name =I915_CONTEXT_CREATE_EXT_SETPARAM , + }, + .param = { + .param =I915_CONTEXT_PARAM_ENGINES , + .size =sizeof_param_engines (cfg->num_engines), + .value =to_user_pointer (&engines), + }, + }; +add_user_ext (&ext_root, &engines_param.base); + } + +return __gem_context_create_ext (fd, cfg->flags, ext_root, ctx_id); +} + +/** +* __intel_ctx_create: +* @fd: open i915 drm file descriptor +* @cfg: configuration for the created context +* @out_ctx: on success, the new intel_ctx_t pointer is written here +* +* Like intel_ctx_create but returns an error instead of asserting. +*/ +int __intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg, +const intel_ctx_t **out_ctx) +{ +uint32_t ctx_id; +intel_ctx_t *ctx; +int err; + +if (cfg) + err =__context_create_cfg (fd, cfg, &ctx_id); +else + err =__gem_context_create (fd, &ctx_id); +if (err) +return err; + + ctx =calloc (1 ,sizeof (*ctx)); +igt_assert (ctx); + + ctx->id = ctx_id; +if (cfg) + ctx->cfg = *cfg; + + *out_ctx = ctx; +return 0 ; +} + +/** +* intel_ctx_create: +* @fd: open i915 drm file descriptor +* @cfg: configuration for the created context +* +* Creates a new intel_ctx_t with the given config +*/ +const intel_ctx_t *intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg) +{ +const intel_ctx_t *ctx; +int err; + + err =__intel_ctx_create (fd, cfg, &ctx); +igt_assert_eq (err,0 ); + +return ctx; +} + +static const intel_ctx_t __intel_ctx_0 = {}; + +/**
lib/intel_ctx.c line 204
Quoted 10 lines
lib/intel_ctx.c new file +10
-0+* intel_ctx_0: +* @fd: open i915 drm file descriptor +* +* Returns an intel_ctx_t representing the default context. +*/ +const intel_ctx_t *intel_ctx_0 (int fd) +{ + (void )fd; +return &__intel_ctx_0; +}
What would you say about:
const intel_ctx_t *intel_ctx_0(int fd)
{
intel_ctx_t *ctx;
if (!gem_has_contexts(fd))
return &__intel_ctx_0;
ctx = calloc(1, sizeof(*ctx));
igt_assert(ctx);
ctx->cfg = intel_ctx_cfg_all_physical(fd);
return ctx;
}and
void intel_ctx_destroy(int fd, const intel_ctx_t *ctx)
{
igt_assert(ctx);
if (ctx->id)
gem_context_destroy(fd, ctx->id);
if (ctx != &__intel_ctx_0)
free((void *)ctx);
}We could avoid a lot of changes in tests which currently use default context, for example in gem_exec_nop.c instead:
ctx = intel_ctx_create_all_physical(device);
just
ctx = intel_ctx_0(device);
in opening igt_fixture. We still would have engines field filled from engine query if kernel supports it.
This way we can avoid unnecessary changes (like in nop_on_ring()) passing context and using it within execbuf. Especially intel_ctx you've proposed enforces using ctx->id in all execbufs making them a little bit prone to bug if someone would just forget setting rsvd1 field.
--
Zbigniew
Quoted 168 lines
lib/intel_ctx.c new file +68
-0+ +/** +* intel_ctx_create_for_engine: +* @fd: open i915 drm file descriptor +* @class: engine class +* @inst: engine instance +* +* Returns an intel_ctx_t containing the specified engine. +*/ +const intel_ctx_t * +intel_ctx_create_for_engine (int fd,unsigned int class,unsigned int inst) +{ +intel_ctx_cfg_t cfg =intel_ctx_cfg_for_engine (class, inst); +return intel_ctx_create (fd, &cfg); +} + +/** +* intel_ctx_create_all_physical: +* @fd: open i915 drm file descriptor +* +* Creates an intel_ctx_t containing all physical engines. On kernels +* without the engines API, the created context will be the same as +* intel_ctx_0() except that it will be a new GEM context. On kernels or +* hardware which do not support contexts, it is the same as intel_ctx_0(). +*/ +const intel_ctx_t *intel_ctx_create_all_physical (int fd) +{ +intel_ctx_cfg_t cfg; + +if (!gem_has_contexts (fd)) +return intel_ctx_0 (fd); + + cfg =intel_ctx_cfg_all_physical (fd); +return intel_ctx_create (fd, &cfg); +} + +/** +* intel_ctx_destroy: +* @fd: open i915 drm file descriptor +* @ctx: context to destroy, or NULL +* +* Destroys an intel_ctx_t. +*/ +void intel_ctx_destroy (int fd,const intel_ctx_t *ctx) +{ +if (!ctx || ctx->id ==0 ) +return ; + +gem_context_destroy (fd, ctx->id); +free ((void *)ctx); +} + +/** +* intel_ctx_engine_class: +* @ctx: an intel_ctx_t +* @engine: an engine specifier +* +* Returns the class for the given engine. +*/ +unsigned int intel_ctx_engine_class (const intel_ctx_t *ctx,unsigned int engine) +{ +if (ctx->cfg.num_engines) { +igt_assert (engine < ctx->cfg.num_engines); +return ctx->cfg.engines[engine].engine_class; + }else { +return gem_execbuf_flags_to_engine_class (engine); + } +}lib/intel_ctx.h new file +75
-0@@ -0,0 +1,75 @@ +/* +* Copyright © 2021 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#ifndef INTEL_CTX_H +#define INTEL_CTX_H + +#include "igt_core.h" + +#include "i915_drm.h" + +#define GEM_MAX_ENGINES I915_EXEC_RING_MASK + 1 + +/** +* intel_ctx_cfg_t: +* @flags: Context create flags +* @vm: VM to inherit or 0 for using a per-context VM +* @num_engines: Number of client-specified engines or 0 for legacy mode +* @engines: Client-specified engines +* +* Represents the full configuration of an intel_ctx. +*/ +typedef struct intel_ctx_cfg { +uint32_t flags; +uint32_t vm; +unsigned int num_engines; +struct i915_engine_class_instance engines[GEM_MAX_ENGINES ]; +}intel_ctx_cfg_t ; + +intel_ctx_cfg_t intel_ctx_cfg_for_engine (unsigned int class,unsigned int inst); +intel_ctx_cfg_t intel_ctx_cfg_all_physical (int fd); + +/** +* intel_ctx_t: +* @id: the context id/handle +* @cfg: the config used to create this context +* +* Represents the full configuration of an intel_ctx. +*/ +typedef struct intel_ctx { +uint32_t id; +intel_ctx_cfg_t cfg; +}intel_ctx_t ; + +int __intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg, +const intel_ctx_t **out_ctx); +const intel_ctx_t *intel_ctx_create (int i915,const intel_ctx_cfg_t *cfg); +const intel_ctx_t *intel_ctx_0 (int fd); +const intel_ctx_t *intel_ctx_create_for_engine (int fd,unsigned int class, +unsigned int inst); +const intel_ctx_t *intel_ctx_create_all_physical (int fd); +void intel_ctx_destroy (int fd,const intel_ctx_t *ctx); + +unsigned int intel_ctx_engine_class (const intel_ctx_t *ctx,unsigned int engine); + +#endif lib/meson.build +1
-0@@ -42,6 +42,7 @@ lib_sources = [ 'intel_batchbuffer.c', 'intel_bufops.c', 'intel_chipset.c', + 'intel_ctx.c', 'intel_device_info.c', 'intel_os.c', 'intel_mmio.c',Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 09/89] lib: Add an intel_ctx wrapper struct and helpers (v4)
Quoted 265 lines · Zbigniew Kempczyński
Quoted 249 lines · Jason Ekstrand
We're trying to clean up some of our technical debt in the i915 API. In particular, context mutability and unnecessary
getparam(). There's quite a bit of the introspection stuff that's not used by any userspace other than IGT. Most drivers don't care about fetching the set of engines, for instance, because they don't forget about what set of engines they asked for int the first place.Unfortunately, IGT relies heavily on context introspection for just about everything when it comes to multi-engine testing. It also likes to use ctx0 as temporary storage for whatever the current test config is. While effective at keeping IGC simple in some ways, this means we're making heavy use of context mutability. Also, passing data around with in tests isn't really what contexts are for.
This patch adds a new
intel_ctx_tstruct which wraps a context and remembers the full context configuration. This will provide similar ease-of-use without having use ctx0 as temporary storage.v2 (Jason Ekstrand):
- Make all intel_ctx_t's constv3 (Jason Ekstrand):
- Fix up the docs so they build properlyv4 (Jason Ekstrand):
- Add anintel_ctx_create_for_enginehelperSigned-off-by Jason Ekstrand <[email protected]>--- .../igt-gpu-tools/igt-gpu-tools-docs.xml | 1 + lib/intel_ctx.c | 272 ++++++++++++++++++ lib/intel_ctx.h | 75 +++++ lib/meson.build | 1 + 4 files changed, 349 insertions(+) create mode 100644 lib/intel_ctx.c create mode 100644 lib/intel_ctx.hdocs/reference/igt-gpu-tools/igt-gpu-tools-docs.xml +1
-0@@ -58,6 +58,7 @@ <xi:include href="xml/gem_engine_topology.xml"/> <xi:include href="xml/gem_scheduler.xml"/> <xi:include href="xml/gem_submission.xml"/> + <xi:include href="xml/intel_ctx.xml"/> </chapter> <xi:include href="xml/igt_test_programs.xml"/>lib/intel_ctx.c new file +194
-0@@ -0,0 +1,272 @@ +/* +* Copyright © 2021 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#include <stddef.h> + +#include "intel_ctx.h" +#include "ioctl_wrappers.h" +#include "i915/gem_engine_topology.h" + +/** +* SECTION:intel_ctx +* @short_description: Wrapper structs for dealing with contexts +* @title: Intel Context Wrapper +* +* This helper library contains a couple of wrapper structs for easier +* dealing with GEM contexts. This includes a context configuration struct +* which represents important context construction parameters and a context +* struct which contains the context ID and its configuration. This makes +* it easier to pass around a context without loosing the context create +* information. +*/ + +static void +add_user_ext (uint64_t *root_ext_u64,struct i915_user_extension *ext) +{ + ext->next_extension = *root_ext_u64; + *root_ext_u64 =to_user_pointer (ext); +} + +static size_t sizeof_param_engines (int count) +{ + return offsetof(struct i915_context_param_engines, engines[count]); +} + +#define SIZEOF_QUERY offsetof(struct drm_i915_query_engine_info, \ + engines[GEM_MAX_ENGINES]) + +/** +* intel_ctx_cfg_all_physical: +* @fd: open i915 drm file descriptor +* +* Returns an intel_ctx_cfg_t containing all physical engines. On kernels +* without the engines API, a default context configuration will be +* returned. +*/ +intel_ctx_cfg_t intel_ctx_cfg_all_physical (int fd) +{ +uint8_t buff[SIZEOF_QUERY ] = { }; +struct drm_i915_query_engine_info *qei = (void *) buff; +intel_ctx_cfg_t cfg = {}; +int i; + +if (__gem_query_engines (fd, qei,SIZEOF_QUERY ) ==0 ) { + cfg.num_engines = qei->num_engines; +for (i =0 ; i < qei->num_engines; i++) + cfg.engines[i] = qei->engines[i].engine; + } + +return cfg; +} + +/** +* intel_ctx_cfg_for_engine: +* @class: engine class +* @inst: engine instance +* +* Returns an intel_ctx_cfg_t containing exactly one engine. +*/ +intel_ctx_cfg_t intel_ctx_cfg_for_engine (unsigned int class,unsigned int inst) +{ +return (intel_ctx_cfg_t ) { + .num_engines =1 , + .engines = { + { .engine_class = class, .engine_instance = inst }, + }, + }; +} + +static int +__context_create_cfg (int fd,const intel_ctx_cfg_t *cfg,uint32_t *ctx_id) +{ +uint64_t ext_root =0 ; +I915_DEFINE_CONTEXT_PARAM_ENGINES (engines,GEM_MAX_ENGINES ); +struct drm_i915_gem_context_create_ext_setparam engines_param, vm_param; +uint32_t i; + +if (cfg->vm) { + vm_param = (struct drm_i915_gem_context_create_ext_setparam ) { + .base = { + .name =I915_CONTEXT_CREATE_EXT_SETPARAM , + }, + .param = { + .param =I915_CONTEXT_PARAM_VM , + .value = cfg->vm, + }, + }; +add_user_ext (&ext_root, &vm_param.base); + } + +if (cfg->num_engines) { +memset (&engines,0 ,sizeof (engines)); +for (i =0 ; i < cfg->num_engines; i++) + engines.engines[i] = cfg->engines[i]; + + engines_param = (struct drm_i915_gem_context_create_ext_setparam ) { + .base = { + .name =I915_CONTEXT_CREATE_EXT_SETPARAM , + }, + .param = { + .param =I915_CONTEXT_PARAM_ENGINES , + .size =sizeof_param_engines (cfg->num_engines), + .value =to_user_pointer (&engines), + }, + }; +add_user_ext (&ext_root, &engines_param.base); + } + +return __gem_context_create_ext (fd, cfg->flags, ext_root, ctx_id); +} + +/** +* __intel_ctx_create: +* @fd: open i915 drm file descriptor +* @cfg: configuration for the created context +* @out_ctx: on success, the new intel_ctx_t pointer is written here +* +* Like intel_ctx_create but returns an error instead of asserting. +*/ +int __intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg, +const intel_ctx_t **out_ctx) +{ +uint32_t ctx_id; +intel_ctx_t *ctx; +int err; + +if (cfg) + err =__context_create_cfg (fd, cfg, &ctx_id); +else + err =__gem_context_create (fd, &ctx_id); +if (err) +return err; + + ctx =calloc (1 ,sizeof (*ctx)); +igt_assert (ctx); + + ctx->id = ctx_id; +if (cfg) + ctx->cfg = *cfg; + + *out_ctx = ctx; +return 0 ; +} + +/** +* intel_ctx_create: +* @fd: open i915 drm file descriptor +* @cfg: configuration for the created context +* +* Creates a new intel_ctx_t with the given config +*/ +const intel_ctx_t *intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg) +{ +const intel_ctx_t *ctx; +int err; + + err =__intel_ctx_create (fd, cfg, &ctx); +igt_assert_eq (err,0 ); + +return ctx; +} + +static const intel_ctx_t __intel_ctx_0 = {}; + +/** lib/intel_ctx.c line 204
Quoted 10 lines
lib/intel_ctx.c new file +10
-0+* intel_ctx_0: +* @fd: open i915 drm file descriptor +* +* Returns an intel_ctx_t representing the default context. +*/ +const intel_ctx_t *intel_ctx_0 (int fd) +{ + (void )fd; +return &__intel_ctx_0; +}What would you say about:
const
intel_ctx_t*intel_ctx_0(int fd)
Quoted 10 lines
{
intel_ctx_t *ctx;
if (!gem_has_contexts(fd))
return &__intel_ctx_0;
ctx = calloc(1, sizeof(*ctx));
igt_assert(ctx);
ctx->cfg = intel_ctx_cfg_all_physical(fd);The problem is that this isn't actually the right config for ctx0. :-(
More on that in a bit.
Quoted 19 lines
return ctx; }and
void
intel_ctx_destroy(int fd, const intel_ctx_t *ctx){ igt_assert(ctx); if (ctx->id) gem_context_destroy(fd, ctx->id); if (ctx != &__intel_ctx_0) free((void *)ctx); }We could avoid a lot of changes in tests which currently use default context, for example in
gem_exec_nop.cinstead:
Quoted 7 lines
ctx = intel_ctx_create_all_physical(device);just
ctx = intel_ctx_0(device);in opening
igt_fixture. We still would have engines field filled from engine query if kernel supports it.
Unfortunately, as I alluded to above, this doesn't actually work. This is where the current test iterators are dangerously subtle and it took me a while to figure out what they were doing. By default, a context doesn't have the all_physical engine set. The all_physical engine set is achieved by querying the kernel for the set of engines and setting up a userspace-managed engine set on the context via CONTEXT_PARAM_ENGINES. By default, however, contexts have the default set of engines and use the legacy ring flag API.
How does this work in all those tests, then? Am I making serious functional changes and iterating over engines differently? No, I'm avoiding serious functional changes. Those tests work by first swapping out the engine set on ctx0 via SET_CONTEXT_PARAM with CONTEXT_PARAM_ENGINES and then iterating over that engine set. So, yes, they technically use ctx0 but it's a whole new context by the time you get to the first execbuf.
Quoted 5 lines
This way we can avoid unnecessary changes (like in
nop_on_ring()) passing context and using it within execbuf. Especiallyintel_ctxyou've proposed enforces usingctx->idin all execbufs making them a little bit prone to bug if someone would just forget setting rsvd1 field.
Yeah, I know all those changes are annoying. I typed them! But one of the things I tried very hard to do is to ensure that every time we have an intel_execution_engine2* or a flags parameter that was really an engine specifier, it's accompanied by the intel_ctx_t* or the intel_ctx_cfg_t* it's relative to. No intel_execution_engine2* or flags parameter is useful by itself, it's always relative to the configuration of the context because the meaning of those flags changes based on the configured engine set.
I hope that makes the over-all change make more sense.
--Jason
Quoted 168 lines
--
ZbigniewQuoted 164 lines
lib/intel_ctx.c new file +68
-0+ +/** +* intel_ctx_create_for_engine: +* @fd: open i915 drm file descriptor +* @class: engine class +* @inst: engine instance +* +* Returns an intel_ctx_t containing the specified engine. +*/ +const intel_ctx_t * +intel_ctx_create_for_engine (int fd,unsigned int class,unsigned int inst) +{ +intel_ctx_cfg_t cfg =intel_ctx_cfg_for_engine (class, inst); +return intel_ctx_create (fd, &cfg); +} + +/** +* intel_ctx_create_all_physical: +* @fd: open i915 drm file descriptor +* +* Creates an intel_ctx_t containing all physical engines. On kernels +* without the engines API, the created context will be the same as +* intel_ctx_0() except that it will be a new GEM context. On kernels or +* hardware which do not support contexts, it is the same as intel_ctx_0(). +*/ +const intel_ctx_t *intel_ctx_create_all_physical (int fd) +{ +intel_ctx_cfg_t cfg; + +if (!gem_has_contexts (fd)) +return intel_ctx_0 (fd); + + cfg =intel_ctx_cfg_all_physical (fd); +return intel_ctx_create (fd, &cfg); +} + +/** +* intel_ctx_destroy: +* @fd: open i915 drm file descriptor +* @ctx: context to destroy, or NULL +* +* Destroys an intel_ctx_t. +*/ +void intel_ctx_destroy (int fd,const intel_ctx_t *ctx) +{ +if (!ctx || ctx->id ==0 ) +return ; + +gem_context_destroy (fd, ctx->id); +free ((void *)ctx); +} + +/** +* intel_ctx_engine_class: +* @ctx: an intel_ctx_t +* @engine: an engine specifier +* +* Returns the class for the given engine. +*/ +unsigned int intel_ctx_engine_class (const intel_ctx_t *ctx,unsigned int engine) +{ +if (ctx->cfg.num_engines) { +igt_assert (engine < ctx->cfg.num_engines); +return ctx->cfg.engines[engine].engine_class; + }else { +return gem_execbuf_flags_to_engine_class (engine); + } +}lib/intel_ctx.h new file +75
-0@@ -0,0 +1,75 @@ +/* +* Copyright © 2021 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#ifndef INTEL_CTX_H +#define INTEL_CTX_H + +#include "igt_core.h" + +#include "i915_drm.h" + +#define GEM_MAX_ENGINES I915_EXEC_RING_MASK + 1 + +/** +* intel_ctx_cfg_t: +* @flags: Context create flags +* @vm: VM to inherit or 0 for using a per-context VM +* @num_engines: Number of client-specified engines or 0 for legacy mode +* @engines: Client-specified engines +* +* Represents the full configuration of an intel_ctx. +*/ +typedef struct intel_ctx_cfg { +uint32_t flags; +uint32_t vm; +unsigned int num_engines; +struct i915_engine_class_instance engines[GEM_MAX_ENGINES ]; +}intel_ctx_cfg_t ; + +intel_ctx_cfg_t intel_ctx_cfg_for_engine (unsigned int class,unsigned int inst); +intel_ctx_cfg_t intel_ctx_cfg_all_physical (int fd); + +/** +* intel_ctx_t: +* @id: the context id/handle +* @cfg: the config used to create this context +* +* Represents the full configuration of an intel_ctx. +*/ +typedef struct intel_ctx { +uint32_t id; +intel_ctx_cfg_t cfg; +}intel_ctx_t ; + +int __intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg, +const intel_ctx_t **out_ctx); +const intel_ctx_t *intel_ctx_create (int i915,const intel_ctx_cfg_t *cfg); +const intel_ctx_t *intel_ctx_0 (int fd); +const intel_ctx_t *intel_ctx_create_for_engine (int fd,unsigned int class, +unsigned int inst); +const intel_ctx_t *intel_ctx_create_all_physical (int fd); +void intel_ctx_destroy (int fd,const intel_ctx_t *ctx); + +unsigned int intel_ctx_engine_class (const intel_ctx_t *ctx,unsigned int engine); + +#endif lib/meson.build +1
-1@@ -42,6 +42,7 @@ lib_sources = [ 'intel_batchbuffer.c', 'intel_bufops.c', 'intel_chipset.c', + 'intel_ctx.c', 'intel_device_info.c', 'intel_os.c', 'intel_mmio.c', --2.31.1
Quoted 4 lines
Quoted 4 lines
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 09/89] lib: Add an intel_ctx wrapper struct and helpers (v4)
Quoted 340 lines · Jason Ekstrand
Quoted 265 lines · Zbigniew Kempczyński
Quoted 249 lines · Jason Ekstrand
We're trying to clean up some of our technical debt in the i915 API. In particular, context mutability and unnecessary
getparam(). There's quite a bit of the introspection stuff that's not used by any userspace other than IGT. Most drivers don't care about fetching the set of engines, for instance, because they don't forget about what set of engines they asked for int the first place.Unfortunately, IGT relies heavily on context introspection for just about everything when it comes to multi-engine testing. It also likes to use ctx0 as temporary storage for whatever the current test config is. While effective at keeping IGC simple in some ways, this means we're making heavy use of context mutability. Also, passing data around with in tests isn't really what contexts are for.
This patch adds a new
intel_ctx_tstruct which wraps a context and remembers the full context configuration. This will provide similar ease-of-use without having use ctx0 as temporary storage.v2 (Jason Ekstrand):
- Make all intel_ctx_t's constv3 (Jason Ekstrand):
- Fix up the docs so they build properlyv4 (Jason Ekstrand):
- Add anintel_ctx_create_for_enginehelperSigned-off-by Jason Ekstrand <[email protected]>--- .../igt-gpu-tools/igt-gpu-tools-docs.xml | 1 + lib/intel_ctx.c | 272 ++++++++++++++++++ lib/intel_ctx.h | 75 +++++ lib/meson.build | 1 + 4 files changed, 349 insertions(+) create mode 100644 lib/intel_ctx.c create mode 100644 lib/intel_ctx.hdocs/reference/igt-gpu-tools/igt-gpu-tools-docs.xml +1
-0@@ -58,6 +58,7 @@ <xi:include href="xml/gem_engine_topology.xml"/> <xi:include href="xml/gem_scheduler.xml"/> <xi:include href="xml/gem_submission.xml"/> + <xi:include href="xml/intel_ctx.xml"/> </chapter> <xi:include href="xml/igt_test_programs.xml"/>lib/intel_ctx.c new file +194
-0@@ -0,0 +1,272 @@ +/* +* Copyright © 2021 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#include <stddef.h> + +#include "intel_ctx.h" +#include "ioctl_wrappers.h" +#include "i915/gem_engine_topology.h" + +/** +* SECTION:intel_ctx +* @short_description: Wrapper structs for dealing with contexts +* @title: Intel Context Wrapper +* +* This helper library contains a couple of wrapper structs for easier +* dealing with GEM contexts. This includes a context configuration struct +* which represents important context construction parameters and a context +* struct which contains the context ID and its configuration. This makes +* it easier to pass around a context without loosing the context create +* information. +*/ + +static void +add_user_ext (uint64_t *root_ext_u64,struct i915_user_extension *ext) +{ + ext->next_extension = *root_ext_u64; + *root_ext_u64 =to_user_pointer (ext); +} + +static size_t sizeof_param_engines (int count) +{ + return offsetof(struct i915_context_param_engines, engines[count]); +} + +#define SIZEOF_QUERY offsetof(struct drm_i915_query_engine_info, \ + engines[GEM_MAX_ENGINES]) + +/** +* intel_ctx_cfg_all_physical: +* @fd: open i915 drm file descriptor +* +* Returns an intel_ctx_cfg_t containing all physical engines. On kernels +* without the engines API, a default context configuration will be +* returned. +*/ +intel_ctx_cfg_t intel_ctx_cfg_all_physical (int fd) +{ +uint8_t buff[SIZEOF_QUERY ] = { }; +struct drm_i915_query_engine_info *qei = (void *) buff; +intel_ctx_cfg_t cfg = {}; +int i; + +if (__gem_query_engines (fd, qei,SIZEOF_QUERY ) ==0 ) { + cfg.num_engines = qei->num_engines; +for (i =0 ; i < qei->num_engines; i++) + cfg.engines[i] = qei->engines[i].engine; + } + +return cfg; +} + +/** +* intel_ctx_cfg_for_engine: +* @class: engine class +* @inst: engine instance +* +* Returns an intel_ctx_cfg_t containing exactly one engine. +*/ +intel_ctx_cfg_t intel_ctx_cfg_for_engine (unsigned int class,unsigned int inst) +{ +return (intel_ctx_cfg_t ) { + .num_engines =1 , + .engines = { + { .engine_class = class, .engine_instance = inst }, + }, + }; +} + +static int +__context_create_cfg (int fd,const intel_ctx_cfg_t *cfg,uint32_t *ctx_id) +{ +uint64_t ext_root =0 ; +I915_DEFINE_CONTEXT_PARAM_ENGINES (engines,GEM_MAX_ENGINES ); +struct drm_i915_gem_context_create_ext_setparam engines_param, vm_param; +uint32_t i; + +if (cfg->vm) { + vm_param = (struct drm_i915_gem_context_create_ext_setparam ) { + .base = { + .name =I915_CONTEXT_CREATE_EXT_SETPARAM , + }, + .param = { + .param =I915_CONTEXT_PARAM_VM , + .value = cfg->vm, + }, + }; +add_user_ext (&ext_root, &vm_param.base); + } + +if (cfg->num_engines) { +memset (&engines,0 ,sizeof (engines)); +for (i =0 ; i < cfg->num_engines; i++) + engines.engines[i] = cfg->engines[i]; + + engines_param = (struct drm_i915_gem_context_create_ext_setparam ) { + .base = { + .name =I915_CONTEXT_CREATE_EXT_SETPARAM , + }, + .param = { + .param =I915_CONTEXT_PARAM_ENGINES , + .size =sizeof_param_engines (cfg->num_engines), + .value =to_user_pointer (&engines), + }, + }; +add_user_ext (&ext_root, &engines_param.base); + } + +return __gem_context_create_ext (fd, cfg->flags, ext_root, ctx_id); +} + +/** +* __intel_ctx_create: +* @fd: open i915 drm file descriptor +* @cfg: configuration for the created context +* @out_ctx: on success, the new intel_ctx_t pointer is written here +* +* Like intel_ctx_create but returns an error instead of asserting. +*/ +int __intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg, +const intel_ctx_t **out_ctx) +{ +uint32_t ctx_id; +intel_ctx_t *ctx; +int err; + +if (cfg) + err =__context_create_cfg (fd, cfg, &ctx_id); +else + err =__gem_context_create (fd, &ctx_id); +if (err) +return err; + + ctx =calloc (1 ,sizeof (*ctx)); +igt_assert (ctx); + + ctx->id = ctx_id; +if (cfg) + ctx->cfg = *cfg; + + *out_ctx = ctx; +return 0 ; +} + +/** +* intel_ctx_create: +* @fd: open i915 drm file descriptor +* @cfg: configuration for the created context +* +* Creates a new intel_ctx_t with the given config +*/ +const intel_ctx_t *intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg) +{ +const intel_ctx_t *ctx; +int err; + + err =__intel_ctx_create (fd, cfg, &ctx); +igt_assert_eq (err,0 ); + +return ctx; +} + +static const intel_ctx_t __intel_ctx_0 = {}; + +/** lib/intel_ctx.c line 204
Quoted 10 lines
lib/intel_ctx.c new file +10
-0+* intel_ctx_0: +* @fd: open i915 drm file descriptor +* +* Returns an intel_ctx_t representing the default context. +*/ +const intel_ctx_t *intel_ctx_0 (int fd) +{ + (void )fd; +return &__intel_ctx_0; +}What would you say about:
const
intel_ctx_t*intel_ctx_0(int fd)Quoted 10 lines
{ intel_ctx_t *ctx; if (!gem_has_contexts(fd)) return &__intel_ctx_0; ctx = calloc(1, sizeof(*ctx)); igt_assert(ctx); ctx->cfg = intel_ctx_cfg_all_physical(fd);The problem is that this isn't actually the right config for ctx0. :-(
More on that in a bit.Quoted 19 lines
return ctx; }and
void
intel_ctx_destroy(int fd, const intel_ctx_t *ctx){ igt_assert(ctx); if (ctx->id) gem_context_destroy(fd, ctx->id); if (ctx != &__intel_ctx_0) free((void *)ctx); }We could avoid a lot of changes in tests which currently use default context, for example in
gem_exec_nop.cinstead:Quoted 7 lines
ctx = intel_ctx_create_all_physical(device);just
ctx = intel_ctx_0(device);in opening
igt_fixture. We still would have engines field filled from engine query if kernel supports it.Unfortunately, as I alluded to above, this doesn't actually work. This is where the current test iterators are dangerously subtle and it took me a while to figure out what they were doing. By default, a context doesn't have the
all_physicalengine set. Theall_physicalengine set is achieved by querying the kernel for the set of engines and setting up a userspace-managed engine set on the context viaCONTEXT_PARAM_ENGINES. By default, however, contexts have the default set of engines and use the legacy ring flag API.How does this work in all those tests, then? Am I making serious functional changes and iterating over engines differently? No, I'm avoiding serious functional changes. Those tests work by first swapping out the engine set on ctx0 via
SET_CONTEXT_PARAMwithCONTEXT_PARAM_ENGINESand then iterating over that engine set. So, yes, they technically use ctx0 but it's a whole new context by the time you get to the first execbuf.Quoted 5 lines
This way we can avoid unnecessary changes (like in
nop_on_ring()) passing context and using it within execbuf. Especiallyintel_ctxyou've proposed enforces usingctx->idin all execbufs making them a little bit prone to bug if someone would just forget setting rsvd1 field.Yeah, I know all those changes are annoying. I typed them! But one of the things I tried very hard to do is to ensure that every time we have an intel_execution_engine2* or a flags parameter that was really an engine specifier, it's accompanied by the intel_ctx_t* or the intel_ctx_cfg_t* it's relative to. No intel_execution_engine2* or flags parameter is useful by itself, it's always relative to the configuration of the context because the meaning of those flags changes based on the configured engine set.
Quoted 3 lines
I hope that makes the over-all change make more sense.
--Jason
As we're not able to set_engines() with your kernel patch anymore what is blocking us from returning all physical engines in default_engines() in the kernel? This would give us ctx0 armed with all engines and we could leave a lot of igt code intact.
--
Zbigniew
Quoted 169 lines
Quoted 169 lines
--
ZbigniewQuoted 164 lines
lib/intel_ctx.c new file +68
-0+ +/** +* intel_ctx_create_for_engine: +* @fd: open i915 drm file descriptor +* @class: engine class +* @inst: engine instance +* +* Returns an intel_ctx_t containing the specified engine. +*/ +const intel_ctx_t * +intel_ctx_create_for_engine (int fd,unsigned int class,unsigned int inst) +{ +intel_ctx_cfg_t cfg =intel_ctx_cfg_for_engine (class, inst); +return intel_ctx_create (fd, &cfg); +} + +/** +* intel_ctx_create_all_physical: +* @fd: open i915 drm file descriptor +* +* Creates an intel_ctx_t containing all physical engines. On kernels +* without the engines API, the created context will be the same as +* intel_ctx_0() except that it will be a new GEM context. On kernels or +* hardware which do not support contexts, it is the same as intel_ctx_0(). +*/ +const intel_ctx_t *intel_ctx_create_all_physical (int fd) +{ +intel_ctx_cfg_t cfg; + +if (!gem_has_contexts (fd)) +return intel_ctx_0 (fd); + + cfg =intel_ctx_cfg_all_physical (fd); +return intel_ctx_create (fd, &cfg); +} + +/** +* intel_ctx_destroy: +* @fd: open i915 drm file descriptor +* @ctx: context to destroy, or NULL +* +* Destroys an intel_ctx_t. +*/ +void intel_ctx_destroy (int fd,const intel_ctx_t *ctx) +{ +if (!ctx || ctx->id ==0 ) +return ; + +gem_context_destroy (fd, ctx->id); +free ((void *)ctx); +} + +/** +* intel_ctx_engine_class: +* @ctx: an intel_ctx_t +* @engine: an engine specifier +* +* Returns the class for the given engine. +*/ +unsigned int intel_ctx_engine_class (const intel_ctx_t *ctx,unsigned int engine) +{ +if (ctx->cfg.num_engines) { +igt_assert (engine < ctx->cfg.num_engines); +return ctx->cfg.engines[engine].engine_class; + }else { +return gem_execbuf_flags_to_engine_class (engine); + } +}lib/intel_ctx.h new file +75
-0@@ -0,0 +1,75 @@ +/* +* Copyright © 2021 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#ifndef INTEL_CTX_H +#define INTEL_CTX_H + +#include "igt_core.h" + +#include "i915_drm.h" + +#define GEM_MAX_ENGINES I915_EXEC_RING_MASK + 1 + +/** +* intel_ctx_cfg_t: +* @flags: Context create flags +* @vm: VM to inherit or 0 for using a per-context VM +* @num_engines: Number of client-specified engines or 0 for legacy mode +* @engines: Client-specified engines +* +* Represents the full configuration of an intel_ctx. +*/ +typedef struct intel_ctx_cfg { +uint32_t flags; +uint32_t vm; +unsigned int num_engines; +struct i915_engine_class_instance engines[GEM_MAX_ENGINES ]; +}intel_ctx_cfg_t ; + +intel_ctx_cfg_t intel_ctx_cfg_for_engine (unsigned int class,unsigned int inst); +intel_ctx_cfg_t intel_ctx_cfg_all_physical (int fd); + +/** +* intel_ctx_t: +* @id: the context id/handle +* @cfg: the config used to create this context +* +* Represents the full configuration of an intel_ctx. +*/ +typedef struct intel_ctx { +uint32_t id; +intel_ctx_cfg_t cfg; +}intel_ctx_t ; + +int __intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg, +const intel_ctx_t **out_ctx); +const intel_ctx_t *intel_ctx_create (int i915,const intel_ctx_cfg_t *cfg); +const intel_ctx_t *intel_ctx_0 (int fd); +const intel_ctx_t *intel_ctx_create_for_engine (int fd,unsigned int class, +unsigned int inst); +const intel_ctx_t *intel_ctx_create_all_physical (int fd); +void intel_ctx_destroy (int fd,const intel_ctx_t *ctx); + +unsigned int intel_ctx_engine_class (const intel_ctx_t *ctx,unsigned int engine); + +#endif lib/meson.build +1
-1@@ -42,6 +42,7 @@ lib_sources = [ 'intel_batchbuffer.c', 'intel_bufops.c', 'intel_chipset.c', + 'intel_ctx.c', 'intel_device_info.c', 'intel_os.c', 'intel_mmio.c', --2.31.1
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 09/89] lib: Add an intel_ctx wrapper struct and helpers (v4)
Quoted 342 lines · Zbigniew Kempczyński
Quoted 340 lines · Jason Ekstrand
Quoted 265 lines · Zbigniew Kempczyński
Quoted 249 lines · Jason Ekstrand
We're trying to clean up some of our technical debt in the i915 API. In particular, context mutability and unnecessary
getparam(). There's quite a bit of the introspection stuff that's not used by any userspace other than IGT. Most drivers don't care about fetching the set of engines, for instance, because they don't forget about what set of engines they asked for int the first place.Unfortunately, IGT relies heavily on context introspection for just about everything when it comes to multi-engine testing. It also likes to use ctx0 as temporary storage for whatever the current test config is. While effective at keeping IGC simple in some ways, this means we're making heavy use of context mutability. Also, passing data around with in tests isn't really what contexts are for.
This patch adds a new
intel_ctx_tstruct which wraps a context and remembers the full context configuration. This will provide similar ease-of-use without having use ctx0 as temporary storage.v2 (Jason Ekstrand):
- Make all intel_ctx_t's constv3 (Jason Ekstrand):
- Fix up the docs so they build properlyv4 (Jason Ekstrand):
- Add anintel_ctx_create_for_enginehelperSigned-off-by Jason Ekstrand <[email protected]>--- .../igt-gpu-tools/igt-gpu-tools-docs.xml | 1 + lib/intel_ctx.c | 272 ++++++++++++++++++ lib/intel_ctx.h | 75 +++++ lib/meson.build | 1 + 4 files changed, 349 insertions(+) create mode 100644 lib/intel_ctx.c create mode 100644 lib/intel_ctx.hdocs/reference/igt-gpu-tools/igt-gpu-tools-docs.xml +1
-0@@ -58,6 +58,7 @@ <xi:include href="xml/gem_engine_topology.xml"/> <xi:include href="xml/gem_scheduler.xml"/> <xi:include href="xml/gem_submission.xml"/> + <xi:include href="xml/intel_ctx.xml"/> </chapter> <xi:include href="xml/igt_test_programs.xml"/>lib/intel_ctx.c new file +194
-0@@ -0,0 +1,272 @@ +/* +* Copyright © 2021 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#include <stddef.h> + +#include "intel_ctx.h" +#include "ioctl_wrappers.h" +#include "i915/gem_engine_topology.h" + +/** +* SECTION:intel_ctx +* @short_description: Wrapper structs for dealing with contexts +* @title: Intel Context Wrapper +* +* This helper library contains a couple of wrapper structs for easier +* dealing with GEM contexts. This includes a context configuration struct +* which represents important context construction parameters and a context +* struct which contains the context ID and its configuration. This makes +* it easier to pass around a context without loosing the context create +* information. +*/ + +static void +add_user_ext (uint64_t *root_ext_u64,struct i915_user_extension *ext) +{ + ext->next_extension = *root_ext_u64; + *root_ext_u64 =to_user_pointer (ext); +} + +static size_t sizeof_param_engines (int count) +{ + return offsetof(struct i915_context_param_engines, engines[count]); +} + +#define SIZEOF_QUERY offsetof(struct drm_i915_query_engine_info, \ + engines[GEM_MAX_ENGINES]) + +/** +* intel_ctx_cfg_all_physical: +* @fd: open i915 drm file descriptor +* +* Returns an intel_ctx_cfg_t containing all physical engines. On kernels +* without the engines API, a default context configuration will be +* returned. +*/ +intel_ctx_cfg_t intel_ctx_cfg_all_physical (int fd) +{ +uint8_t buff[SIZEOF_QUERY ] = { }; +struct drm_i915_query_engine_info *qei = (void *) buff; +intel_ctx_cfg_t cfg = {}; +int i; + +if (__gem_query_engines (fd, qei,SIZEOF_QUERY ) ==0 ) { + cfg.num_engines = qei->num_engines; +for (i =0 ; i < qei->num_engines; i++) + cfg.engines[i] = qei->engines[i].engine; + } + +return cfg; +} + +/** +* intel_ctx_cfg_for_engine: +* @class: engine class +* @inst: engine instance +* +* Returns an intel_ctx_cfg_t containing exactly one engine. +*/ +intel_ctx_cfg_t intel_ctx_cfg_for_engine (unsigned int class,unsigned int inst) +{ +return (intel_ctx_cfg_t ) { + .num_engines =1 , + .engines = { + { .engine_class = class, .engine_instance = inst }, + }, + }; +} + +static int +__context_create_cfg (int fd,const intel_ctx_cfg_t *cfg,uint32_t *ctx_id) +{ +uint64_t ext_root =0 ; +I915_DEFINE_CONTEXT_PARAM_ENGINES (engines,GEM_MAX_ENGINES ); +struct drm_i915_gem_context_create_ext_setparam engines_param, vm_param; +uint32_t i; + +if (cfg->vm) { + vm_param = (struct drm_i915_gem_context_create_ext_setparam ) { + .base = { + .name =I915_CONTEXT_CREATE_EXT_SETPARAM , + }, + .param = { + .param =I915_CONTEXT_PARAM_VM , + .value = cfg->vm, + }, + }; +add_user_ext (&ext_root, &vm_param.base); + } + +if (cfg->num_engines) { +memset (&engines,0 ,sizeof (engines)); +for (i =0 ; i < cfg->num_engines; i++) + engines.engines[i] = cfg->engines[i]; + + engines_param = (struct drm_i915_gem_context_create_ext_setparam ) { + .base = { + .name =I915_CONTEXT_CREATE_EXT_SETPARAM , + }, + .param = { + .param =I915_CONTEXT_PARAM_ENGINES , + .size =sizeof_param_engines (cfg->num_engines), + .value =to_user_pointer (&engines), + }, + }; +add_user_ext (&ext_root, &engines_param.base); + } + +return __gem_context_create_ext (fd, cfg->flags, ext_root, ctx_id); +} + +/** +* __intel_ctx_create: +* @fd: open i915 drm file descriptor +* @cfg: configuration for the created context +* @out_ctx: on success, the new intel_ctx_t pointer is written here +* +* Like intel_ctx_create but returns an error instead of asserting. +*/ +int __intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg, +const intel_ctx_t **out_ctx) +{ +uint32_t ctx_id; +intel_ctx_t *ctx; +int err; + +if (cfg) + err =__context_create_cfg (fd, cfg, &ctx_id); +else + err =__gem_context_create (fd, &ctx_id); +if (err) +return err; + + ctx =calloc (1 ,sizeof (*ctx)); +igt_assert (ctx); + + ctx->id = ctx_id; +if (cfg) + ctx->cfg = *cfg; + + *out_ctx = ctx; +return 0 ; +} + +/** +* intel_ctx_create: +* @fd: open i915 drm file descriptor +* @cfg: configuration for the created context +* +* Creates a new intel_ctx_t with the given config +*/ +const intel_ctx_t *intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg) +{ +const intel_ctx_t *ctx; +int err; + + err =__intel_ctx_create (fd, cfg, &ctx); +igt_assert_eq (err,0 ); + +return ctx; +} + +static const intel_ctx_t __intel_ctx_0 = {}; + +/** lib/intel_ctx.c line 204
Quoted 10 lines
lib/intel_ctx.c new file +10
-0+* intel_ctx_0: +* @fd: open i915 drm file descriptor +* +* Returns an intel_ctx_t representing the default context. +*/ +const intel_ctx_t *intel_ctx_0 (int fd) +{ + (void )fd; +return &__intel_ctx_0; +}What would you say about:
const
intel_ctx_t*intel_ctx_0(int fd)Quoted 10 lines
{ intel_ctx_t *ctx; if (!gem_has_contexts(fd)) return &__intel_ctx_0; ctx = calloc(1, sizeof(*ctx)); igt_assert(ctx); ctx->cfg = intel_ctx_cfg_all_physical(fd);The problem is that this isn't actually the right config for ctx0. :-(
More on that in a bit.Quoted 19 lines
return ctx; }and
void
intel_ctx_destroy(int fd, const intel_ctx_t *ctx){ igt_assert(ctx); if (ctx->id) gem_context_destroy(fd, ctx->id); if (ctx != &__intel_ctx_0) free((void *)ctx); }We could avoid a lot of changes in tests which currently use default context, for example in
gem_exec_nop.cinstead:Quoted 7 lines
ctx = intel_ctx_create_all_physical(device);just
ctx = intel_ctx_0(device);in opening
igt_fixture. We still would have engines field filled from engine query if kernel supports it.Unfortunately, as I alluded to above, this doesn't actually work. This is where the current test iterators are dangerously subtle and it took me a while to figure out what they were doing. By default, a context doesn't have the
all_physicalengine set. Theall_physicalengine set is achieved by querying the kernel for the set of engines and setting up a userspace-managed engine set on the context viaCONTEXT_PARAM_ENGINES. By default, however, contexts have the default set of engines and use the legacy ring flag API.How does this work in all those tests, then? Am I making serious functional changes and iterating over engines differently? No, I'm avoiding serious functional changes. Those tests work by first swapping out the engine set on ctx0 via
SET_CONTEXT_PARAMwithCONTEXT_PARAM_ENGINESand then iterating over that engine set. So, yes, they technically use ctx0 but it's a whole new context by the time you get to the first execbuf.Quoted 5 lines
This way we can avoid unnecessary changes (like in
nop_on_ring()) passing context and using it within execbuf. Especiallyintel_ctxyou've proposed enforces usingctx->idin all execbufs making them a little bit prone to bug if someone would just forget setting rsvd1 field.Yeah, I know all those changes are annoying. I typed them! But one of the things I tried very hard to do is to ensure that every time we have an intel_execution_engine2* or a flags parameter that was really an engine specifier, it's accompanied by the intel_ctx_t* or the intel_ctx_cfg_t* it's relative to. No intel_execution_engine2* or flags parameter is useful by itself, it's always relative to the configuration of the context because the meaning of those flags changes based on the configured engine set.
Quoted 8 lines
Quoted 3 lines
I hope that makes the over-all change make more sense.
--Jason
As we're not able to
set_engines()with your kernel patch anymore what is blocking us from returning all physical engines indefault_engines()in the kernel? This would give us ctx0 armed with all engines and we could leave a lot of igt code intact.
default_engines() returns a set of engines which corresponds to the I915_EXEC_RENDER, I915_EXEC_BLT, and friends. If we have, say, hardware with 4 video engines, it can't be expressed through that interface. Sadly, it's fixed to the 5 engines we have explicit flags for, if they exist.
--Jason
Quoted 173 lines
--
ZbigniewQuoted 169 lines
Quoted 169 lines
--
ZbigniewQuoted 164 lines
lib/intel_ctx.c new file +68
-0+ +/** +* intel_ctx_create_for_engine: +* @fd: open i915 drm file descriptor +* @class: engine class +* @inst: engine instance +* +* Returns an intel_ctx_t containing the specified engine. +*/ +const intel_ctx_t * +intel_ctx_create_for_engine (int fd,unsigned int class,unsigned int inst) +{ +intel_ctx_cfg_t cfg =intel_ctx_cfg_for_engine (class, inst); +return intel_ctx_create (fd, &cfg); +} + +/** +* intel_ctx_create_all_physical: +* @fd: open i915 drm file descriptor +* +* Creates an intel_ctx_t containing all physical engines. On kernels +* without the engines API, the created context will be the same as +* intel_ctx_0() except that it will be a new GEM context. On kernels or +* hardware which do not support contexts, it is the same as intel_ctx_0(). +*/ +const intel_ctx_t *intel_ctx_create_all_physical (int fd) +{ +intel_ctx_cfg_t cfg; + +if (!gem_has_contexts (fd)) +return intel_ctx_0 (fd); + + cfg =intel_ctx_cfg_all_physical (fd); +return intel_ctx_create (fd, &cfg); +} + +/** +* intel_ctx_destroy: +* @fd: open i915 drm file descriptor +* @ctx: context to destroy, or NULL +* +* Destroys an intel_ctx_t. +*/ +void intel_ctx_destroy (int fd,const intel_ctx_t *ctx) +{ +if (!ctx || ctx->id ==0 ) +return ; + +gem_context_destroy (fd, ctx->id); +free ((void *)ctx); +} + +/** +* intel_ctx_engine_class: +* @ctx: an intel_ctx_t +* @engine: an engine specifier +* +* Returns the class for the given engine. +*/ +unsigned int intel_ctx_engine_class (const intel_ctx_t *ctx,unsigned int engine) +{ +if (ctx->cfg.num_engines) { +igt_assert (engine < ctx->cfg.num_engines); +return ctx->cfg.engines[engine].engine_class; + }else { +return gem_execbuf_flags_to_engine_class (engine); + } +}lib/intel_ctx.h new file +75
-0@@ -0,0 +1,75 @@ +/* +* Copyright © 2021 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#ifndef INTEL_CTX_H +#define INTEL_CTX_H + +#include "igt_core.h" + +#include "i915_drm.h" + +#define GEM_MAX_ENGINES I915_EXEC_RING_MASK + 1 + +/** +* intel_ctx_cfg_t: +* @flags: Context create flags +* @vm: VM to inherit or 0 for using a per-context VM +* @num_engines: Number of client-specified engines or 0 for legacy mode +* @engines: Client-specified engines +* +* Represents the full configuration of an intel_ctx. +*/ +typedef struct intel_ctx_cfg { +uint32_t flags; +uint32_t vm; +unsigned int num_engines; +struct i915_engine_class_instance engines[GEM_MAX_ENGINES ]; +}intel_ctx_cfg_t ; + +intel_ctx_cfg_t intel_ctx_cfg_for_engine (unsigned int class,unsigned int inst); +intel_ctx_cfg_t intel_ctx_cfg_all_physical (int fd); + +/** +* intel_ctx_t: +* @id: the context id/handle +* @cfg: the config used to create this context +* +* Represents the full configuration of an intel_ctx. +*/ +typedef struct intel_ctx { +uint32_t id; +intel_ctx_cfg_t cfg; +}intel_ctx_t ; + +int __intel_ctx_create (int fd,const intel_ctx_cfg_t *cfg, +const intel_ctx_t **out_ctx); +const intel_ctx_t *intel_ctx_create (int i915,const intel_ctx_cfg_t *cfg); +const intel_ctx_t *intel_ctx_0 (int fd); +const intel_ctx_t *intel_ctx_create_for_engine (int fd,unsigned int class, +unsigned int inst); +const intel_ctx_t *intel_ctx_create_all_physical (int fd); +void intel_ctx_destroy (int fd,const intel_ctx_t *ctx); + +unsigned int intel_ctx_engine_class (const intel_ctx_t *ctx,unsigned int engine); + +#endif lib/meson.build +1
-1@@ -42,6 +42,7 @@ lib_sources = [ 'intel_batchbuffer.c', 'intel_bufops.c', 'intel_chipset.c', + 'intel_ctx.c', 'intel_device_info.c', 'intel_os.c', 'intel_mmio.c', --2.31.1
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 10/89 lib/i915/gem_engine_topology: Rework query_engine_list()
In reply to Jason EkstrandThis gives us a no-assert version.
--- lib/i915/gem_engine_topology.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
lib/i915/gem_engine_topology.c +12 -10
@@ -95,13 +95,6 @@ int __gem_query_engines(int fd,return __gem_query (fd, &query); } -static void query_engines (int fd, -struct drm_i915_query_engine_info *query_engines, -int length) -{ -igt_assert_eq (__gem_query_engines (fd, query_engines, length),0 ); -} -static void ctx_map_engines (int fd,struct intel_engine_data *ed,struct drm_i915_gem_context_param *param) {
@@ -160,14 +153,16 @@ static void init_engine(struct intel_execution_engine2 *e2,igt_assert (ret <sizeof (e2->name)); } -static void query_engine_list (int fd,struct intel_engine_data *ed) +static int __query_engine_list (int fd,struct intel_engine_data *ed) {uint8_t buff[SIZEOF_QUERY ] = { };struct drm_i915_query_engine_info *query_engine = (struct drm_i915_query_engine_info *) buff; -int i; +int i, err; -query_engines (fd, query_engine,SIZEOF_QUERY ); + err =__gem_query_engines (fd, query_engine,SIZEOF_QUERY ); +if (err) +return err;for (i =0 ; i < query_engine->num_engines; i++) init_engine(&ed->engines[i],
@@ -175,6 +170,13 @@ static void query_engine_list(int fd, struct intel_engine_data *ed) query_engine->engines[i].engine.engine_instance, i); ed->nengines = query_engine->num_engines; + +return 0 ; +} + +static void query_engine_list (int fd,struct intel_engine_data *ed) +{ +igt_assert_eq (__query_engine_list (fd, ed),0 ); } struct intel_execution_engine2 *
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 10/89] lib/i915/gem_engine_topology: Rework query_engine_list()
Quoted 1 line · Jason Ekstrand
This gives us a no-assert version.
LGTM
--
Zbigniew
Quoted 65 lines
Signed-off-by Jason Ekstrand <[email protected]>--- lib/i915/gem_engine_topology.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)lib/i915/gem_engine_topology.c +12
-10@@ -95,13 +95,6 @@ int __gem_query_engines(int fd,return __gem_query (fd, &query); } -static void query_engines (int fd, -struct drm_i915_query_engine_info *query_engines, -int length) -{ -igt_assert_eq (__gem_query_engines (fd, query_engines, length),0 ); -} -static void ctx_map_engines (int fd,struct intel_engine_data *ed,struct drm_i915_gem_context_param *param) {@@ -160,14 +153,16 @@ static void init_engine(struct intel_execution_engine2 *e2,igt_assert (ret <sizeof (e2->name)); } -static void query_engine_list (int fd,struct intel_engine_data *ed) +static int __query_engine_list (int fd,struct intel_engine_data *ed) {uint8_t buff[SIZEOF_QUERY ] = { };struct drm_i915_query_engine_info *query_engine = (struct drm_i915_query_engine_info *) buff; -int i; +int i, err; -query_engines (fd, query_engine,SIZEOF_QUERY ); + err =__gem_query_engines (fd, query_engine,SIZEOF_QUERY ); +if (err) +return err;for (i =0 ; i < query_engine->num_engines; i++) init_engine(&ed->engines[i],@@ -175,6 +170,13 @@ static void query_engine_list(int fd, struct intel_engine_data *ed) query_engine->engines[i].engine.engine_instance, i); ed->nengines = query_engine->num_engines; + +return 0 ; +} + +static void query_engine_list (int fd,struct intel_engine_data *ed) +{ +igt_assert_eq (__query_engine_list (fd, ed),0 ); } struct intel_execution_engine2 *Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 11/89 lib/i915/gem_engine_topology: Factor out static engine listing
In reply to Jason Ekstrand--- lib/i915/gem_engine_topology.c | 51 +++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 22 deletions(-)
lib/i915/gem_engine_topology.c +29 -22
@@ -212,6 +212,34 @@ intel_get_current_physical_engine(struct intel_engine_data *ed)return e; } +static struct intel_engine_data intel_engine_list_for_static (int fd) +{ +const struct intel_execution_engine2 *e2; +struct intel_engine_data engine_data = { }; + +igt_debug ("using pre-allocated engine list\n" ); + +__for_each_static_engine (e2) { +if (igt_only_list_subtests () || + (fd <0 ) || +gem_has_ring (fd, e2->flags)) { +struct intel_execution_engine2 *__e2 = + &engine_data.engines[ + engine_data.nengines]; + +strcpy (__e2->name, e2->name); + __e2->instance = e2->instance; + __e2->class = e2->class; + __e2->flags = e2->flags; + __e2->is_virtual = false; + + engine_data.nengines++; + } + } + +return engine_data; +} +static int gem_topology_get_param (int fd,struct drm_i915_gem_context_param *p) {
@@ -232,28 +260,7 @@ struct intel_engine_data intel_init_engine_list(int fd, uint32_t ctx_id)if (gem_topology_get_param (fd, ¶m)) {/* if kernel does not support engine/context mapping */ -const struct intel_execution_engine2 *e2; - -igt_debug ("using pre-allocated engine list\n" ); - -__for_each_static_engine (e2) { -if (igt_only_list_subtests () || - (fd <0 ) || -gem_has_ring (fd, e2->flags)) { -struct intel_execution_engine2 *__e2 = - &engine_data.engines[ - engine_data.nengines]; - -strcpy (__e2->name, e2->name); - __e2->instance = e2->instance; - __e2->class = e2->class; - __e2->flags = e2->flags; - __e2->is_virtual = false; - - engine_data.nengines++; - } - } -return engine_data; +return intel_engine_list_for_static (fd); }if (!param.size) {
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 11/89] lib/i915/gem_engine_topology: Factor out static engine listing
Quoted 32 lines · Jason Ekstrand
Signed-off-by Jason Ekstrand <[email protected]>Acked-by Daniel Vetter <[email protected]>--- lib/i915/gem_engine_topology.c | 51 +++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 22 deletions(-)lib/i915/gem_engine_topology.c +18
-0@@ -212,6 +212,34 @@ intel_get_current_physical_engine(struct intel_engine_data *ed)return e; } +static struct intel_engine_data intel_engine_list_for_static (int fd) +{ +const struct intel_execution_engine2 *e2; +struct intel_engine_data engine_data = { }; + +igt_debug ("using pre-allocated engine list\n" ); + +__for_each_static_engine (e2) { +if (igt_only_list_subtests () || + (fd <0 ) || +gem_has_ring (fd, e2->flags)) { +struct intel_execution_engine2 *__e2 = + &engine_data.engines[ + engine_data.nengines]; + +strcpy (__e2->name, e2->name); + __e2->instance = e2->instance; + __e2->class = e2->class;
lib/i915/gem_engine_topology.c intel_get_current_physical_engine(struct intel_engine_data *ed) · line 242
Quoted 10 lines
lib/i915/gem_engine_topology.c +10
-0+ __e2->flags = e2->flags; + __e2->is_virtual = false; + + engine_data.nengines++; + } + } + +return engine_data; +} +
Ok, just a function extraction.
--
Zbigniew
Quoted 40 lines
lib/i915/gem_engine_topology.c +1
-22static int gem_topology_get_param (int fd,struct drm_i915_gem_context_param *p) {@@ -232,28 +260,7 @@ struct intel_engine_data intel_init_engine_list(int fd, uint32_t ctx_id)if (gem_topology_get_param (fd, ¶m)) {/* if kernel does not support engine/context mapping */ -const struct intel_execution_engine2 *e2; - -igt_debug ("using pre-allocated engine list\n" ); - -__for_each_static_engine (e2) { -if (igt_only_list_subtests () || - (fd <0 ) || -gem_has_ring (fd, e2->flags)) { -struct intel_execution_engine2 *__e2 = - &engine_data.engines[ - engine_data.nengines]; - -strcpy (__e2->name, e2->name); - __e2->instance = e2->instance; - __e2->class = e2->class; - __e2->flags = e2->flags; - __e2->is_virtual = false; - - engine_data.nengines++; - } - } -return engine_data; +return intel_engine_list_for_static (fd); }if (!param.size) {Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 12/89 lib/i915/gem_engine_topology: Add an iterator which doesn't munge contexts (v2)
In reply to Jason Ekstrandthe current for_each_physical_engine iterators smash the set of engines on the context (or ctx0 for the __ version). This new one just gets the list of engines from i915 and iterates over them.
v2 (Jason Ekstrand):
- Add docs
--- lib/i915/gem_engine_topology.c | 16 ++++++++++++++++ lib/i915/gem_engine_topology.h | 16 ++++++++++++++++ 2 files changed, 32 insertions(+)
lib/i915/gem_engine_topology.c +16 -0
@@ -240,6 +240,22 @@ static struct intel_engine_data intel_engine_list_for_static(int fd)return engine_data; } +/** +* intel_engine_list_of_physical: +* @fd: open i915 drm file descriptor +* +* Returns the list of all physical engines in the device +*/ +struct intel_engine_data intel_engine_list_of_physical (int fd) +{ +struct intel_engine_data engine_data = { }; + +if (__query_engine_list (fd, &engine_data) ==0 ) +return engine_data; + +return intel_engine_list_for_static (fd); +} +static int gem_topology_get_param (int fd,struct drm_i915_gem_context_param *p) {
lib/i915/gem_engine_topology.h +16 -0
@@ -50,6 +50,7 @@ struct intel_engine_data { };bool gem_has_engine_topology (int fd); +struct intel_engine_data intel_engine_list_of_physical (int fd);struct intel_engine_data intel_init_engine_list (int fd,uint32_t ctx_id);/* iteration functions */
@@ -85,6 +86,21 @@ struct intel_execution_engine2 gem_eb_flags_to_engine(unsigned int flags); ((e__) =intel_get_current_engine (&i__)); \ intel_next_engine(&i__)) +/** +* for_each_physical_engine +* @fd__: open i915 drm file descriptor +* @e__: struct intel_execution_engine2 iterator +* +* Iterates over each physical engine in device. Be careful when using +* this iterator as your context may not have all of these engines and the +* intel_execution_engine2::flags field in the iterator may not match your +* context configuration. +*/ +#define for_each_physical_engine (fd__, e__) \ + for (struct intel_engine_data i__##e__ = intel_engine_list_of_physical(fd__); \ + ((e__) = intel_get_current_physical_engine(&i__##e__)); \ + intel_next_engine(&i__##e__)) +/* needs to replace "for_each_physical_engine" when conflicts are fixed */ #define ____for_each_physical_engine (fd__, ctx__, e__) \ for (struct intel_engine_data i__##e__ = intel_init_engine_list(fd__, ctx__); \
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 12/89] lib/i915/gem_engine_topology: Add an iterator which doesn't munge contexts (v2)
Quoted 9 lines · Jason Ekstrand
the current
for_each_physical_engineiterators smash the set of engines on the context (or ctx0 for the __ version). This new one just gets the list of engines from i915 and iterates over them.v2 (Jason Ekstrand):
- Add docsSigned-off-by Jason Ekstrand <[email protected]>Reviewed-by Daniel Vetter <[email protected]>
--
Zbigniew
Quoted 73 lines
--- lib/i915/gem_engine_topology.c | 16 ++++++++++++++++ lib/i915/gem_engine_topology.h | 16 ++++++++++++++++ 2 files changed, 32 insertions(+)lib/i915/gem_engine_topology.c +16
-0@@ -240,6 +240,22 @@ static struct intel_engine_data intel_engine_list_for_static(int fd)return engine_data; } +/** +* intel_engine_list_of_physical: +* @fd: open i915 drm file descriptor +* +* Returns the list of all physical engines in the device +*/ +struct intel_engine_data intel_engine_list_of_physical (int fd) +{ +struct intel_engine_data engine_data = { }; + +if (__query_engine_list (fd, &engine_data) ==0 ) +return engine_data; + +return intel_engine_list_for_static (fd); +} +static int gem_topology_get_param (int fd,struct drm_i915_gem_context_param *p) {lib/i915/gem_engine_topology.h +16
-0@@ -50,6 +50,7 @@ struct intel_engine_data { };bool gem_has_engine_topology (int fd); +struct intel_engine_data intel_engine_list_of_physical (int fd);struct intel_engine_data intel_init_engine_list (int fd,uint32_t ctx_id);/* iteration functions */ @@ -85,6 +86,21 @@ struct intel_execution_engine2 gem_eb_flags_to_engine(unsigned int flags); ((e__) =intel_get_current_engine (&i__)); \ intel_next_engine(&i__)) +/** +* for_each_physical_engine +* @fd__: open i915 drm file descriptor +* @e__: struct intel_execution_engine2 iterator +* +* Iterates over each physical engine in device. Be careful when using +* this iterator as your context may not have all of these engines and the +* intel_execution_engine2::flags field in the iterator may not match your +* context configuration. +*/ +#define for_each_physical_engine (fd__, e__) \ + for (struct intel_engine_data i__##e__ = intel_engine_list_of_physical(fd__); \ + ((e__) = intel_get_current_physical_engine(&i__##e__)); \ + intel_next_engine(&i__##e__)) +/* needs to replace "for_each_physical_engine" when conflicts are fixed */ #define ____for_each_physical_engine (fd__, ctx__, e__) \ for (struct intel_engine_data i__##e__ = intel_init_engine_list(fd__, ctx__); \Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 13/89 lib/i915/gem_engine_topology: Add an iterator for intel_ctx_t (v2)
In reply to Jason Ekstrandv2 (Jason Ekstrand):
- Add documentation
--- lib/i915/gem_engine_topology.c | 69 ++++++++++++++++++++++++++++++++++ lib/i915/gem_engine_topology.h | 29 +++++++++++++- 2 files changed, 96 insertions(+), 2 deletions(-)
lib/i915/gem_engine_topology.c +69 -0
@@ -39,6 +39,47 @@* * This helper library contains functions used for querying and dealing * with engines in GEM contexts. +* +* Combined with intel_ctx_t, these helpers give a pretty standard pattern +* for testing every engine in a device: +* |[<!-- language="C" --> +* const struct intel_execution_engine2 *e; +* const intel_ctx_t *ctx = intel_ctx_create_all_physical(fd); +* +* igt_subtest_with_dynamic("basic") { +* for_each_ctx_engine(fd, ctx, e) { +* igt_dynamic_f("%s", e->name) +* run_ctx_test(fd, ctx, e); +* } +* } +* ]| +* This pattern works regardless of whether or not the engines topology API +* is available and regardless of whether or not your platform supports +* contexts. If engines are unavailable, it falls back to a legacy context +* and if contexts are unavailable, intel_ctx_create_all_physial() will +* return a wrapper around ctx0. +* +* If, for some reason, you want to create a second identical context to +* use with your engine iterator, duplicating the context is easy: +* |[<!-- language="C" --> +* const intel_ctx_t *ctx2 = intel_ctx_create(fd, &ctx->cfg); +* ]| +* +* If you want each subtest to always create its own contexts, there are +* also iterators which work only on a context config. As long as all +* contexts are created from that config, or from one with an identical set +* of engines, the iterator will be valid for those contexts. +* |[<!-- language="C" --> +* const struct intel_execution_engine2 *e; +* intel_ctx_cfg_t cfg = intel_ctx_cfg_all_physical(fd); +* +* igt_subtest_with_dynamic("basic") { +* for_each_ctx_cfg_engine(fd, &cfg, e) { +* igt_dynamic_f("%s", e->name) +* run_ctx_cfg_test(fd, &cfg, e); +* } +* } +* ]| */ /*
@@ -256,6 +297,34 @@ struct intel_engine_data intel_engine_list_of_physical(int fd)return intel_engine_list_for_static (fd); } +/** +* intel_engine_list_for_ctx_cfg: +* @fd: open i915 drm file descriptor +* @cfg: Context config +* +* Returns the list of all engines in the context config +*/ +struct intel_engine_data +intel_engine_list_for_ctx_cfg (int fd,const intel_ctx_cfg_t *cfg) +{ +if (fd >=0 && cfg->num_engines) { +struct intel_engine_data engine_data = { }; +int i; + + engine_data.nengines = cfg->num_engines; +for (i =0 ; i < cfg->num_engines; i++) +init_engine (&engine_data.engines[i], + cfg->engines[i].engine_class, + cfg->engines[i].engine_instance, + i); + +return engine_data; + }else { +/* This is a legacy context */ +return intel_engine_list_for_static (fd); + } +} +static int gem_topology_get_param (int fd,struct drm_i915_gem_context_param *p) {
lib/i915/gem_engine_topology.h +27 -2
@@ -26,8 +26,7 @@#include "igt_gt.h" #include "i915_drm.h" - -#define GEM_MAX_ENGINES I915_EXEC_RING_MASK + 1 +#include "intel_ctx.h" int __gem_query_engines(int fd, struct drm_i915_query_engine_info *query_engines,
@@ -51,6 +50,7 @@ struct intel_engine_data {bool gem_has_engine_topology (int fd);struct intel_engine_data intel_engine_list_of_physical (int fd); +struct intel_engine_data intel_engine_list_for_ctx_cfg (int fd,const intel_ctx_cfg_t *cfg);struct intel_engine_data intel_init_engine_list (int fd,uint32_t ctx_id);/* iteration functions */
@@ -81,6 +81,31 @@ struct intel_execution_engine2 gem_eb_flags_to_engine(unsigned int flags);#define __for_each_static_engine (e__) \ for ((e__) = intel_execution_engines2; (e__)->name[0]; (e__)++) +/** +* for_each_ctx_cfg_engine +* @fd__: open i915 drm file descriptor +* @ctx_cfg__: Intel context config +* @e__: struct intel_execution_engine2 iterator +* +* Iterates over each physical engine in the context config +*/ +#define for_each_ctx_cfg_engine (fd__, ctx_cfg__, e__) \ + for (struct intel_engine_data i__##e__ = \ + intel_engine_list_for_ctx_cfg(fd__, ctx_cfg__); \ + ((e__) = intel_get_current_engine(&i__##e__)); \ + intel_next_engine(&i__##e__)) + +/** +* for_each_ctx_engine +* @fd__: open i915 drm file descriptor +* @ctx__: Intel context wrapper +* @e__: struct intel_execution_engine2 iterator +* +* Iterates over each physical engine in the context +*/ +#define for_each_ctx_engine (fd__, ctx__, e__) \ + for_each_ctx_cfg_engine(fd__, &(ctx__)->cfg, e__) +#define for_each_context_engine (fd__, ctx__, e__) \ for (struct intel_engine_data i__ = intel_init_engine_list(fd__, ctx__); \ ((e__) = intel_get_current_engine(&i__)); \
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 13/89] lib/i915/gem_engine_topology: Add an iterator for intel_ctx_t (v2)
Quoted 26 lines · Jason Ekstrand
v2 (Jason Ekstrand):
- Add documentationSigned-off-by Jason Ekstrand <[email protected]>Reviewed-by Daniel Vetter <[email protected]>--- lib/i915/gem_engine_topology.c | 69 ++++++++++++++++++++++++++++++++++ lib/i915/gem_engine_topology.h | 29 +++++++++++++- 2 files changed, 96 insertions(+), 2 deletions(-)lib/i915/gem_engine_topology.c +8
-0@@ -39,6 +39,47 @@* * This helper library contains functions used for querying and dealing * with engines in GEM contexts. +* +* Combined with intel_ctx_t, these helpers give a pretty standard pattern +* for testing every engine in a device: +* |[<!-- language="C" --> +* const struct intel_execution_engine2 *e; +* const intel_ctx_t *ctx = intel_ctx_create_all_physical(fd); +* +* igt_subtest_with_dynamic("basic") {
lib/i915/gem_engine_topology.c line 59
Quoted 10 lines
lib/i915/gem_engine_topology.c +10
-0+* for_each_ctx_engine(fd, ctx, e) { +* igt_dynamic_f("%s", e->name) +* run_ctx_test(fd, ctx, e); +* } +* } +* ]| +* This pattern works regardless of whether or not the engines topology API +* is available and regardless of whether or not your platform supports +* contexts. If engines are unavailable, it falls back to a legacy context +* and if contexts are unavailable, intel_ctx_create_all_physial() will
^^^^^^^ - typo
Quoted 30 lines
lib/i915/gem_engine_topology.c +23
-0+* return a wrapper around ctx0. +* +* If, for some reason, you want to create a second identical context to +* use with your engine iterator, duplicating the context is easy: +* |[<!-- language="C" --> +* const intel_ctx_t *ctx2 = intel_ctx_create(fd, &ctx->cfg); +* ]| +* +* If you want each subtest to always create its own contexts, there are +* also iterators which work only on a context config. As long as all +* contexts are created from that config, or from one with an identical set +* of engines, the iterator will be valid for those contexts. +* |[<!-- language="C" --> +* const struct intel_execution_engine2 *e; +* intel_ctx_cfg_t cfg = intel_ctx_cfg_all_physical(fd); +* +* igt_subtest_with_dynamic("basic") { +* for_each_ctx_cfg_engine(fd, &cfg, e) { +* igt_dynamic_f("%s", e->name) +* run_ctx_cfg_test(fd, &cfg, e); +* } +* } +* ]| */ /* @@ -256,6 +297,34 @@ struct intel_engine_data intel_engine_list_of_physical(int fd)return intel_engine_list_for_static (fd); }
lib/i915/gem_engine_topology.c struct intel_engine_data intel_engine_list_of_physical(int fd) · line 309
Quoted 10 lines
lib/i915/gem_engine_topology.c +10
-0+/** +* intel_engine_list_for_ctx_cfg: +* @fd: open i915 drm file descriptor +* @cfg: Context config +* +* Returns the list of all engines in the context config +*/ +struct intel_engine_data +intel_engine_list_for_ctx_cfg (int fd,const intel_ctx_cfg_t *cfg) +{
I would add igt_assert(cfg) here especially we expect not-null cfg pointer here.
lib/i915/gem_engine_topology.c struct intel_engine_data intel_engine_list_of_physical(int fd) · line 319
Quoted 10 lines
lib/i915/gem_engine_topology.c +10
-0+if (fd >=0 && cfg->num_engines) { +struct intel_engine_data engine_data = { }; +int i; + + engine_data.nengines = cfg->num_engines; +for (i =0 ; i < cfg->num_engines; i++) +init_engine (&engine_data.engines[i], + cfg->engines[i].engine_class, + cfg->engines[i].engine_instance, + i);
What's the reason of passing incrementing value here? It's confusing especially it is not correspond to legacy engine ids.
--
Zbigniew
Quoted 72 lines
lib/i915/gem_engine_topology.c +8
-0+ +return engine_data; + }else { +/* This is a legacy context */ +return intel_engine_list_for_static (fd); + } +} +static int gem_topology_get_param (int fd,struct drm_i915_gem_context_param *p) {lib/i915/gem_engine_topology.h +27
-2@@ -26,8 +26,7 @@#include "igt_gt.h" #include "i915_drm.h" - -#define GEM_MAX_ENGINES I915_EXEC_RING_MASK + 1 +#include "intel_ctx.h" int __gem_query_engines(int fd, struct drm_i915_query_engine_info *query_engines,@@ -51,6 +50,7 @@ struct intel_engine_data {bool gem_has_engine_topology (int fd);struct intel_engine_data intel_engine_list_of_physical (int fd); +struct intel_engine_data intel_engine_list_for_ctx_cfg (int fd,const intel_ctx_cfg_t *cfg);struct intel_engine_data intel_init_engine_list (int fd,uint32_t ctx_id);/* iteration functions */ @@ -81,6 +81,31 @@ struct intel_execution_engine2 gem_eb_flags_to_engine(unsigned int flags);#define __for_each_static_engine (e__) \ for ((e__) = intel_execution_engines2; (e__)->name[0]; (e__)++) +/** +* for_each_ctx_cfg_engine +* @fd__: open i915 drm file descriptor +* @ctx_cfg__: Intel context config +* @e__: struct intel_execution_engine2 iterator +* +* Iterates over each physical engine in the context config +*/ +#define for_each_ctx_cfg_engine (fd__, ctx_cfg__, e__) \ + for (struct intel_engine_data i__##e__ = \ + intel_engine_list_for_ctx_cfg(fd__, ctx_cfg__); \ + ((e__) = intel_get_current_engine(&i__##e__)); \ + intel_next_engine(&i__##e__)) + +/** +* for_each_ctx_engine +* @fd__: open i915 drm file descriptor +* @ctx__: Intel context wrapper +* @e__: struct intel_execution_engine2 iterator +* +* Iterates over each physical engine in the context +*/ +#define for_each_ctx_engine (fd__, ctx__, e__) \ + for_each_ctx_cfg_engine(fd__, &(ctx__)->cfg, e__) +#define for_each_context_engine (fd__, ctx__, e__) \ for (struct intel_engine_data i__ = intel_init_engine_list(fd__, ctx__); \ ((e__) = intel_get_current_engine(&i__)); \Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 13/89] lib/i915/gem_engine_topology: Add an iterator for intel_ctx_t (v2)
Quoted 32 lines · Zbigniew Kempczyński
Quoted 30 lines · Jason Ekstrand
v2 (Jason Ekstrand):
- Add documentationSigned-off-by Jason Ekstrand <[email protected]>Reviewed-by Daniel Vetter <[email protected]>--- lib/i915/gem_engine_topology.c | 69 ++++++++++++++++++++++++++++++++++ lib/i915/gem_engine_topology.h | 29 +++++++++++++- 2 files changed, 96 insertions(+), 2 deletions(-)lib/i915/gem_engine_topology.c +12
-0@@ -39,6 +39,47 @@* * This helper library contains functions used for querying and dealing * with engines in GEM contexts. +* +* Combined with intel_ctx_t, these helpers give a pretty standard pattern +* for testing every engine in a device: +* |[<!-- language="C" --> +* const struct intel_execution_engine2 *e; +* const intel_ctx_t *ctx = intel_ctx_create_all_physical(fd); +* +* igt_subtest_with_dynamic("basic") { +* for_each_ctx_engine(fd, ctx, e) { +* igt_dynamic_f("%s", e->name) +* run_ctx_test(fd, ctx, e); +* }
Quoted 8 lines
lib/i915/gem_engine_topology.c line 59
Quoted 6 lines
lib/i915/gem_engine_topology.c +6
-0+* } +* ]| +* This pattern works regardless of whether or not the engines topology API +* is available and regardless of whether or not your platform supports +* contexts. If engines are unavailable, it falls back to a legacy context +* and if contexts are unavailable, intel_ctx_create_all_physial() will ^^^^^^^ - typo
Fixed.
Quoted 30 lines
Quoted 30 lines
lib/i915/gem_engine_topology.c +23
-0+* return a wrapper around ctx0. +* +* If, for some reason, you want to create a second identical context to +* use with your engine iterator, duplicating the context is easy: +* |[<!-- language="C" --> +* const intel_ctx_t *ctx2 = intel_ctx_create(fd, &ctx->cfg); +* ]| +* +* If you want each subtest to always create its own contexts, there are +* also iterators which work only on a context config. As long as all +* contexts are created from that config, or from one with an identical set +* of engines, the iterator will be valid for those contexts. +* |[<!-- language="C" --> +* const struct intel_execution_engine2 *e; +* intel_ctx_cfg_t cfg = intel_ctx_cfg_all_physical(fd); +* +* igt_subtest_with_dynamic("basic") { +* for_each_ctx_cfg_engine(fd, &cfg, e) { +* igt_dynamic_f("%s", e->name) +* run_ctx_cfg_test(fd, &cfg, e); +* } +* } +* ]| */ /* @@ -256,6 +297,34 @@ struct intel_engine_data intel_engine_list_of_physical(int fd)return intel_engine_list_for_static (fd); }
Quoted 13 lines
lib/i915/gem_engine_topology.c struct intel_engine_data intel_engine_list_of_physical(int fd) · line 309
Quoted 10 lines
lib/i915/gem_engine_topology.c +10
-0+/** +* intel_engine_list_for_ctx_cfg: +* @fd: open i915 drm file descriptor +* @cfg: Context config +* +* Returns the list of all engines in the context config +*/ +struct intel_engine_data +intel_engine_list_for_ctx_cfg (int fd,const intel_ctx_cfg_t *cfg) +{I would add
igt_assert(cfg)here especially we expect not-null cfg pointer here.
Done.
Quoted 11 lines
lib/i915/gem_engine_topology.c struct intel_engine_data intel_engine_list_of_physical(int fd) · line 319
Quoted 10 lines
lib/i915/gem_engine_topology.c +10
-0+if (fd >=0 && cfg->num_engines) { +struct intel_engine_data engine_data = { }; +int i; + + engine_data.nengines = cfg->num_engines; +for (i =0 ; i < cfg->num_engines; i++) +init_engine (&engine_data.engines[i], + cfg->engines[i].engine_class, + cfg->engines[i].engine_instance, + i);
Quoted 2 lines
What's the reason of passing incrementing value here? It's confusing especially it is not correspond to legacy engine ids.
The final parameter to init_engine() is the "flags" parameter to use with it. For userspace-specified engines, the flags parameter is an engine index, hence i. For legacy contexts it's something like I915_EXEC_RENDER or I915_EXEC_BLT.
--Jason
Quoted 71 lines
--
ZbigniewQuoted 68 lines
lib/i915/gem_engine_topology.c +8
-0+ +return engine_data; + }else { +/* This is a legacy context */ +return intel_engine_list_for_static (fd); + } +} +static int gem_topology_get_param (int fd,struct drm_i915_gem_context_param *p) {lib/i915/gem_engine_topology.h +27
-3@@ -26,8 +26,7 @@#include "igt_gt.h" #include "i915_drm.h" - -#define GEM_MAX_ENGINES I915_EXEC_RING_MASK + 1 +#include "intel_ctx.h" int __gem_query_engines(int fd, struct drm_i915_query_engine_info *query_engines,@@ -51,6 +50,7 @@ struct intel_engine_data {bool gem_has_engine_topology (int fd);struct intel_engine_data intel_engine_list_of_physical (int fd); +struct intel_engine_data intel_engine_list_for_ctx_cfg (int fd,const intel_ctx_cfg_t *cfg);struct intel_engine_data intel_init_engine_list (int fd,uint32_t ctx_id);/* iteration functions */ @@ -81,6 +81,31 @@ struct intel_execution_engine2 gem_eb_flags_to_engine(unsigned int flags);#define __for_each_static_engine (e__) \ for ((e__) = intel_execution_engines2; (e__)->name[0]; (e__)++) +/** +* for_each_ctx_cfg_engine +* @fd__: open i915 drm file descriptor +* @ctx_cfg__: Intel context config +* @e__: struct intel_execution_engine2 iterator +* +* Iterates over each physical engine in the context config +*/ +#define for_each_ctx_cfg_engine (fd__, ctx_cfg__, e__) \ + for (struct intel_engine_data i__##e__ = \ + intel_engine_list_for_ctx_cfg(fd__, ctx_cfg__); \ + ((e__) = intel_get_current_engine(&i__##e__)); \ + intel_next_engine(&i__##e__)) + +/** +* for_each_ctx_engine +* @fd__: open i915 drm file descriptor +* @ctx__: Intel context wrapper +* @e__: struct intel_execution_engine2 iterator +* +* Iterates over each physical engine in the context +*/ +#define for_each_ctx_engine (fd__, ctx__, e__) \ + for_each_ctx_cfg_engine(fd__, &(ctx__)->cfg, e__) +#define for_each_context_engine (fd__, ctx__, e__) \ for (struct intel_engine_data i__ = intel_init_engine_list(fd__, ctx__); \ ((e__) = intel_get_current_engine(&i__)); \ --2.31.1
Quoted 4 lines
Quoted 4 lines
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 14/89 tests/i915/gem_exec_basic: Convert to intel_ctx_t
In reply to Jason EkstrandThis acts as a template for the rest of this patch series. The rough idea is that we create a new context if the HW supports contexts and otherwise we use intel_ctx_0(). Once we have an intel_ctx_t, we can iterate over all of the engines in it in a consistent way.
--- tests/i915/gem_exec_basic.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tests/i915/gem_exec_basic.c +6 -1
@@ -41,10 +41,13 @@ static uint32_t batch_create(int fd) igt_main {const struct intel_execution_engine2 *e; +const intel_ctx_t *ctx =NULL ;int fd =-1 ; igt_fixture { fd =drm_open_driver (DRIVER_INTEL ); + ctx =intel_ctx_create_all_physical (fd); +/* igt_require_gem(fd); // test is mandatory */ igt_fork_hang_detector (fd); }
@@ -54,12 +57,13 @@ igt_main .handle = batch_create(fd), }; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { igt_dynamic_f("%s", e->name) {struct drm_i915_gem_execbuffer2 execbuf = { .buffers_ptr =to_user_pointer (&exec), .buffer_count =1 , .flags = e->flags, + .rsvd1 = ctx->id, };gem_execbuf (fd, &execbuf);
@@ -72,6 +76,7 @@ igt_main igt_fixture {igt_stop_hang_detector (); +intel_ctx_destroy (fd, ctx);close (fd); } }
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 14/89] tests/i915/gem_exec_basic: Convert to intel_ctx_t
Quoted 15 lines · Jason Ekstrand
This acts as a template for the rest of this patch series. The rough idea is that we create a new context if the HW supports contexts and otherwise we use
intel_ctx_0(). Once we have anintel_ctx_t, we can iterate over all of the engines in it in a consistent way.Signed-off-by Jason Ekstrand <[email protected]>--- tests/i915/gem_exec_basic.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tests/i915/gem_exec_basic.c +0
-0
tests/i915/gem_exec_basic.c static uint32_t batch_create(int fd) · line 44
Quoted 4 lines
tests/i915/gem_exec_basic.c +1
-0@@ -41,10 +41,13 @@ static uint32_t batch_create(int fd) igt_main {const struct intel_execution_engine2 *e; +const intel_ctx_t *ctx =NULL ;
Initialization is not necessary here. Other things are ok:
--
Zbigniew
Quoted 39 lines
tests/i915/gem_exec_basic.c +5
-1int fd =-1 ; igt_fixture { fd =drm_open_driver (DRIVER_INTEL ); + ctx =intel_ctx_create_all_physical (fd); +/* igt_require_gem(fd); // test is mandatory */ igt_fork_hang_detector (fd); }@@ -54,12 +57,13 @@ igt_main .handle = batch_create(fd), }; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { igt_dynamic_f("%s", e->name) {struct drm_i915_gem_execbuffer2 execbuf = { .buffers_ptr =to_user_pointer (&exec), .buffer_count =1 , .flags = e->flags, + .rsvd1 = ctx->id, };gem_execbuf (fd, &execbuf);@@ -72,6 +76,7 @@ igt_main igt_fixture {igt_stop_hang_detector (); +intel_ctx_destroy (fd, ctx);close (fd); } }Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 15/89 lib/dummyload: Better document igt_spin_factory
In reply to Jason Ekstrand--- lib/igt_dummyload.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
lib/igt_dummyload.h +16 -6
@@ -59,13 +59,23 @@ typedef struct igt_spin {#define SPIN_CLFLUSH (1 << 0) } igt_spin_t; -struct igt_spin_factory { +/** +* igt_spin_factory_t: +* @ctx: GEM context handle +* @dependency: GEM object to depend on +* @engine: Flags describing the engine to execute on +* @flags: Set of IGT_SPIN_* flags +* @fence: In-fence to wait on +* +* A factory struct which contains creation parameters for an igt_spin_t. +*/ +typedef struct igt_spin_factory {uint32_t ctx;uint32_t dependency;unsigned int engine;unsigned int flags;int fence; -}; +}igt_spin_factory_t ;#define IGT_SPIN_FENCE_IN (1 << 0)#define IGT_SPIN_FENCE_SUBMIT (1 << 1)
@@ -78,14 +88,14 @@ struct igt_spin_factory {#define IGT_SPIN_SOFTDEP (1 << 8)igt_spin_t * -__igt_spin_factory (int fd,const struct igt_spin_factory *opts); +__igt_spin_factory (int fd,const igt_spin_factory_t *opts);igt_spin_t * -igt_spin_factory (int fd,const struct igt_spin_factory *opts); +igt_spin_factory (int fd,const igt_spin_factory_t *opts);#define __igt_spin_new (fd, ...) \ - __igt_spin_factory(fd, &((struct igt_spin_factory){__VA_ARGS__})) + __igt_spin_factory(fd, &((igt_spin_factory_t){__VA_ARGS__}))#define igt_spin_new (fd, ...) \ - igt_spin_factory(fd, &((struct igt_spin_factory){__VA_ARGS__})) + igt_spin_factory(fd, &((igt_spin_factory_t){__VA_ARGS__}))void igt_spin_set_timeout (igt_spin_t *spin,int64_t ns);void igt_spin_reset (igt_spin_t *spin);
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 15/89] lib/dummyload: Better document igt_spin_factory
Quoted 60 lines · Jason Ekstrand
--- lib/igt_dummyload.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)lib/igt_dummyload.h +16
-6@@ -59,13 +59,23 @@ typedef struct igt_spin {#define SPIN_CLFLUSH (1 << 0) } igt_spin_t; -struct igt_spin_factory { +/** +* igt_spin_factory_t: +* @ctx: GEM context handle +* @dependency: GEM object to depend on +* @engine: Flags describing the engine to execute on +* @flags: Set of IGT_SPIN_* flags +* @fence: In-fence to wait on +* +* A factory struct which contains creation parameters for an igt_spin_t. +*/ +typedef struct igt_spin_factory {uint32_t ctx;uint32_t dependency;unsigned int engine;unsigned int flags;int fence; -}; +}igt_spin_factory_t ;#define IGT_SPIN_FENCE_IN (1 << 0)#define IGT_SPIN_FENCE_SUBMIT (1 << 1)@@ -78,14 +88,14 @@ struct igt_spin_factory {#define IGT_SPIN_SOFTDEP (1 << 8)igt_spin_t * -__igt_spin_factory (int fd,const struct igt_spin_factory *opts); +__igt_spin_factory (int fd,const igt_spin_factory_t *opts);igt_spin_t * -igt_spin_factory (int fd,const struct igt_spin_factory *opts); +igt_spin_factory (int fd,const igt_spin_factory_t *opts);#define __igt_spin_new (fd, ...) \ - __igt_spin_factory(fd, &((struct igt_spin_factory){__VA_ARGS__})) + __igt_spin_factory(fd, &((igt_spin_factory_t){__VA_ARGS__}))#define igt_spin_new (fd, ...) \ - igt_spin_factory(fd, &((struct igt_spin_factory){__VA_ARGS__})) + igt_spin_factory(fd, &((igt_spin_factory_t){__VA_ARGS__}))void igt_spin_set_timeout (igt_spin_t *spin,int64_t ns);void igt_spin_reset (igt_spin_t *spin);Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Ok, just typedef + doc.
--
Zbigniew
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 16/89 lib/dummyload: Rename igt_spin_factory::ctx to ctx_id
In reply to Jason Ekstrand--- lib/igt_dummyload.c | 6 +++--- lib/igt_dummyload.h | 4 ++-- lib/igt_gt.c | 2 +- tests/i915/gem_ctx_engines.c | 6 +++--- tests/i915/gem_ctx_exec.c | 2 +- tests/i915/gem_ctx_isolation.c | 18 +++++++++--------- tests/i915/gem_ctx_shared.c | 16 ++++++++-------- tests/i915/gem_eio.c | 2 +- tests/i915/gem_exec_balancer.c | 26 +++++++++++++------------- tests/i915/gem_exec_latency.c | 2 +- tests/i915/gem_exec_nop.c | 2 +- tests/i915/gem_exec_schedule.c | 26 +++++++++++++------------- tests/i915/gem_spin_batch.c | 2 +- tests/i915/gem_sync.c | 2 +- tests/i915/gem_vm_create.c | 4 ++-- tests/i915/gem_watchdog.c | 2 +- tests/i915/gem_workarounds.c | 2 +- tests/i915/perf_pmu.c | 4 ++-- 18 files changed, 64 insertions(+), 64 deletions(-)
lib/igt_dummyload.c +3 -3
@@ -127,7 +127,7 @@ emit_recursive_batch(igt_spin_t *spin,if (opts->engine ==ALL_ENGINES ) {struct intel_execution_engine2 *engine; -for_each_context_engine (fd, opts->ctx, engine) { +for_each_context_engine (fd, opts->ctx_id, engine) {if (opts->flags &IGT_SPIN_POLL_RUN && !gem_class_can_store_dword (fd, engine->class))continue ;
@@ -325,7 +325,7 @@ emit_recursive_batch(igt_spin_t *spin, execbuf->buffers_ptr =to_user_pointer (obj + (2 - execbuf->buffer_count)); - execbuf->rsvd1 = opts->ctx; + execbuf->rsvd1 = opts->ctx_id;if (opts->flags &IGT_SPIN_FENCE_OUT ) execbuf->flags |=I915_EXEC_FENCE_OUT ;
@@ -423,7 +423,7 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts)int class;if (!gem_context_lookup_engine (fd, opts->engine, - opts->ctx, &e)) { + opts->ctx_id, &e)) { class = e.class; }else {gem_require_ring (fd, opts->engine);
lib/igt_dummyload.h +2 -2
@@ -61,7 +61,7 @@ typedef struct igt_spin {/** * igt_spin_factory_t: -* @ctx: GEM context handle +* @ctx_id: GEM context handle * @dependency: GEM object to depend on * @engine: Flags describing the engine to execute on * @flags: Set of IGT_SPIN_* flags
@@ -70,7 +70,7 @@ typedef struct igt_spin {* A factory struct which contains creation parameters for an igt_spin_t. */ typedef struct igt_spin_factory { - uint32_t ctx; + uint32_t ctx_id; uint32_t dependency; unsigned int engine; unsigned int flags;
lib/igt_gt.c +1 -1
@@ -298,7 +298,7 @@ igt_hang_t igt_hang_ctx(int fd, uint32_t ctx, int ring, unsigned flags)context_set_ban (fd, ctx,0 ); spin = __igt_spin_new(fd, - .ctx = ctx, + .ctx_id = ctx, .engine = ring, .flags =IGT_SPIN_NO_PREEMPTION );
tests/i915/gem_ctx_engines.c +3 -3
@@ -336,7 +336,7 @@ static void execute_one(int i915)igt_spin_t *spin;/* Prewarm the spinner */ - spin = igt_spin_new(i915, .ctx = param.ctx_id, + spin = igt_spin_new(i915, .ctx_id = param.ctx_id, .flags = (IGT_SPIN_NO_PREEMPTION |IGT_SPIN_POLL_RUN ));
@@ -439,7 +439,7 @@ static void execute_oneforall(int i915)igt_spin_t *spin; spin = __igt_spin_new(i915, - .ctx = param.ctx_id, + .ctx_id = param.ctx_id, .engine = i); busy.handle = spin->handle;
@@ -480,7 +480,7 @@ static void execute_allforone(int i915)igt_spin_t *spin; spin = __igt_spin_new(i915, - .ctx = param.ctx_id, + .ctx_id = param.ctx_id, .engine = i++); busy.handle = spin->handle;
tests/i915/gem_ctx_exec.c +1 -1
@@ -184,7 +184,7 @@ static void norecovery(int i915)igt_assert_eq (param.value, pass); spin = __igt_spin_new(i915, - .ctx = param.ctx_id, + .ctx_id = param.ctx_id, .flags =IGT_SPIN_POLL_RUN );igt_spin_busywait_until_started (spin);
tests/i915/gem_ctx_isolation.c +9 -9
@@ -629,7 +629,7 @@ static void nonpriv(int fd,tmpl_regs (fd, ctx, e, tmpl, values[v]); - spin = igt_spin_new(fd, .ctx = ctx, .engine = e->flags); + spin = igt_spin_new(fd, .ctx_id = ctx, .engine = e->flags);igt_debug ("%s[%d]: Setting all registers to 0x%08x\n" , __func__, v, values[v]);
@@ -641,12 +641,12 @@ static void nonpriv(int fd,/* Explicit sync to keep the switch between write/read */ syncpt = igt_spin_new(fd, - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags, .flags =IGT_SPIN_FENCE_OUT ); dirt = igt_spin_new(fd, - .ctx = sw, + .ctx_id = sw, .engine = e->flags, .fence = syncpt->out_fence, .flags = (IGT_SPIN_FENCE_IN |
@@ -654,7 +654,7 @@ static void nonpriv(int fd,igt_spin_free (fd, syncpt); syncpt = igt_spin_new(fd, - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags, .fence = dirt->out_fence, .flags =IGT_SPIN_FENCE_IN );
@@ -708,7 +708,7 @@ static void isolation(int fd, ctx[0 ] =gem_context_clone_with_engines (fd,0 ); regs[0 ] =read_regs (fd, ctx[0 ], e, flags); - spin = igt_spin_new(fd, .ctx = ctx[0], .engine = e->flags); + spin = igt_spin_new(fd, .ctx_id = ctx[0], .engine = e->flags);if (flags &DIRTY1 ) { igt_debug("%s[%d]: Setting all registers of ctx 0 to 0x%08x\n",
@@ -776,7 +776,7 @@ static uint32_t create_reset_context(int i915)static void inject_reset_context (int fd,const struct intel_execution_engine2 *e) {struct igt_spin_factory opts = { - .ctx =create_reset_context (fd), + .ctx_id =create_reset_context (fd), .engine = e->flags, .flags =IGT_SPIN_FAST , };
@@ -801,7 +801,7 @@ static void inject_reset_context(int fd, const struct intel_execution_engine2 *eigt_force_gpu_reset (fd);igt_spin_free (fd, spin); -gem_context_destroy (fd, opts.ctx); +gem_context_destroy (fd, opts.ctx_id); } static void preservation(int fd,
@@ -825,7 +825,7 @@ static void preservation(int fd,gem_quiescent_gpu (fd); ctx[num_values] =gem_context_clone_with_engines (fd,0 ); - spin = igt_spin_new(fd, .ctx = ctx[num_values], .engine = e->flags); + spin = igt_spin_new(fd, .ctx_id = ctx[num_values], .engine = e->flags); regs[num_values][0 ] =read_regs (fd, ctx[num_values], e, flags);for (int v =0 ; v < num_values; v++) { ctx[v] =gem_context_clone_with_engines (fd,0 );
@@ -865,7 +865,7 @@ static void preservation(int fd,break ; } - spin = igt_spin_new(fd, .ctx = ctx[num_values], .engine = e->flags); + spin = igt_spin_new(fd, .ctx_id = ctx[num_values], .engine = e->flags);for (int v =0 ; v < num_values; v++) regs[v][1 ] =read_regs (fd, ctx[v], e, flags); regs[num_values][1 ] =read_regs (fd, ctx[num_values], e, flags);
tests/i915/gem_ctx_shared.c +8 -8
@@ -124,8 +124,8 @@ static void disjoint_timelines(int i915) child =gem_context_clone (i915,0 ,I915_CONTEXT_CLONE_VM ,0 ); plug =igt_cork_plug (&cork, i915); - spin[0] = __igt_spin_new(i915, .ctx = 0, .dependency = plug); - spin[1] = __igt_spin_new(i915, .ctx = child); + spin[0] = __igt_spin_new(i915, .ctx_id = 0, .dependency = plug); + spin[1] = __igt_spin_new(i915, .ctx_id = child);/* Wait for the second spinner, will hang if stuck behind the first */ igt_spin_end (spin[1 ]);
@@ -388,7 +388,7 @@ static void exec_single_timeline(int i915, unsigned int engine)continue ;if (spin ==NULL ) { - spin = __igt_spin_new(i915, .ctx = ctx, .engine = e->flags); + spin = __igt_spin_new(i915, .ctx_id = ctx, .engine = e->flags); }else {struct drm_i915_gem_execbuffer2 execbuf = { .buffers_ptr = spin->execbuf.buffers_ptr,
@@ -416,7 +416,7 @@ static void exec_single_timeline(int i915, unsigned int engine)continue ;if (spin ==NULL ) { - spin = __igt_spin_new(i915, .ctx = ctx, .engine = e->flags); + spin = __igt_spin_new(i915, .ctx_id = ctx, .engine = e->flags); }else {struct drm_i915_gem_execbuffer2 execbuf = { .buffers_ptr = spin->execbuf.buffers_ptr,
@@ -510,11 +510,11 @@ static void unplug_show_queue(int i915, struct igt_cork *c, unsigned int engine)for (int n =0 ; n <ARRAY_SIZE (spin); n++) {const struct igt_spin_factory opts = { - .ctx =create_highest_priority (i915), + .ctx_id =create_highest_priority (i915), .engine = engine, }; spin[n] =__igt_spin_factory (i915, &opts); -gem_context_destroy (i915, opts.ctx); +gem_context_destroy (i915, opts.ctx_id); }igt_cork_unplug (c);/* batches will now be queued on the engine */
@@ -592,11 +592,11 @@ static void independent(int i915,for (int n =0 ; n <ARRAY_SIZE (spin); n++) {const struct igt_spin_factory opts = { - .ctx =create_highest_priority (i915), + .ctx_id =create_highest_priority (i915), .engine = e->flags, }; spin[n] =__igt_spin_factory (i915, &opts); -gem_context_destroy (i915, opts.ctx); +gem_context_destroy (i915, opts.ctx_id); } fence =igt_cork_plug (&cork, i915);
tests/i915/gem_eio.c +1 -1
@@ -176,7 +176,7 @@ static int __gem_wait(int fd, uint32_t handle, int64_t timeout)static igt_spin_t *__spin_poll (int fd,uint32_t ctx,unsigned long flags) {struct igt_spin_factory opts = { - .ctx = ctx, + .ctx_id = ctx, .engine = flags, .flags =IGT_SPIN_NO_PREEMPTION |IGT_SPIN_FENCE_OUT , };
tests/i915/gem_exec_balancer.c +13 -13
@@ -530,7 +530,7 @@ static void check_individual_engine(int i915,I915_PMU_ENGINE_BUSY (ci[idx].engine_class, ci[idx].engine_instance)); - spin = igt_spin_new(i915, .ctx = ctx, .engine = idx + 1); + spin = igt_spin_new(i915, .ctx_id = ctx, .engine = idx + 1); load =measure_load (pmu,10000 );igt_spin_free (i915, spin);
@@ -659,13 +659,13 @@ static void bonded(int i915, unsigned int flags) plug =NULL ;if (flags &CORK ) { plug = __igt_spin_new(i915, - .ctx = master, + .ctx_id = master, .engine = bond, .dependency =igt_cork_plug (&cork, i915)); } spin = __igt_spin_new(i915, - .ctx = master, + .ctx_id = master, .engine = bond, .flags =IGT_SPIN_FENCE_OUT );
@@ -806,7 +806,7 @@ static void bonded_slice(int i915)set_load_balancer (i915, ctx, siblings, count,NULL ); spin = __igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .flags = (IGT_SPIN_NO_PREEMPTION |IGT_SPIN_POLL_RUN ));igt_spin_end (spin);/* we just want its address for later */
@@ -831,7 +831,7 @@ static void bonded_slice(int i915)while (!READ_ONCE (*stop)) { spin = igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = (1 + rand() % count), .flags =IGT_SPIN_POLL_RUN );igt_spin_busywait_until_started (spin);
@@ -892,7 +892,7 @@ static void __bonded_chain(int i915, uint32_t ctx,if (priorities[i] <0 )gem_context_set_priority (i915, ctx, priorities[i]); spin = igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = 1, .flags = (IGT_SPIN_POLL_RUN |IGT_SPIN_FENCE_OUT ));
@@ -971,7 +971,7 @@ static void __bonded_chain_inv(int i915, uint32_t ctx,if (priorities[i] <0 )gem_context_set_priority (i915, ctx, priorities[i]); spin = igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = 1, .flags = (IGT_SPIN_POLL_RUN |IGT_SPIN_FENCE_OUT ));
@@ -1838,7 +1838,7 @@ static void __bonded_early(int i915, uint32_t ctx,/* A: spin forever on engine 1 */ spin = igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = (flags & VIRTUAL_ENGINE) ? 0 : 1, .flags =IGT_SPIN_NO_PREEMPTION );
@@ -1953,10 +1953,10 @@ static void busy(int i915)free (ci); spin[0] = __igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .flags =IGT_SPIN_POLL_RUN ); spin[1] = __igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .dependency = scratch);igt_spin_busywait_until_started (spin[0 ]);
@@ -2055,7 +2055,7 @@ static void full(int i915, unsigned int flags) ctx =load_balancer_create (i915, ci, count);if (spin ==NULL ) { - spin = __igt_spin_new(i915, .ctx = ctx); + spin = __igt_spin_new(i915, .ctx_id = ctx); }else {struct drm_i915_gem_execbuffer2 eb = { .buffers_ptr = spin->execbuf.buffers_ptr,
@@ -2602,7 +2602,7 @@ static void semaphore(int i915)for (int i =0 ; i < count; i++) {set_load_balancer (i915, block[i], ci, count,NULL ); spin[i] = __igt_spin_new(i915, - .ctx = block[i], + .ctx_id = block[i], .dependency = scratch); }
@@ -2919,7 +2919,7 @@ static void __fairslice(int i915,for (int i =0 ; i <ARRAY_SIZE (ctx); i++) { ctx[i] =load_balancer_create (i915, ci, count);if (spin ==NULL ) { - spin = __igt_spin_new(i915, .ctx = ctx[i]); + spin = __igt_spin_new(i915, .ctx_id = ctx[i]); }else {struct drm_i915_gem_execbuffer2 eb = { .buffer_count = 1,
tests/i915/gem_exec_latency.c +1 -1
@@ -318,7 +318,7 @@ static void latency_from_ring(int fd,if (flags &PREEMPT ) spin = __igt_spin_new(fd, - .ctx = ctx[0], + .ctx_id = ctx[0], .engine = e->flags);if (flags &CORK ) {
tests/i915/gem_exec_nop.c +1 -1
@@ -917,7 +917,7 @@ static void preempt(int fd, uint32_t handle,intel_detect_and_clear_missed_interrupts (fd); count =0 ; - spin = __igt_spin_new(fd, .ctx = ctx[0], .engine = e->flags); + spin = __igt_spin_new(fd, .ctx_id = ctx[0], .engine = e->flags);clock_gettime (CLOCK_MONOTONIC , &start); do { gem_execbuf(fd, &execbuf);
tests/i915/gem_exec_schedule.c +13 -13
@@ -205,11 +205,11 @@ static void unplug_show_queue(int fd, struct igt_cork *c, unsigned int engine)for (int n =0 ; n < max; n++) {const struct igt_spin_factory opts = { - .ctx =create_highest_priority (fd), + .ctx_id =create_highest_priority (fd), .engine = engine, }; spin[n] =__igt_spin_factory (fd, &opts); -gem_context_destroy (fd, opts.ctx); +gem_context_destroy (fd, opts.ctx_id); }igt_cork_unplug (c);/* batches will now be queued on the engine */
@@ -639,7 +639,7 @@ static void lateslice(int i915, unsigned int engine, unsigned long flags)igt_require (intel_gen (intel_get_drm_devid (i915)) >=8 ); ctx =gem_context_create (i915); - spin[0] = igt_spin_new(i915, .ctx = ctx, .engine = engine, + spin[0] = igt_spin_new(i915, .ctx_id = ctx, .engine = engine, .flags = (IGT_SPIN_POLL_RUN |IGT_SPIN_FENCE_OUT | flags));
@@ -648,7 +648,7 @@ static void lateslice(int i915, unsigned int engine, unsigned long flags)igt_spin_busywait_until_started (spin[0 ]); ctx =gem_context_create (i915); - spin[1] = igt_spin_new(i915, .ctx = ctx, .engine = engine, + spin[1] = igt_spin_new(i915, .ctx_id = ctx, .engine = engine, .fence = spin[0]->out_fence, .flags = (IGT_SPIN_POLL_RUN | IGT_SPIN_FENCE_IN |
@@ -665,7 +665,7 @@ static void lateslice(int i915, unsigned int engine, unsigned long flags)*/ ctx =gem_context_create (i915); - spin[2] = igt_spin_new(i915, .ctx = ctx, .engine = engine, + spin[2] = igt_spin_new(i915, .ctx_id = ctx, .engine = engine, .flags =IGT_SPIN_POLL_RUN | flags);gem_context_destroy (i915, ctx);
@@ -765,7 +765,7 @@ static void submit_slice(int i915, engines.engines[0 ].engine_class = e->class; engines.engines[0 ].engine_instance = e->instance;gem_context_set_param (i915, ¶m); - spin = igt_spin_new(i915, .ctx = param.ctx_id, + spin = igt_spin_new(i915, .ctx_id = param.ctx_id, .fence = fence, .flags = IGT_SPIN_POLL_RUN |
@@ -909,7 +909,7 @@ static void semaphore_codependency(int i915, unsigned long flags) task[i].xcs = __igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags, .flags =IGT_SPIN_POLL_RUN | flags);igt_spin_busywait_until_started (task[i].xcs);
@@ -917,7 +917,7 @@ static void semaphore_codependency(int i915, unsigned long flags)/* Common rcs tasks will be queued in FIFO */ task[i].rcs = __igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = 0, .dependency = task[i].xcs->handle);
@@ -1403,7 +1403,7 @@ static void preempt(int fd, const struct intel_execution_engine2 *e, unsigned flgem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); } spin[n] = __igt_spin_new(fd, - .ctx = ctx[LO], + .ctx_id = ctx[LO], .engine = e->flags, .flags = flags &USERPTR ?IGT_SPIN_USERPTR :0 );igt_debug ("spin[%d].handle=%d\n" , n, spin[n]->handle);
@@ -1439,7 +1439,7 @@ static igt_spin_t *__noise(int fd, uint32_t ctx, int prio, igt_spin_t *spin)__for_each_physical_engine (fd, e) {if (spin ==NULL ) { spin = __igt_spin_new(fd, - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags); }else { struct drm_i915_gem_execbuffer2 eb = {
@@ -1718,7 +1718,7 @@ static void preempt_self(int fd, unsigned ring)gem_context_set_priority (fd, ctx[HI ],MIN_PRIO );__for_each_physical_engine (fd, e) { spin[n] = __igt_spin_new(fd, - .ctx = ctx[NOISE], + .ctx_id = ctx[NOISE], .engine = e->flags); store_dword(fd, ctx[HI], e->flags, result, (n + 1)*sizeof(uint32_t), n + 1,
@@ -1766,7 +1766,7 @@ static void preemptive_hang(int fd, const struct intel_execution_engine2 *e)gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); spin[n] = __igt_spin_new(fd, - .ctx = ctx[LO], + .ctx_id = ctx[LO], .engine = e->flags);gem_context_destroy (fd, ctx[LO ]);
@@ -2751,7 +2751,7 @@ static void fairslice(int i915, ctx[i] =gem_context_clone_with_engines (i915,0 );if (spin ==NULL ) { spin = __igt_spin_new(i915, - .ctx = ctx[i], + .ctx_id = ctx[i], .engine = e->flags, .flags = flags); }else {
tests/i915/gem_spin_batch.c +1 -1
@@ -145,7 +145,7 @@ static void spin_all(int i915, unsigned int flags)/* Prevent preemption so only one is allowed on each engine */ spin = igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags, .flags = (IGT_SPIN_POLL_RUN |IGT_SPIN_NO_PREEMPTION ));
tests/i915/gem_sync.c +1 -1
@@ -1109,7 +1109,7 @@ preempt(int fd, unsigned ring, int num_children, int timeout) do { igt_spin_t *spin = __igt_spin_new(fd, - .ctx = ctx[0], + .ctx_id = ctx[0], .engine = execbuf.flags); do {
tests/i915/gem_vm_create.c +2 -2
@@ -363,7 +363,7 @@ static void async_destroy(int i915)int err; spin[0] = igt_spin_new(i915, - .ctx = arg.ctx_id, + .ctx_id = arg.ctx_id, .flags =IGT_SPIN_POLL_RUN );igt_spin_busywait_until_started (spin[0 ]);
@@ -372,7 +372,7 @@ static void async_destroy(int i915) err =0 ;igt_assert_eq (err,0 ); - spin[1] = __igt_spin_new(i915, .ctx = arg.ctx_id); + spin[1] = __igt_spin_new(i915, .ctx_id = arg.ctx_id);igt_spin_end (spin[0 ]);gem_sync (i915, spin[0 ]->handle);
tests/i915/gem_watchdog.c +1 -1
@@ -305,7 +305,7 @@ static void virtual(int i915)set_load_balancer (i915, ctx[i], ci, count,NULL ); spin[i] = igt_spin_new(i915, - .ctx = ctx[i], + .ctx_id = ctx[i], .flags =spin_flags ()); i++; }
tests/i915/gem_workarounds.c +1 -1
@@ -135,7 +135,7 @@ static int workaround_fail_count(int i915, uint32_t ctx)gem_set_domain (i915, obj[0 ].handle,I915_GEM_DOMAIN_CPU ,0 ); - spin = igt_spin_new(i915, .ctx = ctx, .flags = IGT_SPIN_POLL_RUN); + spin = igt_spin_new(i915, .ctx_id = ctx, .flags = IGT_SPIN_POLL_RUN);igt_spin_busywait_until_started (spin); fw =igt_open_forcewake_handle (i915);
tests/i915/perf_pmu.c +2 -2
@@ -175,7 +175,7 @@ static igt_spin_t * __spin_poll(int fd, uint32_t ctx, const struct intel_execution_engine2 *e) {struct igt_spin_factory opts = { - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags, };
@@ -381,7 +381,7 @@ busy_double_start(int gem_fd, const struct intel_execution_engine2 *e) spin[0 ] =__spin_sync (gem_fd,0 , e);usleep (500e3 ); spin[1] = __igt_spin_new(gem_fd, - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags);/*
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 16/89] lib/dummyload: Rename igt_spin_factory::ctx to ctx_id
Quoted 649 lines · Jason Ekstrand
Signed-off-by Jason Ekstrand <[email protected]>Acked-by Daniel Vetter <[email protected]>--- lib/igt_dummyload.c | 6 +++--- lib/igt_dummyload.h | 4 ++-- lib/igt_gt.c | 2 +- tests/i915/gem_ctx_engines.c | 6 +++--- tests/i915/gem_ctx_exec.c | 2 +- tests/i915/gem_ctx_isolation.c | 18 +++++++++--------- tests/i915/gem_ctx_shared.c | 16 ++++++++-------- tests/i915/gem_eio.c | 2 +- tests/i915/gem_exec_balancer.c | 26 +++++++++++++------------- tests/i915/gem_exec_latency.c | 2 +- tests/i915/gem_exec_nop.c | 2 +- tests/i915/gem_exec_schedule.c | 26 +++++++++++++------------- tests/i915/gem_spin_batch.c | 2 +- tests/i915/gem_sync.c | 2 +- tests/i915/gem_vm_create.c | 4 ++-- tests/i915/gem_watchdog.c | 2 +- tests/i915/gem_workarounds.c | 2 +- tests/i915/perf_pmu.c | 4 ++-- 18 files changed, 64 insertions(+), 64 deletions(-)lib/igt_dummyload.c +3
-3@@ -127,7 +127,7 @@ emit_recursive_batch(igt_spin_t *spin,if (opts->engine ==ALL_ENGINES ) {struct intel_execution_engine2 *engine; -for_each_context_engine (fd, opts->ctx, engine) { +for_each_context_engine (fd, opts->ctx_id, engine) {if (opts->flags &IGT_SPIN_POLL_RUN && !gem_class_can_store_dword (fd, engine->class))continue ;@@ -325,7 +325,7 @@ emit_recursive_batch(igt_spin_t *spin, execbuf->buffers_ptr =to_user_pointer (obj + (2 - execbuf->buffer_count)); - execbuf->rsvd1 = opts->ctx; + execbuf->rsvd1 = opts->ctx_id;if (opts->flags &IGT_SPIN_FENCE_OUT ) execbuf->flags |=I915_EXEC_FENCE_OUT ;@@ -423,7 +423,7 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts)int class;if (!gem_context_lookup_engine (fd, opts->engine, - opts->ctx, &e)) { + opts->ctx_id, &e)) { class = e.class; }else {gem_require_ring (fd, opts->engine);lib/igt_dummyload.h +2
-2@@ -61,7 +61,7 @@ typedef struct igt_spin {/** * igt_spin_factory_t: -* @ctx: GEM context handle +* @ctx_id: GEM context handle * @dependency: GEM object to depend on * @engine: Flags describing the engine to execute on * @flags: Set of IGT_SPIN_* flags @@ -70,7 +70,7 @@ typedef struct igt_spin {* A factory struct which contains creation parameters for an igt_spin_t. */ typedef struct igt_spin_factory { - uint32_t ctx; + uint32_t ctx_id; uint32_t dependency; unsigned int engine; unsigned int flags;lib/igt_gt.c +1
-1@@ -298,7 +298,7 @@ igt_hang_t igt_hang_ctx(int fd, uint32_t ctx, int ring, unsigned flags)context_set_ban (fd, ctx,0 ); spin = __igt_spin_new(fd, - .ctx = ctx, + .ctx_id = ctx, .engine = ring, .flags =IGT_SPIN_NO_PREEMPTION );tests/i915/gem_ctx_engines.c +3
-3@@ -336,7 +336,7 @@ static void execute_one(int i915)igt_spin_t *spin;/* Prewarm the spinner */ - spin = igt_spin_new(i915, .ctx = param.ctx_id, + spin = igt_spin_new(i915, .ctx_id = param.ctx_id, .flags = (IGT_SPIN_NO_PREEMPTION |IGT_SPIN_POLL_RUN ));@@ -439,7 +439,7 @@ static void execute_oneforall(int i915)igt_spin_t *spin; spin = __igt_spin_new(i915, - .ctx = param.ctx_id, + .ctx_id = param.ctx_id, .engine = i); busy.handle = spin->handle;@@ -480,7 +480,7 @@ static void execute_allforone(int i915)igt_spin_t *spin; spin = __igt_spin_new(i915, - .ctx = param.ctx_id, + .ctx_id = param.ctx_id, .engine = i++); busy.handle = spin->handle;tests/i915/gem_ctx_exec.c +1
-1@@ -184,7 +184,7 @@ static void norecovery(int i915)igt_assert_eq (param.value, pass); spin = __igt_spin_new(i915, - .ctx = param.ctx_id, + .ctx_id = param.ctx_id, .flags =IGT_SPIN_POLL_RUN );igt_spin_busywait_until_started (spin);tests/i915/gem_ctx_isolation.c +9
-9@@ -629,7 +629,7 @@ static void nonpriv(int fd,tmpl_regs (fd, ctx, e, tmpl, values[v]); - spin = igt_spin_new(fd, .ctx = ctx, .engine = e->flags); + spin = igt_spin_new(fd, .ctx_id = ctx, .engine = e->flags);igt_debug ("%s[%d]: Setting all registers to 0x%08x\n" , __func__, v, values[v]);@@ -641,12 +641,12 @@ static void nonpriv(int fd,/* Explicit sync to keep the switch between write/read */ syncpt = igt_spin_new(fd, - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags, .flags =IGT_SPIN_FENCE_OUT ); dirt = igt_spin_new(fd, - .ctx = sw, + .ctx_id = sw, .engine = e->flags, .fence = syncpt->out_fence, .flags = (IGT_SPIN_FENCE_IN |@@ -654,7 +654,7 @@ static void nonpriv(int fd,igt_spin_free (fd, syncpt); syncpt = igt_spin_new(fd, - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags, .fence = dirt->out_fence, .flags =IGT_SPIN_FENCE_IN );@@ -708,7 +708,7 @@ static void isolation(int fd, ctx[0 ] =gem_context_clone_with_engines (fd,0 ); regs[0 ] =read_regs (fd, ctx[0 ], e, flags); - spin = igt_spin_new(fd, .ctx = ctx[0], .engine = e->flags); + spin = igt_spin_new(fd, .ctx_id = ctx[0], .engine = e->flags);if (flags &DIRTY1 ) { igt_debug("%s[%d]: Setting all registers of ctx 0 to 0x%08x\n",@@ -776,7 +776,7 @@ static uint32_t create_reset_context(int i915)static void inject_reset_context (int fd,const struct intel_execution_engine2 *e) {struct igt_spin_factory opts = { - .ctx =create_reset_context (fd), + .ctx_id =create_reset_context (fd), .engine = e->flags, .flags =IGT_SPIN_FAST , };@@ -801,7 +801,7 @@ static void inject_reset_context(int fd, const struct intel_execution_engine2 *eigt_force_gpu_reset (fd);igt_spin_free (fd, spin); -gem_context_destroy (fd, opts.ctx); +gem_context_destroy (fd, opts.ctx_id); } static void preservation(int fd,@@ -825,7 +825,7 @@ static void preservation(int fd,gem_quiescent_gpu (fd); ctx[num_values] =gem_context_clone_with_engines (fd,0 ); - spin = igt_spin_new(fd, .ctx = ctx[num_values], .engine = e->flags); + spin = igt_spin_new(fd, .ctx_id = ctx[num_values], .engine = e->flags); regs[num_values][0 ] =read_regs (fd, ctx[num_values], e, flags);for (int v =0 ; v < num_values; v++) { ctx[v] =gem_context_clone_with_engines (fd,0 );@@ -865,7 +865,7 @@ static void preservation(int fd,break ; } - spin = igt_spin_new(fd, .ctx = ctx[num_values], .engine = e->flags); + spin = igt_spin_new(fd, .ctx_id = ctx[num_values], .engine = e->flags);for (int v =0 ; v < num_values; v++) regs[v][1 ] =read_regs (fd, ctx[v], e, flags); regs[num_values][1 ] =read_regs (fd, ctx[num_values], e, flags);tests/i915/gem_ctx_shared.c +8
-8@@ -124,8 +124,8 @@ static void disjoint_timelines(int i915) child =gem_context_clone (i915,0 ,I915_CONTEXT_CLONE_VM ,0 ); plug =igt_cork_plug (&cork, i915); - spin[0] = __igt_spin_new(i915, .ctx = 0, .dependency = plug); - spin[1] = __igt_spin_new(i915, .ctx = child); + spin[0] = __igt_spin_new(i915, .ctx_id = 0, .dependency = plug); + spin[1] = __igt_spin_new(i915, .ctx_id = child);/* Wait for the second spinner, will hang if stuck behind the first */ igt_spin_end (spin[1 ]);@@ -388,7 +388,7 @@ static void exec_single_timeline(int i915, unsigned int engine)continue ;if (spin ==NULL ) { - spin = __igt_spin_new(i915, .ctx = ctx, .engine = e->flags); + spin = __igt_spin_new(i915, .ctx_id = ctx, .engine = e->flags); }else {struct drm_i915_gem_execbuffer2 execbuf = { .buffers_ptr = spin->execbuf.buffers_ptr,@@ -416,7 +416,7 @@ static void exec_single_timeline(int i915, unsigned int engine)continue ;if (spin ==NULL ) { - spin = __igt_spin_new(i915, .ctx = ctx, .engine = e->flags); + spin = __igt_spin_new(i915, .ctx_id = ctx, .engine = e->flags); }else {struct drm_i915_gem_execbuffer2 execbuf = { .buffers_ptr = spin->execbuf.buffers_ptr,@@ -510,11 +510,11 @@ static void unplug_show_queue(int i915, struct igt_cork *c, unsigned int engine)for (int n =0 ; n <ARRAY_SIZE (spin); n++) {const struct igt_spin_factory opts = { - .ctx =create_highest_priority (i915), + .ctx_id =create_highest_priority (i915), .engine = engine, }; spin[n] =__igt_spin_factory (i915, &opts); -gem_context_destroy (i915, opts.ctx); +gem_context_destroy (i915, opts.ctx_id); }igt_cork_unplug (c);/* batches will now be queued on the engine */ @@ -592,11 +592,11 @@ static void independent(int i915,for (int n =0 ; n <ARRAY_SIZE (spin); n++) {const struct igt_spin_factory opts = { - .ctx =create_highest_priority (i915), + .ctx_id =create_highest_priority (i915), .engine = e->flags, }; spin[n] =__igt_spin_factory (i915, &opts); -gem_context_destroy (i915, opts.ctx); +gem_context_destroy (i915, opts.ctx_id); } fence =igt_cork_plug (&cork, i915);tests/i915/gem_eio.c +1
-1@@ -176,7 +176,7 @@ static int __gem_wait(int fd, uint32_t handle, int64_t timeout)static igt_spin_t *__spin_poll (int fd,uint32_t ctx,unsigned long flags) {struct igt_spin_factory opts = { - .ctx = ctx, + .ctx_id = ctx, .engine = flags, .flags =IGT_SPIN_NO_PREEMPTION |IGT_SPIN_FENCE_OUT , };tests/i915/gem_exec_balancer.c +13
-13@@ -530,7 +530,7 @@ static void check_individual_engine(int i915,I915_PMU_ENGINE_BUSY (ci[idx].engine_class, ci[idx].engine_instance)); - spin = igt_spin_new(i915, .ctx = ctx, .engine = idx + 1); + spin = igt_spin_new(i915, .ctx_id = ctx, .engine = idx + 1); load =measure_load (pmu,10000 );igt_spin_free (i915, spin);@@ -659,13 +659,13 @@ static void bonded(int i915, unsigned int flags) plug =NULL ;if (flags &CORK ) { plug = __igt_spin_new(i915, - .ctx = master, + .ctx_id = master, .engine = bond, .dependency =igt_cork_plug (&cork, i915)); } spin = __igt_spin_new(i915, - .ctx = master, + .ctx_id = master, .engine = bond, .flags =IGT_SPIN_FENCE_OUT );@@ -806,7 +806,7 @@ static void bonded_slice(int i915)set_load_balancer (i915, ctx, siblings, count,NULL ); spin = __igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .flags = (IGT_SPIN_NO_PREEMPTION |IGT_SPIN_POLL_RUN ));igt_spin_end (spin);/* we just want its address for later */ @@ -831,7 +831,7 @@ static void bonded_slice(int i915)while (!READ_ONCE (*stop)) { spin = igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = (1 + rand() % count), .flags =IGT_SPIN_POLL_RUN );igt_spin_busywait_until_started (spin);@@ -892,7 +892,7 @@ static void __bonded_chain(int i915, uint32_t ctx,if (priorities[i] <0 )gem_context_set_priority (i915, ctx, priorities[i]); spin = igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = 1, .flags = (IGT_SPIN_POLL_RUN |IGT_SPIN_FENCE_OUT ));@@ -971,7 +971,7 @@ static void __bonded_chain_inv(int i915, uint32_t ctx,if (priorities[i] <0 )gem_context_set_priority (i915, ctx, priorities[i]); spin = igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = 1, .flags = (IGT_SPIN_POLL_RUN |IGT_SPIN_FENCE_OUT ));@@ -1838,7 +1838,7 @@ static void __bonded_early(int i915, uint32_t ctx,/* A: spin forever on engine 1 */ spin = igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = (flags & VIRTUAL_ENGINE) ? 0 : 1, .flags =IGT_SPIN_NO_PREEMPTION );@@ -1953,10 +1953,10 @@ static void busy(int i915)free (ci); spin[0] = __igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .flags =IGT_SPIN_POLL_RUN ); spin[1] = __igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .dependency = scratch);igt_spin_busywait_until_started (spin[0 ]);@@ -2055,7 +2055,7 @@ static void full(int i915, unsigned int flags) ctx =load_balancer_create (i915, ci, count);if (spin ==NULL ) { - spin = __igt_spin_new(i915, .ctx = ctx); + spin = __igt_spin_new(i915, .ctx_id = ctx); }else {struct drm_i915_gem_execbuffer2 eb = { .buffers_ptr = spin->execbuf.buffers_ptr,@@ -2602,7 +2602,7 @@ static void semaphore(int i915)for (int i =0 ; i < count; i++) {set_load_balancer (i915, block[i], ci, count,NULL ); spin[i] = __igt_spin_new(i915, - .ctx = block[i], + .ctx_id = block[i], .dependency = scratch); }@@ -2919,7 +2919,7 @@ static void __fairslice(int i915,for (int i =0 ; i <ARRAY_SIZE (ctx); i++) { ctx[i] =load_balancer_create (i915, ci, count);if (spin ==NULL ) { - spin = __igt_spin_new(i915, .ctx = ctx[i]); + spin = __igt_spin_new(i915, .ctx_id = ctx[i]); }else {struct drm_i915_gem_execbuffer2 eb = { .buffer_count = 1,tests/i915/gem_exec_latency.c +1
-1@@ -318,7 +318,7 @@ static void latency_from_ring(int fd,if (flags &PREEMPT ) spin = __igt_spin_new(fd, - .ctx = ctx[0], + .ctx_id = ctx[0], .engine = e->flags);if (flags &CORK ) {tests/i915/gem_exec_nop.c +1
-1@@ -917,7 +917,7 @@ static void preempt(int fd, uint32_t handle,intel_detect_and_clear_missed_interrupts (fd); count =0 ; - spin = __igt_spin_new(fd, .ctx = ctx[0], .engine = e->flags); + spin = __igt_spin_new(fd, .ctx_id = ctx[0], .engine = e->flags);clock_gettime (CLOCK_MONOTONIC , &start); do { gem_execbuf(fd, &execbuf);tests/i915/gem_exec_schedule.c +13
-13@@ -205,11 +205,11 @@ static void unplug_show_queue(int fd, struct igt_cork *c, unsigned int engine)for (int n =0 ; n < max; n++) {const struct igt_spin_factory opts = { - .ctx =create_highest_priority (fd), + .ctx_id =create_highest_priority (fd), .engine = engine, }; spin[n] =__igt_spin_factory (fd, &opts); -gem_context_destroy (fd, opts.ctx); +gem_context_destroy (fd, opts.ctx_id); }igt_cork_unplug (c);/* batches will now be queued on the engine */ @@ -639,7 +639,7 @@ static void lateslice(int i915, unsigned int engine, unsigned long flags)igt_require (intel_gen (intel_get_drm_devid (i915)) >=8 ); ctx =gem_context_create (i915); - spin[0] = igt_spin_new(i915, .ctx = ctx, .engine = engine, + spin[0] = igt_spin_new(i915, .ctx_id = ctx, .engine = engine, .flags = (IGT_SPIN_POLL_RUN |IGT_SPIN_FENCE_OUT | flags));@@ -648,7 +648,7 @@ static void lateslice(int i915, unsigned int engine, unsigned long flags)igt_spin_busywait_until_started (spin[0 ]); ctx =gem_context_create (i915); - spin[1] = igt_spin_new(i915, .ctx = ctx, .engine = engine, + spin[1] = igt_spin_new(i915, .ctx_id = ctx, .engine = engine, .fence = spin[0]->out_fence, .flags = (IGT_SPIN_POLL_RUN | IGT_SPIN_FENCE_IN |@@ -665,7 +665,7 @@ static void lateslice(int i915, unsigned int engine, unsigned long flags)*/ ctx =gem_context_create (i915); - spin[2] = igt_spin_new(i915, .ctx = ctx, .engine = engine, + spin[2] = igt_spin_new(i915, .ctx_id = ctx, .engine = engine, .flags =IGT_SPIN_POLL_RUN | flags);gem_context_destroy (i915, ctx);@@ -765,7 +765,7 @@ static void submit_slice(int i915, engines.engines[0 ].engine_class = e->class; engines.engines[0 ].engine_instance = e->instance;gem_context_set_param (i915, ¶m); - spin = igt_spin_new(i915, .ctx = param.ctx_id, + spin = igt_spin_new(i915, .ctx_id = param.ctx_id, .fence = fence, .flags = IGT_SPIN_POLL_RUN |@@ -909,7 +909,7 @@ static void semaphore_codependency(int i915, unsigned long flags) task[i].xcs = __igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags, .flags =IGT_SPIN_POLL_RUN | flags);igt_spin_busywait_until_started (task[i].xcs);@@ -917,7 +917,7 @@ static void semaphore_codependency(int i915, unsigned long flags)/* Common rcs tasks will be queued in FIFO */ task[i].rcs = __igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = 0, .dependency = task[i].xcs->handle);@@ -1403,7 +1403,7 @@ static void preempt(int fd, const struct intel_execution_engine2 *e, unsigned flgem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); } spin[n] = __igt_spin_new(fd, - .ctx = ctx[LO], + .ctx_id = ctx[LO], .engine = e->flags, .flags = flags &USERPTR ?IGT_SPIN_USERPTR :0 );igt_debug ("spin[%d].handle=%d\n" , n, spin[n]->handle);@@ -1439,7 +1439,7 @@ static igt_spin_t *__noise(int fd, uint32_t ctx, int prio, igt_spin_t *spin)__for_each_physical_engine (fd, e) {if (spin ==NULL ) { spin = __igt_spin_new(fd, - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags); }else { struct drm_i915_gem_execbuffer2 eb = {@@ -1718,7 +1718,7 @@ static void preempt_self(int fd, unsigned ring)gem_context_set_priority (fd, ctx[HI ],MIN_PRIO );__for_each_physical_engine (fd, e) { spin[n] = __igt_spin_new(fd, - .ctx = ctx[NOISE], + .ctx_id = ctx[NOISE], .engine = e->flags); store_dword(fd, ctx[HI], e->flags, result, (n + 1)*sizeof(uint32_t), n + 1,@@ -1766,7 +1766,7 @@ static void preemptive_hang(int fd, const struct intel_execution_engine2 *e)gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); spin[n] = __igt_spin_new(fd, - .ctx = ctx[LO], + .ctx_id = ctx[LO], .engine = e->flags);gem_context_destroy (fd, ctx[LO ]);@@ -2751,7 +2751,7 @@ static void fairslice(int i915, ctx[i] =gem_context_clone_with_engines (i915,0 );if (spin ==NULL ) { spin = __igt_spin_new(i915, - .ctx = ctx[i], + .ctx_id = ctx[i], .engine = e->flags, .flags = flags); }else {tests/i915/gem_spin_batch.c +1
-1@@ -145,7 +145,7 @@ static void spin_all(int i915, unsigned int flags)/* Prevent preemption so only one is allowed on each engine */ spin = igt_spin_new(i915, - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags, .flags = (IGT_SPIN_POLL_RUN |IGT_SPIN_NO_PREEMPTION ));tests/i915/gem_sync.c +1
-1@@ -1109,7 +1109,7 @@ preempt(int fd, unsigned ring, int num_children, int timeout) do { igt_spin_t *spin = __igt_spin_new(fd, - .ctx = ctx[0], + .ctx_id = ctx[0], .engine = execbuf.flags); do {tests/i915/gem_vm_create.c +2
-2@@ -363,7 +363,7 @@ static void async_destroy(int i915)int err; spin[0] = igt_spin_new(i915, - .ctx = arg.ctx_id, + .ctx_id = arg.ctx_id, .flags =IGT_SPIN_POLL_RUN );igt_spin_busywait_until_started (spin[0 ]);@@ -372,7 +372,7 @@ static void async_destroy(int i915) err =0 ;igt_assert_eq (err,0 ); - spin[1] = __igt_spin_new(i915, .ctx = arg.ctx_id); + spin[1] = __igt_spin_new(i915, .ctx_id = arg.ctx_id);igt_spin_end (spin[0 ]);gem_sync (i915, spin[0 ]->handle);tests/i915/gem_watchdog.c +1
-1@@ -305,7 +305,7 @@ static void virtual(int i915)set_load_balancer (i915, ctx[i], ci, count,NULL ); spin[i] = igt_spin_new(i915, - .ctx = ctx[i], + .ctx_id = ctx[i], .flags =spin_flags ()); i++; }tests/i915/gem_workarounds.c +1
-1@@ -135,7 +135,7 @@ static int workaround_fail_count(int i915, uint32_t ctx)gem_set_domain (i915, obj[0 ].handle,I915_GEM_DOMAIN_CPU ,0 ); - spin = igt_spin_new(i915, .ctx = ctx, .flags = IGT_SPIN_POLL_RUN); + spin = igt_spin_new(i915, .ctx_id = ctx, .flags = IGT_SPIN_POLL_RUN);igt_spin_busywait_until_started (spin); fw =igt_open_forcewake_handle (i915);tests/i915/perf_pmu.c +2
-2@@ -175,7 +175,7 @@ static igt_spin_t * __spin_poll(int fd, uint32_t ctx, const struct intel_execution_engine2 *e) {struct igt_spin_factory opts = { - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags, };@@ -381,7 +381,7 @@ busy_double_start(int gem_fd, const struct intel_execution_engine2 *e) spin[0 ] =__spin_sync (gem_fd,0 , e);usleep (500e3 ); spin[1] = __igt_spin_new(gem_fd, - .ctx = ctx, + .ctx_id = ctx, .engine = e->flags);/* Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
--
Zbigniew
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 17/89 lib/dummyload: Support intel_ctx_t
In reply to Jason Ekstrand--- lib/igt_dummyload.c | 30 ++++++++++++++++++++++-------- lib/igt_dummyload.h | 4 ++++ 2 files changed, 26 insertions(+), 8 deletions(-)
lib/igt_dummyload.c +22 -8
@@ -123,16 +123,28 @@ emit_recursive_batch(igt_spin_t *spin, addr +=random () % addr /2 ; addr &=-4096 ; +assert (!(opts->ctx && opts->ctx_id)); + nengine =0 ;if (opts->engine ==ALL_ENGINES ) {struct intel_execution_engine2 *engine; -for_each_context_engine (fd, opts->ctx_id, engine) { -if (opts->flags &IGT_SPIN_POLL_RUN && - !gem_class_can_store_dword (fd, engine->class)) -continue ; +if (opts->ctx) { +for_each_ctx_engine (fd, opts->ctx, engine) { +if (opts->flags &IGT_SPIN_POLL_RUN && + !gem_class_can_store_dword (fd, engine->class)) +continue ; - flags[nengine++] = engine->flags; + flags[nengine++] = engine->flags; + } + }else { +for_each_context_engine (fd, opts->ctx_id, engine) { +if (opts->flags &IGT_SPIN_POLL_RUN && + !gem_class_can_store_dword (fd, engine->class)) +continue ; + + flags[nengine++] = engine->flags; + } } }else { flags[nengine++] = opts->engine;
@@ -325,7 +337,7 @@ emit_recursive_batch(igt_spin_t *spin, execbuf->buffers_ptr =to_user_pointer (obj + (2 - execbuf->buffer_count)); - execbuf->rsvd1 = opts->ctx_id; + execbuf->rsvd1 = opts->ctx ? opts->ctx->id : opts->ctx_id;if (opts->flags &IGT_SPIN_FENCE_OUT ) execbuf->flags |=I915_EXEC_FENCE_OUT ;
@@ -422,8 +434,10 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts)struct intel_execution_engine2 e;int class; -if (!gem_context_lookup_engine (fd, opts->engine, - opts->ctx_id, &e)) { +if (opts->ctx) { + class = opts->ctx->cfg.engines[opts->engine].engine_class; + }else if (!gem_context_lookup_engine (fd, opts->engine, + opts->ctx_id, &e)) { class = e.class; }else {gem_require_ring (fd, opts->engine);
lib/igt_dummyload.h +4 -0
@@ -31,10 +31,12 @@#include "igt_core.h" #include "igt_list.h" #include "i915_drm.h" +#include "intel_ctx.h" typedef struct igt_spin { struct igt_list_head link; + uint32_t handle; uint32_t poll_handle;
@@ -62,6 +64,7 @@ typedef struct igt_spin {/** * igt_spin_factory_t: * @ctx_id: GEM context handle +* @ctx: intel_ctx_t context wrapper * @dependency: GEM object to depend on * @engine: Flags describing the engine to execute on * @flags: Set of IGT_SPIN_* flags
@@ -71,6 +74,7 @@ typedef struct igt_spin {*/ typedef struct igt_spin_factory { uint32_t ctx_id; + const intel_ctx_t *ctx; uint32_t dependency; unsigned int engine; unsigned int flags;
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 17/89] lib/dummyload: Support intel_ctx_t
Quoted 11 lines · Jason Ekstrand
Signed-off-by Jason Ekstrand <[email protected]>--- lib/igt_dummyload.c | 30 ++++++++++++++++++++++-------- lib/igt_dummyload.h | 4 ++++ 2 files changed, 26 insertions(+), 8 deletions(-)lib/igt_dummyload.c +0
-0
lib/igt_dummyload.c emit_recursive_batch(igt_spin_t *spin, · line 126
Quoted 4 lines
lib/igt_dummyload.c +1
-0@@ -123,16 +123,28 @@ emit_recursive_batch(igt_spin_t *spin, addr +=random () % addr /2 ; addr &=-4096 ; +assert (!(opts->ctx && opts->ctx_id));
igt_assert().
Quoted 56 lines
lib/igt_dummyload.c +21
-8+ nengine =0 ;if (opts->engine ==ALL_ENGINES ) {struct intel_execution_engine2 *engine; -for_each_context_engine (fd, opts->ctx_id, engine) { -if (opts->flags &IGT_SPIN_POLL_RUN && - !gem_class_can_store_dword (fd, engine->class)) -continue ; +if (opts->ctx) { +for_each_ctx_engine (fd, opts->ctx, engine) { +if (opts->flags &IGT_SPIN_POLL_RUN && + !gem_class_can_store_dword (fd, engine->class)) +continue ; - flags[nengine++] = engine->flags; + flags[nengine++] = engine->flags; + } + }else { +for_each_context_engine (fd, opts->ctx_id, engine) { +if (opts->flags &IGT_SPIN_POLL_RUN && + !gem_class_can_store_dword (fd, engine->class)) +continue ; + + flags[nengine++] = engine->flags; + } } }else { flags[nengine++] = opts->engine;@@ -325,7 +337,7 @@ emit_recursive_batch(igt_spin_t *spin, execbuf->buffers_ptr =to_user_pointer (obj + (2 - execbuf->buffer_count)); - execbuf->rsvd1 = opts->ctx_id; + execbuf->rsvd1 = opts->ctx ? opts->ctx->id : opts->ctx_id;if (opts->flags &IGT_SPIN_FENCE_OUT ) execbuf->flags |=I915_EXEC_FENCE_OUT ;@@ -422,8 +434,10 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts)struct intel_execution_engine2 e;int class; -if (!gem_context_lookup_engine (fd, opts->engine, - opts->ctx_id, &e)) { +if (opts->ctx) { + class = opts->ctx->cfg.engines[opts->engine].engine_class; + }else if (!gem_context_lookup_engine (fd, opts->engine, + opts->ctx_id, &e)) { class = e.class; }else {gem_require_ring (fd, opts->engine);lib/igt_dummyload.h +0
-0
lib/igt_dummyload.h line 39
Quoted 9 lines
lib/igt_dummyload.h +2
-0@@ -31,10 +31,12 @@#include "igt_core.h" #include "igt_list.h" #include "i915_drm.h" +#include "intel_ctx.h" typedef struct igt_spin { struct igt_list_head link; +
Extra line.
Apart of that code looks ok. Fix minor nits and:
--
Zbigniew
Quoted 26 lines
lib/igt_dummyload.h +2
-0uint32_t handle;uint32_t poll_handle;@@ -62,6 +64,7 @@ typedef struct igt_spin {/** * igt_spin_factory_t: * @ctx_id: GEM context handle +* @ctx: intel_ctx_t context wrapper * @dependency: GEM object to depend on * @engine: Flags describing the engine to execute on * @flags: Set of IGT_SPIN_* flags @@ -71,6 +74,7 @@ typedef struct igt_spin {*/ typedef struct igt_spin_factory { uint32_t ctx_id; + const intel_ctx_t *ctx; uint32_t dependency; unsigned int engine; unsigned int flags;Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 17/89] lib/dummyload: Support intel_ctx_t
Quoted 16 lines · Zbigniew Kempczyński
Quoted 14 lines · Jason Ekstrand
Signed-off-by Jason Ekstrand <[email protected]>--- lib/igt_dummyload.c | 30 ++++++++++++++++++++++-------- lib/igt_dummyload.h | 4 ++++ 2 files changed, 26 insertions(+), 8 deletions(-)lib/igt_dummyload.c +0
-0@@ -123,16 +123,28 @@ emit_recursive_batch(igt_spin_t *spin, addr +=random () % addr /2 ; addr &=-4096 ;
Quoted 3 lines
lib/igt_dummyload.c emit_recursive_batch(igt_spin_t *spin, · line 126
Quoted 1 line
lib/igt_dummyload.c +1
-0+assert (!(opts->ctx && opts->ctx_id));
igt_assert().
Done
Quoted 61 lines
Quoted 61 lines
lib/igt_dummyload.c +21
-8+ nengine =0 ;if (opts->engine ==ALL_ENGINES ) {struct intel_execution_engine2 *engine; -for_each_context_engine (fd, opts->ctx_id, engine) { -if (opts->flags &IGT_SPIN_POLL_RUN && - !gem_class_can_store_dword (fd, engine->class)) -continue ; +if (opts->ctx) { +for_each_ctx_engine (fd, opts->ctx, engine) { +if (opts->flags &IGT_SPIN_POLL_RUN && + !gem_class_can_store_dword (fd, engine->class)) +continue ; - flags[nengine++] = engine->flags; + flags[nengine++] = engine->flags; + } + }else { +for_each_context_engine (fd, opts->ctx_id, engine) { +if (opts->flags &IGT_SPIN_POLL_RUN && + !gem_class_can_store_dword (fd, engine->class)) +continue ; + + flags[nengine++] = engine->flags; + } } }else { flags[nengine++] = opts->engine;@@ -325,7 +337,7 @@ emit_recursive_batch(igt_spin_t *spin, execbuf->buffers_ptr =to_user_pointer (obj + (2 - execbuf->buffer_count)); - execbuf->rsvd1 = opts->ctx_id; + execbuf->rsvd1 = opts->ctx ? opts->ctx->id : opts->ctx_id;if (opts->flags &IGT_SPIN_FENCE_OUT ) execbuf->flags |=I915_EXEC_FENCE_OUT ;@@ -422,8 +434,10 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts)struct intel_execution_engine2 e;int class; -if (!gem_context_lookup_engine (fd, opts->engine, - opts->ctx_id, &e)) { +if (opts->ctx) { + class = opts->ctx->cfg.engines[opts->engine].engine_class; + }else if (!gem_context_lookup_engine (fd, opts->engine, + opts->ctx_id, &e)) { class = e.class; }else {gem_require_ring (fd, opts->engine);lib/igt_dummyload.h +1
-0@@ -31,10 +31,12 @@#include "igt_core.h" #include "igt_list.h" #include "i915_drm.h" +#include "intel_ctx.h"
Quoted 6 lines
lib/igt_dummyload.h line 39
Quoted 4 lines
lib/igt_dummyload.h +1
-0typedef struct igt_spin { struct igt_list_head link; +Extra line.
Oops. Rebase fail.
Quoted 3 lines
Apart of that code looks ok. Fix minor nits and:
Reviewed-by Zbigniew Kempczyński <[email protected]>
Thanks!
Quoted 25 lines
--
ZbigniewQuoted 22 lines
lib/igt_dummyload.h +2
-1uint32_t handle;uint32_t poll_handle;@@ -62,6 +64,7 @@ typedef struct igt_spin {/** * igt_spin_factory_t: * @ctx_id: GEM context handle +* @ctx: intel_ctx_t context wrapper * @dependency: GEM object to depend on * @engine: Flags describing the engine to execute on * @flags: Set of IGT_SPIN_* flags @@ -71,6 +74,7 @@ typedef struct igt_spin {*/ typedef struct igt_spin_factory { uint32_t ctx_id; + const intel_ctx_t *ctx; uint32_t dependency; unsigned int engine; unsigned int flags; --2.31.1
Quoted 4 lines
Quoted 4 lines
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 18/89 tests/i915/gem_exec_fence: Move the engine data into inter_engine_context
In reply to Jason EkstrandThis will make iteration easier when we switch to intel_ctx_t.
--- tests/i915/gem_exec_fence.c | 79 +++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 39 deletions(-)
tests/i915/gem_exec_fence.c +40 -39
@@ -2346,7 +2346,7 @@ struct inter_engine_context {uint32_t context; } iterations[9 ]; -struct intel_engine_data *engines; +struct intel_engine_data engines;struct inter_engine_batches {void *increment_bb;
@@ -2414,7 +2414,7 @@ static void submit_timeline_execbuf(struct inter_engine_context *context, execbuf->cliprects_ptr =to_user_pointer (&fence_list); } - execbuf->flags |= context->engines->engines[run_engine_idx].flags; + execbuf->flags |= context->engines.engines[run_engine_idx].flags;gem_execbuf (context->fd, execbuf); }
@@ -2659,12 +2659,12 @@ get_cs_timestamp_frequency(int fd)igt_skip ("Kernel with PARAM_CS_TIMESTAMP_FREQUENCY support required\n" ); } -static void setup_timeline_chain_engines (struct inter_engine_context *context,int fd,struct intel_engine_data *engines) +static void setup_timeline_chain_engines (struct inter_engine_context *context,int fd) {memset (context,0 ,sizeof (*context)); context->fd = fd; - context->engines = engines; + context->engines =intel_init_engine_list (fd,0 ); context->wait_context =gem_context_clone_with_engines (fd,0 ); context->wait_timeline =syncobj_create (fd,0 );
@@ -2684,15 +2684,16 @@ static void setup_timeline_chain_engines(struct inter_engine_context *context, igem_write (fd, context->wait_bb_handle,0 , context->wait_bb, context->wait_bb_len); - context->batches =calloc (engines->nengines,sizeof (*context->batches)); -for (uint32_t e =0 ; e < engines->nengines; e++) { + context->batches =calloc (context->engines.nengines, +sizeof (*context->batches)); +for (uint32_t e =0 ; e < context->engines.nengines; e++) {struct inter_engine_batches *batches = &context->batches[e]; batches->timeline =syncobj_create (fd,0 );build_increment_engine_bb ( batches, -gem_engine_mmio_base (fd, engines->engines[e].name)); +gem_engine_mmio_base (fd, context->engines.engines[e].name)); batches->increment_bb_handle =gem_create (fd,4096 );gem_write (fd, batches->increment_bb_handle,0 , batches->increment_bb, batches->increment_bb_len);
@@ -2705,7 +2706,7 @@ static void setup_timeline_chain_engines(struct inter_engine_context *context, i {uint64_t dword =1 ;gem_write (fd, context->engine_counter_object.handle, -sizeof (dword) * (context->engines->nengines -1 ), +sizeof (dword) * (context->engines.nengines -1 ), &dword,sizeof (dword)); } }
@@ -2723,7 +2724,7 @@ static void teardown_timeline_chain_engines(struct inter_engine_context *contextgem_close (context->fd, context->wait_bb_handle);free (context->wait_bb); -for (uint32_t e =0 ; e < context->engines->nengines; e++) { +for (uint32_t e =0 ; e < context->engines.nengines; e++) {struct inter_engine_batches *batches = &context->batches[e];syncobj_destroy (context->fd, batches->timeline);
@@ -2733,12 +2734,12 @@ static void teardown_timeline_chain_engines(struct inter_engine_context *contextfree (context->batches); } -static void test_syncobj_timeline_chain_engines (int fd,struct intel_engine_data *engines) +static void test_syncobj_timeline_chain_engines (int fd) {struct inter_engine_context ctx;uint64_t *counter_output; -setup_timeline_chain_engines (&ctx, fd, engines); +setup_timeline_chain_engines (&ctx, fd);/* * Delay all the other operations by making them depend on an
@@ -2747,11 +2748,11 @@ static void test_syncobj_timeline_chain_engines(int fd, struct intel_engine_datawait_engine (&ctx,0 , ctx.wait_timeline,1 );for (uint32_t iter =0 ; iter <ARRAY_SIZE (ctx.iterations); iter++) { -for (uint32_t engine =0 ; engine < engines->nengines; engine++) { +for (uint32_t engine =0 ; engine < ctx.engines.nengines; engine++) {uint32_t prev_prev_engine = - (engines->nengines + engine -2 ) % engines->nengines; + (ctx.engines.nengines + engine -2 ) % ctx.engines.nengines;uint32_t prev_engine = - (engines->nengines + engine -1 ) % engines->nengines; + (ctx.engines.nengines + engine -1 ) % ctx.engines.nengines;/* * Pick up the wait engine semaphore for the * first increment, then pick up the previous
@@ -2777,28 +2778,28 @@ static void test_syncobj_timeline_chain_engines(int fd, struct intel_engine_data counter_output =gem_mmap__wc (fd, ctx.engine_counter_object.handle,0 ,4096 ,PROT_READ ); -for (uint32_t i =0 ; i < ctx.engines->nengines; i++) +for (uint32_t i =0 ; i < ctx.engines.nengines; i++)igt_debug ("engine %i (%s)\t= %016" PRIx64"\n" , i, - ctx.engines->engines[i].name, counter_output[i]); + ctx.engines.engines[i].name, counter_output[i]);/* * Verify that we get the fibonacci number expected (we start * at the sequence on the second number : 1). */ -igt_assert_eq (counter_output[engines->nengines -1 ], -fib (ARRAY_SIZE (ctx.iterations) * engines->nengines +1 )); +igt_assert_eq (counter_output[ctx.engines.nengines -1 ], +fib (ARRAY_SIZE (ctx.iterations) * ctx.engines.nengines +1 ));munmap (counter_output,4096 );teardown_timeline_chain_engines (&ctx); } -static void test_syncobj_stationary_timeline_chain_engines (int fd,struct intel_engine_data *engines) +static void test_syncobj_stationary_timeline_chain_engines (int fd) {struct inter_engine_context ctx;uint64_t *counter_output; -setup_timeline_chain_engines (&ctx, fd, engines); +setup_timeline_chain_engines (&ctx, fd);/* * Delay all the other operations by making them depend on an
@@ -2807,11 +2808,11 @@ static void test_syncobj_stationary_timeline_chain_engines(int fd, struct intel_wait_engine (&ctx,0 , ctx.wait_timeline,1 );for (uint32_t iter =0 ; iter <ARRAY_SIZE (ctx.iterations); iter++) { -for (uint32_t engine =0 ; engine < engines->nengines; engine++) { +for (uint32_t engine =0 ; engine < ctx.engines.nengines; engine++) {uint32_t prev_prev_engine = - (engines->nengines + engine -2 ) % engines->nengines; + (ctx.engines.nengines + engine -2 ) % ctx.engines.nengines;uint32_t prev_engine = - (engines->nengines + engine -1 ) % engines->nengines; + (ctx.engines.nengines + engine -1 ) % ctx.engines.nengines;/* * Pick up the wait engine semaphore for the * first increment, then pick up the previous
@@ -2843,23 +2844,23 @@ static void test_syncobj_stationary_timeline_chain_engines(int fd, struct intel_ counter_output =gem_mmap__wc (fd, ctx.engine_counter_object.handle,0 ,4096 ,PROT_READ ); -for (uint32_t i =0 ; i < ctx.engines->nengines; i++) +for (uint32_t i =0 ; i < ctx.engines.nengines; i++)igt_debug ("engine %i (%s)\t= %016" PRIx64"\n" , i, - ctx.engines->engines[i].name, counter_output[i]); -igt_assert_eq (counter_output[engines->nengines -1 ], -fib (ARRAY_SIZE (ctx.iterations) * engines->nengines +1 )); + ctx.engines.engines[i].name, counter_output[i]); +igt_assert_eq (counter_output[ctx.engines.nengines -1 ], +fib (ARRAY_SIZE (ctx.iterations) * ctx.engines.nengines +1 ));munmap (counter_output,4096 );teardown_timeline_chain_engines (&ctx); } -static void test_syncobj_backward_timeline_chain_engines (int fd,struct intel_engine_data *engines) +static void test_syncobj_backward_timeline_chain_engines (int fd) {struct inter_engine_context ctx;uint64_t *counter_output; -setup_timeline_chain_engines (&ctx, fd, engines); +setup_timeline_chain_engines (&ctx, fd);/* * Delay all the other operations by making them depend on an
@@ -2868,11 +2869,11 @@ static void test_syncobj_backward_timeline_chain_engines(int fd, struct intel_enwait_engine (&ctx,0 , ctx.wait_timeline,1 );for (uint32_t iter =0 ; iter <ARRAY_SIZE (ctx.iterations); iter++) { -for (uint32_t engine =0 ; engine < engines->nengines; engine++) { +for (uint32_t engine =0 ; engine < ctx.engines.nengines; engine++) {uint32_t prev_prev_engine = - (engines->nengines + engine -2 ) % engines->nengines; + (ctx.engines.nengines + engine -2 ) % ctx.engines.nengines;uint32_t prev_engine = - (engines->nengines + engine -1 ) % engines->nengines; + (ctx.engines.nengines + engine -1 ) % ctx.engines.nengines;/* * Pick up the wait engine semaphore for the * first increment, then pick up the previous
@@ -2904,11 +2905,11 @@ static void test_syncobj_backward_timeline_chain_engines(int fd, struct intel_en counter_output =gem_mmap__wc (fd, ctx.engine_counter_object.handle,0 ,4096 ,PROT_READ ); -for (uint32_t i =0 ; i < ctx.engines->nengines; i++) +for (uint32_t i =0 ; i < ctx.engines.nengines; i++)igt_debug ("engine %i (%s)\t= %016" PRIx64"\n" , i, - ctx.engines->engines[i].name, counter_output[i]); -igt_assert_eq (counter_output[engines->nengines -1 ], -fib (ARRAY_SIZE (ctx.iterations) * engines->nengines +1 )); + ctx.engines.engines[i].name, counter_output[i]); +igt_assert_eq (counter_output[ctx.engines.nengines -1 ], +fib (ARRAY_SIZE (ctx.iterations) * ctx.engines.nengines +1 ));munmap (counter_output,4096 );
@@ -3216,13 +3217,13 @@ igt_main } igt_subtest("syncobj-timeline-chain-engines") -test_syncobj_timeline_chain_engines (i915, &engines); +test_syncobj_timeline_chain_engines (i915); igt_subtest("syncobj-stationary-timeline-chain-engines") -test_syncobj_stationary_timeline_chain_engines (i915, &engines); +test_syncobj_stationary_timeline_chain_engines (i915); igt_subtest("syncobj-backward-timeline-chain-engines") -test_syncobj_backward_timeline_chain_engines (i915, &engines); +test_syncobj_backward_timeline_chain_engines (i915); } igt_fixture {
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 19/89 tests/i915/gem_exec_fence: Convert to intel_ctx_t
In reply to Jason Ekstrand--- tests/i915/gem_exec_fence.c | 245 ++++++++++++++++++++---------------- 1 file changed, 139 insertions(+), 106 deletions(-)
tests/i915/gem_exec_fence.c +139 -106
@@ -30,6 +30,7 @@#include "igt_syncobj.h" #include "igt_sysfs.h" #include "igt_vgem.h" +#include "intel_ctx.h" #include "sw_sync.h" IGT_TEST_DESCRIPTION ("Check that execbuf waits for explicit fences" );
@@ -55,7 +56,8 @@ struct sync_merge_data {#define MI_SEMAPHORE_SAD_EQ_SDD (4 << 12)#define MI_SEMAPHORE_SAD_NEQ_SDD (5 << 12) -static void store (int fd,const struct intel_execution_engine2 *e, +static void store (int fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e,int fence,uint32_t target,unsigned offset_value) {const int SCRATCH =0 ;
@@ -71,6 +73,7 @@ static void store(int fd, const struct intel_execution_engine2 *e, execbuf.buffers_ptr =to_user_pointer (obj); execbuf.buffer_count =2 ; execbuf.flags = e->flags |I915_EXEC_FENCE_IN ; + execbuf.rsvd1 = ctx->id; execbuf.rsvd2 = fence;if (gen <6 ) execbuf.flags |=I915_EXEC_SECURE ;
@@ -118,7 +121,8 @@ static bool fence_busy(int fence)#define NONBLOCK 0x2#define WAIT 0x4 -static void test_fence_busy (int fd,const struct intel_execution_engine2 *e, +static void test_fence_busy (int fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e,unsigned flags) {const unsigned int gen =intel_gen (intel_get_drm_devid (fd));
@@ -138,6 +142,7 @@ static void test_fence_busy(int fd, const struct intel_execution_engine2 *e, execbuf.buffers_ptr =to_user_pointer (&obj); execbuf.buffer_count =1 ; execbuf.flags = e->flags |I915_EXEC_FENCE_OUT ; + execbuf.rsvd1 = ctx->id;memset (&obj,0 ,sizeof (obj)); obj.handle =gem_create (fd,4096 );
@@ -214,7 +219,7 @@ static void test_fence_busy(int fd, const struct intel_execution_engine2 *e,gem_quiescent_gpu (fd); } -static void test_fence_busy_all (int fd,unsigned flags) +static void test_fence_busy_all (int fd,const intel_ctx_t *ctx,unsigned flags) {const struct intel_execution_engine2 *e;const unsigned int gen =intel_gen (intel_get_drm_devid (fd));
@@ -272,7 +277,7 @@ static void test_fence_busy_all(int fd, unsigned flags) i++; all =-1 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) {int fence, new; if ((flags & HANG) == 0 &&
@@ -280,6 +285,7 @@ static void test_fence_busy_all(int fd, unsigned flags)continue ; execbuf.flags = e->flags |I915_EXEC_FENCE_OUT ; + execbuf.rsvd1 = ctx->id; execbuf.rsvd2 =-1 ;gem_execbuf_wr (fd, &execbuf); fence = execbuf.rsvd2 >>32 ;
@@ -336,7 +342,8 @@ static unsigned int spin_hang(unsigned int flags)return IGT_SPIN_NO_PREEMPTION |IGT_SPIN_INVALID_CS ; } -static void test_fence_await (int fd,const struct intel_execution_engine2 *e, +static void test_fence_await (int fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e,unsigned flags) {const struct intel_execution_engine2 *e2;
@@ -350,20 +357,21 @@ static void test_fence_await(int fd, const struct intel_execution_engine2 *e, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); spin = igt_spin_new(fd, + .ctx = ctx, .engine = e->flags, .flags =IGT_SPIN_FENCE_OUT |spin_hang (flags));igt_assert (spin->out_fence !=-1 ); i =0 ; -__for_each_physical_engine (fd, e2) { +for_each_ctx_engine (fd, ctx, e2) {if (!gem_class_can_store_dword (fd, e->class))continue ;if (flags &NONBLOCK ) { -store (fd, e2, spin->out_fence, scratch, i); +store (fd, ctx, e2, spin->out_fence, scratch, i); }else { igt_fork(child, 1) -store (fd, e2, spin->out_fence, scratch, i); +store (fd, ctx, e2, spin->out_fence, scratch, i); } i++;
@@ -439,9 +447,10 @@ static uint32_t timeslicing_batches(int i915, uint32_t *offset)return handle; } -static void test_submit_fence (int i915,unsigned int engine) +static void test_submit_fence (int i915,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e) { -const struct intel_execution_engine2 *e; +const struct intel_execution_engine2 *e2;/* * Create a pair of interlocking batches, that ping pong
@@ -450,8 +459,9 @@ static void test_submit_fence(int i915, unsigned int engine)* switch to the other batch in order to advance. */ -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e2) {unsigned int offset =24 <<20 ; +const intel_ctx_t *tmp_ctx;struct drm_i915_gem_exec_object2 obj = { .offset = offset, .flags =EXEC_OBJECT_PINNED ,
@@ -467,17 +477,19 @@ static void test_submit_fence(int i915, unsigned int engine) result =gem_mmap__device_coherent (i915, obj.handle,0 ,4096 ,PROT_READ ); - execbuf.flags = engine |I915_EXEC_FENCE_OUT ; + execbuf.flags = e->flags |I915_EXEC_FENCE_OUT ; execbuf.batch_start_offset =0 ; + execbuf.rsvd1 = ctx->id;gem_execbuf_wr (i915, &execbuf); - execbuf.rsvd1 =gem_context_clone_with_engines (i915,0 ); + tmp_ctx =intel_ctx_create (i915, &ctx->cfg); + execbuf.rsvd1 = tmp_ctx->id; execbuf.rsvd2 >>=32 ; - execbuf.flags = e->flags; + execbuf.flags = e2->flags; execbuf.flags |=I915_EXEC_FENCE_SUBMIT |I915_EXEC_FENCE_OUT ; execbuf.batch_start_offset = offset;gem_execbuf_wr (i915, &execbuf); -gem_context_destroy (i915, execbuf.rsvd1); +intel_ctx_destroy (i915, tmp_ctx);gem_sync (i915, obj.handle);gem_close (i915, obj.handle);
@@ -532,7 +544,9 @@ static uint32_t submitN_batches(int i915, uint32_t offset, int count)return handle; } -static void test_submitN (int i915,unsigned int engine,int count) +static void test_submitN (int i915,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e, +int count) {unsigned int offset =24 <<20 ;unsigned int sz =ALIGN ((count +1 ) *1024 ,4096 );
@@ -544,7 +558,8 @@ static void test_submitN(int i915, unsigned int engine, int count)struct drm_i915_gem_execbuffer2 execbuf = { .buffers_ptr =to_user_pointer (&obj), .buffer_count =1 , - .flags = engine |I915_EXEC_FENCE_OUT , + .flags = e->flags |I915_EXEC_FENCE_OUT , + .rsvd1 = ctx->id, };uint32_t *result =gem_mmap__device_coherent (i915, obj.handle,0 , sz,PROT_READ );
@@ -555,10 +570,11 @@ static void test_submitN(int i915, unsigned int engine, int count)igt_require (intel_gen (intel_get_drm_devid (i915)) >=8 );for (int i =0 ; i < count; i++) { - execbuf.rsvd1 =gem_context_clone_with_engines (i915,0 ); +const intel_ctx_t *tmp_ctx =intel_ctx_create (i915, &ctx->cfg); + execbuf.rsvd1 = tmp_ctx->id; execbuf.batch_start_offset = (i +1 ) *1024 ;gem_execbuf_wr (i915, &execbuf); -gem_context_destroy (i915, execbuf.rsvd1); +intel_ctx_destroy (i915, tmp_ctx); execbuf.flags |=I915_EXEC_FENCE_SUBMIT ; execbuf.rsvd2 >>=32 ;
@@ -594,7 +610,8 @@ static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)return err; } -static void test_parallel (int i915,const struct intel_execution_engine2 *e) +static void test_parallel (int i915,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e) {const struct intel_execution_engine2 *e2;const unsigned int gen =intel_gen (intel_get_drm_devid (i915));
@@ -608,6 +625,7 @@ static void test_parallel(int i915, const struct intel_execution_engine2 *e) fence = igt_cork_plug(&cork, i915), spin = igt_spin_new(i915, + .ctx = ctx, .engine = e->flags, .fence = fence, .flags = (IGT_SPIN_FENCE_OUT |
@@ -615,7 +633,7 @@ static void test_parallel(int i915, const struct intel_execution_engine2 *e)close (fence);/* Queue all secondaries */ -__for_each_physical_engine (i915, e2) { +for_each_ctx_engine (i915, ctx, e2) {struct drm_i915_gem_relocation_entry reloc = { .target_handle = scratch, .offset =sizeof (uint32_t ),
@@ -632,6 +650,7 @@ static void test_parallel(int i915, const struct intel_execution_engine2 *e) .buffers_ptr = to_user_pointer(obj), .buffer_count = ARRAY_SIZE(obj), .flags = e2->flags | I915_EXEC_FENCE_SUBMIT, + .rsvd1 = ctx->id, .rsvd2 = spin->out_fence, };uint32_t batch[16 ];
@@ -701,7 +720,8 @@ static void test_parallel(int i915, const struct intel_execution_engine2 *e)igt_spin_free (i915, spin); } -static void test_concurrent (int i915,const struct intel_execution_engine2 *e) +static void test_concurrent (int i915,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e) {const unsigned int gen =intel_gen (intel_get_drm_devid (i915));struct drm_i915_gem_relocation_entry reloc = {
@@ -721,10 +741,12 @@ static void test_concurrent(int i915, const struct intel_execution_engine2 *e) .buffers_ptr = to_user_pointer(obj), .buffer_count = ARRAY_SIZE(obj), .flags = e->flags | I915_EXEC_FENCE_SUBMIT, + .rsvd1 = ctx->id, };IGT_CORK_FENCE (cork);uint32_t batch[16 ];igt_spin_t *spin; +const intel_ctx_t *tmp_ctx;uint32_t result;int fence;int i;
@@ -737,6 +759,7 @@ static void test_concurrent(int i915, const struct intel_execution_engine2 *e) fence = igt_cork_plug(&cork, i915), spin = igt_spin_new(i915, + .ctx = ctx, .engine = e->flags, .fence = fence, .flags = (IGT_SPIN_FENCE_OUT |
@@ -760,13 +783,14 @@ static void test_concurrent(int i915, const struct intel_execution_engine2 *e) batch[++i] =MI_BATCH_BUFFER_END ;gem_write (i915, obj[1 ].handle,0 , batch,sizeof (batch)); - execbuf.rsvd1 =gem_context_clone_with_engines (i915,0 ); + tmp_ctx =intel_ctx_create (i915, &ctx->cfg); + execbuf.rsvd1 = tmp_ctx->id; execbuf.rsvd2 = spin->out_fence;if (gen <6 ) execbuf.flags |=I915_EXEC_SECURE ;gem_execbuf (i915, &execbuf); -gem_context_destroy (i915, execbuf.rsvd1); +intel_ctx_destroy (i915, tmp_ctx);gem_close (i915, obj[1 ].handle);/*
@@ -795,7 +819,7 @@ static void test_concurrent(int i915, const struct intel_execution_engine2 *e)igt_spin_free (i915, spin); } -static void test_submit_chain (int i915) +static void test_submit_chain (int i915,const intel_ctx_t *ctx) {const struct intel_execution_engine2 *e;igt_spin_t *spin, *sn;
@@ -806,8 +830,9 @@ static void test_submit_chain(int i915)/* Check that we can simultaneously launch spinners on each engine */ fence =igt_cork_plug (&cork, i915); - __for_each_physical_engine(i915, e) { + for_each_ctx_engine(i915, ctx, e) { spin = igt_spin_new(i915, + .ctx = ctx, .engine = e->flags, .fence = fence, .flags = (IGT_SPIN_POLL_RUN |
@@ -847,7 +872,8 @@ static uint32_t batch_create(int fd)return handle; } -static void test_keep_in_fence (int fd,const struct intel_execution_engine2 *e) +static void test_keep_in_fence (int fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e) {struct sigaction sa = { .sa_handler = alarm_handler };struct drm_i915_gem_exec_object2 obj = {
@@ -857,13 +883,14 @@ static void test_keep_in_fence(int fd, const struct intel_execution_engine2 *e) .buffers_ptr = to_user_pointer(&obj), .buffer_count = 1, .flags = e->flags | I915_EXEC_FENCE_OUT, + .rsvd1 = ctx->id, };unsigned long count, last;struct itimerval itv;igt_spin_t *spin;int fence; - spin = igt_spin_new(fd, .engine = e->flags); + spin = igt_spin_new(fd, .ctx = ctx, .engine = e->flags);gem_execbuf_wr (fd, &execbuf); fence =upper_32_bits (execbuf.rsvd2);
@@ -915,7 +942,8 @@ static void test_keep_in_fence(int fd, const struct intel_execution_engine2 *e) }#define EXPIRED 0x10000 -static void test_long_history (int fd,long ring_size,unsigned flags) +static void test_long_history (int fd,const intel_ctx_t *ctx, +long ring_size,unsigned flags) {const uint32_t sz =1 <<20 ;const uint32_t bbe =MI_BATCH_BUFFER_END ;
@@ -932,7 +960,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags) limit = ring_size /3 ; nengine =0 ; -__for_each_physical_engine (fd, e) +for_each_ctx_engine (fd, ctx, e) engines[nengine++] = e->flags;igt_require (nengine);
@@ -946,6 +974,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags) execbuf.buffers_ptr =to_user_pointer (&obj[1 ]); execbuf.buffer_count =1 ; execbuf.flags =I915_EXEC_FENCE_OUT ; + execbuf.rsvd1 = ctx->id;gem_execbuf_wr (fd, &execbuf); all_fences = execbuf.rsvd2 >>32 ;
@@ -956,7 +985,8 @@ static void test_long_history(int fd, long ring_size, unsigned flags) obj[0 ].handle =igt_cork_plug (&c, fd); igt_until_timeout(5) { - execbuf.rsvd1 =gem_context_clone_with_engines (fd,0 ); +const intel_ctx_t *tmp_ctx =intel_ctx_create (fd, &ctx->cfg); + execbuf.rsvd1 = tmp_ctx->id;for (n =0 ; n < nengine; n++) {struct sync_merge_data merge;
@@ -977,7 +1007,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags) all_fences = merge.fence; } -gem_context_destroy (fd, execbuf.rsvd1); +intel_ctx_destroy (fd, tmp_ctx);if (!--limit)break ; }
@@ -991,7 +1021,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags) execbuf.buffers_ptr =to_user_pointer (&obj[1 ]); execbuf.buffer_count =1 ; execbuf.rsvd2 = all_fences; - execbuf.rsvd1 =0 ; + execbuf.rsvd1 = ctx->id;for (s =0 ; s < ring_size; s++) {for (n =0 ; n < nengine; n++) {
@@ -1257,7 +1287,7 @@ static void test_syncobj_signal(int fd)syncobj_destroy (fd, fence.handle); } -static void test_syncobj_wait (int fd) +static void test_syncobj_wait (int fd,const intel_ctx_t *ctx) {const uint32_t bbe =MI_BATCH_BUFFER_END ;struct drm_i915_gem_exec_object2 obj;
@@ -1299,12 +1329,13 @@ static void test_syncobj_wait(int fd)gem_write (fd, obj.handle,0 , &bbe,sizeof (bbe)); n =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { obj.handle =gem_create (fd,4096 );gem_write (fd, obj.handle,0 , &bbe,sizeof (bbe));/* Now wait upon the blocked engine */ execbuf.flags =I915_EXEC_FENCE_ARRAY | e->flags; + execbuf.rsvd1 = ctx->id; execbuf.cliprects_ptr =to_user_pointer (&fence); execbuf.num_cliprects =1 ; fence.flags =I915_EXEC_FENCE_WAIT ;
@@ -1997,7 +2028,7 @@ static void test_syncobj_timeline_signal(int fd)static const char *test_syncobj_timeline_wait_desc ="Verifies that waiting on a timeline syncobj point between engines" " works" ; -static void test_syncobj_timeline_wait (int fd) +static void test_syncobj_timeline_wait (int fd,const intel_ctx_t *ctx) {const uint32_t bbe[2 ] = {MI_BATCH_BUFFER_END ,
@@ -2024,7 +2055,7 @@ static void test_syncobj_timeline_wait(int fd)gem_quiescent_gpu (fd); - spin = igt_spin_new(fd, .engine = ALL_ENGINES); + spin = igt_spin_new(fd, .ctx = ctx, .engine = ALL_ENGINES);memset (&timeline_fences,0 ,sizeof (timeline_fences)); timeline_fences.base.name =DRM_I915_GEM_EXECBUFFER_EXT_TIMELINE_FENCES ;
@@ -2046,12 +2077,13 @@ static void test_syncobj_timeline_wait(int fd)gem_close (fd, obj.handle); n =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { obj.handle =gem_create (fd,4096 );gem_write (fd, obj.handle,0 , bbe,sizeof (bbe));/* Now wait upon the blocked engine */ execbuf.flags =I915_EXEC_USE_EXTENSIONS | e->flags; + execbuf.rsvd1 = ctx->id, execbuf.cliprects_ptr =to_user_pointer (&timeline_fences); execbuf.num_cliprects =0 ; fence.flags =I915_EXEC_FENCE_WAIT ;
@@ -2341,9 +2373,10 @@ static void test_syncobj_timeline_multiple_ext_nodes(int fd)struct inter_engine_context {int fd; +const intel_ctx_cfg_t *cfg;struct { -uint32_t context; +const intel_ctx_t *ctx; } iterations[9 ];struct intel_engine_data engines;
@@ -2367,7 +2400,7 @@ struct inter_engine_context {void *jump_ptr;void *timestamp2_ptr; -uint32_t wait_context; +const intel_ctx_t *wait_ctx;uint32_t wait_timeline;struct drm_i915_gem_exec_object2 engine_counter_object;
@@ -2495,7 +2528,7 @@ static void wait_engine(struct inter_engine_context *context, .buffers_ptr = to_user_pointer(&objects[0]), .buffer_count = 2, .flags = I915_EXEC_HANDLE_LUT, - .rsvd1 = context->wait_context, + .rsvd1 = context->wait_ctx->id, .batch_len = context->wait_bb_len, };
@@ -2562,7 +2595,7 @@ static void build_increment_engine_bb(struct inter_engine_batches *batch, } static void increment_engine(struct inter_engine_context *context, - uint32_t gem_context, + const intel_ctx_t *ctx, uint32_t read0_engine_idx, uint32_t read1_engine_idx, uint32_t write_engine_idx,
@@ -2585,7 +2618,7 @@ static void increment_engine(struct inter_engine_context *context, .buffers_ptr = to_user_pointer(&objects[0]), .buffer_count = ARRAY_SIZE(objects), .flags = I915_EXEC_HANDLE_LUT, - .rsvd1 = gem_context, + .rsvd1 = ctx->id, .batch_len = batch->increment_bb_len, };
@@ -2659,23 +2692,25 @@ get_cs_timestamp_frequency(int fd)igt_skip ("Kernel with PARAM_CS_TIMESTAMP_FREQUENCY support required\n" ); } -static void setup_timeline_chain_engines (struct inter_engine_context *context,int fd) +static void setup_timeline_chain_engines (struct inter_engine_context *context,int fd, +const intel_ctx_cfg_t *cfg) {memset (context,0 ,sizeof (*context)); context->fd = fd; - context->engines =intel_init_engine_list (fd,0 ); + context->cfg = cfg; + context->engines =intel_engine_list_for_ctx_cfg (fd, cfg); - context->wait_context =gem_context_clone_with_engines (fd,0 ); + context->wait_ctx =intel_ctx_create (fd, cfg); context->wait_timeline =syncobj_create (fd,0 ); context->engine_counter_object.handle =gem_create (fd,4096 );for (uint32_t i =0 ; i <ARRAY_SIZE (context->iterations); i++) { - context->iterations[i].context =gem_context_clone_with_engines (fd,0 ); + context->iterations[i].ctx =intel_ctx_create (fd, context->cfg);/* Give a different priority to all contexts. */ -gem_context_set_priority (fd, context->iterations[i].context, +gem_context_set_priority (fd, context->iterations[i].ctx->id,I915_CONTEXT_MAX_USER_PRIORITY -ARRAY_SIZE (context->iterations) + i); }
@@ -2716,10 +2751,10 @@ static void teardown_timeline_chain_engines(struct inter_engine_context *contextgem_close (context->fd, context->engine_counter_object.handle);for (uint32_t i =0 ; i <ARRAY_SIZE (context->iterations); i++) { -gem_context_destroy (context->fd, context->iterations[i].context); +intel_ctx_destroy (context->fd, context->iterations[i].ctx); } -gem_context_destroy (context->fd, context->wait_context); +intel_ctx_destroy (context->fd, context->wait_ctx);syncobj_destroy (context->fd, context->wait_timeline);gem_close (context->fd, context->wait_bb_handle);free (context->wait_bb);
@@ -2734,12 +2769,12 @@ static void teardown_timeline_chain_engines(struct inter_engine_context *contextfree (context->batches); } -static void test_syncobj_timeline_chain_engines (int fd) +static void test_syncobj_timeline_chain_engines (int fd,const intel_ctx_cfg_t *cfg) {struct inter_engine_context ctx;uint64_t *counter_output; -setup_timeline_chain_engines (&ctx, fd); +setup_timeline_chain_engines (&ctx, fd, cfg);/* * Delay all the other operations by making them depend on an
@@ -2765,7 +2800,7 @@ static void test_syncobj_timeline_chain_engines(int fd) iter ==0 && engine ==0 ?1 : (engine ==0 ? iter : (iter +1 )); - increment_engine(&ctx, ctx.iterations[iter].context, + increment_engine(&ctx, ctx.iterations[iter].ctx, prev_prev_engine /* read0 engine */, prev_engine /* read1 engine */, engine /* write engine */,
@@ -2794,12 +2829,12 @@ static void test_syncobj_timeline_chain_engines(int fd)teardown_timeline_chain_engines (&ctx); } -static void test_syncobj_stationary_timeline_chain_engines (int fd) +static void test_syncobj_stationary_timeline_chain_engines (int fd,const intel_ctx_cfg_t *cfg) {struct inter_engine_context ctx;uint64_t *counter_output; -setup_timeline_chain_engines (&ctx, fd); +setup_timeline_chain_engines (&ctx, fd, cfg);/* * Delay all the other operations by making them depend on an
@@ -2831,7 +2866,7 @@ static void test_syncobj_stationary_timeline_chain_engines(int fd) iter ==0 && engine ==0 ?1 :10 ; - increment_engine(&ctx, ctx.iterations[iter].context, + increment_engine(&ctx, ctx.iterations[iter].ctx, prev_prev_engine /* read0 engine */, prev_engine /* read1 engine */, engine /* write engine */,
@@ -2855,12 +2890,12 @@ static void test_syncobj_stationary_timeline_chain_engines(int fd)teardown_timeline_chain_engines (&ctx); } -static void test_syncobj_backward_timeline_chain_engines (int fd) +static void test_syncobj_backward_timeline_chain_engines (int fd,const intel_ctx_cfg_t *cfg) {struct inter_engine_context ctx;uint64_t *counter_output; -setup_timeline_chain_engines (&ctx, fd); +setup_timeline_chain_engines (&ctx, fd, cfg);/* * Delay all the other operations by making them depend on an
@@ -2892,7 +2927,7 @@ static void test_syncobj_backward_timeline_chain_engines(int fd) iter ==0 && engine ==0 ?1 :1 ; - increment_engine(&ctx, ctx.iterations[iter].context, + increment_engine(&ctx, ctx.iterations[iter].ctx, prev_prev_engine /* read0 engine */, prev_engine /* read1 engine */, engine /* write engine */,
@@ -2919,6 +2954,7 @@ static void test_syncobj_backward_timeline_chain_engines(int fd) igt_main {const struct intel_execution_engine2 *e; +const intel_ctx_t *ctx;int i915 =-1 ; igt_fixture {
@@ -2926,6 +2962,7 @@ igt_mainigt_require_gem (i915);igt_require (gem_has_exec_fence (i915));gem_require_mmap_wc (i915); + ctx =intel_ctx_create_all_physical (i915);gem_submission_print_method (i915); }
@@ -2938,19 +2975,19 @@ igt_main } igt_subtest("basic-busy-all") -test_fence_busy_all (i915,0 ); +test_fence_busy_all (i915, ctx,0 ); igt_subtest("basic-wait-all") -test_fence_busy_all (i915,WAIT ); +test_fence_busy_all (i915, ctx,WAIT ); igt_fixture {igt_stop_hang_detector (); - hang =igt_allow_hang (i915,0 ,0 ); + hang =igt_allow_hang (i915, ctx->id,0 ); } igt_subtest("busy-hang-all") -test_fence_busy_all (i915,HANG ); +test_fence_busy_all (i915, ctx,HANG ); igt_subtest("wait-hang-all") -test_fence_busy_all (i915,WAIT |HANG ); +test_fence_busy_all (i915, ctx,WAIT |HANG ); igt_fixture {igt_disallow_hang (i915, hang);
@@ -2958,7 +2995,7 @@ igt_main } igt_subtest_group { -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_fixture {igt_require (gem_class_can_store_dword (i915, e->class)); }
@@ -2969,42 +3006,42 @@ igt_main } igt_subtest_with_dynamic("basic-busy") { -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) -test_fence_busy (i915, e,0 ); +test_fence_busy (i915, ctx, e,0 ); } } igt_subtest_with_dynamic("basic-wait") { -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) -test_fence_busy (i915, e,WAIT ); +test_fence_busy (i915, ctx, e,WAIT ); } } igt_subtest_with_dynamic("basic-await") { -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) -test_fence_await (i915, e,0 ); +test_fence_await (i915, ctx, e,0 ); } } igt_subtest_with_dynamic("nb-await") { -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) -test_fence_await (i915, - e,NONBLOCK ); +test_fence_await (i915, ctx, e, +NONBLOCK ); } } igt_subtest_with_dynamic("keep-in-fence") { -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) -test_keep_in_fence (i915, e); +test_keep_in_fence (i915, ctx, e); } } igt_subtest_with_dynamic("parallel") {igt_require (has_submit_fence (i915)); -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) { igt_until_timeout(2) -test_parallel (i915, e); +test_parallel (i915, ctx, e); } } }
@@ -3013,9 +3050,9 @@ igt_mainigt_require (has_submit_fence (i915));igt_require (gem_scheduler_has_semaphores (i915));igt_require (gem_scheduler_has_preemption (i915)); -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) -test_concurrent (i915, e); +test_concurrent (i915, ctx, e); } }
@@ -3024,9 +3061,9 @@ igt_mainigt_require (gem_scheduler_has_preemption (i915));igt_require (intel_gen (intel_get_drm_devid (i915)) >=8 ); -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) -test_submit_fence (i915, e->flags); +test_submit_fence (i915, ctx, e); } }
@@ -3035,9 +3072,9 @@ igt_mainigt_require (gem_scheduler_has_preemption (i915));igt_require (intel_gen (intel_get_drm_devid (i915)) >=8 ); -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) -test_submitN (i915, e->flags,3 ); +test_submitN (i915, ctx, e,3 ); } }
@@ -3046,15 +3083,15 @@ igt_mainigt_require (gem_scheduler_has_preemption (i915));igt_require (intel_gen (intel_get_drm_devid (i915)) >=8 ); -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) -test_submitN (i915, e->flags,67 ); +test_submitN (i915, ctx, e,67 ); } } igt_subtest("submit-chain") {igt_require (has_submit_fence (i915)); -test_submit_chain (i915); +test_submit_chain (i915, ctx); } igt_fixture {
@@ -3070,27 +3107,27 @@ igt_main } igt_subtest_with_dynamic("busy-hang") { -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) -test_fence_busy (i915, e,HANG ); +test_fence_busy (i915, ctx, e,HANG ); } } igt_subtest_with_dynamic("wait-hang") { -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) -test_fence_busy (i915, e,HANG |WAIT ); +test_fence_busy (i915, ctx, e,HANG |WAIT ); } } igt_subtest_with_dynamic("await-hang") { -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) -test_fence_await (i915, e,HANG ); +test_fence_await (i915, ctx, e,HANG ); } } igt_subtest_with_dynamic("nb-await-hang") { -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_dynamic_f("%s", e->name) -test_fence_await (i915, e,NONBLOCK |HANG ); +test_fence_await (i915, ctx, e,NONBLOCK |HANG ); } } igt_fixture {
@@ -3111,10 +3148,10 @@ igt_main } igt_subtest("long-history") -test_long_history (i915, ring_size,0 ); +test_long_history (i915, ctx, ring_size,0 ); igt_subtest("expired-history") -test_long_history (i915, ring_size,EXPIRED ); +test_long_history (i915, ctx, ring_size,EXPIRED ); } igt_subtest_group { /* syncobj */
@@ -3140,7 +3177,7 @@ igt_maintest_syncobj_signal (i915); igt_subtest("syncobj-wait") -test_syncobj_wait (i915); +test_syncobj_wait (i915, ctx); igt_subtest("syncobj-export")test_syncobj_export (i915);
@@ -3188,7 +3225,7 @@ igt_mainigt_describe (test_syncobj_timeline_wait_desc); igt_subtest("syncobj-timeline-wait") -test_syncobj_timeline_wait (i915); +test_syncobj_timeline_wait (i915, ctx);igt_describe (test_syncobj_timeline_export_desc);igt_subtest ("syncobj-timeline-export" )
@@ -3203,8 +3240,6 @@ igt_maintest_syncobj_timeline_multiple_ext_nodes (i915); igt_subtest_group { /* syncobj timeline engine chaining */ -struct intel_engine_data engines; - igt_fixture {/* * We need support for MI_ALU on all
@@ -3212,18 +3247,16 @@ igt_main* only on Gen8+ */ igt_require (intel_gen (intel_get_drm_devid (i915)) >=8 ); - engines =intel_init_engine_list (i915,0 ); -igt_require (engines.nengines >1 ); } igt_subtest("syncobj-timeline-chain-engines") -test_syncobj_timeline_chain_engines (i915); +test_syncobj_timeline_chain_engines (i915, &ctx->cfg); igt_subtest("syncobj-stationary-timeline-chain-engines") -test_syncobj_stationary_timeline_chain_engines (i915); +test_syncobj_stationary_timeline_chain_engines (i915, &ctx->cfg); igt_subtest("syncobj-backward-timeline-chain-engines") -test_syncobj_backward_timeline_chain_engines (i915); +test_syncobj_backward_timeline_chain_engines (i915, &ctx->cfg); } igt_fixture {
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 20/89 tests/i915/gem_exec_schedule: Convert to intel_ctx_t
In reply to Jason Ekstrand--- tests/i915/gem_exec_schedule.c | 892 +++++++++++++++++---------------- 1 file changed, 471 insertions(+), 421 deletions(-)
tests/i915/gem_exec_schedule.c +471 -421
@@ -35,11 +35,13 @@#include <unistd.h> #include "i915/gem.h" +#include "i915/gem_vm.h" #include "igt.h" #include "igt_rand.h" #include "igt_rapl.h" #include "igt_sysfs.h" #include "igt_vgem.h" +#include "intel_ctx.h" #include "sw_sync.h" #define LO 0
@@ -51,7 +53,6 @@#define MAX_CONTEXTS 1024#define MAX_ELSP_QLEN 16 -#define MAX_ENGINES (I915_EXEC_RING_MASK + 1)#define MI_SEMAPHORE_WAIT (0x1c << 23)#define MI_SEMAPHORE_POLL (1 << 15)
@@ -89,7 +90,7 @@ void __sync_read_u32_count(int fd, uint32_t handle, uint32_t *dst, uint64_t sizegem_read (fd, handle,0 , dst, size); } -static uint32_t __store_dword (int fd,uint32_t ctx,unsigned ring, +static uint32_t __store_dword (int fd,const intel_ctx_t *ctx,unsigned ring,uint32_t target,uint32_t offset,uint32_t value,uint32_t cork,int fence,unsigned write_domain) {
@@ -106,7 +107,7 @@ static uint32_t __store_dword(int fd, uint32_t ctx, unsigned ring, execbuf.flags = ring;if (gen <6 ) execbuf.flags |=I915_EXEC_SECURE ; - execbuf.rsvd1 = ctx; + execbuf.rsvd1 = ctx->id;if (fence !=-1 ) { execbuf.flags |=I915_EXEC_FENCE_IN ;
@@ -153,7 +154,7 @@ static uint32_t __store_dword(int fd, uint32_t ctx, unsigned ring,return obj[2 ].handle; } -static void store_dword (int fd,uint32_t ctx,unsigned ring, +static void store_dword (int fd,const intel_ctx_t *ctx,unsigned ring,uint32_t target,uint32_t offset,uint32_t value,unsigned write_domain) {
@@ -162,7 +163,7 @@ static void store_dword(int fd, uint32_t ctx, unsigned ring, 0, -1, write_domain)); } -static void store_dword_plug (int fd,uint32_t ctx,unsigned ring, +static void store_dword_plug (int fd,const intel_ctx_t *ctx,unsigned ring,uint32_t target,uint32_t offset,uint32_t value,uint32_t cork,unsigned write_domain) {
@@ -171,7 +172,7 @@ static void store_dword_plug(int fd, uint32_t ctx, unsigned ring, cork, -1, write_domain)); } -static void store_dword_fenced (int fd,uint32_t ctx,unsigned ring, +static void store_dword_fenced (int fd,const intel_ctx_t *ctx,unsigned ring,uint32_t target,uint32_t offset,uint32_t value,int fence,unsigned write_domain) {
@@ -180,21 +181,24 @@ static void store_dword_fenced(int fd, uint32_t ctx, unsigned ring, 0, fence, write_domain)); } -static uint32_t create_highest_priority (int fd) +static const intel_ctx_t * +create_highest_priority (int fd,const intel_ctx_cfg_t *cfg) { -uint32_t ctx =gem_context_clone_with_engines (fd,0 ); +const intel_ctx_t *ctx =intel_ctx_create (fd, cfg);/* * If there is no priority support, all contexts will have equal * priority (and therefore the max user priority), so no context * can overtake us, and we effectively can form a plug. */ -__gem_context_set_priority (fd, ctx,MAX_PRIO ); +__gem_context_set_priority (fd, ctx->id,MAX_PRIO );return ctx; } -static void unplug_show_queue (int fd,struct igt_cork *c,unsigned int engine) +static void unplug_show_queue (int fd,struct igt_cork *c, +const intel_ctx_cfg_t *cfg, +unsigned int engine) {igt_spin_t *spin[MAX_ELSP_QLEN ];int max =MAX_ELSP_QLEN ;
@@ -204,12 +208,9 @@ static void unplug_show_queue(int fd, struct igt_cork *c, unsigned int engine) max =1 ;for (int n =0 ; n < max; n++) { -const struct igt_spin_factory opts = { - .ctx_id =create_highest_priority (fd), - .engine = engine, - }; - spin[n] =__igt_spin_factory (fd, &opts); -gem_context_destroy (fd, opts.ctx_id); +const intel_ctx_t *ctx =create_highest_priority (fd, cfg); + spin[n] = __igt_spin_new(fd, .ctx = ctx, .engine = engine); +intel_ctx_destroy (fd, ctx); }igt_cork_unplug (c);/* batches will now be queued on the engine */
@@ -220,7 +221,7 @@ static void unplug_show_queue(int fd, struct igt_cork *c, unsigned int engine) } -static void fifo (int fd,unsigned ring) +static void fifo (int fd,const intel_ctx_t *ctx,unsigned ring) {IGT_CORK_FENCE (cork);uint32_t scratch;
@@ -232,10 +233,10 @@ static void fifo(int fd, unsigned ring) fence =igt_cork_plug (&cork, fd);/* Same priority, same timeline, final result will be the second eb */ -store_dword_fenced (fd,0 , ring, scratch,0 ,1 , fence,0 ); -store_dword_fenced (fd,0 , ring, scratch,0 ,2 , fence,0 ); +store_dword_fenced (fd, ctx, ring, scratch,0 ,1 , fence,0 ); +store_dword_fenced (fd, ctx, ring, scratch,0 ,2 , fence,0 ); -unplug_show_queue (fd, &cork, ring); +unplug_show_queue (fd, &cork, &ctx->cfg, ring);close (fence); result =__sync_read_u32 (fd, scratch,0 );
@@ -249,7 +250,8 @@ enum implicit_dir { WRITE_READ = 0x2, }; -static void implicit_rw (int i915,unsigned ring,enum implicit_dir dir) +static void implicit_rw (int i915,const intel_ctx_t *ctx,unsigned int ring, +enum implicit_dir dir) {const struct intel_execution_engine2 *e;IGT_CORK_FENCE (cork);
@@ -259,7 +261,7 @@ static void implicit_rw(int i915, unsigned ring, enum implicit_dir dir)int fence; count =0 ; -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) {if (e->flags == ring)continue ;
@@ -274,28 +276,28 @@ static void implicit_rw(int i915, unsigned ring, enum implicit_dir dir) fence =igt_cork_plug (&cork, i915);if (dir &WRITE_READ ) -store_dword_fenced (i915,0 , +store_dword_fenced (i915, ctx, ring, scratch,0 , ~ring, fence,I915_GEM_DOMAIN_RENDER ); -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) {if (e->flags == ring)continue ;if (!gem_class_can_store_dword (i915, e->class))continue ; -store_dword_fenced (i915,0 , +store_dword_fenced (i915, ctx, e->flags, scratch,0 , e->flags, fence,0 ); }if (dir &READ_WRITE ) -store_dword_fenced (i915,0 , +store_dword_fenced (i915, ctx, ring, scratch,0 , ring, fence,I915_GEM_DOMAIN_RENDER ); -unplug_show_queue (i915, &cork, ring); +unplug_show_queue (i915, &cork, &ctx->cfg, ring);close (fence); result =__sync_read_u32 (i915, scratch,0 );
@@ -307,7 +309,8 @@ static void implicit_rw(int i915, unsigned ring, enum implicit_dir dir)igt_assert_eq_u32 (result, ring); } -static void independent (int fd,unsigned int engine,unsigned long flags) +static void independent (int fd,const intel_ctx_t *ctx,unsigned int engine, +unsigned long flags) {const struct intel_execution_engine2 *e;IGT_CORK_FENCE (cork);
@@ -323,7 +326,7 @@ static void independent(int fd, unsigned int engine, unsigned long flags) fence =igt_cork_plug (&cork, fd);/* Check that we can submit to engine while all others are blocked */ -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) {if (e->flags == engine)continue ;
@@ -332,6 +335,7 @@ static void independent(int fd, unsigned int engine, unsigned long flags)if (spin ==NULL ) { spin = __igt_spin_new(fd, + .ctx = ctx, .engine = e->flags, .flags = flags); }else {
@@ -343,14 +347,14 @@ static void independent(int fd, unsigned int engine, unsigned long flags)gem_execbuf (fd, &eb); } -store_dword_fenced (fd,0 , e->flags, scratch,0 , e->flags, fence,0 ); +store_dword_fenced (fd, ctx, e->flags, scratch,0 , e->flags, fence,0 ); }igt_require (spin);/* Same priority, but different timeline (as different engine) */ - batch =__store_dword (fd,0 , engine, scratch,0 , engine,0 , fence,0 ); + batch =__store_dword (fd, ctx, engine, scratch,0 , engine,0 , fence,0 ); -unplug_show_queue (fd, &cork, engine); +unplug_show_queue (fd, &cork, &ctx->cfg, engine);close (fence);gem_sync (fd, batch);
@@ -373,11 +377,12 @@ static void independent(int fd, unsigned int engine, unsigned long flags)gem_close (fd, scratch); } -static void smoketest (int fd,unsigned ring,unsigned timeout) +static void smoketest (int fd,const intel_ctx_cfg_t *cfg, +unsigned ring,unsigned timeout) {const int ncpus =sysconf (_SC_NPROCESSORS_ONLN);const struct intel_execution_engine2 *e; -unsigned engines[MAX_ENGINES ]; +unsigned engines[GEM_MAX_ENGINES ];unsigned nengine;unsigned engine;uint32_t scratch;
@@ -385,7 +390,7 @@ static void smoketest(int fd, unsigned ring, unsigned timeout) nengine =0 ;if (ring ==ALL_ENGINES ) { -__for_each_physical_engine (fd, e) +for_each_ctx_cfg_engine (fd, cfg, e)if (gem_class_can_store_dword (fd, e->class)) engines[nengine++] = e->flags; }else {
@@ -396,16 +401,16 @@ static void smoketest(int fd, unsigned ring, unsigned timeout) scratch =gem_create (fd,4096 ); igt_fork(child, ncpus) {unsigned long count =0 ; -uint32_t ctx; +const intel_ctx_t *ctx;hars_petruska_f54_1_random_perturb (child); - ctx =gem_context_clone_with_engines (fd,0 ); + ctx =intel_ctx_create (fd, cfg);igt_until_timeout (timeout) {int prio; prio =hars_petruska_f54_1_random_unsafe_max (MAX_PRIO -MIN_PRIO ) +MIN_PRIO ; -gem_context_set_priority (fd, ctx, prio); +gem_context_set_priority (fd, ctx->id, prio); engine = engines[hars_petruska_f54_1_random_unsafe_max (nengine)]; store_dword(fd, ctx, engine, scratch,
@@ -416,7 +421,7 @@ static void smoketest(int fd, unsigned ring, unsigned timeout)8 *child +4 , count++, 0); } -gem_context_destroy (fd, ctx); +intel_ctx_destroy (fd, ctx); }igt_waitchildren ();
@@ -483,7 +488,8 @@ static uint32_t timeslicing_batches(int i915, uint32_t *offset)return handle; } -static void timeslice (int i915,unsigned int engine) +static void timeslice (int i915,const intel_ctx_cfg_t *cfg, +unsigned int engine) {unsigned int offset =24 <<20 ;struct drm_i915_gem_exec_object2 obj = {
@@ -494,6 +500,7 @@ static void timeslice(int i915, unsigned int engine) .buffers_ptr = to_user_pointer(&obj), .buffer_count = 1, }; +const intel_ctx_t *ctx;uint32_t *result;int out;
@@ -517,12 +524,13 @@ static void timeslice(int i915, unsigned int engine)/* No coupling between requests; free to timeslice */ - execbuf.rsvd1 =gem_context_clone_with_engines (i915,0 ); + ctx =intel_ctx_create (i915, cfg); + execbuf.rsvd1 = ctx->id; execbuf.rsvd2 >>=32 ; execbuf.flags = engine |I915_EXEC_FENCE_OUT ; execbuf.batch_start_offset = offset;gem_execbuf_wr (i915, &execbuf); -gem_context_destroy (i915, execbuf.rsvd1); +intel_ctx_destroy (i915, ctx);gem_sync (i915, obj.handle);gem_close (i915, obj.handle);
@@ -576,7 +584,8 @@ static uint32_t timesliceN_batches(int i915, uint32_t offset, int count)return handle; } -static void timesliceN (int i915,unsigned int engine,int count) +static void timesliceN (int i915,const intel_ctx_cfg_t *cfg, +unsigned int engine,int count) {const unsigned int sz =ALIGN ((count +1 ) *1024 ,4096 );unsigned int offset =24 <<20 ;
@@ -592,6 +601,7 @@ static void timesliceN(int i915, unsigned int engine, int count) };uint32_t *result =gem_mmap__device_coherent (i915, obj.handle,0 , sz,PROT_READ ); +const intel_ctx_t *ctx;int fence[count];/*
@@ -608,10 +618,11 @@ static void timesliceN(int i915, unsigned int engine, int count)/* No coupling between requests; free to timeslice */ for (int i =0 ; i < count; i++) { - execbuf.rsvd1 =gem_context_clone_with_engines (i915,0 ); + ctx =intel_ctx_create (i915, cfg); + execbuf.rsvd1 = ctx->id; execbuf.batch_start_offset = (i +1 ) *1024 ;;gem_execbuf_wr (i915, &execbuf); -gem_context_destroy (i915, execbuf.rsvd1); +intel_ctx_destroy (i915, ctx); fence[i] = execbuf.rsvd2 >>32 ; }
@@ -629,31 +640,32 @@ static void timesliceN(int i915, unsigned int engine, int count)munmap (result, sz); } -static void lateslice (int i915,unsigned int engine,unsigned long flags) +static void lateslice (int i915,const intel_ctx_cfg_t *cfg, +unsigned int engine,unsigned long flags) { +const intel_ctx_t *ctx;igt_spin_t *spin[3 ]; -uint32_t ctx;igt_require (gem_scheduler_has_semaphores (i915));igt_require (gem_scheduler_has_preemption (i915));igt_require (intel_gen (intel_get_drm_devid (i915)) >=8 ); - ctx =gem_context_create (i915); - spin[0] = igt_spin_new(i915, .ctx_id = ctx, .engine = engine, + ctx =intel_ctx_create (i915, cfg); + spin[0] = igt_spin_new(i915, .ctx = ctx, .engine = engine, .flags = (IGT_SPIN_POLL_RUN |IGT_SPIN_FENCE_OUT | flags)); -gem_context_destroy (i915, ctx); +intel_ctx_destroy (i915, ctx);igt_spin_busywait_until_started (spin[0 ]); - ctx =gem_context_create (i915); - spin[1] = igt_spin_new(i915, .ctx_id = ctx, .engine = engine, + ctx =intel_ctx_create (i915, cfg); + spin[1] = igt_spin_new(i915, .ctx = ctx, .engine = engine, .fence = spin[0]->out_fence, .flags = (IGT_SPIN_POLL_RUN |IGT_SPIN_FENCE_IN | flags)); -gem_context_destroy (i915, ctx); +intel_ctx_destroy (i915, ctx);usleep (5000 );/* give some time for the new spinner to be scheduled */
@@ -664,10 +676,10 @@ static void lateslice(int i915, unsigned int engine, unsigned long flags)* third spinner we then expect timeslicing to be real enabled. */ - ctx =gem_context_create (i915); - spin[2] = igt_spin_new(i915, .ctx_id = ctx, .engine = engine, + ctx =intel_ctx_create (i915, cfg); + spin[2] = igt_spin_new(i915, .ctx = ctx, .engine = engine, .flags =IGT_SPIN_POLL_RUN | flags); -gem_context_destroy (i915, ctx); +intel_ctx_destroy (i915, ctx);igt_spin_busywait_until_started (spin[2 ]);
@@ -689,7 +701,7 @@ static void lateslice(int i915, unsigned int engine, unsigned long flags) }static void cancel_spinner (int i915, -uint32_t ctx,unsigned int engine, +const intel_ctx_t *ctx,unsigned int engine,igt_spin_t *spin) {struct drm_i915_gem_exec_object2 obj = {
@@ -699,7 +711,7 @@ static void cancel_spinner(int i915, .buffers_ptr = to_user_pointer(&obj), .buffer_count = 1, .flags = engine | I915_EXEC_FENCE_SUBMIT, - .rsvd1 = ctx, /* same vm */ + .rsvd1 = ctx->id, /* same vm */ .rsvd2 = spin->out_fence, };uint32_t *map, *cs;
@@ -720,21 +732,18 @@ static void cancel_spinner(int i915,gem_close (i915, obj.handle); } -static void submit_slice (int i915, +static void submit_slice (int i915,const intel_ctx_cfg_t *cfg,const struct intel_execution_engine2 *e, unsigned int flags)#define EARLY_SUBMIT 0x1#define LATE_SUBMIT 0x2#define USERPTR 0x4 { - I915_DEFINE_CONTEXT_PARAM_ENGINES(engines , 1) = {};const struct intel_execution_engine2 *cancel; -struct drm_i915_gem_context_param param = { - .ctx_id =gem_context_create (i915), - .param =I915_CONTEXT_PARAM_ENGINES , - .value =to_user_pointer (&engines), - .size =sizeof (engines), +intel_ctx_cfg_t engine_cfg = { + .num_engines =1 , }; +const intel_ctx_t *ctx;/* * When using a submit fence, we do not want to block concurrent work,
@@ -745,7 +754,7 @@ static void submit_slice(int i915,igt_require (gem_scheduler_has_preemption (i915));igt_require (intel_gen (intel_get_drm_devid (i915)) >=8 ); -__for_each_physical_engine (i915, cancel) { +for_each_ctx_cfg_engine (i915, cfg, cancel) {igt_spin_t *bg, *spin;int timeline =-1 ;int fence =-1 ;
@@ -762,10 +771,10 @@ static void submit_slice(int i915, fence =sw_sync_timeline_create_fence (timeline,1 ); } - engines.engines[0 ].engine_class = e->class; - engines.engines[0 ].engine_instance = e->instance; -gem_context_set_param (i915, ¶m); - spin = igt_spin_new(i915, .ctx_id = param.ctx_id, + engine_cfg.engines[0 ].engine_class = e->class; + engine_cfg.engines[0 ].engine_instance = e->instance; + ctx =intel_ctx_create (i915, &engine_cfg); + spin = igt_spin_new(i915, .ctx = ctx, .fence = fence, .flags = IGT_SPIN_POLL_RUN |
@@ -778,10 +787,13 @@ static void submit_slice(int i915,if (flags &EARLY_SUBMIT )igt_spin_busywait_until_started (spin); - engines.engines[0 ].engine_class = cancel->class; - engines.engines[0 ].engine_instance = cancel->instance; -gem_context_set_param (i915, ¶m); -cancel_spinner (i915, param.ctx_id,0 , spin); +intel_ctx_destroy (i915, ctx); + + engine_cfg.engines[0 ].engine_class = cancel->class; + engine_cfg.engines[0 ].engine_instance = cancel->instance; + ctx =intel_ctx_create (i915, &engine_cfg); + +cancel_spinner (i915, ctx,0 , spin);if (timeline !=-1 )close (timeline);
@@ -789,9 +801,9 @@ static void submit_slice(int i915,gem_sync (i915, spin->handle);igt_spin_free (i915, spin);igt_spin_free (i915, bg); - } -gem_context_destroy (i915, param.ctx_id); +intel_ctx_destroy (i915, ctx); + } }static uint32_t __batch_create (int i915,uint32_t offset)
@@ -810,7 +822,8 @@ static uint32_t batch_create(int i915)return __batch_create (i915,0 ); } -static void semaphore_userlock (int i915,unsigned long flags) +static void semaphore_userlock (int i915,const intel_ctx_t *ctx, +unsigned long flags) {const struct intel_execution_engine2 *e;struct drm_i915_gem_exec_object2 obj = {
@@ -818,6 +831,7 @@ static void semaphore_userlock(int i915, unsigned long flags) };igt_spin_t *spin =NULL ;uint32_t scratch; +const intel_ctx_t *tmp_ctx;igt_require (gem_scheduler_has_semaphores (i915));
@@ -829,9 +843,10 @@ static void semaphore_userlock(int i915, unsigned long flags)*/ scratch =gem_create (i915,4096 ); -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) {if (!spin) { spin = igt_spin_new(i915, + .ctx = ctx, .dependency = scratch, .engine = e->flags, .flags = flags);
@@ -854,13 +869,13 @@ static void semaphore_userlock(int i915, unsigned long flags)* on a HW semaphore) but it should not prevent any real work from * taking precedence. */ - scratch =gem_context_clone_with_engines (i915,0 ); -__for_each_physical_engine (i915, e) { + tmp_ctx =intel_ctx_create (i915, &ctx->cfg); +for_each_ctx_engine (i915, ctx, e) {struct drm_i915_gem_execbuffer2 execbuf = { .buffers_ptr =to_user_pointer (&obj), .buffer_count =1 , .flags = e->flags, - .rsvd1 = scratch, + .rsvd1 = tmp_ctx->id, };if (e->flags == (spin->execbuf.flags &I915_EXEC_RING_MASK ))
@@ -868,14 +883,15 @@ static void semaphore_userlock(int i915, unsigned long flags)gem_execbuf (i915, &execbuf); } -gem_context_destroy (i915, scratch); +intel_ctx_destroy (i915, tmp_ctx);gem_sync (i915, obj.handle);/* to hang unless we can preempt */ gem_close (i915, obj.handle);igt_spin_free (i915, spin); } -static void semaphore_codependency (int i915,unsigned long flags) +static void semaphore_codependency (int i915,const intel_ctx_t *ctx, +unsigned long flags) {const struct intel_execution_engine2 *e;struct {
@@ -894,8 +910,8 @@ static void semaphore_codependency(int i915, unsigned long flags)*/ i =0 ; -__for_each_physical_engine (i915, e) { -uint32_t ctx; +for_each_ctx_engine (i915, ctx, e) { +const intel_ctx_t *tmp_ctx;if (!e->flags) {igt_require (gem_class_can_store_dword (i915, e->class));
@@ -905,11 +921,11 @@ static void semaphore_codependency(int i915, unsigned long flags)if (!gem_class_can_store_dword (i915, e->class))continue ; - ctx =gem_context_clone_with_engines (i915,0 ); + tmp_ctx =intel_ctx_create (i915, &ctx->cfg); task[i].xcs = __igt_spin_new(i915, - .ctx_id = ctx, + .ctx = tmp_ctx, .engine = e->flags, .flags =IGT_SPIN_POLL_RUN | flags);igt_spin_busywait_until_started (task[i].xcs);
@@ -917,11 +933,11 @@ static void semaphore_codependency(int i915, unsigned long flags)/* Common rcs tasks will be queued in FIFO */ task[i].rcs = __igt_spin_new(i915, - .ctx_id = ctx, + .ctx = tmp_ctx, .engine = 0, .dependency = task[i].xcs->handle); -gem_context_destroy (i915, ctx); +intel_ctx_destroy (i915, tmp_ctx);if (++i ==ARRAY_SIZE (task))break ;
@@ -944,11 +960,13 @@ static void semaphore_codependency(int i915, unsigned long flags) } } -static void semaphore_resolve (int i915,unsigned long flags) +static void semaphore_resolve (int i915,const intel_ctx_cfg_t *cfg, +unsigned long flags) {const struct intel_execution_engine2 *e;const uint32_t SEMAPHORE_ADDR =64 <<10 ; -uint32_t semaphore, outer, inner, *sema; +uint32_t semaphore, *sema; +const intel_ctx_t *outer, *inner;/* * Userspace may submit batches that wait upon unresolved
@@ -962,13 +980,13 @@ static void semaphore_resolve(int i915, unsigned long flags)igt_require (gem_scheduler_has_preemption (i915));igt_require (intel_get_drm_devid (i915) >=8 );/* for MI_SEMAPHORE_WAIT */ - outer =gem_context_clone_with_engines (i915,0 ); - inner =gem_context_clone_with_engines (i915,0 ); + outer =intel_ctx_create (i915, cfg); + inner =intel_ctx_create (i915, cfg); semaphore =gem_create (i915,4096 ); sema =gem_mmap__wc (i915, semaphore,0 ,4096 ,PROT_WRITE ); -__for_each_physical_engine (i915, e) { +for_each_ctx_cfg_engine (i915, cfg, e) {struct drm_i915_gem_exec_object2 obj[3 ];struct drm_i915_gem_execbuffer2 eb;uint32_t handle, cancel;
@@ -1023,7 +1041,7 @@ static void semaphore_resolve(int i915, unsigned long flags) obj[2 ].handle = handle; eb.buffer_count =3 ; eb.buffers_ptr =to_user_pointer (obj); - eb.rsvd1 = outer; + eb.rsvd1 = outer->id;gem_execbuf (i915, &eb);/* Then add the GPU hang intermediatory */
@@ -1054,7 +1072,7 @@ static void semaphore_resolve(int i915, unsigned long flags) obj[0 ].flags =EXEC_OBJECT_PINNED ; obj[1 ].handle = cancel; eb.buffer_count =2 ; - eb.rsvd1 = inner; + eb.rsvd1 = inner->id;gem_execbuf (i915, &eb);gem_wait (i915, cancel, &poke);/* match sync's WAIT_PRIORITY */ gem_close (i915, cancel);
@@ -1069,22 +1087,23 @@ static void semaphore_resolve(int i915, unsigned long flags)munmap (sema,4096 );gem_close (i915, semaphore); -gem_context_destroy (i915, inner); -gem_context_destroy (i915, outer); +intel_ctx_destroy (i915, inner); +intel_ctx_destroy (i915, outer); } -static void semaphore_noskip (int i915,unsigned long flags) +static void semaphore_noskip (int i915,const intel_ctx_cfg_t *cfg, +unsigned long flags) {const unsigned int gen =intel_gen (intel_get_drm_devid (i915));const struct intel_execution_engine2 *outer, *inner; -uint32_t ctx; +const intel_ctx_t *ctx;igt_require (gen >=6 );/* MI_STORE_DWORD_IMM convenience */ - ctx =gem_context_clone_with_engines (i915,0 ); + ctx =intel_ctx_create (i915, cfg); -__for_each_physical_engine (i915, outer) { -__for_each_physical_engine (i915, inner) { +for_each_ctx_engine (i915, ctx, outer) { +for_each_ctx_engine (i915, ctx, inner) {struct drm_i915_gem_exec_object2 obj[3 ];struct drm_i915_gem_execbuffer2 eb;uint32_t handle, *cs, *map;
@@ -1094,9 +1113,11 @@ static void semaphore_noskip(int i915, unsigned long flags) !gem_class_can_store_dword(i915, inner->class)) continue; - chain = __igt_spin_new(i915, .engine = outer->flags, .flags = flags); + chain = __igt_spin_new(i915, .ctx = ctx, + .engine = outer->flags, .flags = flags); - spin = __igt_spin_new(i915, .engine = inner->flags, .flags = flags); + spin = __igt_spin_new(i915, .ctx = ctx, + .engine = inner->flags, .flags = flags);igt_spin_end (spin);/* we just want its address for later */ gem_sync (i915, spin->handle);igt_spin_reset (spin);
@@ -1129,7 +1150,7 @@ static void semaphore_noskip(int i915, unsigned long flags)memset (&eb,0 ,sizeof (eb)); eb.buffer_count =3 ; eb.buffers_ptr =to_user_pointer (obj); - eb.rsvd1 = ctx; + eb.rsvd1 = ctx->id; eb.flags = inner->flags;gem_execbuf (i915, &eb);
@@ -1153,11 +1174,12 @@ static void semaphore_noskip(int i915, unsigned long flags) } } -gem_context_destroy (i915, ctx); +intel_ctx_destroy (i915, ctx); }static void -noreorder(int i915, unsigned int engine, int prio, unsigned int flags) +noreorder (int i915,const intel_ctx_cfg_t *cfg, + unsigned int engine, int prio, unsigned int flags)#define CORKED 0x1 {const unsigned int gen =intel_gen (intel_get_drm_devid (i915));
@@ -1169,24 +1191,24 @@ noreorder(int i915, unsigned int engine, int prio, unsigned int flags) .buffers_ptr = to_user_pointer(&obj), .buffer_count = 1, .flags = engine, - .rsvd1 = gem_context_clone_with_engines(i915, 0), }; +intel_ctx_cfg_t vm_cfg = *cfg; +const intel_ctx_t *ctx;IGT_CORK_FENCE (cork);uint32_t *map, *cs;igt_spin_t *slice;igt_spin_t *spin;int fence =-1 ;uint64_t addr; -uint32_t ctx;if (flags &CORKED ) fence =igt_cork_plug (&cork, i915); - ctx =gem_context_clone (i915, execbuf.rsvd1, -I915_CONTEXT_CLONE_ENGINES | -I915_CONTEXT_CLONE_VM , -0 ); - spin =igt_spin_new (i915, ctx, + vm_cfg.vm =gem_vm_create (i915); + + ctx =intel_ctx_create (i915, &vm_cfg); + + spin = igt_spin_new(i915, .ctx = ctx, .engine = engine, .fence = fence, .flags =IGT_SPIN_FENCE_OUT |IGT_SPIN_FENCE_IN );
@@ -1195,7 +1217,7 @@ noreorder(int i915, unsigned int engine, int prio, unsigned int flags)/* Loop around the engines, creating a chain of fences */ spin->execbuf.rsvd2 = (uint64_t )dup (spin->out_fence) <<32 ; spin->execbuf.rsvd2 |=0xffffffff ; -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) {if (e->flags == engine)continue ;
@@ -1208,7 +1230,7 @@ noreorder(int i915, unsigned int engine, int prio, unsigned int flags) }close (spin->execbuf.rsvd2); spin->execbuf.rsvd2 >>=32 ; -gem_context_destroy (i915, ctx); +intel_ctx_destroy (i915, ctx);/* * Wait upon the fence chain, and try to terminate the spinner.
@@ -1241,11 +1263,13 @@ noreorder(int i915, unsigned int engine, int prio, unsigned int flags) execbuf.rsvd2 = spin->execbuf.rsvd2; execbuf.flags |=I915_EXEC_FENCE_IN ; -gem_context_set_priority (i915, execbuf.rsvd1, prio); + ctx =intel_ctx_create (i915, &vm_cfg); +gem_context_set_priority (i915, ctx->id, prio); + execbuf.rsvd1 = ctx->id;gem_execbuf (i915, &execbuf);gem_close (i915, obj.handle); -gem_context_destroy (i915, execbuf.rsvd1); +intel_ctx_destroy (i915, ctx);if (cork.fd !=-1 )igt_cork_unplug (&cork);
@@ -1258,7 +1282,9 @@ noreorder(int i915, unsigned int engine, int prio, unsigned int flags)* * Without timeslices, fallback to waiting a second. */ + ctx =intel_ctx_create (i915, &vm_cfg); slice = igt_spin_new(i915, + .ctx = ctx, .engine = engine, .flags =IGT_SPIN_POLL_RUN ); igt_until_timeout(1) {
@@ -1266,6 +1292,7 @@ noreorder(int i915, unsigned int engine, int prio, unsigned int flags)break ; }igt_spin_free (i915, slice); +intel_ctx_destroy (i915, ctx);/* Check the store did not run before the spinner */ igt_assert_eq (sync_fence_status (spin->out_fence),0 );
@@ -1273,20 +1300,21 @@ noreorder(int i915, unsigned int engine, int prio, unsigned int flags)gem_quiescent_gpu (i915); } -static void reorder(int fd, unsigned ring, unsigned flags) +static void reorder (int fd,const intel_ctx_cfg_t *cfg, + unsigned ring, unsigned flags)#define EQUAL 1 {IGT_CORK_FENCE (cork);uint32_t scratch;uint32_t result; -uint32_t ctx[2 ]; +const intel_ctx_t *ctx[2 ];int fence; - ctx[LO ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); + ctx[LO ] =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx[LO ]->id,MIN_PRIO ); - ctx[HI ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[HI ], flags &EQUAL ?MIN_PRIO :0 ); + ctx[HI ] =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx[HI ]->id, flags &EQUAL ?MIN_PRIO :0 ); scratch =gem_create (fd,4096 ); fence =igt_cork_plug (&cork, fd);
@@ -1294,40 +1322,40 @@ static void reorder(int fd, unsigned ring, unsigned flags)/* We expect the high priority context to be executed first, and * so the final result will be value from the low priority context. */ -store_dword_fenced (fd, ctx[LO ], ring, scratch,0 , ctx[LO ], fence,0 ); -store_dword_fenced (fd, ctx[HI ], ring, scratch,0 , ctx[HI ], fence,0 ); +store_dword_fenced (fd, ctx[LO ], ring, scratch,0 , ctx[LO ]->id, fence,0 ); +store_dword_fenced (fd, ctx[HI ], ring, scratch,0 , ctx[HI ]->id, fence,0 ); -unplug_show_queue (fd, &cork, ring); +unplug_show_queue (fd, &cork, cfg, ring);close (fence); -gem_context_destroy (fd, ctx[LO ]); -gem_context_destroy (fd, ctx[HI ]); - result =__sync_read_u32 (fd, scratch,0 );gem_close (fd, scratch);if (flags &EQUAL )/* equal priority, result will be fifo */ -igt_assert_eq_u32 (result, ctx[HI ]); +igt_assert_eq_u32 (result, ctx[HI ]->id);else -igt_assert_eq_u32 (result, ctx[LO ]); +igt_assert_eq_u32 (result, ctx[LO ]->id); + +intel_ctx_destroy (fd, ctx[LO ]); +intel_ctx_destroy (fd, ctx[HI ]); } -static void promotion (int fd,unsigned ring) +static void promotion (int fd,const intel_ctx_cfg_t *cfg,unsigned ring) {IGT_CORK_FENCE (cork);uint32_t result, dep;uint32_t result_read, dep_read; -uint32_t ctx[3 ]; +const intel_ctx_t *ctx[3 ];int fence; - ctx[LO ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); + ctx[LO ] =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx[LO ]->id,MIN_PRIO ); - ctx[HI ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[HI ],0 ); + ctx[HI ] =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx[HI ]->id,0 ); - ctx[NOISE ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[NOISE ],MIN_PRIO /2 ); + ctx[NOISE ] =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx[NOISE ]->id,MIN_PRIO /2 ); result =gem_create (fd,4096 ); dep =gem_create (fd,4096 );
@@ -1339,30 +1367,30 @@ static void promotion(int fd, unsigned ring)* fifo would be NOISE, LO, HI. * strict priority would be HI, NOISE, LO */ -store_dword_fenced (fd, ctx[NOISE ], ring, result,0 , ctx[NOISE ], fence,0 ); -store_dword_fenced (fd, ctx[LO ], ring, result,0 , ctx[LO ], fence,0 ); +store_dword_fenced (fd, ctx[NOISE ], ring, result,0 , ctx[NOISE ]->id, fence,0 ); +store_dword_fenced (fd, ctx[LO ], ring, result,0 , ctx[LO ]->id, fence,0 );/* link LO <-> HI via a dependency on another buffer */ -store_dword (fd, ctx[LO ], ring, dep,0 , ctx[LO ],I915_GEM_DOMAIN_INSTRUCTION ); -store_dword (fd, ctx[HI ], ring, dep,0 , ctx[HI ],0 ); +store_dword (fd, ctx[LO ], ring, dep,0 , ctx[LO ]->id,I915_GEM_DOMAIN_INSTRUCTION ); +store_dword (fd, ctx[HI ], ring, dep,0 , ctx[HI ]->id,0 ); -store_dword (fd, ctx[HI ], ring, result,0 , ctx[HI ],0 ); +store_dword (fd, ctx[HI ], ring, result,0 , ctx[HI ]->id,0 ); -unplug_show_queue (fd, &cork, ring); +unplug_show_queue (fd, &cork, cfg, ring);close (fence); -gem_context_destroy (fd, ctx[NOISE ]); -gem_context_destroy (fd, ctx[LO ]); -gem_context_destroy (fd, ctx[HI ]); - dep_read =__sync_read_u32 (fd, dep,0 );gem_close (fd, dep); result_read =__sync_read_u32 (fd, result,0 );gem_close (fd, result); -igt_assert_eq_u32 (dep_read, ctx[HI ]); -igt_assert_eq_u32 (result_read, ctx[NOISE ]); +igt_assert_eq_u32 (dep_read, ctx[HI ]->id); +igt_assert_eq_u32 (result_read, ctx[NOISE ]->id); + +intel_ctx_destroy (fd, ctx[NOISE ]); +intel_ctx_destroy (fd, ctx[LO ]); +intel_ctx_destroy (fd, ctx[HI ]); } static bool set_preempt_timeout(int i915,
@@ -1376,34 +1404,35 @@ static bool set_preempt_timeout(int i915,#define NEW_CTX (0x1 << 0)#define HANG_LP (0x1 << 1) -static void preempt (int fd,const struct intel_execution_engine2 *e,unsigned flags) +static void preempt (int fd,const intel_ctx_cfg_t *cfg, +const struct intel_execution_engine2 *e,unsigned flags) {uint32_t result =gem_create (fd,4096 );uint32_t result_read;igt_spin_t *spin[MAX_ELSP_QLEN ]; -uint32_t ctx[2 ]; +const intel_ctx_t *ctx[2 ];igt_hang_t hang;/* Set a fast timeout to speed the test up (if available) */ set_preempt_timeout (fd, e,150 ); - ctx[LO ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); + ctx[LO ] =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx[LO ]->id,MIN_PRIO ); - ctx[HI ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[HI ],MAX_PRIO ); + ctx[HI ] =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx[HI ]->id,MAX_PRIO );if (flags &HANG_LP ) - hang =igt_hang_ctx (fd, ctx[LO ], e->flags,0 ); + hang =igt_hang_ctx (fd, ctx[LO ]->id, e->flags,0 );for (int n =0 ; n <ARRAY_SIZE (spin); n++) {if (flags &NEW_CTX ) { -gem_context_destroy (fd, ctx[LO ]); - ctx[LO ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); +intel_ctx_destroy (fd, ctx[LO ]); + ctx[LO ] =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx[LO ]->id,MIN_PRIO ); } spin[n] = __igt_spin_new(fd, - .ctx_id = ctx[LO], + .ctx = ctx[LO], .engine = e->flags, .flags = flags &USERPTR ?IGT_SPIN_USERPTR :0 );igt_debug ("spin[%d].handle=%d\n" , n, spin[n]->handle);
@@ -1421,8 +1450,8 @@ static void preempt(int fd, const struct intel_execution_engine2 *e, unsigned flif (flags &HANG_LP )igt_post_hang_ring (fd, hang); -gem_context_destroy (fd, ctx[LO ]); -gem_context_destroy (fd, ctx[HI ]); +intel_ctx_destroy (fd, ctx[LO ]); +intel_ctx_destroy (fd, ctx[HI ]);gem_close (fd, result); }
@@ -1430,22 +1459,23 @@ static void preempt(int fd, const struct intel_execution_engine2 *e, unsigned fl#define CHAIN 0x1#define CONTEXTS 0x2 -static igt_spin_t *__noise (int fd,uint32_t ctx,int prio,igt_spin_t *spin) +static igt_spin_t *__noise (int fd,const intel_ctx_t *ctx, +int prio,igt_spin_t *spin) {const struct intel_execution_engine2 *e; -gem_context_set_priority (fd, ctx, prio); +gem_context_set_priority (fd, ctx->id, prio); -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) {if (spin ==NULL ) { spin = __igt_spin_new(fd, - .ctx_id = ctx, + .ctx = ctx, .engine = e->flags); }else {struct drm_i915_gem_execbuffer2 eb = { .buffer_count =1 , .buffers_ptr =to_user_pointer (&spin->obj[IGT_SPIN_BATCH ]), - .rsvd1 = ctx, + .rsvd1 = ctx->id, .flags = e->flags, };gem_execbuf (fd, &eb);
@@ -1456,7 +1486,7 @@ static igt_spin_t *__noise(int fd, uint32_t ctx, int prio, igt_spin_t *spin) }static void __preempt_other (int fd, -uint32_t *ctx, +const intel_ctx_t **ctx,unsigned int target,unsigned int primary,unsigned flags) {
@@ -1472,7 +1502,7 @@ static void __preempt_other(int fd, n++;if (flags &CHAIN ) { -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx[LO ], e) {store_dword (fd, ctx[LO ], e->flags, result, (n +1 )*sizeof (uint32_t ), n +1 ,I915_GEM_DOMAIN_RENDER );
@@ -1496,11 +1526,12 @@ static void __preempt_other(int fd,gem_close (fd, result); } -static void preempt_other (int fd,unsigned ring,unsigned int flags) +static void preempt_other (int fd,const intel_ctx_cfg_t *cfg, +unsigned ring,unsigned int flags) {const struct intel_execution_engine2 *e;igt_spin_t *spin =NULL ; -uint32_t ctx[3 ]; +const intel_ctx_t *ctx[3 ];/* On each engine, insert * [NOISE] spinner,
@@ -1512,16 +1543,16 @@ static void preempt_other(int fd, unsigned ring, unsigned int flags)* can cross engines. */ - ctx[LO ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); + ctx[LO ] =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx[LO ]->id,MIN_PRIO ); - ctx[NOISE ] =gem_context_clone_with_engines (fd,0 ); + ctx[NOISE ] =intel_ctx_create (fd, cfg); spin =__noise (fd, ctx[NOISE ],0 ,NULL ); - ctx[HI ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[HI ],MAX_PRIO ); + ctx[HI ] =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx[HI ]->id,MAX_PRIO ); -__for_each_physical_engine (fd, e) { +for_each_ctx_cfg_engine (fd, cfg, e) {igt_debug ("Primary engine: %s\n" , e->name);__preempt_other (fd, ctx, ring, e->flags, flags);
@@ -1530,12 +1561,12 @@ static void preempt_other(int fd, unsigned ring, unsigned int flags)igt_assert (gem_bo_busy (fd, spin->handle));igt_spin_free (fd, spin); -gem_context_destroy (fd, ctx[LO ]); -gem_context_destroy (fd, ctx[NOISE ]); -gem_context_destroy (fd, ctx[HI ]); +intel_ctx_destroy (fd, ctx[LO ]); +intel_ctx_destroy (fd, ctx[NOISE ]); +intel_ctx_destroy (fd, ctx[HI ]); } -static void __preempt_queue (int fd, +static void __preempt_queue (int fd,const intel_ctx_cfg_t *cfg,unsigned target,unsigned primary,unsigned depth,unsigned flags) {
@@ -1543,33 +1574,33 @@ static void __preempt_queue(int fd,uint32_t result =gem_create (fd,4096 );uint32_t result_read[4096 /sizeof (uint32_t )];igt_spin_t *above =NULL , *below =NULL ; -uint32_t ctx[3 ] = { -gem_context_clone_with_engines (fd,0 ), -gem_context_clone_with_engines (fd,0 ), -gem_context_clone_with_engines (fd,0 ), +const intel_ctx_t *ctx[3 ] = { +intel_ctx_create (fd, cfg), +intel_ctx_create (fd, cfg), +intel_ctx_create (fd, cfg), };int prio =MAX_PRIO ;unsigned int n, i;for (n =0 ; n < depth; n++) {if (flags &CONTEXTS ) { -gem_context_destroy (fd, ctx[NOISE ]); - ctx[NOISE ] =gem_context_clone_with_engines (fd,0 ); +intel_ctx_destroy (fd, ctx[NOISE ]); + ctx[NOISE ] =intel_ctx_create (fd, cfg); } above =__noise (fd, ctx[NOISE ], prio--, above); } -gem_context_set_priority (fd, ctx[HI ], prio--); +gem_context_set_priority (fd, ctx[HI ]->id, prio--);for (; n <MAX_ELSP_QLEN ; n++) {if (flags &CONTEXTS ) { -gem_context_destroy (fd, ctx[NOISE ]); - ctx[NOISE ] =gem_context_clone_with_engines (fd,0 ); +intel_ctx_destroy (fd, ctx[NOISE ]); + ctx[NOISE ] =intel_ctx_create (fd, cfg); } below =__noise (fd, ctx[NOISE ], prio--, below); } -gem_context_set_priority (fd, ctx[LO ], prio--); +gem_context_set_priority (fd, ctx[LO ]->id, prio--); n =0 ; store_dword(fd, ctx[LO], primary,
@@ -1578,7 +1609,7 @@ static void __preempt_queue(int fd, n++;if (flags &CHAIN ) { -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx[LO ], e) {store_dword (fd, ctx[LO ], e->flags, result, (n +1 )*sizeof (uint32_t ), n +1 ,I915_GEM_DOMAIN_RENDER );
@@ -1610,25 +1641,26 @@ static void __preempt_queue(int fd,igt_spin_free (fd, below); } -gem_context_destroy (fd, ctx[LO ]); -gem_context_destroy (fd, ctx[NOISE ]); -gem_context_destroy (fd, ctx[HI ]); +intel_ctx_destroy (fd, ctx[LO ]); +intel_ctx_destroy (fd, ctx[NOISE ]); +intel_ctx_destroy (fd, ctx[HI ]);gem_close (fd, result); } -static void preempt_queue (int fd,unsigned ring,unsigned int flags) +static void preempt_queue (int fd,const intel_ctx_cfg_t *cfg, +unsigned ring,unsigned int flags) {const struct intel_execution_engine2 *e;for (unsigned depth =1 ; depth <=MAX_ELSP_QLEN ; depth *=4 ) -__preempt_queue (fd, ring, ring, depth, flags); +__preempt_queue (fd, cfg, ring, ring, depth, flags); -__for_each_physical_engine (fd, e) { +for_each_ctx_cfg_engine (fd, cfg, e) {if (ring == e->flags)continue ; -__preempt_queue (fd, ring, e->flags,MAX_ELSP_QLEN , flags); +__preempt_queue (fd, cfg, ring, e->flags,MAX_ELSP_QLEN , flags); } }
@@ -1645,19 +1677,16 @@ static void preempt_engines(int i915, const struct intel_execution_engine2 *e, unsigned int flags) { - I915_DEFINE_CONTEXT_PARAM_ENGINES(engines , I915_EXEC_RING_MASK + 1); -struct drm_i915_gem_context_param param = { - .ctx_id =gem_context_create (i915), - .param =I915_CONTEXT_PARAM_ENGINES , - .value =to_user_pointer (&engines), - .size =sizeof (engines), - };struct pnode {struct igt_list_head spinners;struct igt_list_head link; - } pnode[I915_EXEC_RING_MASK +1 ], *p; + } pnode[GEM_MAX_ENGINES ], *p; +struct intel_ctx_cfg cfg = { + .num_engines =GEM_MAX_ENGINES , + };IGT_LIST_HEAD (plist);igt_spin_t *spin, *sn; +const intel_ctx_t *ctx;/* * A quick test that each engine within a context is an independent
@@ -1666,19 +1695,19 @@ static void preempt_engines(int i915,igt_require (has_context_engines (i915)); -for (int n =0 ; n <=I915_EXEC_RING_MASK ; n++) { - engines.engines[n].engine_class = e->class; - engines.engines[n].engine_instance = e->instance; +for (int n =0 ; n <GEM_MAX_ENGINES ; n++) { + cfg.engines[n].engine_class = e->class; + cfg.engines[n].engine_instance = e->instance;IGT_INIT_LIST_HEAD (&pnode[n].spinners);igt_list_add (&pnode[n].link, &plist); } -gem_context_set_param (i915, ¶m); + ctx =intel_ctx_create (i915, &cfg); -for (int n = -I915_EXEC_RING_MASK ; n <=I915_EXEC_RING_MASK ; n++) { +for (int n = -(GEM_MAX_ENGINES -1 ); n <GEM_MAX_ENGINES ; n++) {unsigned int engine = n &I915_EXEC_RING_MASK ; -gem_context_set_priority (i915, param.ctx_id, n); - spin = igt_spin_new(i915, param.ctx_id, .engine = engine); +gem_context_set_priority (i915, ctx->id, n); + spin = igt_spin_new(i915, .ctx = ctx, .engine = engine);igt_list_move_tail (&spin->link, &pnode[engine].spinners);igt_list_move (&pnode[engine].link, &plist);
@@ -1691,17 +1720,18 @@ static void preempt_engines(int i915,igt_spin_free (i915, spin); } } -gem_context_destroy (i915, param.ctx_id); +intel_ctx_destroy (i915, ctx); } -static void preempt_self (int fd,unsigned ring) +static void preempt_self (int fd,const intel_ctx_cfg_t *cfg, +unsigned ring) {const struct intel_execution_engine2 *e;uint32_t result =gem_create (fd,4096 );uint32_t result_read[4096 /sizeof (uint32_t )];igt_spin_t *spin[MAX_ELSP_QLEN ];unsigned int n, i; -uint32_t ctx[3 ]; +const intel_ctx_t *ctx[3 ];/* On each engine, insert * [NOISE] spinner,
@@ -1711,21 +1741,21 @@ static void preempt_self(int fd, unsigned ring)* preempt its own lower priority task on any engine. */ - ctx[NOISE ] =gem_context_clone_with_engines (fd,0 ); - ctx[HI ] =gem_context_clone_with_engines (fd,0 ); + ctx[NOISE ] =intel_ctx_create (fd, cfg); + ctx[HI ] =intel_ctx_create (fd, cfg); n =0 ; -gem_context_set_priority (fd, ctx[HI ],MIN_PRIO ); -__for_each_physical_engine (fd, e) { +gem_context_set_priority (fd, ctx[HI ]->id,MIN_PRIO ); +for_each_ctx_cfg_engine (fd, cfg, e) { spin[n] = __igt_spin_new(fd, - .ctx_id = ctx[NOISE], + .ctx = ctx[NOISE], .engine = e->flags);store_dword (fd, ctx[HI ], e->flags, result, (n +1 )*sizeof (uint32_t ), n +1 ,I915_GEM_DOMAIN_RENDER ); n++; } -gem_context_set_priority (fd, ctx[HI ],MAX_PRIO ); +gem_context_set_priority (fd, ctx[HI ]->id,MAX_PRIO );store_dword (fd, ctx[HI ], ring, result, (n +1 )*sizeof (uint32_t ), n +1 ,I915_GEM_DOMAIN_RENDER );
@@ -1743,36 +1773,37 @@ static void preempt_self(int fd, unsigned ring)for (i =0 ; i <= n; i++)igt_assert_eq_u32 (result_read[i], i); -gem_context_destroy (fd, ctx[NOISE ]); -gem_context_destroy (fd, ctx[HI ]); +intel_ctx_destroy (fd, ctx[NOISE ]); +intel_ctx_destroy (fd, ctx[HI ]);gem_close (fd, result); } -static void preemptive_hang (int fd,const struct intel_execution_engine2 *e) +static void preemptive_hang (int fd,const intel_ctx_cfg_t *cfg, +const struct intel_execution_engine2 *e) {igt_spin_t *spin[MAX_ELSP_QLEN ];igt_hang_t hang; -uint32_t ctx[2 ]; +const intel_ctx_t *ctx[2 ];/* Set a fast timeout to speed the test up (if available) */ set_preempt_timeout (fd, e,150 ); - ctx[HI ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[HI ],MAX_PRIO ); + ctx[HI ] =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx[HI ]->id,MAX_PRIO );for (int n =0 ; n <ARRAY_SIZE (spin); n++) { - ctx[LO ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[LO ],MIN_PRIO ); + ctx[LO ] =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx[LO ]->id,MIN_PRIO ); spin[n] = __igt_spin_new(fd, - .ctx_id = ctx[LO], + .ctx = ctx[LO], .engine = e->flags); -gem_context_destroy (fd, ctx[LO ]); +intel_ctx_destroy (fd, ctx[LO ]); } - hang =igt_hang_ctx (fd, ctx[HI ], e->flags,0 ); + hang =igt_hang_ctx (fd, ctx[HI ]->id, e->flags,0 );igt_post_hang_ring (fd, hang);for (int n =0 ; n <ARRAY_SIZE (spin); n++) {
@@ -1784,10 +1815,11 @@ static void preemptive_hang(int fd, const struct intel_execution_engine2 *e)igt_spin_free (fd, spin[n]); } -gem_context_destroy (fd, ctx[HI ]); +intel_ctx_destroy (fd, ctx[HI ]); } -static void deep (int fd,unsigned ring) +static void deep (int fd,const intel_ctx_cfg_t *cfg, +unsigned ring) {#define XS 8const unsigned int max_req =MAX_PRIO -MIN_PRIO ;
@@ -1799,13 +1831,13 @@ static void deep(int fd, unsigned ring)uint32_t result, dep[XS ];uint32_t read_buf[size /sizeof (uint32_t )];uint32_t expected =0 ; -uint32_t *ctx; +const intel_ctx_t **ctx;int dep_nreq;int n; ctx =malloc (sizeof (*ctx) *MAX_CONTEXTS );for (n =0 ; n <MAX_CONTEXTS ; n++) { - ctx[n] =gem_context_clone_with_engines (fd,0 ); + ctx[n] =intel_ctx_create (fd, cfg); } nreq =gem_submission_measure (fd, ring) / (3 *XS ) *MAX_CONTEXTS ;
@@ -1835,7 +1867,7 @@ static void deep(int fd, unsigned ring) execbuf.buffer_count =XS +2 ; execbuf.flags = ring;for (n =0 ; n <MAX_CONTEXTS ; n++) { - execbuf.rsvd1 = ctx[n]; + execbuf.rsvd1 = ctx[n]->id;gem_execbuf (fd, &execbuf); }gem_close (fd, obj[XS +1 ].handle);
@@ -1853,7 +1885,7 @@ static void deep(int fd, unsigned ring) .buffers_ptr = to_user_pointer(obj), .buffer_count = 3, .flags = ring | (gen < 6 ? I915_EXEC_SECURE : 0), - .rsvd1 = ctx[n % MAX_CONTEXTS], + .rsvd1 = ctx[n % MAX_CONTEXTS]->id, };uint32_t batch[16 ];int i;
@@ -1901,33 +1933,33 @@ static void deep(int fd, unsigned ring) dep_nreq = n;for (n =0 ; n < nreq &&igt_seconds_elapsed (&tv) <4 ; n++) { -uint32_t context = ctx[n %MAX_CONTEXTS ]; -gem_context_set_priority (fd, context,MAX_PRIO - nreq + n); +const intel_ctx_t *context = ctx[n %MAX_CONTEXTS ]; +gem_context_set_priority (fd, context->id,MAX_PRIO - nreq + n); + expected = context->id;for (int m =0 ; m <XS ; m++) { -store_dword_plug (fd, context, ring, result,4 *n, context, dep[m],0 ); -store_dword (fd, context, ring, result,4 *m, context,I915_GEM_DOMAIN_INSTRUCTION ); +store_dword_plug (fd, context, ring, result,4 *n, expected, dep[m],0 ); +store_dword (fd, context, ring, result,4 *m, expected,I915_GEM_DOMAIN_INSTRUCTION ); } - expected = context; }igt_info ("Second deptree: %d requests [%.3fs]\n" , n *XS ,1e-9 *igt_nsec_elapsed (&tv)); -unplug_show_queue (fd, &cork, ring); +unplug_show_queue (fd, &cork, cfg, ring);gem_close (fd, plug);igt_require (expected);/* too slow */ -for (n =0 ; n <MAX_CONTEXTS ; n++) -gem_context_destroy (fd, ctx[n]); -for (int m =0 ; m <XS ; m++) {__sync_read_u32_count (fd, dep[m], read_buf,sizeof (read_buf));gem_close (fd, dep[m]);for (n =0 ; n < dep_nreq; n++) -igt_assert_eq_u32 (read_buf[n], ctx[n %MAX_CONTEXTS ]); +igt_assert_eq_u32 (read_buf[n], ctx[n %MAX_CONTEXTS ]->id); } +for (n =0 ; n <MAX_CONTEXTS ; n++) +intel_ctx_destroy (fd, ctx[n]); +__sync_read_u32_count (fd, result, read_buf,sizeof (read_buf));gem_close (fd, result);
@@ -1951,20 +1983,20 @@ static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)return err; } -static void wide (int fd,unsigned ring) +static void wide (int fd,const intel_ctx_cfg_t *cfg,unsigned ring) {const unsigned int ring_size =gem_submission_measure (fd, ring);struct timespec tv = {};IGT_CORK_FENCE (cork);uint32_t result;uint32_t result_read[MAX_CONTEXTS ]; -uint32_t *ctx; +const intel_ctx_t **ctx;unsigned int count;int fence; ctx =malloc (sizeof (*ctx)*MAX_CONTEXTS );for (int n =0 ; n <MAX_CONTEXTS ; n++) - ctx[n] =gem_context_clone_with_engines (fd,0 ); + ctx[n] =intel_ctx_create (fd, cfg); result =gem_create (fd,4 *MAX_CONTEXTS );
@@ -1975,28 +2007,28 @@ static void wide(int fd, unsigned ring)igt_seconds_elapsed (&tv) <5 && count < ring_size; count++) {for (int n =0 ; n <MAX_CONTEXTS ; n++) { -store_dword_fenced (fd, ctx[n], ring, result,4 *n, ctx[n], +store_dword_fenced (fd, ctx[n], ring, result,4 *n, ctx[n]->id, fence,I915_GEM_DOMAIN_INSTRUCTION ); } }igt_info ("Submitted %d requests over %d contexts in %.1fms\n" , count,MAX_CONTEXTS ,igt_nsec_elapsed (&tv) *1e-6 ); -unplug_show_queue (fd, &cork, ring); +unplug_show_queue (fd, &cork, cfg, ring);close (fence); +__sync_read_u32_count (fd, result, result_read,sizeof (result_read));for (int n =0 ; n <MAX_CONTEXTS ; n++) -gem_context_destroy (fd, ctx[n]); +igt_assert_eq_u32 (result_read[n], ctx[n]->id); -__sync_read_u32_count (fd, result, result_read,sizeof (result_read));for (int n =0 ; n <MAX_CONTEXTS ; n++) -igt_assert_eq_u32 (result_read[n], ctx[n]); +intel_ctx_destroy (fd, ctx[n]);gem_close (fd, result);free (ctx); } -static void reorder_wide (int fd,unsigned ring) +static void reorder_wide (int fd,const intel_ctx_cfg_t *cfg,unsigned ring) {const unsigned int ring_size =gem_submission_measure (fd, ring);const unsigned int gen =intel_gen (intel_get_drm_devid (fd));
@@ -2040,9 +2072,11 @@ static void reorder_wide(int fd, unsigned ring)for (int n =0 , x =1 ; n <ARRAY_SIZE (priorities); n++, x++) {unsigned int sz =ALIGN (ring_size *64 ,4096 );uint32_t *batch; +const intel_ctx_t *tmp_ctx; - execbuf.rsvd1 =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, execbuf.rsvd1, priorities[n]); + tmp_ctx =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, tmp_ctx->id, priorities[n]); + execbuf.rsvd1 = tmp_ctx->id; obj[1 ].handle =gem_create (fd, sz); batch =gem_mmap__device_coherent (fd, obj[1 ].handle,0 , sz,PROT_WRITE );
@@ -2082,10 +2116,10 @@ static void reorder_wide(int fd, unsigned ring)munmap (batch, sz);gem_close (fd, obj[1 ].handle); -gem_context_destroy (fd, execbuf.rsvd1); +intel_ctx_destroy (fd, tmp_ctx); } -unplug_show_queue (fd, &cork, ring); +unplug_show_queue (fd, &cork, cfg, ring);close (fence);__sync_read_u32_count (fd, result, result_read,sizeof (result_read));
@@ -2111,17 +2145,18 @@ static void bind_to_cpu(int cpu)igt_assert (sched_setaffinity (getpid (),sizeof (cpu_set_t), &allowed) ==0 ); } -static void test_pi_ringfull (int fd,unsigned int engine,unsigned int flags) +static void test_pi_ringfull (int fd,const intel_ctx_cfg_t *cfg, +unsigned int engine,unsigned int flags) #define SHARED BIT(0) {const uint32_t bbe =MI_BATCH_BUFFER_END ;struct sigaction sa = { .sa_handler = alarm_handler };struct drm_i915_gem_execbuffer2 execbuf;struct drm_i915_gem_exec_object2 obj[2 ]; +const intel_ctx_t *ctx, *vip;unsigned int last, count;struct itimerval itv;IGT_CORK_HANDLE (c); -uint32_t vip;bool *result;/*
@@ -2153,17 +2188,18 @@ static void test_pi_ringfull(int fd, unsigned int engine, unsigned int flags) execbuf.buffers_ptr =to_user_pointer (&obj[1 ]); execbuf.buffer_count =1 ; - execbuf.flags = engine;/* Warm up both (hi/lo) contexts */ - execbuf.rsvd1 =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, execbuf.rsvd1,MAX_PRIO ); + ctx =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx->id,MAX_PRIO ); + execbuf.rsvd1 = ctx->id;gem_execbuf (fd, &execbuf);gem_sync (fd, obj[1 ].handle); - vip = execbuf.rsvd1; + vip = ctx; - execbuf.rsvd1 =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, execbuf.rsvd1,MIN_PRIO ); + ctx =intel_ctx_create (fd, cfg); +gem_context_set_priority (fd, ctx->id,MIN_PRIO ); + execbuf.rsvd1 = ctx->id;gem_execbuf (fd, &execbuf);gem_sync (fd, obj[1 ].handle);
@@ -2213,7 +2249,7 @@ static void test_pi_ringfull(int fd, unsigned int engine, unsigned int flags)gem_write (fd, obj[1 ].handle,0 , &bbe,sizeof (bbe)); } - result[0 ] = vip != execbuf.rsvd1; + result[0 ] = vip->id != execbuf.rsvd1;igt_debug ("Waking parent\n" );kill (getppid (),SIGALRM );
@@ -2230,7 +2266,7 @@ static void test_pi_ringfull(int fd, unsigned int engine, unsigned int flags)* able to add ourselves to *our* ring without interruption. */ igt_debug ("HP child executing\n" ); - execbuf.rsvd1 = vip; + execbuf.rsvd1 = vip->id; err =__execbuf (fd, &execbuf);igt_debug ("HP execbuf returned %d\n" , err);
@@ -2261,8 +2297,8 @@ static void test_pi_ringfull(int fd, unsigned int engine, unsigned int flags)igt_cork_unplug (&c);igt_waitchildren (); -gem_context_destroy (fd, execbuf.rsvd1); -gem_context_destroy (fd, vip); +intel_ctx_destroy (fd, ctx); +intel_ctx_destroy (fd, vip);gem_close (fd, obj[1 ].handle);gem_close (fd, obj[0 ].handle);munmap (result,4096 );
@@ -2277,8 +2313,8 @@ struct ufd_thread {uint32_t batch;uint32_t scratch;uint32_t *page; +const intel_ctx_cfg_t *cfg;unsigned int engine; -unsigned int flags;int i915;pthread_mutex_t mutex;
@@ -2301,11 +2337,12 @@ static void *ufd_thread(void *arg) { .handle = create_userptr(t->i915, t->page) }, { .handle = t->batch }, }; +const intel_ctx_t *ctx =intel_ctx_create (t->i915, t->cfg);struct drm_i915_gem_execbuffer2 eb = { .buffers_ptr =to_user_pointer (obj), .buffer_count =ARRAY_SIZE (obj), .flags = t->engine, - .rsvd1 =gem_context_clone_with_engines (t->i915,0 ), + .rsvd1 = ctx->id, };gem_context_set_priority (t->i915, eb.rsvd1,MIN_PRIO );
@@ -2314,13 +2351,15 @@ static void *ufd_thread(void *arg)gem_sync (t->i915, obj[0 ].handle);gem_close (t->i915, obj[0 ].handle); -gem_context_destroy (t->i915, eb.rsvd1); +intel_ctx_destroy (t->i915, ctx); t->i915 =-1 ;return NULL ; } -static void test_pi_userfault (int i915,unsigned int engine) +static void test_pi_userfault (int i915, +const intel_ctx_cfg_t *cfg, +unsigned int engine) {const uint32_t bbe =MI_BATCH_BUFFER_END ;struct uffdio_api api = { .api =UFFD_API };
@@ -2353,6 +2392,7 @@ static void test_pi_userfault(int i915, unsigned int engine) "userfaultfd API v%lld:%lld\n", UFFD_API, api.api); t.i915 = i915; + t.cfg = cfg; t.engine = engine; t.page =mmap (NULL ,4096 ,PROT_WRITE ,MAP_SHARED |MAP_ANON ,0 ,0 );
@@ -2383,11 +2423,12 @@ static void test_pi_userfault(int i915, unsigned int engine) .handle = gem_create(i915, 4096), };struct pollfd pfd; +const intel_ctx_t *ctx =intel_ctx_create (i915, cfg);struct drm_i915_gem_execbuffer2 eb = { .buffers_ptr =to_user_pointer (&obj), .buffer_count =1 , .flags = engine |I915_EXEC_FENCE_OUT , - .rsvd1 =gem_context_clone_with_engines (i915,0 ), + .rsvd1 = ctx->id, };gem_context_set_priority (i915, eb.rsvd1,MAX_PRIO );gem_write (i915, obj.handle,0 , &bbe,sizeof (bbe));
@@ -2401,7 +2442,7 @@ static void test_pi_userfault(int i915, unsigned int engine)igt_assert_eq (sync_fence_status (pfd.fd),1 );close (pfd.fd); -gem_context_destroy (i915, eb.rsvd1); +intel_ctx_destroy (i915, ctx); }/* Confirm the low priority context is still waiting */
@@ -2425,15 +2466,10 @@ static void test_pi_userfault(int i915, unsigned int engine)static void *iova_thread (struct ufd_thread *t,int prio) { -unsigned int clone; -uint32_t ctx; - - clone =I915_CONTEXT_CLONE_ENGINES ; -if (t->flags &SHARED ) - clone |=I915_CONTEXT_CLONE_VM ; +const intel_ctx_t *ctx; - ctx =gem_context_clone (t->i915,0 , clone,0 ); -gem_context_set_priority (t->i915, ctx, prio); + ctx =intel_ctx_create (t->i915, t->cfg); +gem_context_set_priority (t->i915, ctx->id, prio); store_dword_plug(t->i915, ctx, t->engine, t->scratch, 0, prio,
@@ -2444,7 +2480,7 @@ static void *iova_thread(struct ufd_thread *t, int prio)pthread_cond_signal (&t->cond);pthread_mutex_unlock (&t->mutex); -gem_context_destroy (t->i915, ctx); +intel_ctx_destroy (t->i915, ctx);return NULL ; }
@@ -2458,8 +2494,10 @@ static void *iova_high(void *arg)return iova_thread (arg,MAX_PRIO ); } -static void test_pi_iova (int i915,unsigned int engine,unsigned int flags) +static void test_pi_iova (int i915,const intel_ctx_cfg_t *cfg, +unsigned int engine,unsigned int flags) { +intel_ctx_cfg_t ufd_cfg = *cfg;struct uffdio_api api = { .api =UFFD_API };struct uffdio_register reg;struct uffdio_copy copy;
@@ -2493,9 +2531,12 @@ static void test_pi_iova(int i915, unsigned int engine, unsigned int flags)igt_require_f (ioctl (ufd,UFFDIO_API , &api) ==0 && api.api ==UFFD_API ,"userfaultfd API v%lld:%lld\n" ,UFFD_API , api.api); +if (flags &SHARED ) + ufd_cfg.vm =gem_vm_create (i915); + t.i915 = i915; + t.cfg = &ufd_cfg; t.engine = engine; - t.flags = flags; t.count =2 ;pthread_cond_init (&t.cond,NULL );
@@ -2534,9 +2575,10 @@ static void test_pi_iova(int i915, unsigned int engine, unsigned int flags)*/ spin = igt_spin_new(i915, .engine = engine);for (int i =0 ; i <MAX_ELSP_QLEN ; i++) { - spin->execbuf.rsvd1 =create_highest_priority (i915); +const intel_ctx_t *ctx =create_highest_priority (i915, cfg); + spin->execbuf.rsvd1 = ctx->id;gem_execbuf (i915, &spin->execbuf); -gem_context_destroy (i915, spin->execbuf.rsvd1); +intel_ctx_destroy (i915, ctx); }/* Kick off the submission threads */
@@ -2573,10 +2615,14 @@ static void test_pi_iova(int i915, unsigned int engine, unsigned int flags)gem_close (i915, t.scratch);munmap (t.page,4096 ); + +if (flags &SHARED ) +gem_vm_destroy (i915, ufd_cfg.vm); +close (ufd); } -static void measure_semaphore_power (int i915) +static void measure_semaphore_power (int i915,const intel_ctx_t *ctx) {const struct intel_execution_engine2 *signaler, *e;struct rapl gpu, pkg;
@@ -2584,7 +2630,7 @@ static void measure_semaphore_power(int i915)igt_require (gpu_power_open (&gpu) ==0 );pkg_power_open (&pkg); -__for_each_physical_engine (i915, signaler) { +for_each_ctx_engine (i915, ctx, signaler) {struct {struct power_sample pkg, gpu; } s_spin[2 ], s_sema[2 ];
@@ -2596,6 +2642,7 @@ static void measure_semaphore_power(int i915)continue ; spin = __igt_spin_new(i915, + .ctx = ctx, .engine = signaler->flags, .flags =IGT_SPIN_POLL_RUN );gem_wait (i915, spin->handle, &jiffie);/* waitboost */
@@ -2608,13 +2655,14 @@ static void measure_semaphore_power(int i915)rapl_read (&pkg, &s_spin[1 ].pkg);/* Add a waiter to each engine */ -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) {igt_spin_t *sema;if (e->flags == signaler->flags)continue ; sema = __igt_spin_new(i915, + .ctx = ctx, .engine = e->flags, .dependency = spin->handle);
@@ -2686,8 +2734,7 @@ static int cmp_u32(const void *A, const void *B)return 0 ; } -static uint32_t read_ctx_timestamp (int i915, -uint32_t ctx, +static uint32_t read_ctx_timestamp (int i915,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {const int use_64b =intel_gen (intel_get_drm_devid (i915)) >=8 ;
@@ -2703,7 +2750,7 @@ static uint32_t read_ctx_timestamp(int i915, .buffers_ptr = to_user_pointer(&obj), .buffer_count = 1, .flags = e->flags, - .rsvd1 = ctx, + .rsvd1 = ctx->id, };#define RUNTIME (base + 0x3a8)uint32_t *map, *cs;
@@ -2736,7 +2783,7 @@ static uint32_t read_ctx_timestamp(int i915,return ts; } -static void fairslice (int i915, +static void fairslice (int i915,const intel_ctx_cfg_t *cfg,const struct intel_execution_engine2 *e,unsigned long flags,int duration)
@@ -2744,14 +2791,14 @@ static void fairslice(int i915,const double timeslice_duration_ns =1e6 ;igt_spin_t *spin =NULL ;double threshold; -uint32_t ctx[3 ]; +const intel_ctx_t *ctx[3 ];uint32_t ts[3 ];for (int i =0 ; i <ARRAY_SIZE (ctx); i++) { - ctx[i] =gem_context_clone_with_engines (i915,0 ); + ctx[i] =intel_ctx_create (i915, cfg);if (spin ==NULL ) { spin = __igt_spin_new(i915, - .ctx_id = ctx[i], + .ctx = ctx[i], .engine = e->flags, .flags = flags); }else {
@@ -2759,7 +2806,7 @@ static void fairslice(int i915, .buffer_count = 1, .buffers_ptr = to_user_pointer(&spin->obj[IGT_SPIN_BATCH]), .flags = e->flags, - .rsvd1 = ctx[i], + .rsvd1 = ctx[i]->id, };gem_execbuf (i915, &eb); }
@@ -2773,7 +2820,7 @@ static void fairslice(int i915, ts[i] =read_ctx_timestamp (i915, ctx[i], e);for (int i =0 ; i <ARRAY_SIZE (ctx); i++) -gem_context_destroy (i915, ctx[i]); +intel_ctx_destroy (i915, ctx[i]);igt_spin_free (i915, spin);/*
@@ -2800,18 +2847,19 @@ static void fairslice(int i915, 1e-6 * threshold * 2); } -#define test_each_engine (T , i915, e) \ - igt_subtest_with_dynamic(T) __for_each_physical_engine(i915, e) \ +#define test_each_engine (T , i915, ctx, e) \ + igt_subtest_with_dynamic(T) for_each_ctx_engine(i915, ctx, e) \ igt_dynamic_f("%s", e->name) -#define test_each_engine_store (T , i915, e) \ - igt_subtest_with_dynamic(T) __for_each_physical_engine(i915, e) \ +#define test_each_engine_store (T , i915, ctx, e) \ + igt_subtest_with_dynamic(T) for_each_ctx_engine(i915, ctx, e) \ for_each_if(gem_class_can_store_dword(fd, e->class)) \ igt_dynamic_f("%s", e->name) igt_main {int fd =-1 ; +const intel_ctx_t *ctx =NULL ; igt_fixture {igt_require_sw_sync ();
@@ -2823,6 +2871,7 @@ igt_mainigt_require_gem (fd);gem_require_mmap_wc (fd);gem_require_contexts (fd); + ctx =intel_ctx_create_all_physical (fd);igt_fork_hang_detector (fd); }
@@ -2830,22 +2879,22 @@ igt_main igt_subtest_group {const struct intel_execution_engine2 *e; - test_each_engine_store("fifo", fd, e) -fifo (fd, e->flags); + test_each_engine_store("fifo", fd, ctx, e) +fifo (fd, ctx, e->flags); - test_each_engine_store("implicit-read-write", fd, e) -implicit_rw (fd, e->flags,READ_WRITE ); + test_each_engine_store("implicit-read-write", fd, ctx, e) +implicit_rw (fd, ctx, e->flags,READ_WRITE ); - test_each_engine_store("implicit-write-read", fd, e) -implicit_rw (fd, e->flags,WRITE_READ ); + test_each_engine_store("implicit-write-read", fd, ctx, e) +implicit_rw (fd, ctx, e->flags,WRITE_READ ); - test_each_engine_store("implicit-boths", fd, e) -implicit_rw (fd, e->flags,READ_WRITE |WRITE_READ ); + test_each_engine_store("implicit-boths", fd, ctx, e) +implicit_rw (fd, ctx, e->flags,READ_WRITE |WRITE_READ ); - test_each_engine_store("independent", fd, e) -independent (fd, e->flags,0 ); - test_each_engine_store("u-independent", fd, e) -independent (fd, e->flags,IGT_SPIN_USERPTR ); + test_each_engine_store("independent", fd, ctx, e) +independent (fd, ctx, e->flags,0 ); + test_each_engine_store("u-independent", fd, ctx, e) +independent (fd, ctx, e->flags,IGT_SPIN_USERPTR ); } igt_subtest_group {
@@ -2856,19 +2905,19 @@ igt_mainigt_require (gem_scheduler_has_ctx_priority (fd)); } - test_each_engine("timeslicing", fd, e) -timeslice (fd, e->flags); + test_each_engine("timeslicing", fd, ctx, e) +timeslice (fd, &ctx->cfg, e->flags); - test_each_engine("thriceslice", fd, e) -timesliceN (fd, e->flags,3 ); + test_each_engine("thriceslice", fd, ctx, e) +timesliceN (fd, &ctx->cfg, e->flags,3 ); - test_each_engine("manyslice", fd, e) -timesliceN (fd, e->flags,67 ); + test_each_engine("manyslice", fd, ctx, e) +timesliceN (fd, &ctx->cfg, e->flags,67 ); - test_each_engine("lateslice", fd, e) -lateslice (fd, e->flags,0 ); - test_each_engine("u-lateslice", fd, e) -lateslice (fd, e->flags,IGT_SPIN_USERPTR ); + test_each_engine("lateslice", fd, ctx, e) +lateslice (fd, &ctx->cfg, e->flags,0 ); + test_each_engine("u-lateslice", fd, ctx, e) +lateslice (fd, &ctx->cfg, e->flags,IGT_SPIN_USERPTR ); igt_subtest_group { igt_fixture {
@@ -2877,23 +2926,23 @@ igt_mainigt_require (intel_gen (intel_get_drm_devid (fd)) >=8 ); } - test_each_engine("fairslice", fd, e) -fairslice (fd, e,0 ,2 ); + test_each_engine("fairslice", fd, ctx, e) +fairslice (fd, &ctx->cfg, e,0 ,2 ); - test_each_engine("u-fairslice", fd, e) -fairslice (fd, e,IGT_SPIN_USERPTR ,2 ); + test_each_engine("u-fairslice", fd, ctx, e) +fairslice (fd, &ctx->cfg, e,IGT_SPIN_USERPTR ,2 ); igt_subtest("fairslice-all") { -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { igt_fork(child, 1) -fairslice (fd, e,0 ,2 ); +fairslice (fd, &ctx->cfg, e,0 ,2 ); }igt_waitchildren (); } igt_subtest("u-fairslice-all") { -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { igt_fork(child, 1) -fairslice (fd, e, +fairslice (fd, &ctx->cfg, e,IGT_SPIN_USERPTR ,2 ); }
@@ -2901,84 +2950,84 @@ igt_main } } - test_each_engine("submit-early-slice", fd, e) -submit_slice (fd, e,EARLY_SUBMIT ); - test_each_engine("u-submit-early-slice", fd, e) -submit_slice (fd, e,EARLY_SUBMIT |USERPTR ); - test_each_engine("submit-golden-slice", fd, e) -submit_slice (fd, e,0 ); - test_each_engine("u-submit-golden-slice", fd, e) -submit_slice (fd, e,USERPTR ); - test_each_engine("submit-late-slice", fd, e) -submit_slice (fd, e,LATE_SUBMIT ); - test_each_engine("u-submit-late-slice", fd, e) -submit_slice (fd, e,LATE_SUBMIT |USERPTR ); + test_each_engine("submit-early-slice", fd, ctx, e) +submit_slice (fd, &ctx->cfg, e,EARLY_SUBMIT ); + test_each_engine("u-submit-early-slice", fd, ctx, e) +submit_slice (fd, &ctx->cfg, e,EARLY_SUBMIT |USERPTR ); + test_each_engine("submit-golden-slice", fd, ctx, e) +submit_slice (fd, &ctx->cfg, e,0 ); + test_each_engine("u-submit-golden-slice", fd, ctx, e) +submit_slice (fd, &ctx->cfg, e,USERPTR ); + test_each_engine("submit-late-slice", fd, ctx, e) +submit_slice (fd, &ctx->cfg, e,LATE_SUBMIT ); + test_each_engine("u-submit-late-slice", fd, ctx, e) +submit_slice (fd, &ctx->cfg, e,LATE_SUBMIT |USERPTR ); igt_subtest("semaphore-user") -semaphore_userlock (fd,0 ); +semaphore_userlock (fd, ctx,0 ); igt_subtest("semaphore-codependency") -semaphore_codependency (fd,0 ); +semaphore_codependency (fd, ctx,0 ); igt_subtest("semaphore-resolve") -semaphore_resolve (fd,0 ); +semaphore_resolve (fd, &ctx->cfg,0 ); igt_subtest("semaphore-noskip") -semaphore_noskip (fd,0 ); +semaphore_noskip (fd, &ctx->cfg,0 ); igt_subtest("u-semaphore-user") -semaphore_userlock (fd,IGT_SPIN_USERPTR ); +semaphore_userlock (fd, ctx,IGT_SPIN_USERPTR ); igt_subtest("u-semaphore-codependency") -semaphore_codependency (fd,IGT_SPIN_USERPTR ); +semaphore_codependency (fd, ctx,IGT_SPIN_USERPTR ); igt_subtest("u-semaphore-resolve") -semaphore_resolve (fd,IGT_SPIN_USERPTR ); +semaphore_resolve (fd, &ctx->cfg,IGT_SPIN_USERPTR ); igt_subtest("u-semaphore-noskip") -semaphore_noskip (fd,IGT_SPIN_USERPTR ); +semaphore_noskip (fd, &ctx->cfg,IGT_SPIN_USERPTR ); igt_subtest("smoketest-all") -smoketest (fd,ALL_ENGINES ,30 ); +smoketest (fd, &ctx->cfg,ALL_ENGINES ,30 ); - test_each_engine_store("in-order", fd, e) -reorder (fd, e->flags,EQUAL ); + test_each_engine_store("in-order", fd, ctx, e) +reorder (fd, &ctx->cfg, e->flags,EQUAL ); - test_each_engine_store("out-order", fd, e) -reorder (fd, e->flags,0 ); + test_each_engine_store("out-order", fd, ctx, e) +reorder (fd, &ctx->cfg, e->flags,0 ); - test_each_engine_store("promotion", fd, e) -promotion (fd, e->flags); + test_each_engine_store("promotion", fd, ctx, e) +promotion (fd, &ctx->cfg, e->flags); igt_subtest_group { igt_fixture {igt_require (gem_scheduler_has_preemption (fd)); } - test_each_engine_store("preempt", fd, e) -preempt (fd, e,0 ); + test_each_engine_store("preempt", fd, ctx, e) +preempt (fd, &ctx->cfg, e,0 ); - test_each_engine_store("preempt-contexts", fd, e) -preempt (fd, e,NEW_CTX ); + test_each_engine_store("preempt-contexts", fd, ctx, e) +preempt (fd, &ctx->cfg, e,NEW_CTX ); - test_each_engine_store("preempt-user", fd, e) -preempt (fd, e,USERPTR ); + test_each_engine_store("preempt-user", fd, ctx, e) +preempt (fd, &ctx->cfg, e,USERPTR ); - test_each_engine_store("preempt-self", fd, e) -preempt_self (fd, e->flags); + test_each_engine_store("preempt-self", fd, ctx, e) +preempt_self (fd, &ctx->cfg, e->flags); - test_each_engine_store("preempt-other", fd, e) -preempt_other (fd, e->flags,0 ); + test_each_engine_store("preempt-other", fd, ctx, e) +preempt_other (fd, &ctx->cfg, e->flags,0 ); - test_each_engine_store("preempt-other-chain", fd, e) -preempt_other (fd, e->flags,CHAIN ); + test_each_engine_store("preempt-other-chain", fd, ctx, e) +preempt_other (fd, &ctx->cfg, e->flags,CHAIN ); - test_each_engine_store("preempt-queue", fd, e) -preempt_queue (fd, e->flags,0 ); + test_each_engine_store("preempt-queue", fd, ctx, e) +preempt_queue (fd, &ctx->cfg, e->flags,0 ); - test_each_engine_store("preempt-queue-chain", fd, e) -preempt_queue (fd, e->flags,CHAIN ); - test_each_engine_store("preempt-queue-contexts", fd, e) -preempt_queue (fd, e->flags,CONTEXTS ); + test_each_engine_store("preempt-queue-chain", fd, ctx, e) +preempt_queue (fd, &ctx->cfg, e->flags,CHAIN ); + test_each_engine_store("preempt-queue-contexts", fd, ctx, e) +preempt_queue (fd, &ctx->cfg, e->flags,CONTEXTS ); - test_each_engine_store("preempt-queue-contexts-chain", fd, e) -preempt_queue (fd, e->flags,CONTEXTS |CHAIN ); + test_each_engine_store("preempt-queue-contexts-chain", fd, ctx, e) +preempt_queue (fd, &ctx->cfg, e->flags,CONTEXTS |CHAIN ); - test_each_engine_store("preempt-engines", fd, e) + test_each_engine_store("preempt-engines", fd, ctx, e)preempt_engines (fd, e,0 ); igt_subtest_group {
@@ -2989,11 +3038,11 @@ igt_main hang =igt_allow_hang (fd,0 ,0 ); } - test_each_engine_store("preempt-hang", fd, e) -preempt (fd, e,NEW_CTX |HANG_LP ); + test_each_engine_store("preempt-hang", fd, ctx, e) +preempt (fd, &ctx->cfg, e,NEW_CTX |HANG_LP ); - test_each_engine_store("preemptive-hang", fd, e) -preemptive_hang (fd, e); + test_each_engine_store("preemptive-hang", fd, ctx, e) +preemptive_hang (fd, &ctx->cfg, e); igt_fixture {igt_disallow_hang (fd, hang);
@@ -3002,30 +3051,30 @@ igt_main } } - test_each_engine_store("noreorder", fd, e) -noreorder (fd, e->flags,0 ,0 ); + test_each_engine_store("noreorder", fd, ctx, e) +noreorder (fd, &ctx->cfg, e->flags,0 ,0 ); - test_each_engine_store("noreorder-priority", fd, e) { + test_each_engine_store("noreorder-priority", fd, ctx, e) {igt_require (gem_scheduler_enabled (fd)); -noreorder (fd, e->flags,MAX_PRIO ,0 ); +noreorder (fd, &ctx->cfg, e->flags,MAX_PRIO ,0 ); } - test_each_engine_store("noreorder-corked", fd, e) { + test_each_engine_store("noreorder-corked", fd, ctx, e) {igt_require (gem_scheduler_enabled (fd)); -noreorder (fd, e->flags,MAX_PRIO ,CORKED ); +noreorder (fd, &ctx->cfg, e->flags,MAX_PRIO ,CORKED ); } - test_each_engine_store("deep", fd, e) -deep (fd, e->flags); + test_each_engine_store("deep", fd, ctx, e) +deep (fd, &ctx->cfg, e->flags); - test_each_engine_store("wide", fd, e) -wide (fd, e->flags); + test_each_engine_store("wide", fd, ctx, e) +wide (fd, &ctx->cfg, e->flags); - test_each_engine_store("reorder-wide", fd, e) -reorder_wide (fd, e->flags); + test_each_engine_store("reorder-wide", fd, ctx, e) +reorder_wide (fd, &ctx->cfg, e->flags); - test_each_engine_store("smoketest", fd, e) -smoketest (fd, e->flags,5 ); + test_each_engine_store("smoketest", fd, ctx, e) +smoketest (fd, &ctx->cfg, e->flags,5 ); } igt_subtest_group {
@@ -3037,20 +3086,20 @@ igt_mainigt_require (gem_scheduler_has_preemption (fd)); } - test_each_engine("pi-ringfull", fd, e) -test_pi_ringfull (fd, e->flags,0 ); + test_each_engine("pi-ringfull", fd, ctx, e) +test_pi_ringfull (fd, &ctx->cfg, e->flags,0 ); - test_each_engine("pi-common", fd, e) -test_pi_ringfull (fd, e->flags,SHARED ); + test_each_engine("pi-common", fd, ctx, e) +test_pi_ringfull (fd, &ctx->cfg, e->flags,SHARED ); - test_each_engine("pi-userfault", fd, e) -test_pi_userfault (fd, e->flags); + test_each_engine("pi-userfault", fd, ctx, e) +test_pi_userfault (fd, &ctx->cfg, e->flags); - test_each_engine("pi-distinct-iova", fd, e) -test_pi_iova (fd, e->flags,0 ); + test_each_engine("pi-distinct-iova", fd, ctx, e) +test_pi_iova (fd, &ctx->cfg, e->flags,0 ); - test_each_engine("pi-shared-iova", fd, e) -test_pi_iova (fd, e->flags,SHARED ); + test_each_engine("pi-shared-iova", fd, ctx, e) +test_pi_iova (fd, &ctx->cfg, e->flags,SHARED ); } igt_subtest_group {
@@ -3060,11 +3109,12 @@ igt_main } igt_subtest("semaphore-power") -measure_semaphore_power (fd); +measure_semaphore_power (fd, ctx); } igt_fixture {igt_stop_hang_detector (); +intel_ctx_destroy (fd, ctx);close (fd); } }
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 21/89 tests/i915/perf_pmu: Convert to intel_ctx_t
In reply to Jason Ekstrand--- tests/i915/perf_pmu.c | 228 ++++++++++++++++++++++++------------------ 1 file changed, 128 insertions(+), 100 deletions(-)
tests/i915/perf_pmu.c +128 -100
@@ -46,6 +46,7 @@#include "igt_perf.h" #include "igt_sysfs.h" #include "igt_pm.h" +#include "intel_ctx.h" #include "sw_sync.h" IGT_TEST_DESCRIPTION ("Test the i915 pmu perf interface" );
@@ -171,11 +172,11 @@ static unsigned int measured_usleep(unsigned int usec)#define FLAG_HANG (32)#define TEST_S3 (64) -static igt_spin_t *__spin_poll (int fd,uint32_t ctx, +static igt_spin_t *__spin_poll (int fd,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {struct igt_spin_factory opts = { - .ctx_id = ctx, + .ctx = ctx, .engine = e->flags, };
@@ -214,7 +215,7 @@ static unsigned long __spin_wait(int fd, igt_spin_t *spin)return igt_nsec_elapsed (&start); } -static igt_spin_t *__spin_sync (int fd,uint32_t ctx, +static igt_spin_t *__spin_sync (int fd,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {igt_spin_t *spin =__spin_poll (fd, ctx, e);
@@ -224,7 +225,7 @@ static igt_spin_t * __spin_sync(int fd, uint32_t ctx,return spin; } -static igt_spin_t *spin_sync (int fd,uint32_t ctx, +static igt_spin_t *spin_sync (int fd,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {igt_require_gem (fd);
@@ -232,7 +233,7 @@ static igt_spin_t * spin_sync(int fd, uint32_t ctx,return __spin_sync (fd, ctx, e); } -static igt_spin_t *spin_sync_flags (int fd,uint32_t ctx,unsigned int flags) +static igt_spin_t *spin_sync_flags (int fd,const intel_ctx_t *ctx,unsigned int flags) {struct intel_execution_engine2 e = { };
@@ -276,7 +277,8 @@ static void end_spin(int fd, igt_spin_t *spin, unsigned int flags) }static void -single (int gem_fd,const struct intel_execution_engine2 *e,unsigned int flags) +single (int gem_fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e,unsigned int flags) {unsigned long slept;igt_spin_t *spin;
@@ -286,7 +288,7 @@ single(int gem_fd, const struct intel_execution_engine2 *e, unsigned int flags) fd =open_pmu (gem_fd,I915_PMU_ENGINE_BUSY (e->class, e->instance));if (flags &TEST_BUSY ) - spin =spin_sync (gem_fd,0 , e); + spin =spin_sync (gem_fd, ctx, e);else spin =NULL ;
@@ -322,7 +324,8 @@ single(int gem_fd, const struct intel_execution_engine2 *e, unsigned int flags) }static void -busy_start (int gem_fd,const struct intel_execution_engine2 *e) +busy_start (int gem_fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e) {unsigned long slept;uint64_t val, ts[2 ];
@@ -335,7 +338,7 @@ busy_start(int gem_fd, const struct intel_execution_engine2 *e)*/ sleep (2 ); - spin =__spin_sync (gem_fd,0 , e); + spin =__spin_sync (gem_fd, ctx, e); fd =open_pmu (gem_fd,I915_PMU_ENGINE_BUSY (e->class, e->instance));
@@ -357,15 +360,16 @@ busy_start(int gem_fd, const struct intel_execution_engine2 *e)* will depend on the CI systems running it a lot to detect issues. */ static void -busy_double_start (int gem_fd,const struct intel_execution_engine2 *e) +busy_double_start (int gem_fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e) {unsigned long slept;uint64_t val, val2, ts[2 ];igt_spin_t *spin[2 ]; -uint32_t ctx; +const intel_ctx_t *tmp_ctx;int fd; - ctx =gem_context_clone_with_engines (gem_fd,0 ); + tmp_ctx =intel_ctx_create (gem_fd, &ctx->cfg);/* * Defeat the busy stats delayed disable, we need to guarantee we are
@@ -378,10 +382,10 @@ busy_double_start(int gem_fd, const struct intel_execution_engine2 *e)* re-submission in execlists mode. Make sure busyness is correctly * reported with the engine busy, and after the engine went idle. */ - spin[0 ] =__spin_sync (gem_fd,0 , e); + spin[0 ] =__spin_sync (gem_fd, ctx, e);usleep (500e3 ); spin[1] = __igt_spin_new(gem_fd, - .ctx_id = ctx, + .ctx = tmp_ctx, .engine = e->flags);/*
@@ -412,7 +416,7 @@ busy_double_start(int gem_fd, const struct intel_execution_engine2 *e)close (fd); -gem_context_destroy (gem_fd, ctx); +intel_ctx_destroy (gem_fd, tmp_ctx);assert_within_epsilon (val, ts[1 ] - ts[0 ], tolerance);igt_assert_eq (val2,0 );
@@ -440,7 +444,8 @@ static void log_busy(unsigned int num_engines, uint64_t *val) }static void -busy_check_all (int gem_fd,const struct intel_execution_engine2 *e, +busy_check_all (int gem_fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e,const unsigned int num_engines,unsigned int flags) {struct intel_execution_engine2 *e_;
@@ -453,7 +458,7 @@ busy_check_all(int gem_fd, const struct intel_execution_engine2 *e, i =0 ; fd[0 ] =-1 ; -__for_each_physical_engine (gem_fd, e_) { +for_each_ctx_engine (gem_fd, ctx, e_) {if (e->class == e_->class && e->instance == e_->instance) busy_idx = i;
@@ -465,7 +470,7 @@ busy_check_all(int gem_fd, const struct intel_execution_engine2 *e,igt_assert_eq (i, num_engines); - spin =spin_sync (gem_fd,0 , e); + spin =spin_sync (gem_fd, ctx, e);pmu_read_multi (fd[0 ], num_engines, tval[0 ]); slept =measured_usleep (batch_duration_ns /1000 );if (flags &TEST_TRAILING_IDLE )
@@ -506,7 +511,8 @@ __submit_spin(int gem_fd, igt_spin_t *spin, }static void -most_busy_check_all (int gem_fd,const struct intel_execution_engine2 *e, +most_busy_check_all (int gem_fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e,const unsigned int num_engines,unsigned int flags) {struct intel_execution_engine2 *e_;
@@ -518,13 +524,13 @@ most_busy_check_all(int gem_fd, const struct intel_execution_engine2 *e,unsigned int idle_idx, i; i =0 ; -__for_each_physical_engine (gem_fd, e_) { +for_each_ctx_engine (gem_fd, ctx, e_) {if (e->class == e_->class && e->instance == e_->instance) idle_idx = i;else if (spin)__submit_spin (gem_fd, spin, e_,64 );else - spin =__spin_poll (gem_fd,0 , e_); + spin =__spin_poll (gem_fd, ctx, e_); val[i++] =I915_PMU_ENGINE_BUSY (e_->class, e_->instance); }
@@ -564,7 +570,8 @@ most_busy_check_all(int gem_fd, const struct intel_execution_engine2 *e, }static void -all_busy_check_all (int gem_fd,const unsigned int num_engines, +all_busy_check_all (int gem_fd,const intel_ctx_t *ctx, +const unsigned int num_engines,unsigned int flags) {struct intel_execution_engine2 *e;
@@ -576,11 +583,11 @@ all_busy_check_all(int gem_fd, const unsigned int num_engines,unsigned int i; i =0 ; -__for_each_physical_engine (gem_fd, e) { +for_each_ctx_engine (gem_fd, ctx, e) {if (spin)__submit_spin (gem_fd, spin, e,64 );else - spin =__spin_poll (gem_fd,0 , e); + spin =__spin_poll (gem_fd, ctx, e); val[i++] =I915_PMU_ENGINE_BUSY (e->class, e->instance); }
@@ -615,7 +622,9 @@ all_busy_check_all(int gem_fd, const unsigned int num_engines, }static void -no_sema (int gem_fd,const struct intel_execution_engine2 *e,unsigned int flags) +no_sema (int gem_fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e, +unsigned int flags) {igt_spin_t *spin;uint64_t val[2 ][2 ];
@@ -627,7 +636,7 @@ no_sema(int gem_fd, const struct intel_execution_engine2 *e, unsigned int flags) fd[0]);if (flags &TEST_BUSY ) - spin =spin_sync (gem_fd,0 , e); + spin =spin_sync (gem_fd, ctx, e);else spin =NULL ;
@@ -658,7 +667,8 @@ no_sema(int gem_fd, const struct intel_execution_engine2 *e, unsigned int flags)#define MI_SEMAPHORE_SAD_NEQ_SDD (5 << 12)static void -sema_wait (int gem_fd,const struct intel_execution_engine2 *e, +sema_wait (int gem_fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e,unsigned int flags) {struct drm_i915_gem_relocation_entry reloc[2 ] = {};
@@ -717,6 +727,7 @@ sema_wait(int gem_fd, const struct intel_execution_engine2 *e, eb.buffer_count =2 ; eb.buffers_ptr =to_user_pointer (obj); eb.flags = e->flags; + eb.rsvd1 = ctx->id;/** * Start the semaphore wait PMU and after some known time let the above
@@ -788,7 +799,7 @@ create_sema(int gem_fd, struct drm_i915_gem_relocation_entry *reloc) }static void -__sema_busy (int gem_fd,int pmu, +__sema_busy (int gem_fd,int pmu,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,int sema_pct,int busy_pct)
@@ -810,6 +821,7 @@ __sema_busy(int gem_fd, int pmu, .buffer_count = 1, .buffers_ptr = to_user_pointer(&obj), .flags = e->flags, + .rsvd1 = ctx->id, };igt_spin_t *spin;uint32_t *map;
@@ -821,7 +833,7 @@ __sema_busy(int gem_fd, int pmu, map =gem_mmap__wc (gem_fd, obj.handle,0 ,4096 ,PROT_WRITE );gem_execbuf (gem_fd, &eb); - spin = igt_spin_new(gem_fd, .engine = e->flags); + spin = igt_spin_new(gem_fd, .ctx = ctx, .engine = e->flags);/* Wait until the batch is executed and the semaphore is busy-waiting */ while (!READ_ONCE (*map) &&gem_bo_busy (gem_fd, obj.handle))
@@ -861,7 +873,7 @@ __sema_busy(int gem_fd, int pmu, }static void -sema_busy (int gem_fd, +sema_busy (int gem_fd,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,unsigned int flags) {
@@ -874,15 +886,15 @@ sema_busy(int gem_fd, fd[1 ] =open_group (gem_fd,I915_PMU_ENGINE_BUSY (e->class, e->instance), fd[0 ]); -__sema_busy (gem_fd, fd[0 ], e,50 ,100 ); -__sema_busy (gem_fd, fd[0 ], e,25 ,50 ); -__sema_busy (gem_fd, fd[0 ], e,75 ,75 ); +__sema_busy (gem_fd, fd[0 ], ctx, e,50 ,100 ); +__sema_busy (gem_fd, fd[0 ], ctx, e,25 ,50 ); +__sema_busy (gem_fd, fd[0 ], ctx, e,75 ,75 );close (fd[0 ]);close (fd[1 ]); } -static void test_awake (int i915) +static void test_awake (int i915,const intel_ctx_t *ctx) {const struct intel_execution_engine2 *e;unsigned long slept;
@@ -893,8 +905,8 @@ static void test_awake(int i915)igt_skip_on (fd <0 );/* Check that each engine is captured by the GT wakeref */ -__for_each_physical_engine (i915, e) { - igt_spin_new(i915, .engine = e->flags); +for_each_ctx_engine (i915, ctx, e) { + igt_spin_new(i915, .ctx = ctx, .engine = e->flags); val =pmu_read_single (fd); slept =measured_usleep (batch_duration_ns /1000 );
@@ -905,8 +917,8 @@ static void test_awake(int i915) }/* And that the total GT wakeref matches walltime not summation */ -__for_each_physical_engine (i915, e) - igt_spin_new(i915, .engine = e->flags); +for_each_ctx_engine (i915, ctx, e) + igt_spin_new(i915, .ctx = ctx, .engine = e->flags); val =pmu_read_single (fd); slept =measured_usleep (batch_duration_ns /1000 );
@@ -995,7 +1007,8 @@ static int has_secure_batches(const int fd) }static void -event_wait (int gem_fd,const struct intel_execution_engine2 *e) +event_wait (int gem_fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e) {struct drm_i915_gem_exec_object2 obj = { };struct drm_i915_gem_execbuffer2 eb = { };
@@ -1051,6 +1064,7 @@ event_wait(int gem_fd, const struct intel_execution_engine2 *e) eb.buffer_count =1 ; eb.buffers_ptr =to_user_pointer (&obj); eb.flags = e->flags |I915_EXEC_SECURE ; + eb.rsvd1 = ctx->id;for_each_pipe_with_valid_output (&data.display, p, output) {struct igt_helper_process waiter = { };
@@ -1123,7 +1137,8 @@ event_wait(int gem_fd, const struct intel_execution_engine2 *e) }static void -multi_client (int gem_fd,const struct intel_execution_engine2 *e) +multi_client (int gem_fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e) {uint64_t config =I915_PMU_ENGINE_BUSY (e->class, e->instance);unsigned long slept[2 ];
@@ -1142,7 +1157,7 @@ multi_client(int gem_fd, const struct intel_execution_engine2 *e)*/ fd[1 ] =open_pmu (gem_fd, config); - spin =spin_sync (gem_fd,0 , e); + spin =spin_sync (gem_fd, ctx, e); val[0 ] = val[1 ] =__pmu_read_single (fd[0 ], &ts[0 ]); slept[1 ] =measured_usleep (batch_duration_ns /1000 );
@@ -1705,7 +1720,8 @@ test_rc6(int gem_fd, unsigned int flags) }static void -test_enable_race (int gem_fd,const struct intel_execution_engine2 *e) +test_enable_race (int gem_fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e) {uint64_t config =I915_PMU_ENGINE_BUSY (e->class, e->instance);struct igt_helper_process engine_load = { };
@@ -1723,6 +1739,7 @@ test_enable_race(int gem_fd, const struct intel_execution_engine2 *e) eb.buffer_count =1 ; eb.buffers_ptr =to_user_pointer (&obj); eb.flags = e->flags; + eb.rsvd1 = ctx->id;/* * This test is probabilistic so run in a few times to increase the
@@ -1769,7 +1786,8 @@ test_enable_race(int gem_fd, const struct intel_execution_engine2 *e) __assert_within(x, ref, tolerance, tolerance)static void -accuracy (int gem_fd,const struct intel_execution_engine2 *e, +accuracy (int gem_fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e,unsigned long target_busy_pct,unsigned long target_iters) {
@@ -1819,7 +1837,7 @@ accuracy(int gem_fd, const struct intel_execution_engine2 *e,igt_spin_t *spin;/* Allocate our spin batch and idle it. */ - spin = igt_spin_new(gem_fd, .engine = e->flags); + spin = igt_spin_new(gem_fd, .ctx = ctx, .engine = e->flags);igt_spin_end (spin);gem_sync (gem_fd, spin->handle);
@@ -1978,6 +1996,7 @@ static int unload_i915(void)static void test_unload (unsigned int num_engines) { igt_fork(child, 1) { +intel_ctx_cfg_t cfg;const struct intel_execution_engine2 *e;int fd[4 + num_engines *3 ], i;uint64_t *buf;
@@ -2003,7 +2022,8 @@ static void test_unload(unsigned int num_engines)if (fd[count] !=-1 ) count++; -__for_each_physical_engine (i915, e) { + cfg =intel_ctx_cfg_all_physical (i915); +for_each_ctx_cfg_engine (i915, &cfg, e) { fd[count] =perf_i915_open_group (i915,I915_PMU_ENGINE_BUSY (e->class, e->instance), fd[count -1 ]);
@@ -2051,12 +2071,12 @@ static void test_unload(unsigned int num_engines)igt_assert_eq (unload_i915 (),0 ); } -#define test_each_engine (T , i915, e) \ - igt_subtest_with_dynamic(T) __for_each_physical_engine(i915, e) \ +#define test_each_engine (T , i915, ctx, e) \ + igt_subtest_with_dynamic(T) for_each_ctx_engine(i915, ctx, e) \ igt_dynamic_f("%s", e->name) -#define test_each_rcs (T , i915, e) \ - igt_subtest_with_dynamic(T) __for_each_physical_engine(i915, e) \ +#define test_each_rcs (T , i915, ctx, e) \ + igt_subtest_with_dynamic(T) for_each_ctx_engine(i915, ctx, e) \ for_each_if((e)->class == I915_ENGINE_CLASS_RENDER) \ igt_dynamic_f("%s", e->name)
@@ -2064,6 +2084,7 @@ igt_main {const struct intel_execution_engine2 *e;unsigned int num_engines =0 ; +const intel_ctx_t *ctx =NULL ;int fd =-1 ;/**
@@ -2078,7 +2099,9 @@ igt_mainigt_require_gem (fd);igt_require (i915_perf_type_id (fd) >0 ); -__for_each_physical_engine (fd, e) + ctx =intel_ctx_create_all_physical (fd); + +for_each_ctx_engine (fd, ctx, e) num_engines++;igt_require (num_engines); }
@@ -2106,48 +2129,48 @@ igt_main* Test that a single engine metric can be initialized or it * is correctly rejected. */ - test_each_engine("init-busy", fd, e) + test_each_engine("init-busy", fd, ctx, e)init (fd, e,I915_SAMPLE_BUSY ); - test_each_engine("init-wait", fd, e) + test_each_engine("init-wait", fd, ctx, e)init (fd, e,I915_SAMPLE_WAIT ); - test_each_engine("init-sema", fd, e) + test_each_engine("init-sema", fd, ctx, e)init (fd, e,I915_SAMPLE_SEMA );/** * Test that engines show no load when idle. */ - test_each_engine("idle", fd, e) -single (fd, e,0 ); + test_each_engine("idle", fd, ctx, e) +single (fd, ctx, e,0 );/** * Test that a single engine reports load correctly. */ - test_each_engine("busy", fd, e) -single (fd, e,TEST_BUSY ); - test_each_engine("busy-idle", fd, e) -single (fd, e,TEST_BUSY |TEST_TRAILING_IDLE ); + test_each_engine("busy", fd, ctx, e) +single (fd, ctx, e,TEST_BUSY ); + test_each_engine("busy-idle", fd, ctx, e) +single (fd, ctx, e,TEST_BUSY |TEST_TRAILING_IDLE );/** * Test that when one engine is loaded other report no * load. */ - test_each_engine("busy-check-all", fd, e) -busy_check_all (fd, e, num_engines,TEST_BUSY ); - test_each_engine("busy-idle-check-all", fd, e) -busy_check_all (fd, e, num_engines, + test_each_engine("busy-check-all", fd, ctx, e) +busy_check_all (fd, ctx, e, num_engines,TEST_BUSY ); + test_each_engine("busy-idle-check-all", fd, ctx, e) +busy_check_all (fd, ctx, e, num_engines,TEST_BUSY |TEST_TRAILING_IDLE );/** * Test that when all except one engine are loaded all * loads are correctly reported. */ - test_each_engine("most-busy-check-all", fd, e) -most_busy_check_all (fd, e, num_engines, + test_each_engine("most-busy-check-all", fd, ctx, e) +most_busy_check_all (fd, ctx, e, num_engines,TEST_BUSY ); - test_each_engine("most-busy-idle-check-all", fd, e) -most_busy_check_all (fd, e, num_engines, + test_each_engine("most-busy-idle-check-all", fd, ctx, e) +most_busy_check_all (fd, ctx, e, num_engines,TEST_BUSY |TEST_TRAILING_IDLE );
@@ -2155,40 +2178,40 @@ igt_main* Test that semphore counters report no activity on * idle or busy engines. */ - test_each_engine("idle-no-semaphores", fd, e) -no_sema (fd, e,0 ); + test_each_engine("idle-no-semaphores", fd, ctx, e) +no_sema (fd, ctx, e,0 ); - test_each_engine("busy-no-semaphores", fd, e) -no_sema (fd, e,TEST_BUSY ); + test_each_engine("busy-no-semaphores", fd, ctx, e) +no_sema (fd, ctx, e,TEST_BUSY ); - test_each_engine("busy-idle-no-semaphores", fd, e) -no_sema (fd, e,TEST_BUSY |TEST_TRAILING_IDLE ); + test_each_engine("busy-idle-no-semaphores", fd, ctx, e) +no_sema (fd, ctx, e,TEST_BUSY |TEST_TRAILING_IDLE );/** * Test that semaphore waits are correctly reported. */ - test_each_engine("semaphore-wait", fd, e) -sema_wait (fd, e,TEST_BUSY ); + test_each_engine("semaphore-wait", fd, ctx, e) +sema_wait (fd, ctx, e,TEST_BUSY ); - test_each_engine("semaphore-wait-idle", fd, e) -sema_wait (fd, e,TEST_BUSY |TEST_TRAILING_IDLE ); + test_each_engine("semaphore-wait-idle", fd, ctx, e) +sema_wait (fd, ctx, e,TEST_BUSY |TEST_TRAILING_IDLE ); - test_each_engine("semaphore-busy", fd, e) -sema_busy (fd, e,0 ); + test_each_engine("semaphore-busy", fd, ctx, e) +sema_busy (fd, ctx, e,0 );/** * Check that two perf clients do not influence each * others observations. */ - test_each_engine("multi-client", fd, e) -multi_client (fd, e); + test_each_engine("multi-client", fd, ctx, e) +multi_client (fd, ctx, e);/** * Check that reported usage is correct when PMU is * enabled after the batch is running. */ - test_each_engine("busy-start", fd, e) -busy_start (fd, e); + test_each_engine("busy-start", fd, ctx, e) +busy_start (fd, ctx, e);/** * Check that reported usage is correct when PMU is
@@ -2197,16 +2220,16 @@ igt_main igt_subtest_group {igt_fixture gem_require_contexts (fd ); - test_each_engine("busy-double-start", fd, e) -busy_double_start (fd, e); + test_each_engine("busy-double-start", fd, ctx, e) +busy_double_start (fd, ctx, e); }/** * Check that the PMU can be safely enabled in face of * interrupt-heavy engine load. */ - test_each_engine("enable-race", fd, e) -test_enable_race (fd, e); + test_each_engine("enable-race", fd, ctx, e) +test_enable_race (fd, ctx, e); igt_subtest_group {const unsigned int pct[] = {2 ,50 ,98 };
@@ -2216,18 +2239,18 @@ igt_main*/ for (unsigned int i =0 ; i <ARRAY_SIZE (pct); i++) { igt_subtest_with_dynamic_f("busy-accuracy-%u", pct[i]) { -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { igt_dynamic_f("%s", e->name) -accuracy (fd, e, pct[i],10 ); +accuracy (fd, ctx, e, pct[i],10 ); } } } } - test_each_engine("busy-hang", fd, e) { + test_each_engine("busy-hang", fd, ctx, e) {igt_hang_t hang =igt_allow_hang (fd,0 ,0 ); -single (fd, e,TEST_BUSY |FLAG_HANG ); +single (fd, ctx, e,TEST_BUSY |FLAG_HANG );igt_disallow_hang (fd, hang); }
@@ -2235,17 +2258,18 @@ igt_main/** * Test that event waits are correctly reported. */ - test_each_rcs("event-wait", fd, e) -event_wait (fd, e); + test_each_rcs("event-wait", fd, ctx, e) +event_wait (fd, ctx, e);/** * Test that when all engines are loaded all loads are * correctly reported. */ igt_subtest("all-busy-check-all") -all_busy_check_all (fd, num_engines,TEST_BUSY ); +all_busy_check_all (fd, ctx, num_engines, +TEST_BUSY ); igt_subtest("all-busy-idle-check-all") -all_busy_check_all (fd, num_engines, +all_busy_check_all (fd, ctx, num_engines,TEST_BUSY |TEST_TRAILING_IDLE );/**
@@ -2290,32 +2314,36 @@ igt_main* Test GT wakeref tracking (similar to RC0, opposite of RC6) */ igt_subtest("gt-awake") -test_awake (fd); +test_awake (fd, ctx);/** * Check render nodes are counted. */ igt_subtest_group {int render_fd =-1 ; +const intel_ctx_t *render_ctx =NULL ; igt_fixture { render_fd =__drm_open_driver_render (DRIVER_INTEL );igt_require_gem (render_fd); + render_ctx =intel_ctx_create_all_physical (render_fd);gem_quiescent_gpu (fd); } - test_each_engine("render-node-busy", render_fd, e) -single (render_fd, e,TEST_BUSY ); - test_each_engine("render-node-busy-idle", render_fd, e) -single (render_fd, e,TEST_BUSY |TEST_TRAILING_IDLE ); + test_each_engine("render-node-busy", render_fd, ctx, e) +single (render_fd, render_ctx, e,TEST_BUSY ); + test_each_engine("render-node-busy-idle", render_fd, ctx, e) +single (render_fd, render_ctx, e,TEST_BUSY |TEST_TRAILING_IDLE ); igt_fixture { +intel_ctx_destroy (render_fd, render_ctx);close (render_fd); } } igt_fixture { +intel_ctx_destroy (fd, ctx);close (fd); }
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 22/89 tests/i915/gem_exec_nop: Convert to intel_ctx_t
In reply to Jason Ekstrand--- tests/i915/gem_exec_nop.c | 156 ++++++++++++++++++++++---------------- 1 file changed, 92 insertions(+), 64 deletions(-)
tests/i915/gem_exec_nop.c +92 -64
@@ -45,6 +45,7 @@#include "igt_device.h" #include "igt_rand.h" #include "igt_sysfs.h" +#include "intel_ctx.h" #define ENGINE_FLAGS (I915_EXEC_RING_MASK | I915_EXEC_BSD_MASK)
@@ -62,7 +63,7 @@ static double elapsed(const struct timespec *start, const struct timespec *end) (end->tv_nsec - start->tv_nsec)*1e-9); } -static double nop_on_ring (int fd,uint32_t handle, +static double nop_on_ring (int fd,uint32_t handle,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,int timeout_ms,unsigned long *out)
@@ -81,6 +82,7 @@ static double nop_on_ring(int fd, uint32_t handle, execbuf.flags = e->flags; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags = e->flags;gem_execbuf (fd, &execbuf);
@@ -101,7 +103,8 @@ static double nop_on_ring(int fd, uint32_t handle,return elapsed (&start, &now); } -static void poll_ring (int fd,const struct intel_execution_engine2 *e, +static void poll_ring (int fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e,int timeout) {const unsigned int gen =intel_gen (intel_get_drm_devid (fd));
@@ -185,6 +188,7 @@ static void poll_ring(int fd, const struct intel_execution_engine2 *e, execbuf.buffers_ptr =to_user_pointer (&obj); execbuf.buffer_count =1 ; execbuf.flags = e->flags | flags; + execbuf.rsvd1 = ctx->id; cycles =0 ; do {
@@ -212,7 +216,8 @@ static void poll_ring(int fd, const struct intel_execution_engine2 *e,gem_close (fd, obj.handle); } -static void poll_sequential (int fd,const char *name,int timeout) +static void poll_sequential (int fd,const intel_ctx_t *ctx, +const char *name,int timeout) {const unsigned int gen =intel_gen (intel_get_drm_devid (fd));const struct intel_execution_engine2 *e;
@@ -232,7 +237,7 @@ static void poll_sequential(int fd, const char *name, int timeout) flags |=I915_EXEC_SECURE ; nengine =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) {if (!gem_class_can_store_dword (fd, e->class) || !gem_class_has_mutable_submission (fd, e->class))continue ;
@@ -312,6 +317,7 @@ static void poll_sequential(int fd, const char *name, int timeout)memset (&execbuf,0 ,sizeof (execbuf)); execbuf.buffers_ptr =to_user_pointer (obj); execbuf.buffer_count =ARRAY_SIZE (obj); + execbuf.rsvd1 = ctx->id; cycles =0 ; do {
@@ -342,19 +348,19 @@ static void poll_sequential(int fd, const char *name, int timeout)gem_close (fd, obj[0 ].handle); } -static void single (int fd,uint32_t handle, +static void single (int fd,uint32_t handle,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {double time;unsigned long count; - time =nop_on_ring (fd, handle, e,20000 , &count); + time =nop_on_ring (fd, handle, ctx, e,20000 , &count);igt_info ("%s: %'lu cycles: %.3fus\n" , e->name, count, time*1e6 / count); }static double -stable_nop_on_ring (int fd,uint32_t handle, +stable_nop_on_ring (int fd,uint32_t handle,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,int timeout_ms,int reps)
@@ -371,7 +377,7 @@ stable_nop_on_ring(int fd, uint32_t handle,unsigned long count;double time; - time =nop_on_ring (fd, handle, e, timeout_ms, &count); + time =nop_on_ring (fd, handle, ctx, e, timeout_ms, &count);igt_stats_push_float (&s, time / count); }
@@ -387,7 +393,7 @@ stable_nop_on_ring(int fd, uint32_t handle, "'%s' != '%s' (%f not within %f%% tolerance of %f)\n",\#x , #ref, x, tolerance * 100.0, ref) -static void headless (int fd,uint32_t handle, +static void headless (int fd,uint32_t handle,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {unsigned int nr_connected =0 ;
@@ -411,11 +417,11 @@ static void headless(int fd, uint32_t handle,/* set graphics mode to prevent blanking */ kmstest_set_vt_graphics_mode (); -nop_on_ring (fd, handle, e,10 , &count); +nop_on_ring (fd, handle, ctx, e,10 , &count);igt_require_f (count >100 ,"submillisecond precision required\n" );/* benchmark nops */ - n_display =stable_nop_on_ring (fd, handle, e,500 ,5 ); + n_display =stable_nop_on_ring (fd, handle, ctx, e,500 ,5 );igt_info ("With one display connected: %.2fus\n" , n_display *1e6 );
@@ -423,7 +429,7 @@ static void headless(int fd, uint32_t handle,kmstest_unset_all_crtcs (fd, res);/* benchmark nops again */ - n_headless =stable_nop_on_ring (fd, handle, e,500 ,5 ); + n_headless =stable_nop_on_ring (fd, handle, ctx, e,500 ,5 );igt_info ("Without a display connected (headless): %.2fus\n" , n_headless *1e6 );
@@ -431,7 +437,8 @@ static void headless(int fd, uint32_t handle,assert_within_epsilon (n_headless, n_display,0.1f ); } -static void parallel (int fd,uint32_t handle,int timeout) +static void parallel (int fd,uint32_t handle, +const intel_ctx_t *ctx,int timeout) {const struct intel_execution_engine2 *e;struct drm_i915_gem_execbuffer2 execbuf;
@@ -445,11 +452,11 @@ static void parallel(int fd, uint32_t handle, int timeout) sum =0 ; nengine =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { engines[nengine] = e->flags; names[nengine++] =strdup (e->name); - time =nop_on_ring (fd, handle, e,250 , &count) / count; + time =nop_on_ring (fd, handle, ctx, e,250 , &count) / count; sum += time;igt_debug ("%s: %.3fus\n" , e->name,1e6 *time); }
@@ -464,6 +471,7 @@ static void parallel(int fd, uint32_t handle, int timeout) execbuf.buffer_count =1 ; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags =0 ;gem_execbuf (fd, &execbuf);
@@ -494,7 +502,8 @@ static void parallel(int fd, uint32_t handle, int timeout)igt_assert_eq (intel_detect_and_clear_missed_interrupts (fd),0 ); } -static void independent (int fd,uint32_t handle,int timeout) +static void independent (int fd,uint32_t handle, +const intel_ctx_t *ctx,int timeout) {const struct intel_execution_engine2 *e;struct drm_i915_gem_execbuffer2 execbuf;
@@ -507,11 +516,11 @@ static void independent(int fd, uint32_t handle, int timeout) sum =0 ; nengine =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { engines[nengine] = e->flags; names[nengine++] =strdup (e->name); - time =nop_on_ring (fd, handle, e,250 , &count) / count; + time =nop_on_ring (fd, handle, ctx, e,250 , &count) / count; sum += time;igt_debug ("%s: %.3fus\n" , e->name,1e6 *time); }
@@ -526,6 +535,7 @@ static void independent(int fd, uint32_t handle, int timeout) execbuf.buffer_count =1 ; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags =0 ;gem_execbuf (fd, &execbuf);
@@ -562,7 +572,7 @@ static void independent(int fd, uint32_t handle, int timeout)igt_assert_eq (intel_detect_and_clear_missed_interrupts (fd),0 ); } -static void multiple (int fd, +static void multiple (int fd,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,int timeout) {
@@ -581,6 +591,7 @@ static void multiple(int fd, execbuf.flags = e->flags; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags = e->flags;gem_execbuf (fd, &execbuf);
@@ -592,9 +603,11 @@ static void multiple(int fd,unsigned long count;double time;int i915; +const intel_ctx_t *child_ctx; i915 =gem_reopen_driver (fd); -gem_context_copy_engines (fd,0 , i915,0 ); + child_ctx =intel_ctx_create (i915, &ctx->cfg); + execbuf.rsvd1 = child_ctx->id; obj.handle =gem_create (i915,4096 );gem_write (i915, obj.handle,0 , &bbe,sizeof (bbe));
@@ -609,6 +622,7 @@ static void multiple(int fd, }while (elapsed (&start, &now) < timeout); time =elapsed (&start, &now) / count;igt_info ("%d: %ld cycles, %.3fus\n" , child, count,1e6 *time); +intel_ctx_destroy (i915, child_ctx); }igt_waitchildren ();
@@ -617,7 +631,8 @@ static void multiple(int fd,gem_close (fd, obj.handle); } -static void series (int fd,uint32_t handle,int timeout) +static void series (int fd,uint32_t handle, +const intel_ctx_t *ctx,int timeout) {const struct intel_execution_engine2 *e;struct drm_i915_gem_execbuffer2 execbuf;
@@ -630,8 +645,8 @@ static void series(int fd, uint32_t handle, int timeout)const char *name; nengine =0 ; -__for_each_physical_engine (fd, e) { - time =nop_on_ring (fd, handle, e,250 , &count) / count; +for_each_ctx_engine (fd, ctx, e) { + time =nop_on_ring (fd, handle, ctx, e,250 , &count) / count;if (time > max) { name = e->name; max = time;
@@ -653,6 +668,7 @@ static void series(int fd, uint32_t handle, int timeout) execbuf.buffer_count =1 ; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags =0 ;gem_execbuf (fd, &execbuf);
@@ -688,9 +704,11 @@ static void xchg(void *array, unsigned i, unsigned j) u[j] = tmp; } -static void sequential (int fd,uint32_t handle,unsigned flags,int timeout) +static void sequential (int fd,uint32_t handle, +const intel_ctx_t *ctx,unsigned flags,int timeout) {const int ncpus = flags &FORKED ?sysconf (_SC_NPROCESSORS_ONLN) :1 ; +const intel_ctx_t *tmp_ctx =NULL , *child_ctx =NULL ;const struct intel_execution_engine2 *e;struct drm_i915_gem_execbuffer2 execbuf;struct drm_i915_gem_exec_object2 obj[2 ];
@@ -707,10 +725,10 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout) nengine =0 ; sum =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) {unsigned long count; - time =nop_on_ring (fd, handle, e,250 , &count) / count; + time =nop_on_ring (fd, handle, ctx, e,250 , &count) / count; sum += time;igt_debug ("%s: %.3fus\n" , e->name,1e6 *time);
@@ -734,7 +752,8 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout)if (flags &CONTEXT ) {gem_require_contexts (fd); - execbuf.rsvd1 =gem_context_clone_with_engines (fd,0 ); + tmp_ctx =intel_ctx_create (fd, &ctx->cfg); + execbuf.rsvd1 = tmp_ctx->id; }for (n =0 ; n < nengine; n++) {
@@ -754,7 +773,8 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout)if (flags &CONTEXT ) {gem_require_contexts (fd); - execbuf.rsvd1 =gem_context_clone_with_engines (fd,0 ); + child_ctx =intel_ctx_create (fd, &ctx->cfg); + execbuf.rsvd1 = child_ctx->id; }hars_petruska_f54_1_random_perturb (child);
@@ -777,7 +797,7 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout) results[child] =elapsed (&start, &now) / count;if (flags &CONTEXT ) -gem_context_destroy (fd, execbuf.rsvd1); +intel_ctx_destroy (fd, child_ctx);gem_close (fd, obj[0 ].handle); }
@@ -793,7 +813,7 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout) nengine, ncpus, 1e6*results[ncpus], 1e6*sum*ncpus);if (flags &CONTEXT ) -gem_context_destroy (fd, execbuf.rsvd1); +intel_ctx_destroy (fd, tmp_ctx);gem_close (fd, obj[0 ].handle);munmap (results,4096 );
@@ -810,6 +830,7 @@ static bool fence_wait(int fence) }static void fence_signal (int fd,uint32_t handle, +const intel_ctx_t *ctx,const struct intel_execution_engine2 *ring_id,const char *ring_name,int timeout) {
@@ -827,7 +848,7 @@ static void fence_signal(int fd, uint32_t handle, nengine =0 ;if (!ring_id) { -__for_each_physical_engine (fd, __e) +for_each_ctx_engine (fd, ctx, __e) engines[nengine++] = __e->flags; }else { engines[nengine++] = ring_id->flags;
@@ -845,6 +866,7 @@ static void fence_signal(int fd, uint32_t handle, execbuf.buffers_ptr =to_user_pointer (&obj); execbuf.buffer_count =1 ; execbuf.flags =I915_EXEC_FENCE_OUT ; + execbuf.rsvd1 = ctx->id; n =0 ; count =0 ;
@@ -885,20 +907,21 @@ static void fence_signal(int fd, uint32_t handle, }static void preempt (int fd,uint32_t handle, +const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {struct drm_i915_gem_execbuffer2 execbuf;struct drm_i915_gem_exec_object2 obj;struct timespec start, now;unsigned long count; -uint32_t ctx[2 ]; +const intel_ctx_t *tmp_ctx[2 ];igt_spin_t *spin; - ctx[0 ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[0 ],MIN_PRIO ); + tmp_ctx[0 ] =intel_ctx_create (fd, &ctx->cfg); +gem_context_set_priority (fd, tmp_ctx[0 ]->id,MIN_PRIO ); - ctx[1 ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[1 ],MAX_PRIO ); + tmp_ctx[1 ] =intel_ctx_create (fd, &ctx->cfg); +gem_context_set_priority (fd, tmp_ctx[1 ]->id,MAX_PRIO );memset (&obj,0 ,sizeof (obj)); obj.handle = handle;
@@ -909,15 +932,16 @@ static void preempt(int fd, uint32_t handle, execbuf.flags = e->flags; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags = e->flags;gem_execbuf (fd, &execbuf); } - execbuf.rsvd1 = ctx[1 ]; + execbuf.rsvd1 = tmp_ctx[1 ]->id;intel_detect_and_clear_missed_interrupts (fd); count =0 ; - spin = __igt_spin_new(fd, .ctx_id = ctx[0], .engine = e->flags); + spin = __igt_spin_new(fd, .ctx = tmp_ctx[0], .engine = e->flags);clock_gettime (CLOCK_MONOTONIC , &start); do { gem_execbuf(fd, &execbuf);
@@ -927,8 +951,8 @@ static void preempt(int fd, uint32_t handle,igt_spin_free (fd, spin);igt_assert_eq (intel_detect_and_clear_missed_interrupts (fd),0 ); -gem_context_destroy (fd, ctx[1 ]); -gem_context_destroy (fd, ctx[0 ]); +intel_ctx_destroy (fd, tmp_ctx[1 ]); +intel_ctx_destroy (fd, tmp_ctx[0 ]);igt_info ("%s: %'lu cycles: %.3fus\n" , e->name, count,elapsed (&start, &now)*1e6 / count);
@@ -937,6 +961,7 @@ static void preempt(int fd, uint32_t handle, igt_main {const struct intel_execution_engine2 *e; +const intel_ctx_t *ctx =NULL ;uint32_t handle =0 ;int device =-1 ;
@@ -948,6 +973,8 @@ igt_maingem_submission_print_method (device);gem_scheduler_print_capability (device); + ctx =intel_ctx_create_all_physical (device); + handle =gem_create (device,4096 );gem_write (device, handle,0 , &bbe,sizeof (bbe));
@@ -955,57 +982,57 @@ igt_main } igt_subtest("basic-series") -series (device, handle,2 ); +series (device, handle, ctx,2 ); igt_subtest("basic-parallel") -parallel (device, handle,2 ); +parallel (device, handle, ctx,2 ); igt_subtest("basic-sequential") -sequential (device, handle,0 ,2 ); +sequential (device, handle, ctx,0 ,2 ); igt_subtest_with_dynamic("single") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) { igt_dynamic_f("%s", e->name) -single (device, handle, e); +single (device, handle, ctx, e); } } igt_subtest_with_dynamic("signal") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) { igt_dynamic_f("%s", e->name) -fence_signal (device, handle, e, - e->name,2 ); +fence_signal (device, handle, ctx, + e, e->name,2 ); } }igt_subtest ("signal-all" ) /* NULL value means all engines */ -fence_signal (device, handle,NULL ,"all" ,20 ); +fence_signal (device, handle, ctx,NULL ,"all" ,20 ); igt_subtest("series") -series (device, handle,20 ); +series (device, handle, ctx,20 ); igt_subtest("parallel") -parallel (device, handle,20 ); +parallel (device, handle, ctx,20 ); igt_subtest("independent") -independent (device, handle,20 ); +independent (device, handle, ctx,20 ); igt_subtest_with_dynamic("multiple") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) { igt_dynamic_f("%s", e->name) -multiple (device, e,20 ); +multiple (device, ctx, e,20 ); } } igt_subtest("sequential") -sequential (device, handle,0 ,20 ); +sequential (device, handle, ctx,0 ,20 ); igt_subtest("forked-sequential") -sequential (device, handle,FORKED ,20 ); +sequential (device, handle, ctx,FORKED ,20 ); igt_subtest("context-sequential") -sequential (device, handle,FORKED |CONTEXT ,20 ); +sequential (device, handle, ctx,FORKED |CONTEXT ,20 ); igt_subtest_group { igt_fixture {
@@ -1014,9 +1041,9 @@ igt_mainigt_require (gem_scheduler_has_preemption (device)); } igt_subtest_with_dynamic("preempt") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) { igt_dynamic_f("%s", e->name) -preempt (device, handle, e); +preempt (device, handle, ctx, e); } } }
@@ -1027,29 +1054,30 @@ igt_main } igt_subtest_with_dynamic("poll") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) {/* Requires master for STORE_DWORD on gen4/5 */ igt_dynamic_f("%s", e->name) -poll_ring (device, e,20 ); +poll_ring (device, ctx, e,20 ); } } igt_subtest_with_dynamic("headless") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) {igt_dynamic_f ("%s" , e->name) /* Requires master for changing display modes */ -headless (device, handle, e); +headless (device, handle, ctx, e); } } igt_subtest("poll-sequential") -poll_sequential (device,"Sequential" ,20 ); +poll_sequential (device, ctx,"Sequential" ,20 ); } igt_fixture {igt_stop_hang_detector ();gem_close (device, handle); +intel_ctx_destroy (device, ctx);close (device); } }
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 22/89] tests/i915/gem_exec_nop: Convert to intel_ctx_t
Quoted 18 lines · Jason Ekstrand
Signed-off-by Jason Ekstrand <[email protected]>--- tests/i915/gem_exec_nop.c | 156 ++++++++++++++++++++++---------------- 1 file changed, 92 insertions(+), 64 deletions(-)tests/i915/gem_exec_nop.c +1
-0@@ -45,6 +45,7 @@#include "igt_device.h" #include "igt_rand.h" #include "igt_sysfs.h" +#include "intel_ctx.h" #define ENGINE_FLAGS (I915_EXEC_RING_MASK | I915_EXEC_BSD_MASK)
tests/i915/gem_exec_nop.c static double elapsed(const struct timespec *start, const struct timespec *end) · line 69
Quoted 8 lines
tests/i915/gem_exec_nop.c +1
-1@@ -62,7 +63,7 @@ static double elapsed(const struct timespec *start, const struct timespec *end) (end->tv_nsec - start->tv_nsec)*1e-9); } -static double nop_on_ring (int fd,uint32_t handle, +static double nop_on_ring (int fd,uint32_t handle,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,int timeout_ms,unsigned long *out)
When I started to looking at this test I realized we unnecessary have to use newly created context instead using default one. This enforces changes everywhere but we really don't need this imo.
Shouldn't we provide intel_ctx_0 filled with cfg/engines if query engines exists instead of returning pointer to statically defined zeroed structure? Destroy path can diverge the situation - if we allocate intel_ctx_t structure instead of returning pointer to predefined one pointer comparison get us know we should free it.
In both cases - engines queried or statically returned for_each_ctx_*() should work.
--
Zbigniew
Quoted 541 lines
tests/i915/gem_exec_nop.c +90
-63@@ -81,6 +82,7 @@ static double nop_on_ring(int fd, uint32_t handle, execbuf.flags = e->flags; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags = e->flags;gem_execbuf (fd, &execbuf);@@ -101,7 +103,8 @@ static double nop_on_ring(int fd, uint32_t handle,return elapsed (&start, &now); } -static void poll_ring (int fd,const struct intel_execution_engine2 *e, +static void poll_ring (int fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e,int timeout) {const unsigned int gen =intel_gen (intel_get_drm_devid (fd));@@ -185,6 +188,7 @@ static void poll_ring(int fd, const struct intel_execution_engine2 *e, execbuf.buffers_ptr =to_user_pointer (&obj); execbuf.buffer_count =1 ; execbuf.flags = e->flags | flags; + execbuf.rsvd1 = ctx->id; cycles =0 ; do {@@ -212,7 +216,8 @@ static void poll_ring(int fd, const struct intel_execution_engine2 *e,gem_close (fd, obj.handle); } -static void poll_sequential (int fd,const char *name,int timeout) +static void poll_sequential (int fd,const intel_ctx_t *ctx, +const char *name,int timeout) {const unsigned int gen =intel_gen (intel_get_drm_devid (fd));const struct intel_execution_engine2 *e;@@ -232,7 +237,7 @@ static void poll_sequential(int fd, const char *name, int timeout) flags |=I915_EXEC_SECURE ; nengine =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) {if (!gem_class_can_store_dword (fd, e->class) || !gem_class_has_mutable_submission (fd, e->class))continue ;@@ -312,6 +317,7 @@ static void poll_sequential(int fd, const char *name, int timeout)memset (&execbuf,0 ,sizeof (execbuf)); execbuf.buffers_ptr =to_user_pointer (obj); execbuf.buffer_count =ARRAY_SIZE (obj); + execbuf.rsvd1 = ctx->id; cycles =0 ; do {@@ -342,19 +348,19 @@ static void poll_sequential(int fd, const char *name, int timeout)gem_close (fd, obj[0 ].handle); } -static void single (int fd,uint32_t handle, +static void single (int fd,uint32_t handle,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {double time;unsigned long count; - time =nop_on_ring (fd, handle, e,20000 , &count); + time =nop_on_ring (fd, handle, ctx, e,20000 , &count);igt_info ("%s: %'lu cycles: %.3fus\n" , e->name, count, time*1e6 / count); }static double -stable_nop_on_ring (int fd,uint32_t handle, +stable_nop_on_ring (int fd,uint32_t handle,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,int timeout_ms,int reps)@@ -371,7 +377,7 @@ stable_nop_on_ring(int fd, uint32_t handle,unsigned long count;double time; - time =nop_on_ring (fd, handle, e, timeout_ms, &count); + time =nop_on_ring (fd, handle, ctx, e, timeout_ms, &count);igt_stats_push_float (&s, time / count); }@@ -387,7 +393,7 @@ stable_nop_on_ring(int fd, uint32_t handle, "'%s' != '%s' (%f not within %f%% tolerance of %f)\n",\#x , #ref, x, tolerance * 100.0, ref) -static void headless (int fd,uint32_t handle, +static void headless (int fd,uint32_t handle,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {unsigned int nr_connected =0 ;@@ -411,11 +417,11 @@ static void headless(int fd, uint32_t handle,/* set graphics mode to prevent blanking */ kmstest_set_vt_graphics_mode (); -nop_on_ring (fd, handle, e,10 , &count); +nop_on_ring (fd, handle, ctx, e,10 , &count);igt_require_f (count >100 ,"submillisecond precision required\n" );/* benchmark nops */ - n_display =stable_nop_on_ring (fd, handle, e,500 ,5 ); + n_display =stable_nop_on_ring (fd, handle, ctx, e,500 ,5 );igt_info ("With one display connected: %.2fus\n" , n_display *1e6 );@@ -423,7 +429,7 @@ static void headless(int fd, uint32_t handle,kmstest_unset_all_crtcs (fd, res);/* benchmark nops again */ - n_headless =stable_nop_on_ring (fd, handle, e,500 ,5 ); + n_headless =stable_nop_on_ring (fd, handle, ctx, e,500 ,5 );igt_info ("Without a display connected (headless): %.2fus\n" , n_headless *1e6 );@@ -431,7 +437,8 @@ static void headless(int fd, uint32_t handle,assert_within_epsilon (n_headless, n_display,0.1f ); } -static void parallel (int fd,uint32_t handle,int timeout) +static void parallel (int fd,uint32_t handle, +const intel_ctx_t *ctx,int timeout) {const struct intel_execution_engine2 *e;struct drm_i915_gem_execbuffer2 execbuf;@@ -445,11 +452,11 @@ static void parallel(int fd, uint32_t handle, int timeout) sum =0 ; nengine =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { engines[nengine] = e->flags; names[nengine++] =strdup (e->name); - time =nop_on_ring (fd, handle, e,250 , &count) / count; + time =nop_on_ring (fd, handle, ctx, e,250 , &count) / count; sum += time;igt_debug ("%s: %.3fus\n" , e->name,1e6 *time); }@@ -464,6 +471,7 @@ static void parallel(int fd, uint32_t handle, int timeout) execbuf.buffer_count =1 ; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags =0 ;gem_execbuf (fd, &execbuf);@@ -494,7 +502,8 @@ static void parallel(int fd, uint32_t handle, int timeout)igt_assert_eq (intel_detect_and_clear_missed_interrupts (fd),0 ); } -static void independent (int fd,uint32_t handle,int timeout) +static void independent (int fd,uint32_t handle, +const intel_ctx_t *ctx,int timeout) {const struct intel_execution_engine2 *e;struct drm_i915_gem_execbuffer2 execbuf;@@ -507,11 +516,11 @@ static void independent(int fd, uint32_t handle, int timeout) sum =0 ; nengine =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { engines[nengine] = e->flags; names[nengine++] =strdup (e->name); - time =nop_on_ring (fd, handle, e,250 , &count) / count; + time =nop_on_ring (fd, handle, ctx, e,250 , &count) / count; sum += time;igt_debug ("%s: %.3fus\n" , e->name,1e6 *time); }@@ -526,6 +535,7 @@ static void independent(int fd, uint32_t handle, int timeout) execbuf.buffer_count =1 ; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags =0 ;gem_execbuf (fd, &execbuf);@@ -562,7 +572,7 @@ static void independent(int fd, uint32_t handle, int timeout)igt_assert_eq (intel_detect_and_clear_missed_interrupts (fd),0 ); } -static void multiple (int fd, +static void multiple (int fd,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,int timeout) {@@ -581,6 +591,7 @@ static void multiple(int fd, execbuf.flags = e->flags; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags = e->flags;gem_execbuf (fd, &execbuf);@@ -592,9 +603,11 @@ static void multiple(int fd,unsigned long count;double time;int i915; +const intel_ctx_t *child_ctx; i915 =gem_reopen_driver (fd); -gem_context_copy_engines (fd,0 , i915,0 ); + child_ctx =intel_ctx_create (i915, &ctx->cfg); + execbuf.rsvd1 = child_ctx->id; obj.handle =gem_create (i915,4096 );gem_write (i915, obj.handle,0 , &bbe,sizeof (bbe));@@ -609,6 +622,7 @@ static void multiple(int fd, }while (elapsed (&start, &now) < timeout); time =elapsed (&start, &now) / count;igt_info ("%d: %ld cycles, %.3fus\n" , child, count,1e6 *time); +intel_ctx_destroy (i915, child_ctx); }igt_waitchildren ();@@ -617,7 +631,8 @@ static void multiple(int fd,gem_close (fd, obj.handle); } -static void series (int fd,uint32_t handle,int timeout) +static void series (int fd,uint32_t handle, +const intel_ctx_t *ctx,int timeout) {const struct intel_execution_engine2 *e;struct drm_i915_gem_execbuffer2 execbuf;@@ -630,8 +645,8 @@ static void series(int fd, uint32_t handle, int timeout)const char *name; nengine =0 ; -__for_each_physical_engine (fd, e) { - time =nop_on_ring (fd, handle, e,250 , &count) / count; +for_each_ctx_engine (fd, ctx, e) { + time =nop_on_ring (fd, handle, ctx, e,250 , &count) / count;if (time > max) { name = e->name; max = time;@@ -653,6 +668,7 @@ static void series(int fd, uint32_t handle, int timeout) execbuf.buffer_count =1 ; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags =0 ;gem_execbuf (fd, &execbuf);@@ -688,9 +704,11 @@ static void xchg(void *array, unsigned i, unsigned j) u[j] = tmp; } -static void sequential (int fd,uint32_t handle,unsigned flags,int timeout) +static void sequential (int fd,uint32_t handle, +const intel_ctx_t *ctx,unsigned flags,int timeout) {const int ncpus = flags &FORKED ?sysconf (_SC_NPROCESSORS_ONLN) :1 ; +const intel_ctx_t *tmp_ctx =NULL , *child_ctx =NULL ;const struct intel_execution_engine2 *e;struct drm_i915_gem_execbuffer2 execbuf;struct drm_i915_gem_exec_object2 obj[2 ];@@ -707,10 +725,10 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout) nengine =0 ; sum =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) {unsigned long count; - time =nop_on_ring (fd, handle, e,250 , &count) / count; + time =nop_on_ring (fd, handle, ctx, e,250 , &count) / count; sum += time;igt_debug ("%s: %.3fus\n" , e->name,1e6 *time);@@ -734,7 +752,8 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout)if (flags &CONTEXT ) {gem_require_contexts (fd); - execbuf.rsvd1 =gem_context_clone_with_engines (fd,0 ); + tmp_ctx =intel_ctx_create (fd, &ctx->cfg); + execbuf.rsvd1 = tmp_ctx->id; }for (n =0 ; n < nengine; n++) {@@ -754,7 +773,8 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout)if (flags &CONTEXT ) {gem_require_contexts (fd); - execbuf.rsvd1 =gem_context_clone_with_engines (fd,0 ); + child_ctx =intel_ctx_create (fd, &ctx->cfg); + execbuf.rsvd1 = child_ctx->id; }hars_petruska_f54_1_random_perturb (child);@@ -777,7 +797,7 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout) results[child] =elapsed (&start, &now) / count;if (flags &CONTEXT ) -gem_context_destroy (fd, execbuf.rsvd1); +intel_ctx_destroy (fd, child_ctx);gem_close (fd, obj[0 ].handle); }@@ -793,7 +813,7 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout) nengine, ncpus, 1e6*results[ncpus], 1e6*sum*ncpus);if (flags &CONTEXT ) -gem_context_destroy (fd, execbuf.rsvd1); +intel_ctx_destroy (fd, tmp_ctx);gem_close (fd, obj[0 ].handle);munmap (results,4096 );@@ -810,6 +830,7 @@ static bool fence_wait(int fence) }static void fence_signal (int fd,uint32_t handle, +const intel_ctx_t *ctx,const struct intel_execution_engine2 *ring_id,const char *ring_name,int timeout) {@@ -827,7 +848,7 @@ static void fence_signal(int fd, uint32_t handle, nengine =0 ;if (!ring_id) { -__for_each_physical_engine (fd, __e) +for_each_ctx_engine (fd, ctx, __e) engines[nengine++] = __e->flags; }else { engines[nengine++] = ring_id->flags;@@ -845,6 +866,7 @@ static void fence_signal(int fd, uint32_t handle, execbuf.buffers_ptr =to_user_pointer (&obj); execbuf.buffer_count =1 ; execbuf.flags =I915_EXEC_FENCE_OUT ; + execbuf.rsvd1 = ctx->id; n =0 ; count =0 ;@@ -885,20 +907,21 @@ static void fence_signal(int fd, uint32_t handle, }static void preempt (int fd,uint32_t handle, +const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {struct drm_i915_gem_execbuffer2 execbuf;struct drm_i915_gem_exec_object2 obj;struct timespec start, now;unsigned long count; -uint32_t ctx[2 ]; +const intel_ctx_t *tmp_ctx[2 ];igt_spin_t *spin; - ctx[0 ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[0 ],MIN_PRIO ); + tmp_ctx[0 ] =intel_ctx_create (fd, &ctx->cfg); +gem_context_set_priority (fd, tmp_ctx[0 ]->id,MIN_PRIO ); - ctx[1 ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[1 ],MAX_PRIO ); + tmp_ctx[1 ] =intel_ctx_create (fd, &ctx->cfg); +gem_context_set_priority (fd, tmp_ctx[1 ]->id,MAX_PRIO );memset (&obj,0 ,sizeof (obj)); obj.handle = handle;@@ -909,15 +932,16 @@ static void preempt(int fd, uint32_t handle, execbuf.flags = e->flags; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags = e->flags;gem_execbuf (fd, &execbuf); } - execbuf.rsvd1 = ctx[1 ]; + execbuf.rsvd1 = tmp_ctx[1 ]->id;intel_detect_and_clear_missed_interrupts (fd); count =0 ; - spin = __igt_spin_new(fd, .ctx_id = ctx[0], .engine = e->flags); + spin = __igt_spin_new(fd, .ctx = tmp_ctx[0], .engine = e->flags);clock_gettime (CLOCK_MONOTONIC , &start); do { gem_execbuf(fd, &execbuf);@@ -927,8 +951,8 @@ static void preempt(int fd, uint32_t handle,igt_spin_free (fd, spin);igt_assert_eq (intel_detect_and_clear_missed_interrupts (fd),0 ); -gem_context_destroy (fd, ctx[1 ]); -gem_context_destroy (fd, ctx[0 ]); +intel_ctx_destroy (fd, tmp_ctx[1 ]); +intel_ctx_destroy (fd, tmp_ctx[0 ]);igt_info ("%s: %'lu cycles: %.3fus\n" , e->name, count,elapsed (&start, &now)*1e6 / count);@@ -937,6 +961,7 @@ static void preempt(int fd, uint32_t handle, igt_main {const struct intel_execution_engine2 *e; +const intel_ctx_t *ctx =NULL ;uint32_t handle =0 ;int device =-1 ;@@ -948,6 +973,8 @@ igt_maingem_submission_print_method (device);gem_scheduler_print_capability (device); + ctx =intel_ctx_create_all_physical (device); + handle =gem_create (device,4096 );gem_write (device, handle,0 , &bbe,sizeof (bbe));@@ -955,57 +982,57 @@ igt_main } igt_subtest("basic-series") -series (device, handle,2 ); +series (device, handle, ctx,2 ); igt_subtest("basic-parallel") -parallel (device, handle,2 ); +parallel (device, handle, ctx,2 ); igt_subtest("basic-sequential") -sequential (device, handle,0 ,2 ); +sequential (device, handle, ctx,0 ,2 ); igt_subtest_with_dynamic("single") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) { igt_dynamic_f("%s", e->name) -single (device, handle, e); +single (device, handle, ctx, e); } } igt_subtest_with_dynamic("signal") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) { igt_dynamic_f("%s", e->name) -fence_signal (device, handle, e, - e->name,2 ); +fence_signal (device, handle, ctx, + e, e->name,2 ); } }igt_subtest ("signal-all" ) /* NULL value means all engines */ -fence_signal (device, handle,NULL ,"all" ,20 ); +fence_signal (device, handle, ctx,NULL ,"all" ,20 ); igt_subtest("series") -series (device, handle,20 ); +series (device, handle, ctx,20 ); igt_subtest("parallel") -parallel (device, handle,20 ); +parallel (device, handle, ctx,20 ); igt_subtest("independent") -independent (device, handle,20 ); +independent (device, handle, ctx,20 ); igt_subtest_with_dynamic("multiple") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) { igt_dynamic_f("%s", e->name) -multiple (device, e,20 ); +multiple (device, ctx, e,20 ); } } igt_subtest("sequential") -sequential (device, handle,0 ,20 ); +sequential (device, handle, ctx,0 ,20 ); igt_subtest("forked-sequential") -sequential (device, handle,FORKED ,20 ); +sequential (device, handle, ctx,FORKED ,20 ); igt_subtest("context-sequential") -sequential (device, handle,FORKED |CONTEXT ,20 ); +sequential (device, handle, ctx,FORKED |CONTEXT ,20 ); igt_subtest_group { igt_fixture {@@ -1014,9 +1041,9 @@ igt_mainigt_require (gem_scheduler_has_preemption (device)); } igt_subtest_with_dynamic("preempt") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) { igt_dynamic_f("%s", e->name) -preempt (device, handle, e); +preempt (device, handle, ctx, e); } } }@@ -1027,29 +1054,30 @@ igt_main } igt_subtest_with_dynamic("poll") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) {/* Requires master for STORE_DWORD on gen4/5 */ igt_dynamic_f("%s", e->name) -poll_ring (device, e,20 ); +poll_ring (device, ctx, e,20 ); } } igt_subtest_with_dynamic("headless") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) {igt_dynamic_f ("%s" , e->name) /* Requires master for changing display modes */ -headless (device, handle, e); +headless (device, handle, ctx, e); } } igt_subtest("poll-sequential") -poll_sequential (device,"Sequential" ,20 ); +poll_sequential (device, ctx,"Sequential" ,20 ); } igt_fixture {igt_stop_hang_detector ();gem_close (device, handle); +intel_ctx_destroy (device, ctx);close (device); } }Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 22/89] tests/i915/gem_exec_nop: Convert to intel_ctx_t
Quoted 33 lines · Zbigniew Kempczyński
Quoted 18 lines · Jason Ekstrand
Signed-off-by Jason Ekstrand <[email protected]>--- tests/i915/gem_exec_nop.c | 156 ++++++++++++++++++++++---------------- 1 file changed, 92 insertions(+), 64 deletions(-)tests/i915/gem_exec_nop.c +1
-0@@ -45,6 +45,7 @@#include "igt_device.h" #include "igt_rand.h" #include "igt_sysfs.h" +#include "intel_ctx.h" #define ENGINE_FLAGS (I915_EXEC_RING_MASK | I915_EXEC_BSD_MASK)tests/i915/gem_exec_nop.c static double elapsed(const struct timespec *start, const struct timespec *end) · line 69
Quoted 8 lines
tests/i915/gem_exec_nop.c +1
-1@@ -62,7 +63,7 @@ static double elapsed(const struct timespec *start, const struct timespec *end) (end->tv_nsec - start->tv_nsec)*1e-9); } -static double nop_on_ring (int fd,uint32_t handle, +static double nop_on_ring (int fd,uint32_t handle,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,int timeout_ms,unsigned long *out)When I started to looking at this test I realized we unnecessary have to use newly created context instead using default one. This enforces changes everywhere but we really don't need this imo.
Quoted 5 lines
Shouldn't we provide
intel_ctx_0filled with cfg/engines if query engines exists instead of returning pointer to statically defined zeroed structure? Destroy path can diverge the situation - if we allocateintel_ctx_tstructure instead of returning pointer to predefined one pointer comparison get us know we should free it.
I'm a bit unclear what you're asking here. There are two separate things, I think.
First, regarding intel_ctx_0. I chose to make it a pointer to a static struct so we can throw an intel_ctx_0(fd) in places without worrying about memory leaks. We then check for ctx0 in the destructor so it's safe to free it or not. We could also always create a new struct and, in the case where someone wants quick access to ctx0, accept the memory leak. This is IGT after all. Little leaks are no big deal since the processes are small and short-lived.
Second, regarding having intel_ctx_0 filled with all physical engines. That's not how ctx0 works. It starts off with the set of legacy default engines. On newer hardware with more than 2 video engines or with a compute engine, we can't get at those engines with the legacy API. The only way to get at them is to create a new context. Prior to the cleanups, we could reset the engine set on ctx0 to get at more engines but that's exactly what we're deleting.
Not sure if that answered the question or not.
--Jason
Quoted 544 lines
In both cases - engines queried or statically returned for_each_ctx_*() should work.
--
ZbigniewQuoted 537 lines
tests/i915/gem_exec_nop.c +90
-64@@ -81,6 +82,7 @@ static double nop_on_ring(int fd, uint32_t handle, execbuf.flags = e->flags; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags = e->flags;gem_execbuf (fd, &execbuf);@@ -101,7 +103,8 @@ static double nop_on_ring(int fd, uint32_t handle,return elapsed (&start, &now); } -static void poll_ring (int fd,const struct intel_execution_engine2 *e, +static void poll_ring (int fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e,int timeout) {const unsigned int gen =intel_gen (intel_get_drm_devid (fd));@@ -185,6 +188,7 @@ static void poll_ring(int fd, const struct intel_execution_engine2 *e, execbuf.buffers_ptr =to_user_pointer (&obj); execbuf.buffer_count =1 ; execbuf.flags = e->flags | flags; + execbuf.rsvd1 = ctx->id; cycles =0 ; do {@@ -212,7 +216,8 @@ static void poll_ring(int fd, const struct intel_execution_engine2 *e,gem_close (fd, obj.handle); } -static void poll_sequential (int fd,const char *name,int timeout) +static void poll_sequential (int fd,const intel_ctx_t *ctx, +const char *name,int timeout) {const unsigned int gen =intel_gen (intel_get_drm_devid (fd));const struct intel_execution_engine2 *e;@@ -232,7 +237,7 @@ static void poll_sequential(int fd, const char *name, int timeout) flags |=I915_EXEC_SECURE ; nengine =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) {if (!gem_class_can_store_dword (fd, e->class) || !gem_class_has_mutable_submission (fd, e->class))continue ;@@ -312,6 +317,7 @@ static void poll_sequential(int fd, const char *name, int timeout)memset (&execbuf,0 ,sizeof (execbuf)); execbuf.buffers_ptr =to_user_pointer (obj); execbuf.buffer_count =ARRAY_SIZE (obj); + execbuf.rsvd1 = ctx->id; cycles =0 ; do {@@ -342,19 +348,19 @@ static void poll_sequential(int fd, const char *name, int timeout)gem_close (fd, obj[0 ].handle); } -static void single (int fd,uint32_t handle, +static void single (int fd,uint32_t handle,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {double time;unsigned long count; - time =nop_on_ring (fd, handle, e,20000 , &count); + time =nop_on_ring (fd, handle, ctx, e,20000 , &count);igt_info ("%s: %'lu cycles: %.3fus\n" , e->name, count, time*1e6 / count); }static double -stable_nop_on_ring (int fd,uint32_t handle, +stable_nop_on_ring (int fd,uint32_t handle,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,int timeout_ms,int reps)@@ -371,7 +377,7 @@ stable_nop_on_ring(int fd, uint32_t handle,unsigned long count;double time; - time =nop_on_ring (fd, handle, e, timeout_ms, &count); + time =nop_on_ring (fd, handle, ctx, e, timeout_ms, &count);igt_stats_push_float (&s, time / count); }@@ -387,7 +393,7 @@ stable_nop_on_ring(int fd, uint32_t handle, "'%s' != '%s' (%f not within %f%% tolerance of %f)\n",\#x , #ref, x, tolerance * 100.0, ref) -static void headless (int fd,uint32_t handle, +static void headless (int fd,uint32_t handle,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {unsigned int nr_connected =0 ;@@ -411,11 +417,11 @@ static void headless(int fd, uint32_t handle,/* set graphics mode to prevent blanking */ kmstest_set_vt_graphics_mode (); -nop_on_ring (fd, handle, e,10 , &count); +nop_on_ring (fd, handle, ctx, e,10 , &count);igt_require_f (count >100 ,"submillisecond precision required\n" );/* benchmark nops */ - n_display =stable_nop_on_ring (fd, handle, e,500 ,5 ); + n_display =stable_nop_on_ring (fd, handle, ctx, e,500 ,5 );igt_info ("With one display connected: %.2fus\n" , n_display *1e6 );@@ -423,7 +429,7 @@ static void headless(int fd, uint32_t handle,kmstest_unset_all_crtcs (fd, res);/* benchmark nops again */ - n_headless =stable_nop_on_ring (fd, handle, e,500 ,5 ); + n_headless =stable_nop_on_ring (fd, handle, ctx, e,500 ,5 );igt_info ("Without a display connected (headless): %.2fus\n" , n_headless *1e6 );@@ -431,7 +437,8 @@ static void headless(int fd, uint32_t handle,assert_within_epsilon (n_headless, n_display,0.1f ); } -static void parallel (int fd,uint32_t handle,int timeout) +static void parallel (int fd,uint32_t handle, +const intel_ctx_t *ctx,int timeout) {const struct intel_execution_engine2 *e;struct drm_i915_gem_execbuffer2 execbuf;@@ -445,11 +452,11 @@ static void parallel(int fd, uint32_t handle, int timeout) sum =0 ; nengine =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { engines[nengine] = e->flags; names[nengine++] =strdup (e->name); - time =nop_on_ring (fd, handle, e,250 , &count) / count; + time =nop_on_ring (fd, handle, ctx, e,250 , &count) / count; sum += time;igt_debug ("%s: %.3fus\n" , e->name,1e6 *time); }@@ -464,6 +471,7 @@ static void parallel(int fd, uint32_t handle, int timeout) execbuf.buffer_count =1 ; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags =0 ;gem_execbuf (fd, &execbuf);@@ -494,7 +502,8 @@ static void parallel(int fd, uint32_t handle, int timeout)igt_assert_eq (intel_detect_and_clear_missed_interrupts (fd),0 ); } -static void independent (int fd,uint32_t handle,int timeout) +static void independent (int fd,uint32_t handle, +const intel_ctx_t *ctx,int timeout) {const struct intel_execution_engine2 *e;struct drm_i915_gem_execbuffer2 execbuf;@@ -507,11 +516,11 @@ static void independent(int fd, uint32_t handle, int timeout) sum =0 ; nengine =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { engines[nengine] = e->flags; names[nengine++] =strdup (e->name); - time =nop_on_ring (fd, handle, e,250 , &count) / count; + time =nop_on_ring (fd, handle, ctx, e,250 , &count) / count; sum += time;igt_debug ("%s: %.3fus\n" , e->name,1e6 *time); }@@ -526,6 +535,7 @@ static void independent(int fd, uint32_t handle, int timeout) execbuf.buffer_count =1 ; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags =0 ;gem_execbuf (fd, &execbuf);@@ -562,7 +572,7 @@ static void independent(int fd, uint32_t handle, int timeout)igt_assert_eq (intel_detect_and_clear_missed_interrupts (fd),0 ); } -static void multiple (int fd, +static void multiple (int fd,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,int timeout) {@@ -581,6 +591,7 @@ static void multiple(int fd, execbuf.flags = e->flags; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags = e->flags;gem_execbuf (fd, &execbuf);@@ -592,9 +603,11 @@ static void multiple(int fd,unsigned long count;double time;int i915; +const intel_ctx_t *child_ctx; i915 =gem_reopen_driver (fd); -gem_context_copy_engines (fd,0 , i915,0 ); + child_ctx =intel_ctx_create (i915, &ctx->cfg); + execbuf.rsvd1 = child_ctx->id; obj.handle =gem_create (i915,4096 );gem_write (i915, obj.handle,0 , &bbe,sizeof (bbe));@@ -609,6 +622,7 @@ static void multiple(int fd, }while (elapsed (&start, &now) < timeout); time =elapsed (&start, &now) / count;igt_info ("%d: %ld cycles, %.3fus\n" , child, count,1e6 *time); +intel_ctx_destroy (i915, child_ctx); }igt_waitchildren ();@@ -617,7 +631,8 @@ static void multiple(int fd,gem_close (fd, obj.handle); } -static void series (int fd,uint32_t handle,int timeout) +static void series (int fd,uint32_t handle, +const intel_ctx_t *ctx,int timeout) {const struct intel_execution_engine2 *e;struct drm_i915_gem_execbuffer2 execbuf;@@ -630,8 +645,8 @@ static void series(int fd, uint32_t handle, int timeout)const char *name; nengine =0 ; -__for_each_physical_engine (fd, e) { - time =nop_on_ring (fd, handle, e,250 , &count) / count; +for_each_ctx_engine (fd, ctx, e) { + time =nop_on_ring (fd, handle, ctx, e,250 , &count) / count;if (time > max) { name = e->name; max = time;@@ -653,6 +668,7 @@ static void series(int fd, uint32_t handle, int timeout) execbuf.buffer_count =1 ; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags =0 ;gem_execbuf (fd, &execbuf);@@ -688,9 +704,11 @@ static void xchg(void *array, unsigned i, unsigned j) u[j] = tmp; } -static void sequential (int fd,uint32_t handle,unsigned flags,int timeout) +static void sequential (int fd,uint32_t handle, +const intel_ctx_t *ctx,unsigned flags,int timeout) {const int ncpus = flags &FORKED ?sysconf (_SC_NPROCESSORS_ONLN) :1 ; +const intel_ctx_t *tmp_ctx =NULL , *child_ctx =NULL ;const struct intel_execution_engine2 *e;struct drm_i915_gem_execbuffer2 execbuf;struct drm_i915_gem_exec_object2 obj[2 ];@@ -707,10 +725,10 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout) nengine =0 ; sum =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) {unsigned long count; - time =nop_on_ring (fd, handle, e,250 , &count) / count; + time =nop_on_ring (fd, handle, ctx, e,250 , &count) / count; sum += time;igt_debug ("%s: %.3fus\n" , e->name,1e6 *time);@@ -734,7 +752,8 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout)if (flags &CONTEXT ) {gem_require_contexts (fd); - execbuf.rsvd1 =gem_context_clone_with_engines (fd,0 ); + tmp_ctx =intel_ctx_create (fd, &ctx->cfg); + execbuf.rsvd1 = tmp_ctx->id; }for (n =0 ; n < nengine; n++) {@@ -754,7 +773,8 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout)if (flags &CONTEXT ) {gem_require_contexts (fd); - execbuf.rsvd1 =gem_context_clone_with_engines (fd,0 ); + child_ctx =intel_ctx_create (fd, &ctx->cfg); + execbuf.rsvd1 = child_ctx->id; }hars_petruska_f54_1_random_perturb (child);@@ -777,7 +797,7 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout) results[child] =elapsed (&start, &now) / count;if (flags &CONTEXT ) -gem_context_destroy (fd, execbuf.rsvd1); +intel_ctx_destroy (fd, child_ctx);gem_close (fd, obj[0 ].handle); }@@ -793,7 +813,7 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout) nengine, ncpus, 1e6*results[ncpus], 1e6*sum*ncpus);if (flags &CONTEXT ) -gem_context_destroy (fd, execbuf.rsvd1); +intel_ctx_destroy (fd, tmp_ctx);gem_close (fd, obj[0 ].handle);munmap (results,4096 );@@ -810,6 +830,7 @@ static bool fence_wait(int fence) }static void fence_signal (int fd,uint32_t handle, +const intel_ctx_t *ctx,const struct intel_execution_engine2 *ring_id,const char *ring_name,int timeout) {@@ -827,7 +848,7 @@ static void fence_signal(int fd, uint32_t handle, nengine =0 ;if (!ring_id) { -__for_each_physical_engine (fd, __e) +for_each_ctx_engine (fd, ctx, __e) engines[nengine++] = __e->flags; }else { engines[nengine++] = ring_id->flags;@@ -845,6 +866,7 @@ static void fence_signal(int fd, uint32_t handle, execbuf.buffers_ptr =to_user_pointer (&obj); execbuf.buffer_count =1 ; execbuf.flags =I915_EXEC_FENCE_OUT ; + execbuf.rsvd1 = ctx->id; n =0 ; count =0 ;@@ -885,20 +907,21 @@ static void fence_signal(int fd, uint32_t handle, }static void preempt (int fd,uint32_t handle, +const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {struct drm_i915_gem_execbuffer2 execbuf;struct drm_i915_gem_exec_object2 obj;struct timespec start, now;unsigned long count; -uint32_t ctx[2 ]; +const intel_ctx_t *tmp_ctx[2 ];igt_spin_t *spin; - ctx[0 ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[0 ],MIN_PRIO ); + tmp_ctx[0 ] =intel_ctx_create (fd, &ctx->cfg); +gem_context_set_priority (fd, tmp_ctx[0 ]->id,MIN_PRIO ); - ctx[1 ] =gem_context_clone_with_engines (fd,0 ); -gem_context_set_priority (fd, ctx[1 ],MAX_PRIO ); + tmp_ctx[1 ] =intel_ctx_create (fd, &ctx->cfg); +gem_context_set_priority (fd, tmp_ctx[1 ]->id,MAX_PRIO );memset (&obj,0 ,sizeof (obj)); obj.handle = handle;@@ -909,15 +932,16 @@ static void preempt(int fd, uint32_t handle, execbuf.flags = e->flags; execbuf.flags |=I915_EXEC_HANDLE_LUT ; execbuf.flags |=I915_EXEC_NO_RELOC ; + execbuf.rsvd1 = ctx->id;if (__gem_execbuf (fd, &execbuf)) { execbuf.flags = e->flags;gem_execbuf (fd, &execbuf); } - execbuf.rsvd1 = ctx[1 ]; + execbuf.rsvd1 = tmp_ctx[1 ]->id;intel_detect_and_clear_missed_interrupts (fd); count =0 ; - spin = __igt_spin_new(fd, .ctx_id = ctx[0], .engine = e->flags); + spin = __igt_spin_new(fd, .ctx = tmp_ctx[0], .engine = e->flags);clock_gettime (CLOCK_MONOTONIC , &start); do { gem_execbuf(fd, &execbuf);@@ -927,8 +951,8 @@ static void preempt(int fd, uint32_t handle,igt_spin_free (fd, spin);igt_assert_eq (intel_detect_and_clear_missed_interrupts (fd),0 ); -gem_context_destroy (fd, ctx[1 ]); -gem_context_destroy (fd, ctx[0 ]); +intel_ctx_destroy (fd, tmp_ctx[1 ]); +intel_ctx_destroy (fd, tmp_ctx[0 ]);igt_info ("%s: %'lu cycles: %.3fus\n" , e->name, count,elapsed (&start, &now)*1e6 / count);@@ -937,6 +961,7 @@ static void preempt(int fd, uint32_t handle, igt_main {const struct intel_execution_engine2 *e; +const intel_ctx_t *ctx =NULL ;uint32_t handle =0 ;int device =-1 ;@@ -948,6 +973,8 @@ igt_maingem_submission_print_method (device);gem_scheduler_print_capability (device); + ctx =intel_ctx_create_all_physical (device); + handle =gem_create (device,4096 );gem_write (device, handle,0 , &bbe,sizeof (bbe));@@ -955,57 +982,57 @@ igt_main } igt_subtest("basic-series") -series (device, handle,2 ); +series (device, handle, ctx,2 ); igt_subtest("basic-parallel") -parallel (device, handle,2 ); +parallel (device, handle, ctx,2 ); igt_subtest("basic-sequential") -sequential (device, handle,0 ,2 ); +sequential (device, handle, ctx,0 ,2 ); igt_subtest_with_dynamic("single") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) { igt_dynamic_f("%s", e->name) -single (device, handle, e); +single (device, handle, ctx, e); } } igt_subtest_with_dynamic("signal") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) { igt_dynamic_f("%s", e->name) -fence_signal (device, handle, e, - e->name,2 ); +fence_signal (device, handle, ctx, + e, e->name,2 ); } }igt_subtest ("signal-all" ) /* NULL value means all engines */ -fence_signal (device, handle,NULL ,"all" ,20 ); +fence_signal (device, handle, ctx,NULL ,"all" ,20 ); igt_subtest("series") -series (device, handle,20 ); +series (device, handle, ctx,20 ); igt_subtest("parallel") -parallel (device, handle,20 ); +parallel (device, handle, ctx,20 ); igt_subtest("independent") -independent (device, handle,20 ); +independent (device, handle, ctx,20 ); igt_subtest_with_dynamic("multiple") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) { igt_dynamic_f("%s", e->name) -multiple (device, e,20 ); +multiple (device, ctx, e,20 ); } } igt_subtest("sequential") -sequential (device, handle,0 ,20 ); +sequential (device, handle, ctx,0 ,20 ); igt_subtest("forked-sequential") -sequential (device, handle,FORKED ,20 ); +sequential (device, handle, ctx,FORKED ,20 ); igt_subtest("context-sequential") -sequential (device, handle,FORKED |CONTEXT ,20 ); +sequential (device, handle, ctx,FORKED |CONTEXT ,20 ); igt_subtest_group { igt_fixture {@@ -1014,9 +1041,9 @@ igt_mainigt_require (gem_scheduler_has_preemption (device)); } igt_subtest_with_dynamic("preempt") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) { igt_dynamic_f("%s", e->name) -preempt (device, handle, e); +preempt (device, handle, ctx, e); } } }@@ -1027,29 +1054,30 @@ igt_main } igt_subtest_with_dynamic("poll") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) {/* Requires master for STORE_DWORD on gen4/5 */ igt_dynamic_f("%s", e->name) -poll_ring (device, e,20 ); +poll_ring (device, ctx, e,20 ); } } igt_subtest_with_dynamic("headless") { -__for_each_physical_engine (device, e) { +for_each_ctx_engine (device, ctx, e) {igt_dynamic_f ("%s" , e->name) /* Requires master for changing display modes */ -headless (device, handle, e); +headless (device, handle, ctx, e); } } igt_subtest("poll-sequential") -poll_sequential (device,"Sequential" ,20 ); +poll_sequential (device, ctx,"Sequential" ,20 ); } igt_fixture {igt_stop_hang_detector ();gem_close (device, handle); +intel_ctx_destroy (device, ctx);close (device); } } --2.31.1
Quoted 4 lines
Quoted 4 lines
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 23/89 tests/i915/gem_exec_reloc: Convert to intel_ctx_t
In reply to Jason Ekstrand--- tests/i915/gem_exec_reloc.c | 102 ++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 40 deletions(-)
tests/i915/gem_exec_reloc.c +62 -40
@@ -266,7 +266,7 @@ static void check_bo(int fd, uint32_t handle)munmap (map,4096 ); } -static void active (int fd,unsigned engine) +static void active (int fd,const intel_ctx_t *ctx,unsigned engine) {const unsigned int gen =intel_gen (intel_get_drm_devid (fd));struct drm_i915_gem_relocation_entry reloc;
@@ -280,7 +280,7 @@ static void active(int fd, unsigned engine)if (engine ==ALL_ENGINES ) {const struct intel_execution_engine2 *e; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) {if (gem_class_can_store_dword (fd, e->class)) engines[nengine++] = e->flags; }
@@ -308,6 +308,7 @@ static void active(int fd, unsigned engine) execbuf.buffer_count =2 ;if (gen <6 ) execbuf.flags |=I915_EXEC_SECURE ; + execbuf.rsvd1 = ctx->id;for (pass =0 ; pass <1024 ; pass++) {uint32_t batch[16 ];
@@ -367,7 +368,8 @@ static uint64_t many_relocs(unsigned long count, unsigned long *out)return to_user_pointer (reloc); } -static void __many_active (int i915,unsigned engine,unsigned long count) +static void __many_active (int i915,const intel_ctx_t *ctx,unsigned engine, +unsigned long count) {unsigned long reloc_sz;struct drm_i915_gem_exec_object2 obj[2 ] = {{
@@ -379,10 +381,12 @@ static void __many_active(int i915, unsigned engine, unsigned long count) .buffers_ptr = to_user_pointer(obj), .buffer_count = ARRAY_SIZE(obj), .flags = engine | I915_EXEC_HANDLE_LUT, + .rsvd1 = ctx->id, };igt_spin_t *spin; spin = __igt_spin_new(i915, + .ctx = ctx, .engine = engine, .dependency = obj[0].handle, .flags = (IGT_SPIN_FENCE_OUT |
@@ -405,7 +409,7 @@ static void __many_active(int i915, unsigned engine, unsigned long count)gem_close (i915, obj[0 ].handle); } -static void many_active (int i915,unsigned engine) +static void many_active (int i915,const intel_ctx_t *ctx,unsigned engine) {const uint64_t max =2048 ;unsigned long count =256 ;
@@ -418,7 +422,7 @@ static void many_active(int i915, unsigned engine)break ;igt_debug ("Testing count:%lu\n" , count); -__many_active (i915, engine, count); +__many_active (i915, ctx, engine, count); count <<=1 ;if (count >= max)
@@ -426,7 +430,8 @@ static void many_active(int i915, unsigned engine) } } -static void __wide_active (int i915,unsigned engine,unsigned long count) +static void __wide_active (int i915,const intel_ctx_t *ctx,unsigned engine, +unsigned long count) {struct drm_i915_gem_relocation_entry *reloc =calloc (count,sizeof (*reloc));
@@ -436,6 +441,7 @@ static void __wide_active(int i915, unsigned engine, unsigned long count) .buffers_ptr = to_user_pointer(obj), .buffer_count = count + 1, .flags = engine | I915_EXEC_HANDLE_LUT, + .rsvd1 = ctx->id, };igt_spin_t *spin;
@@ -446,6 +452,7 @@ static void __wide_active(int i915, unsigned engine, unsigned long count) } spin = __igt_spin_new(i915, + .ctx = ctx, .engine = engine, .flags = (IGT_SPIN_FENCE_OUT |IGT_SPIN_NO_PREEMPTION ));
@@ -475,7 +482,7 @@ static void __wide_active(int i915, unsigned engine, unsigned long count)free (reloc); } -static void wide_active (int i915,unsigned engine) +static void wide_active (int i915,const intel_ctx_t *ctx,unsigned engine) {const uint64_t max =gem_aperture_size (i915) /4096 /2 ;unsigned long count =256 ;
@@ -488,7 +495,7 @@ static void wide_active(int i915, unsigned engine)break ;igt_debug ("Testing count:%lu\n" , count); -__wide_active (i915, engine, count); +__wide_active (i915, ctx, engine, count); count <<=1 ;if (count >= max)
@@ -501,7 +508,7 @@ static unsigned int offset_in_page(void *addr)return (uintptr_t )addr &4095 ; } -static void active_spin (int fd,unsigned engine) +static void active_spin (int fd,const intel_ctx_t *ctx,unsigned engine) {const uint32_t bbe =MI_BATCH_BUFFER_END ;struct drm_i915_gem_relocation_entry reloc;
@@ -510,6 +517,7 @@ static void active_spin(int fd, unsigned engine)igt_spin_t *spin; spin = igt_spin_new(fd, + .ctx = ctx, .engine = engine, .flags =IGT_SPIN_NO_PREEMPTION );
@@ -529,6 +537,7 @@ static void active_spin(int fd, unsigned engine) execbuf.buffers_ptr =to_user_pointer (obj); execbuf.buffer_count =2 ; execbuf.flags = engine; + execbuf.rsvd1 = ctx->id;gem_execbuf (fd, &execbuf);gem_close (fd, obj[1 ].handle);
@@ -541,7 +550,7 @@ static void active_spin(int fd, unsigned engine)igt_spin_free (fd, spin); } -static void others_spin (int i915,unsigned engine) +static void others_spin (int i915,const intel_ctx_t *ctx,unsigned engine) {struct drm_i915_gem_relocation_entry reloc = {};struct drm_i915_gem_exec_object2 obj = {
@@ -552,18 +561,20 @@ static void others_spin(int i915, unsigned engine) .buffers_ptr = to_user_pointer(&obj), .buffer_count = 1, .flags = engine, + .rsvd1 = ctx->id, };const struct intel_execution_engine2 *e;igt_spin_t *spin =NULL ;uint64_t addr;int fence; -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) {if (e->flags == engine)continue ;if (!spin) { spin = igt_spin_new(i915, + .ctx = ctx, .engine = e->flags, .flags =IGT_SPIN_FENCE_OUT ); fence =dup (spin->out_fence);
@@ -985,12 +996,13 @@ static void sighandler(int sig) stop =1 ; } -static void parallel_child (int i915, +static void parallel_child (int i915,const intel_ctx_t *ctx,const struct intel_execution_engine2 *engine,struct drm_i915_gem_relocation_entry *reloc,uint32_t common) { - igt_spin_t *spin = __igt_spin_new(i915, .engine = engine->flags); + igt_spin_t *spin = __igt_spin_new(i915, .ctx = ctx, + .engine = engine->flags);struct drm_i915_gem_exec_object2 reloc_target = { .handle =gem_create (i915,32 *1024 *8 ), .relocation_count =32 *1024 ,
@@ -1005,6 +1017,7 @@ static void parallel_child(int i915, .buffers_ptr = to_user_pointer(obj), .buffer_count = ARRAY_SIZE(obj), .flags = engine->flags | I915_EXEC_HANDLE_LUT, + .rsvd1 = ctx->id, };struct sigaction act = { .sa_handler = sighandler,
@@ -1032,7 +1045,7 @@ static void kill_children(int sig)signal (sig,SIG_DFL ); } -static void parallel (int i915) +static void parallel (int i915,const intel_ctx_t *ctx) {const struct intel_execution_engine2 *e;struct drm_i915_gem_relocation_entry *reloc;
@@ -1043,16 +1056,16 @@ static void parallel(int i915) reloc =parallel_relocs (32 *1024 , &reloc_sz); stop =0 ; -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) { igt_fork(child, 1) -parallel_child (i915, e, reloc, common); +parallel_child (i915, ctx, e, reloc, common); }sleep (2 );if (gem_scheduler_has_preemption (i915)) { -uint32_t ctx =gem_context_clone_with_engines (i915,0 ); +const intel_ctx_t *tmp_ctx =intel_ctx_create (i915, &ctx->cfg); -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) {struct drm_i915_gem_exec_object2 obj[2 ] = { { .handle = common }, { .handle = batch },
@@ -1061,12 +1074,12 @@ static void parallel(int i915) .buffers_ptr = to_user_pointer(obj), .buffer_count = ARRAY_SIZE(obj), .flags = e->flags, - .rsvd1 = ctx, + .rsvd1 = tmp_ctx->id, };gem_execbuf (i915, &execbuf); } -gem_context_destroy (i915, ctx); +intel_ctx_destroy (i915, tmp_ctx); }gem_sync (i915, batch);gem_close (i915, batch);
@@ -1120,7 +1133,7 @@ static void xchg_u32(void *array, unsigned i, unsigned j) u32[j] = tmp; } -static void concurrent_child (int i915, +static void concurrent_child (int i915,const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,uint32_t *common,int num_common,int in,int out)
@@ -1133,6 +1146,7 @@ static void concurrent_child(int i915, .buffers_ptr = to_user_pointer(obj), .buffer_count = ARRAY_SIZE(obj), .flags = e->flags | I915_EXEC_HANDLE_LUT | (gen < 6 ? I915_EXEC_SECURE : 0), + .rsvd1 = ctx->id, };uint32_t *batch = &obj[num_common +1 ].handle;unsigned long count =0 ;
@@ -1213,7 +1227,7 @@ static uint32_t create_concurrent_batch(int i915, unsigned int count)return handle; } -static void concurrent (int i915,int num_common) +static void concurrent (int i915,const intel_ctx_t *ctx,int num_common) {const struct intel_execution_engine2 *e;int in[2 ], out[2 ];
@@ -1239,12 +1253,12 @@ static void concurrent(int i915, int num_common) common[n] =gem_create (i915,4 *4 *CONCURRENT ); nchild =0 ; -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) {if (!gem_class_can_store_dword (i915, e->class))continue ; igt_fork(child, 1) -concurrent_child (i915, e, +concurrent_child (i915, ctx, e, common, num_common, in[0 ], out[1 ]);
@@ -1308,6 +1322,7 @@ pin_scanout(igt_display_t *dpy, igt_output_t *output, struct igt_fb *fb)static void scanout (int i915,igt_display_t *dpy, +const intel_ctx_t *ctx,const struct intel_execution_engine2 *e) {struct drm_i915_gem_relocation_entry reloc = {};
@@ -1318,6 +1333,7 @@ static void scanout(int i915, .buffers_ptr = to_user_pointer(obj), .buffer_count = 2, .flags = e->flags, + .rsvd1 = ctx->id, };igt_output_t *output;struct igt_fb fb;
@@ -1437,6 +1453,7 @@ static void invalid_domains(int fd) igt_main { +const intel_ctx_t *ctx =0 ;const struct intel_execution_engine2 *e; const struct mode { const char *name;
@@ -1480,6 +1497,11 @@ igt_mainigt_require_gem (fd);/* Check if relocations supported by platform */ igt_require (gem_has_relocations (fd)); + +if (gem_has_contexts (fd)) + ctx =intel_ctx_create_all_physical (fd); +else + ctx =intel_ctx_0 (fd); }for (f = flags; f->name; f++) {
@@ -1541,52 +1563,52 @@ igt_main igt_subtest_with_dynamic("basic-active") { igt_dynamic("all") -active (fd,ALL_ENGINES ); +active (fd, ctx,ALL_ENGINES ); -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) {if (!gem_class_can_store_dword (fd, e->class))continue ; igt_dynamic_f("%s", e->name) -active (fd, e->flags); +active (fd, ctx, e->flags); } } igt_subtest_with_dynamic("basic-spin") { -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { igt_dynamic_f("%s", e->name) -active_spin (fd, e->flags); +active_spin (fd, ctx, e->flags); } } igt_subtest_with_dynamic("basic-spin-others") { -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { igt_dynamic_f("%s", e->name) -others_spin (fd, e->flags); +others_spin (fd, ctx, e->flags); } } igt_subtest_with_dynamic("basic-many-active") { -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { igt_dynamic_f("%s", e->name) -many_active (fd, e->flags); +many_active (fd, ctx, e->flags); } } igt_subtest_with_dynamic("basic-wide-active") { -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { igt_dynamic_f("%s", e->name) -wide_active (fd, e->flags); +wide_active (fd, ctx, e->flags); } } igt_subtest("basic-parallel") -parallel (fd); +parallel (fd, ctx); igt_subtest("basic-concurrent0") -concurrent (fd,0 ); +concurrent (fd, ctx,0 ); igt_subtest("basic-concurrent16") -concurrent (fd,16 ); +concurrent (fd, ctx,16 ); igt_subtest("invalid-domains")invalid_domains (fd);
@@ -1604,9 +1626,9 @@ igt_main } igt_subtest_with_dynamic("basic-scanout") { -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { igt_dynamic_f("%s", e->name) -scanout (fd, &display, e); +scanout (fd, &display, ctx, e); } }
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 24/89 tests/i915/gem_busy: Convert to intel_ctx_t
In reply to Jason Ekstrand--- tests/i915/gem_busy.c | 77 +++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 32 deletions(-)
tests/i915/gem_busy.c +45 -32
@@ -67,6 +67,7 @@ static void __gem_busy(int fd,static bool exec_noop (int fd,uint32_t *handles, +const intel_ctx_t *ctx,unsigned flags,bool write) {
@@ -84,6 +85,7 @@ static bool exec_noop(int fd, execbuf.buffers_ptr =to_user_pointer (exec); execbuf.buffer_count =3 ; execbuf.flags = flags; + execbuf.rsvd1 = ctx->id;igt_debug ("Queuing handle for %s on engine %d\n" , write ?"writing" :"reading" , flags);return __gem_execbuf (fd, &execbuf) ==0 ;
@@ -96,7 +98,8 @@ static bool still_busy(int fd, uint32_t handle)return write; } -static void semaphore (int fd,const struct intel_execution_engine2 *e) +static void semaphore (int fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e) {struct intel_execution_engine2 *__e;uint32_t bbe =MI_BATCH_BUFFER_END ;
@@ -113,18 +116,19 @@ static void semaphore(int fd, const struct intel_execution_engine2 *e)/* Create a long running batch which we can use to hog the GPU */ handle[BUSY ] =gem_create (fd,4096 ); spin = igt_spin_new(fd, + .ctx = ctx, .engine = e->flags, .dependency = handle[BUSY ]);/* Queue a batch after the busy, it should block and remain "busy" */ -igt_assert (exec_noop (fd, handle, e->flags, false)); +igt_assert (exec_noop (fd, handle, ctx, e->flags, false));igt_assert (still_busy (fd, handle[BUSY ]));__gem_busy (fd, handle[TEST ], &read, &write);igt_assert_eq (read,1 << e->class);igt_assert_eq (write,0 );/* Requeue with a write */ -igt_assert (exec_noop (fd, handle, e->flags, true)); +igt_assert (exec_noop (fd, handle, ctx, e->flags, true));igt_assert (still_busy (fd, handle[BUSY ]));__gem_busy (fd, handle[TEST ], &read, &write);igt_assert_eq (read,1 << e->class);
@@ -132,8 +136,8 @@ static void semaphore(int fd, const struct intel_execution_engine2 *e)/* Now queue it for a read across all available rings */ active =0 ; -__for_each_physical_engine (fd, __e) { -if (exec_noop (fd, handle, __e->flags, false)) +for_each_ctx_engine (fd, ctx, __e) { +if (exec_noop (fd, handle, ctx, __e->flags, false)) active |=1 << __e->class; }igt_assert (still_busy (fd, handle[BUSY ]));
@@ -157,7 +161,8 @@ static void semaphore(int fd, const struct intel_execution_engine2 *e)#define PARALLEL 1#define HANG 2 -static void one (int fd,const struct intel_execution_engine2 *e,unsigned test_flags) +static void one (int fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e,unsigned test_flags) {uint32_t scratch =gem_create (fd,4096 );uint32_t read[2 ], write[2 ];
@@ -167,6 +172,7 @@ static void one(int fd, const struct intel_execution_engine2 *e, unsigned test_fint timeout; spin = igt_spin_new(fd, + .ctx = ctx, .engine = e->flags, .dependency = scratch, .flags = (test_flags &HANG ) ?IGT_SPIN_NO_PREEMPTION :0 );
@@ -177,13 +183,13 @@ static void one(int fd, const struct intel_execution_engine2 *e, unsigned test_fif (test_flags &PARALLEL ) {struct intel_execution_engine2 *e2; -__for_each_physical_engine (fd, e2) { +for_each_ctx_engine (fd, ctx, e2) {if (e2->class == e->class && e2->instance == e->instance)continue ;igt_debug ("Testing %s in parallel\n" , e2->name); -one (fd, e2,0 ); +one (fd, ctx, e2,0 ); } }
@@ -228,7 +234,7 @@ static void xchg_u32(void *array, unsigned i, unsigned j) u32[j] = tmp; } -static void close_race (int fd) +static void close_race (int fd,const intel_ctx_t *ctx) {const unsigned int ncpus =sysconf (_SC_NPROCESSORS_ONLN);const unsigned int nhandles =gem_submission_measure (fd,ALL_ENGINES );
@@ -247,7 +253,7 @@ static void close_race(int fd)*/ nengine =0 ; -__for_each_physical_engine (fd, e) +for_each_ctx_engine (fd, ctx, e) engines[nengine++] = e->flags;igt_require (nengine);
@@ -295,6 +301,7 @@ static void close_race(int fd)for (i =0 ; i < nhandles; i++) { spin[i] = __igt_spin_new(fd, + .ctx = ctx, .engine = engines[rand () % nengine]); handles[i] = spin[i]->handle; }
@@ -303,6 +310,7 @@ static void close_race(int fd)for (i =0 ; i < nhandles; i++) {igt_spin_free (fd, spin[i]); spin[i] = __igt_spin_new(fd, + .ctx = ctx, .engine = engines[rand () % nengine]); handles[i] = spin[i]->handle;__sync_synchronize ();
@@ -354,10 +362,12 @@ static bool has_extended_busy_ioctl(int fd)return read !=0 ; } -static void basic (int fd,const struct intel_execution_engine2 *e,unsigned flags) +static void basic (int fd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e,unsigned flags) {igt_spin_t *spin = igt_spin_new(fd, + .ctx = ctx, .engine = e->flags, .flags = flags &HANG ?IGT_SPIN_NO_PREEMPTION |IGT_SPIN_INVALID_CS :0 );
@@ -384,32 +394,34 @@ static void basic(int fd, const struct intel_execution_engine2 *e, unsigned flagigt_spin_free (fd, spin); } -static void all (int i915) +static void all (int i915,const intel_ctx_t *ctx) {const struct intel_execution_engine2 *e; -__for_each_physical_engine (i915, e) - igt_fork(child, 1) basic(i915, e, 0); +for_each_ctx_engine (i915, ctx, e) + igt_fork(child, 1) basic(i915, ctx, e, 0);igt_waitchildren (); } -#define test_each_engine (T , i915, e) \ - igt_subtest_with_dynamic(T) __for_each_physical_engine(i915, e) \ +#define test_each_engine (T , i915, ctx, e) \ + igt_subtest_with_dynamic(T) for_each_ctx_engine(i915, ctx, e) \ igt_dynamic_f("%s", (e)->name) -#define test_each_engine_store (T , i915, e) \ - igt_subtest_with_dynamic(T) __for_each_physical_engine(i915, e) \ +#define test_each_engine_store (T , i915, ctx, e) \ + igt_subtest_with_dynamic(T) for_each_ctx_engine(i915, ctx, e) \ for_each_if (gem_class_can_store_dword(i915, (e)->class)) \ igt_dynamic_f("%s", (e)->name) igt_main {const struct intel_execution_engine2 *e; +const intel_ctx_t *ctx =NULL ;int fd =-1 ; igt_fixture { fd =drm_open_driver_master (DRIVER_INTEL );igt_require_gem (fd); + ctx =intel_ctx_create_all_physical (fd); } igt_subtest_group {
@@ -420,13 +432,13 @@ igt_main igt_subtest_with_dynamic("busy") { igt_dynamic("all") {gem_quiescent_gpu (fd); -all (fd); +all (fd, ctx); } -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) { igt_dynamic_f("%s", e->name) {gem_quiescent_gpu (fd); -basic (fd, e,0 ); +basic (fd, ctx, e,0 ); } } }
@@ -437,15 +449,15 @@ igt_maingem_require_mmap_wc (fd); } - test_each_engine_store("extended", fd, e) { + test_each_engine_store("extended", fd, ctx, e) {gem_quiescent_gpu (fd); -one (fd, e,0 ); +one (fd, ctx, e,0 );gem_quiescent_gpu (fd); } - test_each_engine_store("parallel", fd, e) { + test_each_engine_store("parallel", fd, ctx, e) {gem_quiescent_gpu (fd); -one (fd, e,PARALLEL ); +one (fd, ctx, e,PARALLEL );gem_quiescent_gpu (fd); } }
@@ -456,15 +468,15 @@ igt_mainigt_require (has_semaphores (fd)); } - test_each_engine("semaphore", fd, e) { + test_each_engine("semaphore", fd, ctx, e) {gem_quiescent_gpu (fd); -semaphore (fd, e); +semaphore (fd, ctx, e);gem_quiescent_gpu (fd); } } igt_subtest("close-race") -close_race (fd); +close_race (fd, ctx); igt_fixture {igt_stop_hang_detector ();
@@ -478,9 +490,9 @@ igt_main hang =igt_allow_hang (fd,0 ,0 ); } - test_each_engine("hang", fd, e) { + test_each_engine("hang", fd, ctx, e) {gem_quiescent_gpu (fd); -basic (fd, e,HANG ); +basic (fd, ctx, e,HANG );gem_quiescent_gpu (fd); }
@@ -490,9 +502,9 @@ igt_maingem_require_mmap_wc (fd); } - test_each_engine_store("hang-extended", fd, e) { + test_each_engine_store("hang-extended", fd, ctx, e) {gem_quiescent_gpu (fd); -one (fd, e,HANG ); +one (fd, ctx, e,HANG );gem_quiescent_gpu (fd); } }
@@ -503,6 +515,7 @@ igt_main } igt_fixture { +intel_ctx_destroy (fd, ctx);close (fd); } }
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 25/89 tests/i915/gem_ctx_isolation: Convert to intel_ctx_t
In reply to Jason Ekstrand--- tests/i915/gem_ctx_isolation.c | 126 +++++++++++++++++---------------- 1 file changed, 66 insertions(+), 60 deletions(-)
tests/i915/gem_ctx_isolation.c +66 -60
@@ -232,7 +232,7 @@ static bool ignore_register(uint32_t offset, uint32_t mmio_base) }static void tmpl_regs (int fd, -uint32_t ctx, +const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,uint32_t handle,uint32_t value)
@@ -277,7 +277,7 @@ static void tmpl_regs(int fd, }static uint32_t read_regs (int fd, -uint32_t ctx, +const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,unsigned int flags) {
@@ -349,7 +349,7 @@ static uint32_t read_regs(int fd, execbuf.buffers_ptr =to_user_pointer (obj); execbuf.buffer_count =2 ; execbuf.flags = e->flags; - execbuf.rsvd1 = ctx; + execbuf.rsvd1 = ctx->id;gem_execbuf (fd, &execbuf);gem_close (fd, obj[1 ].handle);free (reloc);
@@ -358,7 +358,7 @@ static uint32_t read_regs(int fd, }static void write_regs (int fd, -uint32_t ctx, +const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,unsigned int flags,uint32_t value)
@@ -413,13 +413,13 @@ static void write_regs(int fd, execbuf.buffers_ptr =to_user_pointer (&obj); execbuf.buffer_count =1 ; execbuf.flags = e->flags; - execbuf.rsvd1 = ctx; + execbuf.rsvd1 = ctx->id;gem_execbuf (fd, &execbuf);gem_close (fd, obj.handle); }static void restore_regs (int fd, -uint32_t ctx, +const intel_ctx_t *ctx,const struct intel_execution_engine2 *e,unsigned int flags,uint32_t regs)
@@ -491,7 +491,7 @@ static void restore_regs(int fd, execbuf.buffers_ptr =to_user_pointer (obj); execbuf.buffer_count =2 ; execbuf.flags = e->flags; - execbuf.rsvd1 = ctx; + execbuf.rsvd1 = ctx->id;gem_execbuf (fd, &execbuf);gem_close (fd, obj[1 ].handle); }
@@ -595,7 +595,7 @@ static void compare_regs(int fd, const struct intel_execution_engine2 *e, num_errors, who); } -static void nonpriv (int fd, +static void nonpriv (int fd,const intel_ctx_cfg_t *cfg,const struct intel_execution_engine2 *e,unsigned int flags) {
@@ -620,33 +620,34 @@ static void nonpriv(int fd, for (int v = 0; v < num_values; v++) { igt_spin_t *spin = NULL; - uint32_t ctx, regs[2], tmpl; + const intel_ctx_t *ctx; + uint32_t regs[2], tmpl; - ctx = gem_context_clone_with_engines(fd, 0); + ctx = intel_ctx_create(fd, cfg); tmpl = read_regs(fd, ctx, e, flags); regs[0] = read_regs(fd, ctx, e, flags); tmpl_regs(fd, ctx, e, tmpl, values[v]); - spin = igt_spin_new(fd, .ctx_id = ctx, .engine = e->flags); + spin = igt_spin_new(fd, .ctx = ctx, .engine = e->flags); igt_debug("%s[%d]: Setting all registers to 0x%08x\n", __func__, v, values[v]); write_regs(fd, ctx, e, flags, values[v]); if (flags & DIRTY2) { - uint32_t sw = gem_context_clone_with_engines(fd, 0); + const intel_ctx_t *sw = intel_ctx_create(fd, &ctx->cfg); igt_spin_t *syncpt, *dirt; /* Explicit sync to keep the switch between write/read */ syncpt = igt_spin_new(fd, - .ctx_id = ctx, + .ctx = ctx, .engine = e->flags, .flags = IGT_SPIN_FENCE_OUT); dirt = igt_spin_new(fd, - .ctx_id = sw, + .ctx = sw, .engine = e->flags, .fence = syncpt->out_fence, .flags = (IGT_SPIN_FENCE_IN |
@@ -654,14 +655,14 @@ static void nonpriv(int fd,igt_spin_free (fd, syncpt); syncpt = igt_spin_new(fd, - .ctx_id = ctx, + .ctx = ctx, .engine = e->flags, .fence = dirt->out_fence, .flags =IGT_SPIN_FENCE_IN );igt_spin_free (fd, dirt);igt_spin_free (fd, syncpt); -gem_context_destroy (fd, sw); +intel_ctx_destroy (fd, sw); } regs[1 ] =read_regs (fd, ctx, e, flags);
@@ -678,12 +679,12 @@ static void nonpriv(int fd,for (int n =0 ; n <ARRAY_SIZE (regs); n++)gem_close (fd, regs[n]); -gem_context_destroy (fd, ctx); +intel_ctx_destroy (fd, ctx);gem_close (fd, tmpl); } } -static void isolation (int fd, +static void isolation (int fd,const intel_ctx_cfg_t *cfg,const struct intel_execution_engine2 *e,unsigned int flags) {
@@ -703,12 +704,13 @@ static void isolation(int fd,for (int v =0 ; v < num_values; v++) {igt_spin_t *spin =NULL ; -uint32_t ctx[2 ], regs[2 ], tmp; +const intel_ctx_t *ctx[2 ]; +uint32_t regs[2 ], tmp; - ctx[0 ] =gem_context_clone_with_engines (fd,0 ); + ctx[0 ] =intel_ctx_create (fd, cfg); regs[0 ] =read_regs (fd, ctx[0 ], e, flags); - spin = igt_spin_new(fd, .ctx_id = ctx[0], .engine = e->flags); + spin = igt_spin_new(fd, .ctx = ctx[0], .engine = e->flags);if (flags &DIRTY1 ) { igt_debug("%s[%d]: Setting all registers of ctx 0 to 0x%08x\n",
@@ -724,7 +726,7 @@ static void isolation(int fd,* the default values from this context, but if goes badly we * see the corruption from the previous context instead! */ - ctx[1 ] =gem_context_clone_with_engines (fd,0 ); + ctx[1 ] =intel_ctx_create (fd, cfg); regs[1 ] =read_regs (fd, ctx[1 ], e, flags);if (flags &DIRTY2 ) {
@@ -749,7 +751,7 @@ static void isolation(int fd,for (int n =0 ; n <ARRAY_SIZE (ctx); n++) {gem_close (fd, regs[n]); -gem_context_destroy (fd, ctx[n]); +intel_ctx_destroy (fd, ctx[n]); }gem_close (fd, tmp); }
@@ -762,21 +764,25 @@ static void isolation(int fd,#define S4 (4 << 8)#define SLEEP_MASK (0xf << 8) -static uint32_t create_reset_context (int i915) +static const intel_ctx_t * +create_reset_context (int i915,const intel_ctx_cfg_t *cfg) { +const intel_ctx_t *ctx =intel_ctx_create (i915, cfg);struct drm_i915_gem_context_param param = { - .ctx_id =gem_context_clone_with_engines (i915,0 ), + .ctx_id = ctx->id, .param =I915_CONTEXT_PARAM_BANNABLE , };gem_context_set_param (i915, ¶m); -return param.ctx_id; +return ctx; } -static void inject_reset_context (int fd,const struct intel_execution_engine2 *e) +static void inject_reset_context (int fd,const intel_ctx_cfg_t *cfg, +const struct intel_execution_engine2 *e) { +const intel_ctx_t *ctx =create_reset_context (fd, cfg);struct igt_spin_factory opts = { - .ctx_id =create_reset_context (fd), + .ctx = ctx, .engine = e->flags, .flags =IGT_SPIN_FAST , };
@@ -801,10 +807,10 @@ static void inject_reset_context(int fd, const struct intel_execution_engine2 *eigt_force_gpu_reset (fd);igt_spin_free (fd, spin); -gem_context_destroy (fd, opts.ctx_id); +intel_ctx_destroy (fd, ctx); } -static void preservation (int fd, +static void preservation (int fd,const intel_ctx_cfg_t *cfg,const struct intel_execution_engine2 *e,unsigned int flags) {
@@ -818,17 +824,17 @@ static void preservation(int fd,0xdeadbeef };const unsigned int num_values =ARRAY_SIZE (values); -uint32_t ctx[num_values +1 ]; +const intel_ctx_t *ctx[num_values +1 ];uint32_t regs[num_values +1 ][2 ];igt_spin_t *spin;gem_quiescent_gpu (fd); - ctx[num_values] =gem_context_clone_with_engines (fd,0 ); - spin = igt_spin_new(fd, .ctx_id = ctx[num_values], .engine = e->flags); + ctx[num_values] =intel_ctx_create (fd, cfg); + spin = igt_spin_new(fd, .ctx = ctx[num_values], .engine = e->flags); regs[num_values][0 ] =read_regs (fd, ctx[num_values], e, flags);for (int v =0 ; v < num_values; v++) { - ctx[v] =gem_context_clone_with_engines (fd,0 ); + ctx[v] =intel_ctx_create (fd, cfg);write_regs (fd, ctx[v], e, flags, values[v]); regs[v][0 ] =read_regs (fd, ctx[v], e, flags);
@@ -838,7 +844,7 @@ static void preservation(int fd,igt_spin_free (fd, spin);if (flags &RESET ) -inject_reset_context (fd, e); +inject_reset_context (fd, cfg, e);switch (flags &SLEEP_MASK ) {case NOSLEEP :
@@ -865,7 +871,7 @@ static void preservation(int fd,break ; } - spin = igt_spin_new(fd, .ctx_id = ctx[num_values], .engine = e->flags); + spin = igt_spin_new(fd, .ctx = ctx[num_values], .engine = e->flags);for (int v =0 ; v < num_values; v++) regs[v][1 ] =read_regs (fd, ctx[v], e, flags); regs[num_values][1 ] =read_regs (fd, ctx[num_values], e, flags);
@@ -879,10 +885,10 @@ static void preservation(int fd,gem_close (fd, regs[v][0 ]);gem_close (fd, regs[v][1 ]); -gem_context_destroy (fd, ctx[v]); +intel_ctx_destroy (fd, ctx[v]); }compare_regs (fd, e, regs[num_values][0 ], regs[num_values][1 ],"clean" ); -gem_context_destroy (fd, ctx[num_values]); +intel_ctx_destroy (fd, ctx[num_values]); }static unsigned int __has_context_isolation (int fd)
@@ -900,8 +906,8 @@ static unsigned int __has_context_isolation(int fd)return value; } -#define test_each_engine (e, i915, mask) \ - __for_each_physical_engine(i915, e) \ +#define test_each_engine (e, i915, cfg, mask) \ + for_each_ctx_cfg_engine(i915, cfg, e) \ for_each_if(mask & (1 << (e)->class)) \ igt_dynamic_f("%s", (e)->name)
@@ -909,6 +915,7 @@ igt_main {unsigned int has_context_isolation =0 ;const struct intel_execution_engine2 *e; +intel_ctx_cfg_t cfg;int i915 =-1 ; igt_fixture {
@@ -917,6 +924,7 @@ igt_main i915 =drm_open_driver (DRIVER_INTEL );igt_require_gem (i915);igt_require (gem_has_contexts (i915)); + cfg =intel_ctx_cfg_all_physical (i915); has_context_isolation =__has_context_isolation (i915);igt_require (has_context_isolation);
@@ -928,50 +936,48 @@ igt_mainigt_skip_on (gen >LAST_KNOWN_GEN ); } -/* __for_each_physical_engine switches context to all engines. */ - igt_fixture {igt_fork_hang_detector (i915 ); } igt_subtest_with_dynamic("nonpriv") { - test_each_engine(e, i915, has_context_isolation) -nonpriv (i915, e,0 ); + test_each_engine(e, i915, &cfg, has_context_isolation) +nonpriv (i915, &cfg, e,0 ); } igt_subtest_with_dynamic("nonpriv-switch") { - test_each_engine(e, i915, has_context_isolation) -nonpriv (i915, e,DIRTY2 ); + test_each_engine(e, i915, &cfg, has_context_isolation) +nonpriv (i915, &cfg, e,DIRTY2 ); } igt_subtest_with_dynamic("clean") { - test_each_engine(e, i915, has_context_isolation) -isolation (i915, e,0 ); + test_each_engine(e, i915, &cfg, has_context_isolation) +isolation (i915, &cfg, e,0 ); } igt_subtest_with_dynamic("dirty-create") { - test_each_engine(e, i915, has_context_isolation) -isolation (i915, e,DIRTY1 ); + test_each_engine(e, i915, &cfg, has_context_isolation) +isolation (i915, &cfg, e,DIRTY1 ); } igt_subtest_with_dynamic("dirty-switch") { - test_each_engine(e, i915, has_context_isolation) -isolation (i915, e,DIRTY2 ); + test_each_engine(e, i915, &cfg, has_context_isolation) +isolation (i915, &cfg, e,DIRTY2 ); } igt_subtest_with_dynamic("preservation") { - test_each_engine(e, i915, has_context_isolation) -preservation (i915, e,0 ); + test_each_engine(e, i915, &cfg, has_context_isolation) +preservation (i915, &cfg, e,0 ); } igt_subtest_with_dynamic("preservation-S3") { - test_each_engine(e, i915, has_context_isolation) -preservation (i915, e,S3 ); + test_each_engine(e, i915, &cfg, has_context_isolation) +preservation (i915, &cfg, e,S3 ); } igt_subtest_with_dynamic("preservation-S4") { - test_each_engine(e, i915, has_context_isolation) -preservation (i915, e,S4 ); + test_each_engine(e, i915, &cfg, has_context_isolation) +preservation (i915, &cfg, e,S4 ); } igt_fixture {
@@ -981,8 +987,8 @@ igt_main igt_subtest_with_dynamic("preservation-reset") {igt_hang_t hang =igt_allow_hang (i915,0 ,0 ); - test_each_engine(e, i915, has_context_isolation) -preservation (i915, e,RESET ); + test_each_engine(e, i915, &cfg, has_context_isolation) +preservation (i915, &cfg, e,RESET );igt_disallow_hang (i915, hang); }
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 26/89 tests/i915/gem_exec_async: Convert to intel_ctx_t
In reply to Jason Ekstrand--- tests/i915/gem_exec_async.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-)
tests/i915/gem_exec_async.c +20 -12
@@ -26,7 +26,7 @@IGT_TEST_DESCRIPTION ("Check that we can issue concurrent writes across the engines." ); -static void store_dword (int fd,unsigned ring, +static void store_dword (int fd,const intel_ctx_t *ctx,unsigned ring,uint32_t target,uint32_t offset,uint32_t value) {const unsigned int gen =intel_gen (intel_get_drm_devid (fd));
@@ -42,6 +42,7 @@ static void store_dword(int fd, unsigned ring, execbuf.flags = ring;if (gen <6 ) execbuf.flags |=I915_EXEC_SECURE ; + execbuf.rsvd1 = ctx->id;memset (obj,0 ,sizeof (obj)); obj[0 ].handle = target;
@@ -79,7 +80,8 @@ static void store_dword(int fd, unsigned ring,gem_close (fd, obj[1 ].handle); } -static void one (int fd,unsigned engine,unsigned int flags) +static void one (int fd,const intel_ctx_t *ctx, +unsigned engine,unsigned int flags) #define FORKED (1 << 0) {const struct intel_execution_engine2 *e;
@@ -93,10 +95,11 @@ static void one(int fd, unsigned engine, unsigned int flags)* the scratch for write. Then on the other rings try and * write into that target. If it blocks we hang the GPU... */ - spin = igt_spin_new(fd, .engine = engine, .dependency = scratch); + spin = igt_spin_new(fd, .ctx = ctx, .engine = engine, + .dependency = scratch); i =0 ; -__for_each_physical_engine (fd, e) { +for_each_ctx_engine (fd, ctx, e) {if (e->flags == engine)continue ;
@@ -105,9 +108,9 @@ static void one(int fd, unsigned engine, unsigned int flags)if (flags &FORKED ) { igt_fork(child, 1) -store_dword (fd, e->flags, scratch,4 *i, ~i); +store_dword (fd, ctx, e->flags, scratch,4 *i, ~i); }else { -store_dword (fd, e->flags, scratch,4 *i, ~i); +store_dword (fd, ctx, e->flags, scratch,4 *i, ~i); } i++; }
@@ -134,13 +137,14 @@ static bool has_async_execbuf(int fd)return async >0 ; } -#define test_each_engine (T , i915, e) \ - igt_subtest_with_dynamic(T) __for_each_physical_engine(i915, e) \ +#define test_each_engine (T , i915, ctx, e) \ + igt_subtest_with_dynamic(T) for_each_ctx_engine(i915, ctx, e) \ igt_dynamic_f("%s", (e)->name) igt_main {const struct intel_execution_engine2 *e; +const intel_ctx_t *ctx =NULL ;int fd =-1 ; igt_fixture {
@@ -148,17 +152,21 @@ igt_mainigt_require_gem (fd);gem_require_mmap_wc (fd);igt_require (has_async_execbuf (fd)); + + ctx =intel_ctx_create_all_physical (fd); +igt_fork_hang_detector (fd); } - test_each_engine("concurrent-writes", fd, e) -one (fd, e->flags,0 ); + test_each_engine("concurrent-writes", fd, ctx, e) +one (fd, ctx, e->flags,0 ); - test_each_engine("forked-writes", fd, e) -one (fd, e->flags,FORKED ); + test_each_engine("forked-writes", fd, ctx, e) +one (fd, ctx, e->flags,FORKED ); igt_fixture {igt_stop_hang_detector (); +intel_ctx_destroy (fd, ctx);close (fd); } }
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 27/89 tests/i915/sysfs_clients: Convert to intel_ctx_t
In reply to Jason Ekstrand--- tests/i915/sysfs_clients.c | 87 ++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 41 deletions(-)
tests/i915/sysfs_clients.c +46 -41
@@ -18,12 +18,12 @@#include "drmtest.h" #include "i915/gem.h" -#include "i915/gem_context.h" #include "i915/gem_engine_topology.h" #include "i915/gem_mman.h" #include "igt_aux.h" #include "igt_dummyload.h" #include "igt_sysfs.h" +#include "intel_ctx.h" #include "ioctl_wrappers.h" #define __require_within_epsilon (x, ref, tol_up, tol_down) \
@@ -392,34 +392,26 @@ static uint64_t measured_usleep(unsigned int usec)return igt_nsec_elapsed (&tv); } -static int reopen_client (int i915) -{ -int clone; - - clone =gem_reopen_driver (i915); -gem_context_copy_engines (i915,0 , clone,0 ); -close (i915); - -return clone; -} -static void -busy_one (int i915,int clients,const struct intel_execution_engine2 *e) +busy_one (int i915,int clients,const intel_ctx_cfg_t *cfg, +const struct intel_execution_engine2 *e) {int64_t active, idle, old, other[MAX_CLASS ];struct timespec tv; +const intel_ctx_t *ctx;igt_spin_t *spin;uint64_t delay;int me;/* Create a fresh client with 0 runtime */ - i915 =reopen_client (i915); + i915 =gem_reopen_driver (i915); me =find_me (clients,getpid ());igt_assert (me !=-1 ); + ctx =intel_ctx_create (i915, cfg); spin = igt_spin_new(i915, -gem_context_clone_with_engines (i915,0 ), + .ctx = ctx, .engine = e->flags, .flags =IGT_SPIN_POLL_RUN );igt_spin_busywait_until_started (spin);
@@ -471,7 +463,7 @@ busy_one(int i915, int clients, const struct intel_execution_engine2 *e)igt_assert (idle >= active); } -gem_context_destroy (i915, spin->execbuf.rsvd1); +intel_ctx_destroy (i915, ctx);/* And finally after the executing context is no more */ old =read_runtime (me, e->class);
@@ -512,28 +504,29 @@ busy_one(int i915, int clients, const struct intel_execution_engine2 *e)close (i915); } -static void busy_all (int i915,int clients) +static void busy_all (int i915,int clients,const intel_ctx_cfg_t *cfg) {const struct intel_execution_engine2 *e;int64_t active[MAX_CLASS ];int64_t idle[MAX_CLASS ];int64_t old[MAX_CLASS ];uint64_t classes =0 ; +const intel_ctx_t *ctx;igt_spin_t *spin;int expect =0 ;int64_t delay;int me;/* Create a fresh client with 0 runtime */ - i915 =reopen_client (i915); + i915 =gem_reopen_driver (i915); me =find_me (clients,getpid ());igt_assert (me !=-1 ); - spin =igt_spin_new (i915, -gem_context_clone_with_engines (i915,0 ), + ctx =intel_ctx_create (i915, cfg); + spin = igt_spin_new(i915, .ctx = ctx, .flags =IGT_SPIN_POLL_RUN ); -__for_each_physical_engine (i915, e) { +for_each_ctx_engine (i915, ctx, e) {if (!gem_class_can_store_dword (i915, e->class))continue ;
@@ -579,7 +572,7 @@ static void busy_all(int i915, int clients)igt_assert (idle[i] >= active[i]); } -gem_context_destroy (i915, spin->execbuf.rsvd1); +intel_ctx_destroy (i915, ctx);igt_spin_free (i915, spin);/* And finally after the executing context is no more */
@@ -596,17 +589,19 @@ static void busy_all(int i915, int clients) }static void -split_child (int i915,int clients, +split_child (int i915,int clients,const intel_ctx_cfg_t *cfg,const struct intel_execution_engine2 *e,int sv) {int64_t runtime[2 ] = {}; +const intel_ctx_t *ctx;igt_spin_t *spin;int go =1 ; - i915 =reopen_client (i915); + i915 =gem_reopen_driver (i915); - spin = igt_spin_new(i915, .engine = e->flags); + ctx =intel_ctx_create (i915, cfg); + spin = igt_spin_new(i915, .ctx = ctx, .engine = e->flags);igt_spin_end (spin);gem_sync (i915, spin->handle);
@@ -626,12 +621,14 @@ split_child(int i915, int clients,igt_spin_free (i915, spin); runtime[0 ] =read_runtime (find_me (clients,getpid ()), e->class); +intel_ctx_destroy (i915, ctx);write (sv, runtime,sizeof (runtime)); }static void -__split (int i915,int clients,const struct intel_execution_engine2 *e,int f, -void (*fn)(int i915,int clients, +__split (int i915,int clients,const intel_ctx_cfg_t *cfg, +const struct intel_execution_engine2 *e,int f, +void (*fn)(int i915,int clients,const intel_ctx_cfg_t *cfg,const struct intel_execution_engine2 *e,int sv)) {
@@ -652,7 +649,7 @@ __split(int i915, int clients, const struct intel_execution_engine2 *e, int f,igt_assert (socketpair (AF_UNIX ,SOCK_DGRAM ,0 , c->sv) ==0 ); igt_fork(child, 1) -fn (i915, clients, e, c->sv[1 ]); +fn (i915, clients, cfg, e, c->sv[1 ]);read (c->sv[0 ], &go,sizeof (go)); }
@@ -720,13 +717,14 @@ __split(int i915, int clients, const struct intel_execution_engine2 *e, int f, }static void -split (int i915,int clients,const struct intel_execution_engine2 *e,int f) +split (int i915,int clients,const intel_ctx_cfg_t *cfg, +const struct intel_execution_engine2 *e,int f) { -__split (i915, clients, e, f, split_child); +__split (i915, clients, cfg, e, f, split_child); }static void -sema_child (int i915,int clients, +sema_child (int i915,int clients,const intel_ctx_cfg_t *cfg,const struct intel_execution_engine2 *e,int sv) {
@@ -739,9 +737,12 @@ sema_child(int i915, int clients, .buffer_count = 1, .flags = e->flags, }; +const intel_ctx_t *ctx;uint32_t *cs, *sema; - i915 =reopen_client (i915); + i915 =gem_reopen_driver (i915); + ctx =intel_ctx_create (i915, cfg); + execbuf.rsvd1 = ctx->id; obj.handle =gem_create (i915,4096 ); obj.offset = obj.handle <<12 ;
@@ -771,6 +772,7 @@ sema_child(int i915, int clients, *sema =0 ;gem_execbuf (i915, &execbuf);gem_close (i915, obj.handle); +intel_ctx_destroy (i915, ctx);write (sv, sema,sizeof (*sema));read (sv, sema,sizeof (*sema));
@@ -794,9 +796,10 @@ sema_child(int i915, int clients, }static void -sema (int i915,int clients,const struct intel_execution_engine2 *e,int f) +sema (int i915,int clients,const intel_ctx_cfg_t *cfg, +const struct intel_execution_engine2 *e,int f) { -__split (i915, clients, e, f, sema_child); +__split (i915, clients, cfg, e, f, sema_child); }static int read_all (int clients,pid_t pid,int class,uint64_t *runtime)
@@ -944,21 +947,23 @@ static bool has_busy(int clients)static void test_busy (int i915,int clients) {const struct intel_execution_engine2 *e; +intel_ctx_cfg_t cfg;const int frac[] = {10 ,25 ,50 }; igt_fixture {igt_require (gem_has_contexts (i915 ));igt_require (has_busy (clients)); + cfg =intel_ctx_cfg_all_physical (i915); } igt_subtest_with_dynamic("busy") { -__for_each_physical_engine (i915, e) { +for_each_ctx_cfg_engine (i915, &cfg, e) {if (!gem_class_can_store_dword (i915, e->class))continue ; igt_dynamic_f("%s", e->name) {gem_quiescent_gpu (i915); igt_fork(child, 1) -busy_one (i915, clients, e); +busy_one (i915, clients, &cfg, e);igt_waitchildren ();gem_quiescent_gpu (i915); }
@@ -967,7 +972,7 @@ static void test_busy(int i915, int clients) igt_dynamic("all") {gem_quiescent_gpu (i915); igt_fork(child, 1) -busy_all (i915, clients); +busy_all (i915, clients, &cfg);igt_waitchildren ();gem_quiescent_gpu (i915); }
@@ -975,10 +980,10 @@ static void test_busy(int i915, int clients)for (int i =0 ; i <ARRAY_SIZE (frac); i++) { igt_subtest_with_dynamic_f("split-%d", frac[i]) { -__for_each_physical_engine (i915, e) { +for_each_ctx_cfg_engine (i915, &cfg, e) { igt_dynamic_f("%s", e->name) {gem_quiescent_gpu (i915); -split (i915, clients, e, frac[i]); +split (i915, clients, &cfg, e, frac[i]);gem_quiescent_gpu (i915); } }
@@ -993,13 +998,13 @@ static void test_busy(int i915, int clients)for (int i =0 ; i <ARRAY_SIZE (frac); i++) { igt_subtest_with_dynamic_f("sema-%d", frac[i]) { -__for_each_physical_engine (i915, e) { +for_each_ctx_cfg_engine (i915, &cfg, e) {if (!gem_class_has_mutable_submission (i915, e->class))continue ; igt_dynamic_f("%s", e->name) {igt_drop_caches_set (i915,DROP_RESET_ACTIVE ); -sema (i915, clients, e, frac[i]); +sema (i915, clients, &cfg, e, frac[i]);gem_quiescent_gpu (i915); }igt_drop_caches_set (i915,DROP_RESET_ACTIVE );
Signature · 6 lines
2.31.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev