From: Chris Wilson <chris@chris-wilson.co.uk> To: intel-gfx@lists.freedesktop.org Cc: igt-dev@lists.freedesktop.org Subject: [Intel-gfx] [PATCH i-g-t 1/5] lib/i915: Create a context wrapping one specific engine Date: Wed, 11 Mar 2020 09:34:44 +0000 [thread overview] Message-ID: <20200311093448.4103262-1-chris@chris-wilson.co.uk> (raw) Quite frequently we want to execute on one precise engine, so add a convenience routine to create a context that contains only that engine in the default [0] slot. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> --- lib/i915/gem_context.c | 64 +++++++++++++++++++++++++++++++----------- lib/i915/gem_context.h | 2 ++ 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c index 50dfee3d1..169e43d2e 100644 --- a/lib/i915/gem_context.c +++ b/lib/i915/gem_context.c @@ -43,6 +43,21 @@ * software features improving submission model (context priority). */ +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; +} + /** * gem_has_contexts: * @fd: open i915 drm file descriptor @@ -324,17 +339,14 @@ __gem_context_clone(int i915, .flags = flags | I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS, .extensions = to_user_pointer(&clone), }; - int err = 0; + int err; - if (igt_ioctl(i915, DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT, &arg)) { - err = -errno; - igt_assume(err); - } + err = create_ext_ioctl(i915, &arg); + if (err) + return err; *out = arg.ctx_id; - - errno = 0; - return err; + return 0; } static bool __gem_context_has(int i915, uint32_t share, unsigned int flags) @@ -382,16 +394,8 @@ bool gem_has_context_clone(int i915) .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS, .extensions = to_user_pointer(&ext), }; - int err; - - err = 0; - if (igt_ioctl(i915, DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT, &create)) { - err = -errno; - igt_assume(err); - } - errno = 0; - return err == -ENOENT; + return create_ext_ioctl(i915, &create) == -ENOENT; } /** @@ -492,3 +496,29 @@ gem_context_copy_engines(int src_fd, uint32_t src, int dst_fd, uint32_t dst) param.ctx_id = dst; gem_context_set_param(dst_fd, ¶m); } + +uint32_t gem_context_create_for_engine(int i915, unsigned int class, unsigned int inst) +{ + I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, 1) = { + .engines = { { .engine_class = class, .engine_instance = inst } } + }; + struct drm_i915_gem_context_create_ext_setparam p_engines = { + .base = { + .name = I915_CONTEXT_CREATE_EXT_SETPARAM, + .next_extension = 0, /* end of chain */ + }, + .param = { + .param = I915_CONTEXT_PARAM_ENGINES, + .value = to_user_pointer(&engines), + .size = sizeof(engines), + }, + }; + struct drm_i915_gem_context_create_ext create = { + .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS, + .extensions = to_user_pointer(&p_engines), + }; + + igt_assert_eq(create_ext_ioctl(i915, &create), 0); + igt_assert_neq(create.ctx_id, 0); + return create.ctx_id; +} diff --git a/lib/i915/gem_context.h b/lib/i915/gem_context.h index 15e5db281..b478c47a1 100644 --- a/lib/i915/gem_context.h +++ b/lib/i915/gem_context.h @@ -34,6 +34,8 @@ int __gem_context_create(int fd, uint32_t *ctx_id); void gem_context_destroy(int fd, uint32_t ctx_id); int __gem_context_destroy(int fd, uint32_t ctx_id); +uint32_t gem_context_create_for_engine(int fd, unsigned int class, unsigned int inst); + int __gem_context_clone(int i915, uint32_t src, unsigned int share, unsigned int flags, -- 2.25.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
WARNING: multiple messages have this Message-ID (diff)
From: Chris Wilson <chris@chris-wilson.co.uk> To: intel-gfx@lists.freedesktop.org Cc: igt-dev@lists.freedesktop.org Subject: [igt-dev] [PATCH i-g-t 1/5] lib/i915: Create a context wrapping one specific engine Date: Wed, 11 Mar 2020 09:34:44 +0000 [thread overview] Message-ID: <20200311093448.4103262-1-chris@chris-wilson.co.uk> (raw) Quite frequently we want to execute on one precise engine, so add a convenience routine to create a context that contains only that engine in the default [0] slot. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> --- lib/i915/gem_context.c | 64 +++++++++++++++++++++++++++++++----------- lib/i915/gem_context.h | 2 ++ 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c index 50dfee3d1..169e43d2e 100644 --- a/lib/i915/gem_context.c +++ b/lib/i915/gem_context.c @@ -43,6 +43,21 @@ * software features improving submission model (context priority). */ +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; +} + /** * gem_has_contexts: * @fd: open i915 drm file descriptor @@ -324,17 +339,14 @@ __gem_context_clone(int i915, .flags = flags | I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS, .extensions = to_user_pointer(&clone), }; - int err = 0; + int err; - if (igt_ioctl(i915, DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT, &arg)) { - err = -errno; - igt_assume(err); - } + err = create_ext_ioctl(i915, &arg); + if (err) + return err; *out = arg.ctx_id; - - errno = 0; - return err; + return 0; } static bool __gem_context_has(int i915, uint32_t share, unsigned int flags) @@ -382,16 +394,8 @@ bool gem_has_context_clone(int i915) .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS, .extensions = to_user_pointer(&ext), }; - int err; - - err = 0; - if (igt_ioctl(i915, DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT, &create)) { - err = -errno; - igt_assume(err); - } - errno = 0; - return err == -ENOENT; + return create_ext_ioctl(i915, &create) == -ENOENT; } /** @@ -492,3 +496,29 @@ gem_context_copy_engines(int src_fd, uint32_t src, int dst_fd, uint32_t dst) param.ctx_id = dst; gem_context_set_param(dst_fd, ¶m); } + +uint32_t gem_context_create_for_engine(int i915, unsigned int class, unsigned int inst) +{ + I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, 1) = { + .engines = { { .engine_class = class, .engine_instance = inst } } + }; + struct drm_i915_gem_context_create_ext_setparam p_engines = { + .base = { + .name = I915_CONTEXT_CREATE_EXT_SETPARAM, + .next_extension = 0, /* end of chain */ + }, + .param = { + .param = I915_CONTEXT_PARAM_ENGINES, + .value = to_user_pointer(&engines), + .size = sizeof(engines), + }, + }; + struct drm_i915_gem_context_create_ext create = { + .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS, + .extensions = to_user_pointer(&p_engines), + }; + + igt_assert_eq(create_ext_ioctl(i915, &create), 0); + igt_assert_neq(create.ctx_id, 0); + return create.ctx_id; +} diff --git a/lib/i915/gem_context.h b/lib/i915/gem_context.h index 15e5db281..b478c47a1 100644 --- a/lib/i915/gem_context.h +++ b/lib/i915/gem_context.h @@ -34,6 +34,8 @@ int __gem_context_create(int fd, uint32_t *ctx_id); void gem_context_destroy(int fd, uint32_t ctx_id); int __gem_context_destroy(int fd, uint32_t ctx_id); +uint32_t gem_context_create_for_engine(int fd, unsigned int class, unsigned int inst); + int __gem_context_clone(int i915, uint32_t src, unsigned int share, unsigned int flags, -- 2.25.1 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev
next reply other threads:[~2020-03-11 9:35 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-11 9:34 Chris Wilson [this message] 2020-03-11 9:34 ` [igt-dev] [PATCH i-g-t 1/5] lib/i915: Create a context wrapping one specific engine Chris Wilson 2020-03-11 9:34 ` [Intel-gfx] [PATCH i-g-t 2/5] lib/i915: Dynamic subtest constructor for sysfs/engines Chris Wilson 2020-03-13 22:21 ` Andi Shyti 2020-03-13 22:21 ` [igt-dev] " Andi Shyti 2020-03-11 9:34 ` [Intel-gfx] [PATCH i-g-t 3/5] i915: Exercise preemption timeout controls in sysfs Chris Wilson 2020-03-11 9:34 ` [igt-dev] " Chris Wilson 2020-03-13 22:26 ` [Intel-gfx] " Andi Shyti 2020-03-11 9:34 ` [Intel-gfx] [PATCH i-g-t 4/5] i915: Exercise sysfs heartbeat controls Chris Wilson 2020-03-11 9:34 ` [igt-dev] " Chris Wilson 2020-03-11 9:34 ` [Intel-gfx] [PATCH i-g-t 5/5] i915: Exercise timeslice sysfs property Chris Wilson 2020-03-11 9:34 ` [igt-dev] " Chris Wilson 2020-03-11 15:42 ` [igt-dev] ✗ GitLab.Pipeline: failure for series starting with [i-g-t,1/5] lib/i915: Create a context wrapping one specific engine Patchwork 2020-03-11 15:46 ` [igt-dev] ✗ Fi.CI.BAT: " Patchwork 2020-03-13 22:02 ` [Intel-gfx] [PATCH i-g-t 1/5] " Andi Shyti 2020-03-13 22:02 ` [igt-dev] " Andi Shyti
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200311093448.4103262-1-chris@chris-wilson.co.uk \ --to=chris@chris-wilson.co.uk \ --cc=igt-dev@lists.freedesktop.org \ --cc=intel-gfx@lists.freedesktop.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.