From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> Account ring buffers and logical context space against the owning client memory usage stats. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> --- drivers/gpu/drm/i915/gem/i915_gem_context.c | 6 ++++++ drivers/gpu/drm/i915/i915_drm_client.c | 10 ++++++++++ drivers/gpu/drm/i915/i915_drm_client.h | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c index 35cf6608180e..3f4c74aed3c5 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c @@ -1703,6 +1703,8 @@ static void gem_context_register(struct i915_gem_context *ctx, u32 id) { struct drm_i915_private *i915 = ctx->i915; + struct i915_gem_engines_iter it; + struct intel_context *ce; void *old; ctx->file_priv = fpriv; @@ -1721,6 +1723,10 @@ static void gem_context_register(struct i915_gem_context *ctx, list_add_tail(&ctx->link, &i915->gem.contexts.list); spin_unlock(&i915->gem.contexts.lock); + for_each_gem_engine(ce, i915_gem_context_lock_engines(ctx), it) + i915_drm_client_add_context(fpriv->client, ce); + i915_gem_context_unlock_engines(ctx); + /* And finally expose ourselves to userspace via the idr */ old = xa_store(&fpriv->context_xa, id, ctx, GFP_KERNEL); WARN_ON(old); diff --git a/drivers/gpu/drm/i915/i915_drm_client.c b/drivers/gpu/drm/i915/i915_drm_client.c index b0b35bcdd2b3..31316edbf30b 100644 --- a/drivers/gpu/drm/i915/i915_drm_client.c +++ b/drivers/gpu/drm/i915/i915_drm_client.c @@ -145,4 +145,14 @@ void i915_drm_client_remove_object(struct drm_i915_gem_object *obj) i915_drm_client_put(client); } + +void i915_drm_client_add_context(struct i915_drm_client *client, + struct intel_context *ce) +{ + if (ce->state) + i915_drm_client_add_object(client, ce->state->obj); + + if (ce->ring != ce->engine->legacy.ring && ce->ring->vma) + i915_drm_client_add_object(client, ce->ring->vma->obj); +} #endif diff --git a/drivers/gpu/drm/i915/i915_drm_client.h b/drivers/gpu/drm/i915/i915_drm_client.h index dfeaaf204c00..e1e2a7cca1b1 100644 --- a/drivers/gpu/drm/i915/i915_drm_client.h +++ b/drivers/gpu/drm/i915/i915_drm_client.h @@ -14,6 +14,7 @@ #include "i915_file_private.h" #include "gem/i915_gem_object_types.h" +#include "gt/intel_context_types.h" #define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE @@ -72,6 +73,8 @@ void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file); void i915_drm_client_add_object(struct i915_drm_client *client, struct drm_i915_gem_object *obj); void i915_drm_client_remove_object(struct drm_i915_gem_object *obj); +void i915_drm_client_add_context(struct i915_drm_client *client, + struct intel_context *ce); #else static inline void i915_drm_client_add_object(struct i915_drm_client *client, struct drm_i915_gem_object *obj) @@ -82,6 +85,12 @@ static inline void i915_drm_client_add_object(struct i915_drm_client *client, static inline void i915_drm_client_remove_object(struct drm_i915_gem_object *obj) { +} + +static inline void i915_drm_client_add_context(struct i915_drm_client *client, + struct intel_context *ce) +{ + } #endif -- 2.39.2