Commit | Line | Data |
---|---|---|
5f0d4d14 TU |
1 | /* SPDX-License-Identifier: MIT */ |
2 | /* | |
3 | * Copyright © 2020 Intel Corporation | |
4 | */ | |
5 | ||
6 | #ifndef __I915_DRM_CLIENT_H__ | |
7 | #define __I915_DRM_CLIENT_H__ | |
8 | ||
9 | #include <linux/kref.h> | |
49bd54b3 TU |
10 | #include <linux/list.h> |
11 | #include <linux/spinlock.h> | |
5f0d4d14 | 12 | |
34b68c17 | 13 | #include <uapi/drm/i915_drm.h> |
8399eec8 | 14 | |
e4ae85e3 TU |
15 | #include "i915_file_private.h" |
16 | #include "gem/i915_gem_object_types.h" | |
dc1a2775 | 17 | #include "gt/intel_context_types.h" |
e4ae85e3 | 18 | |
ecf8eca5 | 19 | #define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE |
8399eec8 | 20 | |
e894b724 TU |
21 | struct drm_file; |
22 | struct drm_printer; | |
5f0d4d14 TU |
23 | |
24 | struct i915_drm_client { | |
25 | struct kref kref; | |
26 | ||
49bd54b3 TU |
27 | spinlock_t ctx_lock; /* For add/remove from ctx_list. */ |
28 | struct list_head ctx_list; /* List of contexts belonging to client. */ | |
29 | ||
e4ae85e3 TU |
30 | #ifdef CONFIG_PROC_FS |
31 | /** | |
32 | * @objects_lock: lock protecting @objects_list | |
33 | */ | |
34 | spinlock_t objects_lock; | |
35 | ||
36 | /** | |
37 | * @objects_list: list of objects created by this client | |
38 | * | |
39 | * Protected by @objects_lock. | |
40 | */ | |
41 | struct list_head objects_list; | |
42 | #endif | |
43 | ||
8399eec8 TU |
44 | /** |
45 | * @past_runtime: Accumulation of pphwsp runtimes from closed contexts. | |
46 | */ | |
47 | atomic64_t past_runtime[I915_LAST_UABI_ENGINE_CLASS + 1]; | |
5f0d4d14 TU |
48 | }; |
49 | ||
5f0d4d14 TU |
50 | static inline struct i915_drm_client * |
51 | i915_drm_client_get(struct i915_drm_client *client) | |
52 | { | |
53 | kref_get(&client->kref); | |
54 | return client; | |
55 | } | |
56 | ||
57 | void __i915_drm_client_free(struct kref *kref); | |
58 | ||
59 | static inline void i915_drm_client_put(struct i915_drm_client *client) | |
60 | { | |
61 | kref_put(&client->kref, __i915_drm_client_free); | |
62 | } | |
63 | ||
e894b724 | 64 | struct i915_drm_client *i915_drm_client_alloc(void); |
5f0d4d14 | 65 | |
e894b724 | 66 | void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file); |
055634e4 | 67 | |
e4ae85e3 TU |
68 | #ifdef CONFIG_PROC_FS |
69 | void i915_drm_client_add_object(struct i915_drm_client *client, | |
70 | struct drm_i915_gem_object *obj); | |
44eea8d0 | 71 | void i915_drm_client_remove_object(struct drm_i915_gem_object *obj); |
dc1a2775 TU |
72 | void i915_drm_client_add_context_objects(struct i915_drm_client *client, |
73 | struct intel_context *ce); | |
e4ae85e3 TU |
74 | #else |
75 | static inline void i915_drm_client_add_object(struct i915_drm_client *client, | |
76 | struct drm_i915_gem_object *obj) | |
77 | { | |
78 | } | |
79 | ||
44eea8d0 TU |
80 | static inline void |
81 | i915_drm_client_remove_object(struct drm_i915_gem_object *obj) | |
e4ae85e3 TU |
82 | { |
83 | } | |
dc1a2775 TU |
84 | |
85 | static inline void | |
86 | i915_drm_client_add_context_objects(struct i915_drm_client *client, | |
87 | struct intel_context *ce) | |
88 | { | |
89 | } | |
e4ae85e3 TU |
90 | #endif |
91 | ||
5f0d4d14 | 92 | #endif /* !__I915_DRM_CLIENT_H__ */ |