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 | |
ecf8eca5 | 15 | #define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE |
8399eec8 | 16 | |
e894b724 TU |
17 | struct drm_file; |
18 | struct drm_printer; | |
5f0d4d14 TU |
19 | |
20 | struct i915_drm_client { | |
21 | struct kref kref; | |
22 | ||
23 | unsigned int id; | |
24 | ||
49bd54b3 TU |
25 | spinlock_t ctx_lock; /* For add/remove from ctx_list. */ |
26 | struct list_head ctx_list; /* List of contexts belonging to client. */ | |
27 | ||
8399eec8 TU |
28 | /** |
29 | * @past_runtime: Accumulation of pphwsp runtimes from closed contexts. | |
30 | */ | |
31 | atomic64_t past_runtime[I915_LAST_UABI_ENGINE_CLASS + 1]; | |
5f0d4d14 TU |
32 | }; |
33 | ||
5f0d4d14 TU |
34 | static inline struct i915_drm_client * |
35 | i915_drm_client_get(struct i915_drm_client *client) | |
36 | { | |
37 | kref_get(&client->kref); | |
38 | return client; | |
39 | } | |
40 | ||
41 | void __i915_drm_client_free(struct kref *kref); | |
42 | ||
43 | static inline void i915_drm_client_put(struct i915_drm_client *client) | |
44 | { | |
45 | kref_put(&client->kref, __i915_drm_client_free); | |
46 | } | |
47 | ||
e894b724 | 48 | struct i915_drm_client *i915_drm_client_alloc(void); |
5f0d4d14 | 49 | |
e894b724 | 50 | void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file); |
055634e4 | 51 | |
5f0d4d14 | 52 | #endif /* !__I915_DRM_CLIENT_H__ */ |