Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
c209da9
Breadcrumbs
linux
/
drivers
/
gpu
/
drm
/
i915
/
gt
/
intel_context.h
Copy path
Blame
Blame
Latest commit
History
History
262 lines (212 loc) · 6.54 KB
Breadcrumbs
linux
/
drivers
/
gpu
/
drm
/
i915
/
gt
/
intel_context.h
Top
File metadata and controls
Code
Blame
262 lines (212 loc) · 6.54 KB
Raw
/* SPDX-License-Identifier: MIT */ /* * Copyright © 2019 Intel Corporation */ #ifndef __INTEL_CONTEXT_H__ #define __INTEL_CONTEXT_H__ #include <linux/bitops.h> #include <linux/lockdep.h> #include <linux/types.h> #include "i915_active.h" #include "i915_drv.h" #include "intel_context_types.h" #include "intel_engine_types.h" #include "intel_ring_types.h" #include "intel_timeline_types.h" #define CE_TRACE(ce, fmt, ...) do { \ const struct intel_context *ce__ = (ce); \ ENGINE_TRACE(ce__->engine, "context:%llx " fmt, \ ce__->timeline->fence_context, \ ##__VA_ARGS__); \ } while (0) struct i915_gem_ww_ctx; void intel_context_init(struct intel_context *ce, struct intel_engine_cs *engine); void intel_context_fini(struct intel_context *ce); struct intel_context * intel_context_create(struct intel_engine_cs *engine); int intel_context_alloc_state(struct intel_context *ce); void intel_context_free(struct intel_context *ce); int intel_context_reconfigure_sseu(struct intel_context *ce, const struct intel_sseu sseu); /** * intel_context_lock_pinned - Stablises the 'pinned' status of the HW context * @ce - the context * * Acquire a lock on the pinned status of the HW context, such that the context * can neither be bound to the GPU or unbound whilst the lock is held, i.e. * intel_context_is_pinned() remains stable. */ static inline int intel_context_lock_pinned(struct intel_context *ce) __acquires(ce->pin_mutex) { return mutex_lock_interruptible(&ce->pin_mutex); } /** * intel_context_is_pinned - Reports the 'pinned' status * @ce - the context * * While in use by the GPU, the context, along with its ring and page * tables is pinned into memory and the GTT. * * Returns: true if the context is currently pinned for use by the GPU. */ static inline bool intel_context_is_pinned(struct intel_context *ce) { return atomic_read(&ce->pin_count); } /** * intel_context_unlock_pinned - Releases the earlier locking of 'pinned' status * @ce - the context * * Releases the lock earlier acquired by intel_context_unlock_pinned(). */ static inline void intel_context_unlock_pinned(struct intel_context *ce) __releases(ce->pin_mutex) { mutex_unlock(&ce->pin_mutex); } int __intel_context_do_pin(struct intel_context *ce); int __intel_context_do_pin_ww(struct intel_context *ce, struct i915_gem_ww_ctx *ww); static inline bool intel_context_pin_if_active(struct intel_context *ce) { return atomic_inc_not_zero(&ce->pin_count); } static inline int intel_context_pin(struct intel_context *ce) { if (likely(intel_context_pin_if_active(ce))) return 0; return __intel_context_do_pin(ce); } static inline int intel_context_pin_ww(struct intel_context *ce, struct i915_gem_ww_ctx *ww) { if (likely(intel_context_pin_if_active(ce))) return 0; return __intel_context_do_pin_ww(ce, ww); } static inline void __intel_context_pin(struct intel_context *ce) { GEM_BUG_ON(!intel_context_is_pinned(ce)); atomic_inc(&ce->pin_count); } void intel_context_unpin(struct intel_context *ce); void intel_context_enter_engine(struct intel_context *ce); void intel_context_exit_engine(struct intel_context *ce); static inline void intel_context_enter(struct intel_context *ce) { lockdep_assert_held(&ce->timeline->mutex); if (!ce->active_count++) ce->ops->enter(ce); } static inline void intel_context_mark_active(struct intel_context *ce) { lockdep_assert_held(&ce->timeline->mutex); ++ce->active_count; } static inline void intel_context_exit(struct intel_context *ce) { lockdep_assert_held(&ce->timeline->mutex); GEM_BUG_ON(!ce->active_count); if (!--ce->active_count) ce->ops->exit(ce); } static inline struct intel_context *intel_context_get(struct intel_context *ce) { kref_get(&ce->ref); return ce; } static inline void intel_context_put(struct intel_context *ce) { kref_put(&ce->ref, ce->ops->destroy); } static inline struct intel_timeline *__must_check intel_context_timeline_lock(struct intel_context *ce) __acquires(&ce->timeline->mutex) { struct intel_timeline *tl = ce->timeline; int err; err = mutex_lock_interruptible(&tl->mutex); if (err) return ERR_PTR(err); return tl; } static inline void intel_context_timeline_unlock(struct intel_timeline *tl) __releases(&tl->mutex) { mutex_unlock(&tl->mutex); } int intel_context_prepare_remote_request(struct intel_context *ce, struct i915_request *rq); struct i915_request *intel_context_create_request(struct intel_context *ce); static inline struct intel_ring *__intel_context_ring_size(u64 sz) { return u64_to_ptr(struct intel_ring, sz); } static inline bool intel_context_is_barrier(const struct intel_context *ce) { return test_bit(CONTEXT_BARRIER_BIT, &ce->flags); } static inline bool intel_context_is_closed(const struct intel_context *ce) { return test_bit(CONTEXT_CLOSED_BIT, &ce->flags); } static inline bool intel_context_has_inflight(const struct intel_context *ce) { return test_bit(COPS_HAS_INFLIGHT_BIT, &ce->ops->flags); } static inline bool intel_context_use_semaphores(const struct intel_context *ce) { return test_bit(CONTEXT_USE_SEMAPHORES, &ce->flags); } static inline void intel_context_set_use_semaphores(struct intel_context *ce) { set_bit(CONTEXT_USE_SEMAPHORES, &ce->flags); } static inline void intel_context_clear_use_semaphores(struct intel_context *ce) { clear_bit(CONTEXT_USE_SEMAPHORES, &ce->flags); } static inline bool intel_context_is_banned(const struct intel_context *ce) { return test_bit(CONTEXT_BANNED, &ce->flags); } static inline bool intel_context_set_banned(struct intel_context *ce) { return test_and_set_bit(CONTEXT_BANNED, &ce->flags); } static inline bool intel_context_force_single_submission(const struct intel_context *ce) { return test_bit(CONTEXT_FORCE_SINGLE_SUBMISSION, &ce->flags); } static inline void intel_context_set_single_submission(struct intel_context *ce) { __set_bit(CONTEXT_FORCE_SINGLE_SUBMISSION, &ce->flags); } static inline bool intel_context_nopreempt(const struct intel_context *ce) { return test_bit(CONTEXT_NOPREEMPT, &ce->flags); } static inline void intel_context_set_nopreempt(struct intel_context *ce) { set_bit(CONTEXT_NOPREEMPT, &ce->flags); } static inline void intel_context_clear_nopreempt(struct intel_context *ce) { clear_bit(CONTEXT_NOPREEMPT, &ce->flags); } u64 intel_context_get_total_runtime_ns(const struct intel_context *ce); u64 intel_context_get_avg_runtime_ns(struct intel_context *ce); static inline u64 intel_context_clock(void) { /* As we mix CS cycles with CPU clocks, use the raw monotonic clock. */ return ktime_get_raw_fast_ns(); } #endif /* __INTEL_CONTEXT_H__ */
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
You can’t perform that action at this time.