Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / i915 / gt / intel_timeline.h
blob9882cd911d8edf6e4a383f269459e5fd4e3cb7f2
1 /*
2 * Copyright © 2016 Intel Corporation
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:
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.
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.
25 #ifndef I915_TIMELINE_H
26 #define I915_TIMELINE_H
28 #include <linux/lockdep.h>
30 #include "i915_active.h"
31 #include "i915_syncmap.h"
32 #include "intel_timeline_types.h"
34 struct intel_timeline *
35 __intel_timeline_create(struct intel_gt *gt,
36 struct i915_vma *global_hwsp,
37 unsigned int offset);
39 static inline struct intel_timeline *
40 intel_timeline_create(struct intel_gt *gt)
42 return __intel_timeline_create(gt, NULL, 0);
45 static inline struct intel_timeline *
46 intel_timeline_create_from_engine(struct intel_engine_cs *engine,
47 unsigned int offset)
49 return __intel_timeline_create(engine->gt,
50 engine->status_page.vma,
51 offset);
54 static inline struct intel_timeline *
55 intel_timeline_get(struct intel_timeline *timeline)
57 kref_get(&timeline->kref);
58 return timeline;
61 void __intel_timeline_free(struct kref *kref);
62 static inline void intel_timeline_put(struct intel_timeline *timeline)
64 kref_put(&timeline->kref, __intel_timeline_free);
67 static inline int __intel_timeline_sync_set(struct intel_timeline *tl,
68 u64 context, u32 seqno)
70 return i915_syncmap_set(&tl->sync, context, seqno);
73 static inline int intel_timeline_sync_set(struct intel_timeline *tl,
74 const struct dma_fence *fence)
76 return __intel_timeline_sync_set(tl, fence->context, fence->seqno);
79 static inline bool __intel_timeline_sync_is_later(struct intel_timeline *tl,
80 u64 context, u32 seqno)
82 return i915_syncmap_is_later(&tl->sync, context, seqno);
85 static inline bool intel_timeline_sync_is_later(struct intel_timeline *tl,
86 const struct dma_fence *fence)
88 return __intel_timeline_sync_is_later(tl, fence->context, fence->seqno);
91 void __intel_timeline_pin(struct intel_timeline *tl);
92 int intel_timeline_pin(struct intel_timeline *tl, struct i915_gem_ww_ctx *ww);
93 void intel_timeline_enter(struct intel_timeline *tl);
94 int intel_timeline_get_seqno(struct intel_timeline *tl,
95 struct i915_request *rq,
96 u32 *seqno);
97 void intel_timeline_exit(struct intel_timeline *tl);
98 void intel_timeline_unpin(struct intel_timeline *tl);
100 void intel_timeline_reset_seqno(const struct intel_timeline *tl);
102 int intel_timeline_read_hwsp(struct i915_request *from,
103 struct i915_request *until,
104 u32 *hwsp_offset);
106 void intel_gt_init_timelines(struct intel_gt *gt);
107 void intel_gt_fini_timelines(struct intel_gt *gt);
109 #endif