clk: baikal-t1: Convert to platform device driver
[platform/kernel/linux-starfive.git] / drivers / gpu / drm / i915 / gt / intel_gt_types.h
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2019 Intel Corporation
4  */
5
6 #ifndef __INTEL_GT_TYPES__
7 #define __INTEL_GT_TYPES__
8
9 #include <linux/ktime.h>
10 #include <linux/list.h>
11 #include <linux/llist.h>
12 #include <linux/mutex.h>
13 #include <linux/notifier.h>
14 #include <linux/spinlock.h>
15 #include <linux/types.h>
16 #include <linux/workqueue.h>
17
18 #include "uc/intel_uc.h"
19 #include "intel_gsc.h"
20
21 #include "i915_vma.h"
22 #include "intel_engine_types.h"
23 #include "intel_gt_buffer_pool_types.h"
24 #include "intel_hwconfig.h"
25 #include "intel_llc_types.h"
26 #include "intel_reset_types.h"
27 #include "intel_rc6_types.h"
28 #include "intel_rps_types.h"
29 #include "intel_migrate_types.h"
30 #include "intel_wakeref.h"
31 #include "pxp/intel_pxp_types.h"
32
33 struct drm_i915_private;
34 struct i915_ggtt;
35 struct intel_engine_cs;
36 struct intel_uncore;
37
38 struct intel_mmio_range {
39         u32 start;
40         u32 end;
41 };
42
43 /*
44  * The hardware has multiple kinds of multicast register ranges that need
45  * special register steering (and future platforms are expected to add
46  * additional types).
47  *
48  * During driver startup, we initialize the steering control register to
49  * direct reads to a slice/subslice that are valid for the 'subslice' class
50  * of multicast registers.  If another type of steering does not have any
51  * overlap in valid steering targets with 'subslice' style registers, we will
52  * need to explicitly re-steer reads of registers of the other type.
53  *
54  * Only the replication types that may need additional non-default steering
55  * are listed here.
56  */
57 enum intel_steering_type {
58         L3BANK,
59         MSLICE,
60         LNCF,
61
62         /*
63          * On some platforms there are multiple types of MCR registers that
64          * will always return a non-terminated value at instance (0, 0).  We'll
65          * lump those all into a single category to keep things simple.
66          */
67         INSTANCE0,
68
69         NUM_STEERING_TYPES
70 };
71
72 enum intel_submission_method {
73         INTEL_SUBMISSION_RING,
74         INTEL_SUBMISSION_ELSP,
75         INTEL_SUBMISSION_GUC,
76 };
77
78 struct intel_gt {
79         struct drm_i915_private *i915;
80         struct intel_uncore *uncore;
81         struct i915_ggtt *ggtt;
82
83         struct intel_uc uc;
84         struct intel_gsc gsc;
85
86         struct mutex tlb_invalidate_lock;
87
88         struct i915_wa_list wa_list;
89
90         struct intel_gt_timelines {
91                 spinlock_t lock; /* protects active_list */
92                 struct list_head active_list;
93         } timelines;
94
95         struct intel_gt_requests {
96                 /**
97                  * We leave the user IRQ off as much as possible,
98                  * but this means that requests will finish and never
99                  * be retired once the system goes idle. Set a timer to
100                  * fire periodically while the ring is running. When it
101                  * fires, go retire requests.
102                  */
103                 struct delayed_work retire_work;
104         } requests;
105
106         struct {
107                 struct llist_head list;
108                 struct work_struct work;
109         } watchdog;
110
111         struct intel_wakeref wakeref;
112         atomic_t user_wakeref;
113
114         struct list_head closed_vma;
115         spinlock_t closed_lock; /* guards the list of closed_vma */
116
117         ktime_t last_init_time;
118         struct intel_reset reset;
119
120         /**
121          * Is the GPU currently considered idle, or busy executing
122          * userspace requests? Whilst idle, we allow runtime power
123          * management to power down the hardware and display clocks.
124          * In order to reduce the effect on performance, there
125          * is a slight delay before we do so.
126          */
127         intel_wakeref_t awake;
128
129         u32 clock_frequency;
130         u32 clock_period_ns;
131
132         struct intel_llc llc;
133         struct intel_rc6 rc6;
134         struct intel_rps rps;
135
136         spinlock_t irq_lock;
137         u32 gt_imr;
138         u32 pm_ier;
139         u32 pm_imr;
140
141         u32 pm_guc_events;
142
143         struct {
144                 bool active;
145
146                 /**
147                  * @lock: Lock protecting the below fields.
148                  */
149                 seqcount_mutex_t lock;
150
151                 /**
152                  * @total: Total time this engine was busy.
153                  *
154                  * Accumulated time not counting the most recent block in cases
155                  * where engine is currently busy (active > 0).
156                  */
157                 ktime_t total;
158
159                 /**
160                  * @start: Timestamp of the last idle to active transition.
161                  *
162                  * Idle is defined as active == 0, active is active > 0.
163                  */
164                 ktime_t start;
165         } stats;
166
167         struct intel_engine_cs *engine[I915_NUM_ENGINES];
168         struct intel_engine_cs *engine_class[MAX_ENGINE_CLASS + 1]
169                                             [MAX_ENGINE_INSTANCE + 1];
170         enum intel_submission_method submission_method;
171
172         /*
173          * Default address space (either GGTT or ppGTT depending on arch).
174          *
175          * Reserved for exclusive use by the kernel.
176          */
177         struct i915_address_space *vm;
178
179         /*
180          * A pool of objects to use as shadow copies of client batch buffers
181          * when the command parser is enabled. Prevents the client from
182          * modifying the batch contents after software parsing.
183          *
184          * Buffers older than 1s are periodically reaped from the pool,
185          * or may be reclaimed by the shrinker before then.
186          */
187         struct intel_gt_buffer_pool buffer_pool;
188
189         struct i915_vma *scratch;
190
191         struct intel_migrate migrate;
192
193         const struct intel_mmio_range *steering_table[NUM_STEERING_TYPES];
194
195         struct {
196                 u8 groupid;
197                 u8 instanceid;
198         } default_steering;
199
200         /*
201          * Base of per-tile GTTMMADR where we can derive the MMIO and the GGTT.
202          */
203         phys_addr_t phys_addr;
204
205         struct intel_gt_info {
206                 unsigned int id;
207
208                 intel_engine_mask_t engine_mask;
209
210                 u32 l3bank_mask;
211
212                 u8 num_engines;
213
214                 /* General presence of SFC units */
215                 u8 sfc_mask;
216
217                 /* Media engine access to SFC per instance */
218                 u8 vdbox_sfc_access;
219
220                 /* Slice/subslice/EU info */
221                 struct sseu_dev_info sseu;
222
223                 unsigned long mslice_mask;
224
225                 /** @hwconfig: hardware configuration data */
226                 struct intel_hwconfig hwconfig;
227         } info;
228
229         struct {
230                 u8 uc_index;
231                 u8 wb_index; /* Only used on HAS_L3_CCS_READ() platforms */
232         } mocs;
233
234         struct intel_pxp pxp;
235
236         /* gt/gtN sysfs */
237         struct kobject sysfs_gt;
238 };
239
240 enum intel_gt_scratch_field {
241         /* 8 bytes */
242         INTEL_GT_SCRATCH_FIELD_DEFAULT = 0,
243
244         /* 8 bytes */
245         INTEL_GT_SCRATCH_FIELD_RENDER_FLUSH = 128,
246
247         /* 8 bytes */
248         INTEL_GT_SCRATCH_FIELD_COHERENTL3_WA = 256,
249
250         /* 6 * 8 bytes */
251         INTEL_GT_SCRATCH_FIELD_PERF_CS_GPR = 2048,
252
253         /* 4 bytes */
254         INTEL_GT_SCRATCH_FIELD_PERF_PREDICATE_RESULT_1 = 2096,
255 };
256
257 #endif /* __INTEL_GT_TYPES_H__ */