forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/gpu/drm/i915/gvt/gtt.h
....@@ -88,14 +88,15 @@
8888 void (*mm_free_page_table)(struct intel_vgpu_mm *mm);
8989 struct list_head oos_page_use_list_head;
9090 struct list_head oos_page_free_list_head;
91
+ struct mutex ppgtt_mm_lock;
9192 struct list_head ppgtt_mm_lru_list_head;
9293
9394 struct page *scratch_page;
9495 unsigned long scratch_mfn;
9596 };
9697
97
-typedef enum {
98
- GTT_TYPE_INVALID = -1,
98
+enum intel_gvt_gtt_type {
99
+ GTT_TYPE_INVALID = 0,
99100
100101 GTT_TYPE_GGTT_PTE,
101102
....@@ -123,7 +124,7 @@
123124 GTT_TYPE_PPGTT_PML4_PT,
124125
125126 GTT_TYPE_MAX,
126
-} intel_gvt_gtt_type_t;
127
+};
127128
128129 enum intel_gvt_mm_type {
129130 INTEL_GVT_MM_GGTT,
....@@ -131,6 +132,12 @@
131132 };
132133
133134 #define GVT_RING_CTX_NR_PDPS GEN8_3LVL_PDPES
135
+
136
+struct intel_gvt_partial_pte {
137
+ unsigned long offset;
138
+ u64 data;
139
+ struct list_head list;
140
+};
134141
135142 struct intel_vgpu_mm {
136143 enum intel_gvt_mm_type type;
....@@ -141,7 +148,7 @@
141148
142149 union {
143150 struct {
144
- intel_gvt_gtt_type_t root_entry_type;
151
+ enum intel_gvt_gtt_type root_entry_type;
145152 /*
146153 * The 4 PDPs in ring context. For 48bit addressing,
147154 * only PDP0 is valid and point to PML4. For 32it
....@@ -153,17 +160,20 @@
153160
154161 struct list_head list;
155162 struct list_head lru_list;
163
+ struct list_head link; /* possible LRI shadow mm list */
156164 } ppgtt_mm;
157165 struct {
158166 void *virtual_ggtt;
159
- unsigned long last_partial_off;
160
- u64 last_partial_data;
167
+ /* Save/restore for PM */
168
+ u64 *host_ggtt_aperture;
169
+ u64 *host_ggtt_hidden;
170
+ struct list_head partial_pte_list;
161171 } ggtt_mm;
162172 };
163173 };
164174
165175 struct intel_vgpu_mm *intel_vgpu_create_ppgtt_mm(struct intel_vgpu *vgpu,
166
- intel_gvt_gtt_type_t root_entry_type, u64 pdps[]);
176
+ enum intel_gvt_gtt_type root_entry_type, u64 pdps[]);
167177
168178 static inline void intel_vgpu_mm_get(struct intel_vgpu_mm *mm)
169179 {
....@@ -199,24 +209,24 @@
199209 struct intel_vgpu_scratch_pt scratch_pt[GTT_TYPE_MAX];
200210 };
201211
202
-extern int intel_vgpu_init_gtt(struct intel_vgpu *vgpu);
203
-extern void intel_vgpu_clean_gtt(struct intel_vgpu *vgpu);
212
+int intel_vgpu_init_gtt(struct intel_vgpu *vgpu);
213
+void intel_vgpu_clean_gtt(struct intel_vgpu *vgpu);
204214 void intel_vgpu_reset_ggtt(struct intel_vgpu *vgpu, bool invalidate_old);
205215 void intel_vgpu_invalidate_ppgtt(struct intel_vgpu *vgpu);
206216
207
-extern int intel_gvt_init_gtt(struct intel_gvt *gvt);
208
-void intel_vgpu_reset_gtt(struct intel_vgpu *vgpu);
209
-extern void intel_gvt_clean_gtt(struct intel_gvt *gvt);
217
+int intel_gvt_init_gtt(struct intel_gvt *gvt);
218
+void intel_gvt_clean_gtt(struct intel_gvt *gvt);
210219
211
-extern struct intel_vgpu_mm *intel_gvt_find_ppgtt_mm(struct intel_vgpu *vgpu,
212
- int page_table_level, void *root_entry);
220
+struct intel_vgpu_mm *intel_gvt_find_ppgtt_mm(struct intel_vgpu *vgpu,
221
+ int page_table_level,
222
+ void *root_entry);
213223
214224 struct intel_vgpu_oos_page {
215225 struct intel_vgpu_ppgtt_spt *spt;
216226 struct list_head list;
217227 struct list_head vm_list;
218228 int id;
219
- unsigned char mem[I915_GTT_PAGE_SIZE];
229
+ void *mem;
220230 };
221231
222232 #define GTT_ENTRY_NUM_IN_ONE_PAGE 512
....@@ -227,7 +237,7 @@
227237 struct intel_vgpu *vgpu;
228238
229239 struct {
230
- intel_gvt_gtt_type_t type;
240
+ enum intel_gvt_gtt_type type;
231241 bool pde_ips; /* for 64KB PTEs */
232242 void *vaddr;
233243 struct page *page;
....@@ -235,7 +245,7 @@
235245 } shadow_page;
236246
237247 struct {
238
- intel_gvt_gtt_type_t type;
248
+ enum intel_gvt_gtt_type type;
239249 bool pde_ips; /* for 64KB PTEs */
240250 unsigned long gfn;
241251 unsigned long write_cnt;
....@@ -261,7 +271,7 @@
261271 u64 pdps[]);
262272
263273 struct intel_vgpu_mm *intel_vgpu_get_ppgtt_mm(struct intel_vgpu *vgpu,
264
- intel_gvt_gtt_type_t root_entry_type, u64 pdps[]);
274
+ enum intel_gvt_gtt_type root_entry_type, u64 pdps[]);
265275
266276 int intel_vgpu_put_ppgtt_mm(struct intel_vgpu *vgpu, u64 pdps[]);
267277
....@@ -271,4 +281,7 @@
271281 int intel_vgpu_emulate_ggtt_mmio_write(struct intel_vgpu *vgpu,
272282 unsigned int off, void *p_data, unsigned int bytes);
273283
284
+void intel_vgpu_destroy_all_ppgtt_mm(struct intel_vgpu *vgpu);
285
+void intel_gvt_restore_ggtt(struct intel_gvt *gvt);
286
+
274287 #endif /* _GVT_GTT_H_ */