mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 22:02:02 +00:00
drm/i915: Account ring buffer and context state storage
Account ring buffers and logical context space against the owning client memory usage stats. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20231107101806.608990-4-tvrtko.ursulin@linux.intel.com
This commit is contained in:
parent
978e1a52ca
commit
dc1a277507
3 changed files with 33 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
#include "gem/i915_gem_context.h"
|
#include "gem/i915_gem_context.h"
|
||||||
#include "gem/i915_gem_pm.h"
|
#include "gem/i915_gem_pm.h"
|
||||||
|
|
||||||
|
#include "i915_drm_client.h"
|
||||||
#include "i915_drv.h"
|
#include "i915_drv.h"
|
||||||
#include "i915_trace.h"
|
#include "i915_trace.h"
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ intel_context_create(struct intel_engine_cs *engine)
|
||||||
|
|
||||||
int intel_context_alloc_state(struct intel_context *ce)
|
int intel_context_alloc_state(struct intel_context *ce)
|
||||||
{
|
{
|
||||||
|
struct i915_gem_context *ctx;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&ce->pin_mutex))
|
if (mutex_lock_interruptible(&ce->pin_mutex))
|
||||||
|
@ -66,6 +68,18 @@ int intel_context_alloc_state(struct intel_context *ce)
|
||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
set_bit(CONTEXT_ALLOC_BIT, &ce->flags);
|
set_bit(CONTEXT_ALLOC_BIT, &ce->flags);
|
||||||
|
|
||||||
|
rcu_read_lock();
|
||||||
|
ctx = rcu_dereference(ce->gem_context);
|
||||||
|
if (ctx && !kref_get_unless_zero(&ctx->ref))
|
||||||
|
ctx = NULL;
|
||||||
|
rcu_read_unlock();
|
||||||
|
if (ctx) {
|
||||||
|
if (ctx->client)
|
||||||
|
i915_drm_client_add_context_objects(ctx->client,
|
||||||
|
ce);
|
||||||
|
i915_gem_context_put(ctx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
|
|
|
@ -144,4 +144,14 @@ bool i915_drm_client_remove_object(struct drm_i915_gem_object *obj)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void i915_drm_client_add_context_objects(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
|
#endif
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "i915_file_private.h"
|
#include "i915_file_private.h"
|
||||||
#include "gem/i915_gem_object_types.h"
|
#include "gem/i915_gem_object_types.h"
|
||||||
|
#include "gt/intel_context_types.h"
|
||||||
|
|
||||||
#define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE
|
#define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE
|
||||||
|
|
||||||
|
@ -70,6 +71,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,
|
void i915_drm_client_add_object(struct i915_drm_client *client,
|
||||||
struct drm_i915_gem_object *obj);
|
struct drm_i915_gem_object *obj);
|
||||||
bool i915_drm_client_remove_object(struct drm_i915_gem_object *obj);
|
bool i915_drm_client_remove_object(struct drm_i915_gem_object *obj);
|
||||||
|
void i915_drm_client_add_context_objects(struct i915_drm_client *client,
|
||||||
|
struct intel_context *ce);
|
||||||
#else
|
#else
|
||||||
static inline void i915_drm_client_add_object(struct i915_drm_client *client,
|
static inline void i915_drm_client_add_object(struct i915_drm_client *client,
|
||||||
struct drm_i915_gem_object *obj)
|
struct drm_i915_gem_object *obj)
|
||||||
|
@ -79,6 +82,12 @@ static inline void i915_drm_client_add_object(struct i915_drm_client *client,
|
||||||
static inline bool i915_drm_client_remove_object(struct drm_i915_gem_object *obj)
|
static inline bool i915_drm_client_remove_object(struct drm_i915_gem_object *obj)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
i915_drm_client_add_context_objects(struct i915_drm_client *client,
|
||||||
|
struct intel_context *ce)
|
||||||
|
{
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !__I915_DRM_CLIENT_H__ */
|
#endif /* !__I915_DRM_CLIENT_H__ */
|
||||||
|
|
Loading…
Reference in a new issue