drm/i915/gvt: Refine non privilege register address calucation
[sfrench/cifs-2.6.git] / drivers / gpu / drm / i915 / i915_active_types.h
1 /*
2  * SPDX-License-Identifier: MIT
3  *
4  * Copyright © 2019 Intel Corporation
5  */
6
7 #ifndef _I915_ACTIVE_TYPES_H_
8 #define _I915_ACTIVE_TYPES_H_
9
10 #include <linux/atomic.h>
11 #include <linux/dma-fence.h>
12 #include <linux/llist.h>
13 #include <linux/mutex.h>
14 #include <linux/rbtree.h>
15 #include <linux/rcupdate.h>
16 #include <linux/workqueue.h>
17
18 #include "i915_utils.h"
19
20 struct i915_active_fence {
21         struct dma_fence __rcu *fence;
22         struct dma_fence_cb cb;
23 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)
24         /*
25          * Incorporeal!
26          *
27          * Updates to the i915_active_request must be serialised under a lock
28          * to ensure that the timeline is ordered. Normally, this is the
29          * timeline->mutex, but another mutex may be used so long as it is
30          * done so consistently.
31          *
32          * For lockdep tracking of the above, we store the lock we intend
33          * to always use for updates of this i915_active_request during
34          * construction and assert that is held on every update.
35          */
36         struct mutex *lock;
37 #endif
38 };
39
40 struct active_node;
41
42 #define I915_ACTIVE_MAY_SLEEP BIT(0)
43
44 #define __i915_active_call __aligned(4)
45 #define i915_active_may_sleep(fn) ptr_pack_bits(&(fn), I915_ACTIVE_MAY_SLEEP, 2)
46
47 struct i915_active {
48         atomic_t count;
49         struct mutex mutex;
50
51         struct active_node *cache;
52         struct rb_root tree;
53
54         /* Preallocated "exclusive" node */
55         struct i915_active_fence excl;
56
57         unsigned long flags;
58 #define I915_ACTIVE_RETIRE_SLEEPS BIT(0)
59
60         int (*active)(struct i915_active *ref);
61         void (*retire)(struct i915_active *ref);
62
63         struct work_struct work;
64
65         struct llist_head preallocated_barriers;
66 };
67
68 #endif /* _I915_ACTIVE_TYPES_H_ */