Merge tag 'drm-intel-gt-next-2020-11-12-1' of git://anongit.freedesktop.org/drm/drm...
[linux-2.6-microblaze.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 };
24
25 struct active_node;
26
27 #define I915_ACTIVE_MAY_SLEEP BIT(0)
28
29 #define __i915_active_call __aligned(4)
30 #define i915_active_may_sleep(fn) ptr_pack_bits(&(fn), I915_ACTIVE_MAY_SLEEP, 2)
31
32 struct i915_active {
33         atomic_t count;
34         struct mutex mutex;
35
36         spinlock_t tree_lock;
37         struct active_node *cache;
38         struct rb_root tree;
39
40         /* Preallocated "exclusive" node */
41         struct i915_active_fence excl;
42
43         unsigned long flags;
44 #define I915_ACTIVE_RETIRE_SLEEPS BIT(0)
45
46         int (*active)(struct i915_active *ref);
47         void (*retire)(struct i915_active *ref);
48
49         struct work_struct work;
50
51         struct llist_head preallocated_barriers;
52 };
53
54 #endif /* _I915_ACTIVE_TYPES_H_ */