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 TU |
12 | #include <linux/xarray.h> |
13 | ||
8399eec8 TU |
14 | #include "gt/intel_engine_types.h" |
15 | ||
ecf8eca5 | 16 | #define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE |
8399eec8 | 17 | |
5f0d4d14 TU |
18 | struct drm_i915_private; |
19 | ||
20 | struct i915_drm_clients { | |
21 | struct drm_i915_private *i915; | |
22 | ||
23 | struct xarray xarray; | |
24 | u32 next_id; | |
25 | }; | |
26 | ||
27 | struct i915_drm_client { | |
28 | struct kref kref; | |
29 | ||
30 | unsigned int id; | |
31 | ||
49bd54b3 TU |
32 | spinlock_t ctx_lock; /* For add/remove from ctx_list. */ |
33 | struct list_head ctx_list; /* List of contexts belonging to client. */ | |
34 | ||
5f0d4d14 | 35 | struct i915_drm_clients *clients; |
8399eec8 TU |
36 | |
37 | /** | |
38 | * @past_runtime: Accumulation of pphwsp runtimes from closed contexts. | |
39 | */ | |
40 | atomic64_t past_runtime[I915_LAST_UABI_ENGINE_CLASS + 1]; | |
5f0d4d14 TU |
41 | }; |
42 | ||
43 | void i915_drm_clients_init(struct i915_drm_clients *clients, | |
44 | struct drm_i915_private *i915); | |
45 | ||
46 | static inline struct i915_drm_client * | |
47 | i915_drm_client_get(struct i915_drm_client *client) | |
48 | { | |
49 | kref_get(&client->kref); | |
50 | return client; | |
51 | } | |
52 | ||
53 | void __i915_drm_client_free(struct kref *kref); | |
54 | ||
55 | static inline void i915_drm_client_put(struct i915_drm_client *client) | |
56 | { | |
57 | kref_put(&client->kref, __i915_drm_client_free); | |
58 | } | |
59 | ||
60 | struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients); | |
61 | ||
055634e4 TU |
62 | #ifdef CONFIG_PROC_FS |
63 | void i915_drm_client_fdinfo(struct seq_file *m, struct file *f); | |
64 | #endif | |
65 | ||
5f0d4d14 TU |
66 | void i915_drm_clients_fini(struct i915_drm_clients *clients); |
67 | ||
68 | #endif /* !__I915_DRM_CLIENT_H__ */ |