Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.1.
 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>
10#include <linux/list.h>
11#include <linux/spinlock.h>
12
13#include <uapi/drm/i915_drm.h>
14
15#include "i915_file_private.h"
16#include "gem/i915_gem_object_types.h"
17#include "gt/intel_context_types.h"
18
19#define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE
20
21struct drm_file;
22struct drm_printer;
23
24struct i915_drm_client {
25	struct kref kref;
26
27	unsigned int id;
28
29	spinlock_t ctx_lock; /* For add/remove from ctx_list. */
30	struct list_head ctx_list; /* List of contexts belonging to client. */
31
32#ifdef CONFIG_PROC_FS
33	/**
34	 * @objects_lock: lock protecting @objects_list
35	 */
36	spinlock_t objects_lock;
37
38	/**
39	 * @objects_list: list of objects created by this client
40	 *
41	 * Protected by @objects_lock.
42	 */
43	struct list_head objects_list;
44#endif
45
46	/**
47	 * @past_runtime: Accumulation of pphwsp runtimes from closed contexts.
48	 */
49	atomic64_t past_runtime[I915_LAST_UABI_ENGINE_CLASS + 1];
50};
51
52static inline struct i915_drm_client *
53i915_drm_client_get(struct i915_drm_client *client)
54{
55	kref_get(&client->kref);
56	return client;
57}
58
59void __i915_drm_client_free(struct kref *kref);
60
61static inline void i915_drm_client_put(struct i915_drm_client *client)
62{
63	kref_put(&client->kref, __i915_drm_client_free);
64}
65
66struct i915_drm_client *i915_drm_client_alloc(void);
67
68void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file);
69
70#ifdef CONFIG_PROC_FS
71void i915_drm_client_add_object(struct i915_drm_client *client,
72				struct drm_i915_gem_object *obj);
73void i915_drm_client_remove_object(struct drm_i915_gem_object *obj);
74void i915_drm_client_add_context_objects(struct i915_drm_client *client,
75					 struct intel_context *ce);
76#else
77static inline void i915_drm_client_add_object(struct i915_drm_client *client,
78					      struct drm_i915_gem_object *obj)
79{
80}
81
82static inline void
83i915_drm_client_remove_object(struct drm_i915_gem_object *obj)
84{
85}
86
87static inline void
88i915_drm_client_add_context_objects(struct i915_drm_client *client,
89				    struct intel_context *ce)
90{
91}
92#endif
93
94#endif /* !__I915_DRM_CLIENT_H__ */