forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
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,17 @@
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
+ struct list_head partial_pte_list;
161168 } ggtt_mm;
162169 };
163170 };
164171
165172 struct intel_vgpu_mm *intel_vgpu_create_ppgtt_mm(struct intel_vgpu *vgpu,
166
- intel_gvt_gtt_type_t root_entry_type, u64 pdps[]);
173
+ enum intel_gvt_gtt_type root_entry_type, u64 pdps[]);
167174
168175 static inline void intel_vgpu_mm_get(struct intel_vgpu_mm *mm)
169176 {
....@@ -199,24 +206,25 @@
199206 struct intel_vgpu_scratch_pt scratch_pt[GTT_TYPE_MAX];
200207 };
201208
202
-extern int intel_vgpu_init_gtt(struct intel_vgpu *vgpu);
203
-extern void intel_vgpu_clean_gtt(struct intel_vgpu *vgpu);
209
+int intel_vgpu_init_gtt(struct intel_vgpu *vgpu);
210
+void intel_vgpu_clean_gtt(struct intel_vgpu *vgpu);
204211 void intel_vgpu_reset_ggtt(struct intel_vgpu *vgpu, bool invalidate_old);
205212 void intel_vgpu_invalidate_ppgtt(struct intel_vgpu *vgpu);
206213
207
-extern int intel_gvt_init_gtt(struct intel_gvt *gvt);
214
+int intel_gvt_init_gtt(struct intel_gvt *gvt);
208215 void intel_vgpu_reset_gtt(struct intel_vgpu *vgpu);
209
-extern void intel_gvt_clean_gtt(struct intel_gvt *gvt);
216
+void intel_gvt_clean_gtt(struct intel_gvt *gvt);
210217
211
-extern struct intel_vgpu_mm *intel_gvt_find_ppgtt_mm(struct intel_vgpu *vgpu,
212
- int page_table_level, void *root_entry);
218
+struct intel_vgpu_mm *intel_gvt_find_ppgtt_mm(struct intel_vgpu *vgpu,
219
+ int page_table_level,
220
+ void *root_entry);
213221
214222 struct intel_vgpu_oos_page {
215223 struct intel_vgpu_ppgtt_spt *spt;
216224 struct list_head list;
217225 struct list_head vm_list;
218226 int id;
219
- unsigned char mem[I915_GTT_PAGE_SIZE];
227
+ void *mem;
220228 };
221229
222230 #define GTT_ENTRY_NUM_IN_ONE_PAGE 512
....@@ -227,7 +235,7 @@
227235 struct intel_vgpu *vgpu;
228236
229237 struct {
230
- intel_gvt_gtt_type_t type;
238
+ enum intel_gvt_gtt_type type;
231239 bool pde_ips; /* for 64KB PTEs */
232240 void *vaddr;
233241 struct page *page;
....@@ -235,7 +243,7 @@
235243 } shadow_page;
236244
237245 struct {
238
- intel_gvt_gtt_type_t type;
246
+ enum intel_gvt_gtt_type type;
239247 bool pde_ips; /* for 64KB PTEs */
240248 unsigned long gfn;
241249 unsigned long write_cnt;
....@@ -261,7 +269,7 @@
261269 u64 pdps[]);
262270
263271 struct intel_vgpu_mm *intel_vgpu_get_ppgtt_mm(struct intel_vgpu *vgpu,
264
- intel_gvt_gtt_type_t root_entry_type, u64 pdps[]);
272
+ enum intel_gvt_gtt_type root_entry_type, u64 pdps[]);
265273
266274 int intel_vgpu_put_ppgtt_mm(struct intel_vgpu *vgpu, u64 pdps[]);
267275
....@@ -271,4 +279,6 @@
271279 int intel_vgpu_emulate_ggtt_mmio_write(struct intel_vgpu *vgpu,
272280 unsigned int off, void *p_data, unsigned int bytes);
273281
282
+void intel_vgpu_destroy_all_ppgtt_mm(struct intel_vgpu *vgpu);
283
+
274284 #endif /* _GVT_GTT_H_ */