diff options
author | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2020-01-27 09:19:09 +0000 |
---|---|---|
committer | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2020-01-29 09:42:06 +0000 |
commit | e83261cd2901551b5cd4e860e2ca016afb873c14 (patch) | |
tree | c14cdd62d3e9a00476521899709d93c23a2516d4 /lib/i915/gem_context.c | |
parent | c662007d7e45a596e62e93f5cca8d47e6cee520e (diff) |
lib/i915: Add helper for copying engine maps from one context to another
We also need to support copying across file descriptors.
v2:
* Copy over even if src is unset. (Chris)
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sreedhar Telukuntla <sreedhar.telukuntla@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/i915/gem_context.c')
-rw-r--r-- | lib/i915/gem_context.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c index 0b6a554d..50dfee3d 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 helper 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)) + return; + + param.ctx_id = dst; + gem_context_set_param(dst_fd, ¶m); +} |