Expose a new context parameters to opting out of persistent behaviour. Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> Reviewed-by: Andi Shyti <andi.shyti@xxxxxxxxx> --- lib/i915/gem_context.c | 37 +++++++++++++++++++++++++++++++++++++ lib/i915/gem_context.h | 8 ++++++++ 2 files changed, 45 insertions(+) diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c index 83c5df961..1fae5191f 100644 --- a/lib/i915/gem_context.c +++ b/lib/i915/gem_context.c @@ -272,6 +272,43 @@ void gem_context_set_priority(int fd, uint32_t ctx_id, int prio) igt_assert_eq(__gem_context_set_priority(fd, ctx_id, prio), 0); } +/** + * __gem_context_set_persistence: + * @i915: open i915 drm file descriptor + * @ctx: i915 context id + * @state: desired persistence + * + * Declare whether this context is allowed to persist after closing until + * its requests are complete (persistent=true) or if it should be + * immediately reaped on closing and its requests cancelled + * (persistent=false). + * + * Returns: An integer equal to zero for success and negative for failure + */ +int __gem_context_set_persistence(int i915, uint32_t ctx, bool state) +{ + struct drm_i915_gem_context_param p = { + .ctx_id = ctx, + .param = I915_CONTEXT_PARAM_PERSISTENCE, + .value = state, + }; + + return __gem_context_set_param(i915, &p); +} + +/** + * __gem_context_set_persistence: + * @i915: open i915 drm file descriptor + * @ctx: i915 context id + * @state: desired persistence + * + * Like __gem_context_set_persistence(), except we assert on failure. + */ +void gem_context_set_persistence(int i915, uint32_t ctx, bool state) +{ + igt_assert_eq(__gem_context_set_persistence(i915, ctx, state), 0); +} + int __gem_context_clone(int i915, uint32_t src, unsigned int share, diff --git a/lib/i915/gem_context.h b/lib/i915/gem_context.h index 8043c3401..c0d4c9615 100644 --- a/lib/i915/gem_context.h +++ b/lib/i915/gem_context.h @@ -24,6 +24,11 @@ #ifndef GEM_CONTEXT_H #define GEM_CONTEXT_H +#include <stdbool.h> +#include <stdint.h> + +struct drm_i915_gem_context_param; + uint32_t gem_context_create(int fd); int __gem_context_create(int fd, uint32_t *ctx_id); void gem_context_destroy(int fd, uint32_t ctx_id); @@ -58,6 +63,9 @@ int __gem_context_get_param(int fd, struct drm_i915_gem_context_param *p); int __gem_context_set_priority(int fd, uint32_t ctx, int prio); void gem_context_set_priority(int fd, uint32_t ctx, int prio); +int __gem_context_set_persistence(int i915, uint32_t ctx, bool state); +void gem_context_set_persistence(int i915, uint32_t ctx, bool state); + bool gem_context_has_engine(int fd, uint32_t ctx, uint64_t engine); #endif /* GEM_CONTEXT_H */ -- 2.24.0.rc0 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx