1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2016 Intel Corporation
6 #ifndef I915_TIMELINE_H
7 #define I915_TIMELINE_H
9 #include <linux/lockdep.h>
11 #include "i915_active.h"
12 #include "i915_syncmap.h"
13 #include "intel_timeline_types.h"
17 struct intel_timeline *
18 __intel_timeline_create(struct intel_gt *gt,
19 struct i915_vma *global_hwsp,
22 static inline struct intel_timeline *
23 intel_timeline_create(struct intel_gt *gt)
25 return __intel_timeline_create(gt, NULL, 0);
28 struct intel_timeline *
29 intel_timeline_create_from_engine(struct intel_engine_cs *engine,
32 static inline struct intel_timeline *
33 intel_timeline_get(struct intel_timeline *timeline)
35 kref_get(&timeline->kref);
39 void __intel_timeline_free(struct kref *kref);
40 static inline void intel_timeline_put(struct intel_timeline *timeline)
42 kref_put(&timeline->kref, __intel_timeline_free);
45 static inline int __intel_timeline_sync_set(struct intel_timeline *tl,
46 u64 context, u32 seqno)
48 return i915_syncmap_set(&tl->sync, context, seqno);
51 static inline int intel_timeline_sync_set(struct intel_timeline *tl,
52 const struct dma_fence *fence)
54 return __intel_timeline_sync_set(tl, fence->context, fence->seqno);
57 static inline bool __intel_timeline_sync_is_later(struct intel_timeline *tl,
58 u64 context, u32 seqno)
60 return i915_syncmap_is_later(&tl->sync, context, seqno);
63 static inline bool intel_timeline_sync_is_later(struct intel_timeline *tl,
64 const struct dma_fence *fence)
66 return __intel_timeline_sync_is_later(tl, fence->context, fence->seqno);
69 void __intel_timeline_pin(struct intel_timeline *tl);
70 int intel_timeline_pin(struct intel_timeline *tl, struct i915_gem_ww_ctx *ww);
71 void intel_timeline_enter(struct intel_timeline *tl);
72 int intel_timeline_get_seqno(struct intel_timeline *tl,
73 struct i915_request *rq,
75 void intel_timeline_exit(struct intel_timeline *tl);
76 void intel_timeline_unpin(struct intel_timeline *tl);
78 void intel_timeline_reset_seqno(const struct intel_timeline *tl);
80 int intel_timeline_read_hwsp(struct i915_request *from,
81 struct i915_request *until,
84 void intel_gt_init_timelines(struct intel_gt *gt);
85 void intel_gt_fini_timelines(struct intel_gt *gt);
87 void intel_gt_show_timelines(struct intel_gt *gt,
88 struct drm_printer *m,
89 void (*show_request)(struct drm_printer *m,
90 const struct i915_request *rq,
95 intel_timeline_is_last(const struct intel_timeline *tl,
96 const struct i915_request *rq)
98 return list_is_last_rcu(&rq->link, &tl->requests);
101 I915_SELFTEST_DECLARE(int intel_timeline_pin_map(struct intel_timeline *tl));