From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> To: igt-dev@lists.freedesktop.org Cc: Intel-gfx@lists.freedesktop.org Subject: [Intel-gfx] [PATCH i-g-t 1/2] lib/i915: Add helper for copying engine maps from one context to another Date: Fri, 24 Jan 2020 12:17:58 +0000 [thread overview] Message-ID: <20200124121759.22308-1-tvrtko.ursulin@linux.intel.com> (raw) From: Tvrtko Ursulin <tvrtko.ursulin@intel.com> We also need to support copying across file descriptors. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Sreedhar Telukuntla <sreedhar.telukuntla@intel.com> --- lib/i915/gem_context.c | 30 ++++++++++++++++++++++++++++++ lib/i915/gem_context.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c index 0b6a554dfe27..41957b66ca52 100644 --- a/lib/i915/gem_context.c +++ b/lib/i915/gem_context.c @@ -462,3 +462,33 @@ bool gem_context_has_engine(int fd, uint32_t ctx, uint64_t engine) return __gem_execbuf(fd, &execbuf) == -ENOENT; } + +/** + * gem_context_copy_engines: + * @src_fd: open i915 drm file descriptor where @src context belongs to + * @src: source engine map context id + * @dst_fd: open i915 drm file descriptor where @dst context belongs to + * @dst: destination engine map context id + * + * Special purpose wrapper for copying engine map from one context to another. + * + * In can be called regardless of whether the kernel supports context engine + * maps and is a no-op if not supported. + */ +void +gem_context_copy_engines(int src_fd, uint32_t src, int dst_fd, uint32_t dst) +{ + I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, I915_EXEC_RING_MASK + 1); + struct drm_i915_gem_context_param param = { + .param = I915_CONTEXT_PARAM_ENGINES, + .ctx_id = src, + .size = sizeof(engines), + .value = to_user_pointer(&engines), + }; + + if (__gem_context_get_param(src_fd, ¶m) || !param.size) + return; + + param.ctx_id = dst; + gem_context_set_param(dst_fd, ¶m); +} diff --git a/lib/i915/gem_context.h b/lib/i915/gem_context.h index cf2ba33fee8f..15e5db281b79 100644 --- a/lib/i915/gem_context.h +++ b/lib/i915/gem_context.h @@ -42,6 +42,8 @@ uint32_t gem_context_clone(int i915, uint32_t src, unsigned int share, unsigned int flags); uint32_t gem_context_clone_with_engines(int i915, uint32_t src); +void gem_context_copy_engines(int src_fd, uint32_t src, + int dst_fd, uint32_t dst); uint32_t gem_queue_create(int i915); uint32_t gem_queue_clone_with_engines(int i915, uint32_t src); -- 2.20.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: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> To: igt-dev@lists.freedesktop.org Cc: Intel-gfx@lists.freedesktop.org, Tvrtko Ursulin <tvrtko.ursulin@intel.com> Subject: [igt-dev] [PATCH i-g-t 1/2] lib/i915: Add helper for copying engine maps from one context to another Date: Fri, 24 Jan 2020 12:17:58 +0000 [thread overview] Message-ID: <20200124121759.22308-1-tvrtko.ursulin@linux.intel.com> (raw) From: Tvrtko Ursulin <tvrtko.ursulin@intel.com> We also need to support copying across file descriptors. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Sreedhar Telukuntla <sreedhar.telukuntla@intel.com> --- lib/i915/gem_context.c | 30 ++++++++++++++++++++++++++++++ lib/i915/gem_context.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c index 0b6a554dfe27..41957b66ca52 100644 --- a/lib/i915/gem_context.c +++ b/lib/i915/gem_context.c @@ -462,3 +462,33 @@ bool gem_context_has_engine(int fd, uint32_t ctx, uint64_t engine) return __gem_execbuf(fd, &execbuf) == -ENOENT; } + +/** + * gem_context_copy_engines: + * @src_fd: open i915 drm file descriptor where @src context belongs to + * @src: source engine map context id + * @dst_fd: open i915 drm file descriptor where @dst context belongs to + * @dst: destination engine map context id + * + * Special purpose wrapper for copying engine map from one context to another. + * + * In can be called regardless of whether the kernel supports context engine + * maps and is a no-op if not supported. + */ +void +gem_context_copy_engines(int src_fd, uint32_t src, int dst_fd, uint32_t dst) +{ + I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, I915_EXEC_RING_MASK + 1); + struct drm_i915_gem_context_param param = { + .param = I915_CONTEXT_PARAM_ENGINES, + .ctx_id = src, + .size = sizeof(engines), + .value = to_user_pointer(&engines), + }; + + if (__gem_context_get_param(src_fd, ¶m) || !param.size) + return; + + param.ctx_id = dst; + gem_context_set_param(dst_fd, ¶m); +} diff --git a/lib/i915/gem_context.h b/lib/i915/gem_context.h index cf2ba33fee8f..15e5db281b79 100644 --- a/lib/i915/gem_context.h +++ b/lib/i915/gem_context.h @@ -42,6 +42,8 @@ uint32_t gem_context_clone(int i915, uint32_t src, unsigned int share, unsigned int flags); uint32_t gem_context_clone_with_engines(int i915, uint32_t src); +void gem_context_copy_engines(int src_fd, uint32_t src, + int dst_fd, uint32_t dst); uint32_t gem_queue_create(int i915); uint32_t gem_queue_clone_with_engines(int i915, uint32_t src); -- 2.20.1 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev
next reply other threads:[~2020-01-24 12:18 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-01-24 12:17 Tvrtko Ursulin [this message] 2020-01-24 12:17 ` [igt-dev] [PATCH i-g-t 1/2] lib/i915: Add helper for copying engine maps from one context to another Tvrtko Ursulin 2020-01-24 12:17 ` [Intel-gfx] [PATCH i-g-t 2/2] tests/i915/gem_exec_parallel:Set engine map to default context Tvrtko Ursulin 2020-01-24 12:17 ` [igt-dev] " Tvrtko Ursulin 2020-01-24 12:25 ` [Intel-gfx] " Chris Wilson 2020-01-24 12:25 ` Chris Wilson 2020-01-24 12:23 ` [Intel-gfx] [PATCH i-g-t 1/2] lib/i915: Add helper for copying engine maps from one context to another Chris Wilson 2020-01-24 12:23 ` [igt-dev] " Chris Wilson 2020-01-24 12:26 ` [Intel-gfx] " Tvrtko Ursulin 2020-01-24 12:26 ` [igt-dev] " Tvrtko Ursulin 2020-01-24 12:29 ` [Intel-gfx] " Chris Wilson 2020-01-24 12:29 ` [igt-dev] " Chris Wilson 2020-01-24 12:28 ` [Intel-gfx] [PATCH i-g-t v2 " Tvrtko Ursulin 2020-01-24 12:28 ` [igt-dev] " Tvrtko Ursulin 2020-01-24 12:48 ` [Intel-gfx] " Chris Wilson 2020-01-24 12:48 ` [igt-dev] " Chris Wilson
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=20200124121759.22308-1-tvrtko.ursulin@linux.intel.com \ --to=tvrtko.ursulin@linux.intel.com \ --cc=Intel-gfx@lists.freedesktop.org \ --cc=igt-dev@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.