1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2020 Intel Corporation
6 #ifndef __I915_DRM_CLIENT_H__
7 #define __I915_DRM_CLIENT_H__
9 #include <linux/kref.h>
10 #include <linux/list.h>
11 #include <linux/spinlock.h>
13 #include <uapi/drm/i915_drm.h>
15 #include "i915_file_private.h"
16 #include "gem/i915_gem_object_types.h"
17 #include "gt/intel_context_types.h"
19 #define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE
24 struct i915_drm_client {
27 spinlock_t ctx_lock; /* For add/remove from ctx_list. */
28 struct list_head ctx_list; /* List of contexts belonging to client. */
32 * @objects_lock: lock protecting @objects_list
34 spinlock_t objects_lock;
37 * @objects_list: list of objects created by this client
39 * Protected by @objects_lock.
41 struct list_head objects_list;
45 * @past_runtime: Accumulation of pphwsp runtimes from closed contexts.
47 atomic64_t past_runtime[I915_LAST_UABI_ENGINE_CLASS + 1];
50 static inline struct i915_drm_client *
51 i915_drm_client_get(struct i915_drm_client *client)
53 kref_get(&client->kref);
57 void __i915_drm_client_free(struct kref *kref);
59 static inline void i915_drm_client_put(struct i915_drm_client *client)
61 kref_put(&client->kref, __i915_drm_client_free);
64 struct i915_drm_client *i915_drm_client_alloc(void);
66 void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file);
69 void i915_drm_client_add_object(struct i915_drm_client *client,
70 struct drm_i915_gem_object *obj);
71 void i915_drm_client_remove_object(struct drm_i915_gem_object *obj);
72 void i915_drm_client_add_context_objects(struct i915_drm_client *client,
73 struct intel_context *ce);
75 static inline void i915_drm_client_add_object(struct i915_drm_client *client,
76 struct drm_i915_gem_object *obj)
81 i915_drm_client_remove_object(struct drm_i915_gem_object *obj)
86 i915_drm_client_add_context_objects(struct i915_drm_client *client,
87 struct intel_context *ce)
92 #endif /* !__I915_DRM_CLIENT_H__ */