Linux-libre 5.4.49-gnu
[librecmc/linux-libre.git] / drivers / gpu / drm / i915 / gt / intel_context_types.h
1 /*
2  * SPDX-License-Identifier: MIT
3  *
4  * Copyright © 2019 Intel Corporation
5  */
6
7 #ifndef __INTEL_CONTEXT_TYPES__
8 #define __INTEL_CONTEXT_TYPES__
9
10 #include <linux/kref.h>
11 #include <linux/list.h>
12 #include <linux/mutex.h>
13 #include <linux/types.h>
14
15 #include "i915_active_types.h"
16 #include "i915_utils.h"
17 #include "intel_engine_types.h"
18 #include "intel_sseu.h"
19
20 struct i915_gem_context;
21 struct i915_vma;
22 struct intel_context;
23 struct intel_ring;
24
25 struct intel_context_ops {
26         int (*alloc)(struct intel_context *ce);
27
28         int (*pin)(struct intel_context *ce);
29         void (*unpin)(struct intel_context *ce);
30
31         void (*enter)(struct intel_context *ce);
32         void (*exit)(struct intel_context *ce);
33
34         void (*reset)(struct intel_context *ce);
35         void (*destroy)(struct kref *kref);
36 };
37
38 struct intel_context {
39         struct kref ref;
40
41         struct intel_engine_cs *engine;
42         struct intel_engine_cs *inflight;
43 #define intel_context_inflight(ce) ptr_mask_bits((ce)->inflight, 2)
44 #define intel_context_inflight_count(ce) ptr_unmask_bits((ce)->inflight, 2)
45
46         struct i915_address_space *vm;
47         struct i915_gem_context *gem_context;
48
49         struct list_head signal_link;
50         struct list_head signals;
51
52         struct i915_vma *state;
53         struct intel_ring *ring;
54         struct intel_timeline *timeline;
55
56         unsigned long flags;
57 #define CONTEXT_ALLOC_BIT 0
58
59         u32 *lrc_reg_state;
60         u64 lrc_desc;
61
62         unsigned int active_count; /* protected by timeline->mutex */
63
64         atomic_t pin_count;
65         struct mutex pin_mutex; /* guards pinning and associated on-gpuing */
66
67         /**
68          * active: Active tracker for the rq activity (inc. external) on this
69          * intel_context object.
70          */
71         struct i915_active active;
72
73         const struct intel_context_ops *ops;
74
75         /** sseu: Control eu/slice partitioning */
76         struct intel_sseu sseu;
77 };
78
79 #endif /* __INTEL_CONTEXT_TYPES__ */