]> git.ipfire.org Git - thirdparty/kernel/stable.git/blob - drivers/gpu/drm/i915/i915_timeline.h
Merge tag 'pwm/for-5.2-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git...
[thirdparty/kernel/stable.git] / drivers / gpu / drm / i915 / i915_timeline.h
1 /*
2 * Copyright © 2016 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 */
24
25 #ifndef I915_TIMELINE_H
26 #define I915_TIMELINE_H
27
28 #include <linux/lockdep.h>
29
30 #include "i915_active.h"
31 #include "i915_syncmap.h"
32 #include "i915_timeline_types.h"
33
34 int i915_timeline_init(struct drm_i915_private *i915,
35 struct i915_timeline *tl,
36 struct i915_vma *hwsp);
37 void i915_timeline_fini(struct i915_timeline *tl);
38
39 static inline void
40 i915_timeline_set_subclass(struct i915_timeline *timeline,
41 unsigned int subclass)
42 {
43 lockdep_set_subclass(&timeline->lock, subclass);
44
45 /*
46 * Due to an interesting quirk in lockdep's internal debug tracking,
47 * after setting a subclass we must ensure the lock is used. Otherwise,
48 * nr_unused_locks is incremented once too often.
49 */
50 #ifdef CONFIG_DEBUG_LOCK_ALLOC
51 local_irq_disable();
52 lock_map_acquire(&timeline->lock.dep_map);
53 lock_map_release(&timeline->lock.dep_map);
54 local_irq_enable();
55 #endif
56 }
57
58 struct i915_timeline *
59 i915_timeline_create(struct drm_i915_private *i915,
60 struct i915_vma *global_hwsp);
61
62 static inline struct i915_timeline *
63 i915_timeline_get(struct i915_timeline *timeline)
64 {
65 kref_get(&timeline->kref);
66 return timeline;
67 }
68
69 void __i915_timeline_free(struct kref *kref);
70 static inline void i915_timeline_put(struct i915_timeline *timeline)
71 {
72 kref_put(&timeline->kref, __i915_timeline_free);
73 }
74
75 static inline int __i915_timeline_sync_set(struct i915_timeline *tl,
76 u64 context, u32 seqno)
77 {
78 return i915_syncmap_set(&tl->sync, context, seqno);
79 }
80
81 static inline int i915_timeline_sync_set(struct i915_timeline *tl,
82 const struct dma_fence *fence)
83 {
84 return __i915_timeline_sync_set(tl, fence->context, fence->seqno);
85 }
86
87 static inline bool __i915_timeline_sync_is_later(struct i915_timeline *tl,
88 u64 context, u32 seqno)
89 {
90 return i915_syncmap_is_later(&tl->sync, context, seqno);
91 }
92
93 static inline bool i915_timeline_sync_is_later(struct i915_timeline *tl,
94 const struct dma_fence *fence)
95 {
96 return __i915_timeline_sync_is_later(tl, fence->context, fence->seqno);
97 }
98
99 int i915_timeline_pin(struct i915_timeline *tl);
100 int i915_timeline_get_seqno(struct i915_timeline *tl,
101 struct i915_request *rq,
102 u32 *seqno);
103 void i915_timeline_unpin(struct i915_timeline *tl);
104
105 int i915_timeline_read_hwsp(struct i915_request *from,
106 struct i915_request *until,
107 u32 *hwsp_offset);
108
109 void i915_timelines_init(struct drm_i915_private *i915);
110 void i915_timelines_park(struct drm_i915_private *i915);
111 void i915_timelines_fini(struct drm_i915_private *i915);
112
113 #endif