forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/include/drm/ttm/ttm_tt.h
....@@ -30,7 +30,7 @@
3030 #include <linux/types.h>
3131
3232 struct ttm_tt;
33
-struct ttm_mem_reg;
33
+struct ttm_resource;
3434 struct ttm_buffer_object;
3535 struct ttm_operation_ctx;
3636
....@@ -42,54 +42,17 @@
4242 #define TTM_PAGE_FLAG_SG (1 << 8)
4343 #define TTM_PAGE_FLAG_NO_RETRY (1 << 9)
4444
45
+#define TTM_PAGE_FLAG_PRIV_POPULATED (1 << 31)
46
+
4547 enum ttm_caching_state {
4648 tt_uncached,
4749 tt_wc,
4850 tt_cached
4951 };
5052
51
-struct ttm_backend_func {
52
- /**
53
- * struct ttm_backend_func member bind
54
- *
55
- * @ttm: Pointer to a struct ttm_tt.
56
- * @bo_mem: Pointer to a struct ttm_mem_reg describing the
57
- * memory type and location for binding.
58
- *
59
- * Bind the backend pages into the aperture in the location
60
- * indicated by @bo_mem. This function should be able to handle
61
- * differences between aperture and system page sizes.
62
- */
63
- int (*bind) (struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem);
64
-
65
- /**
66
- * struct ttm_backend_func member unbind
67
- *
68
- * @ttm: Pointer to a struct ttm_tt.
69
- *
70
- * Unbind previously bound backend pages. This function should be
71
- * able to handle differences between aperture and system page sizes.
72
- */
73
- int (*unbind) (struct ttm_tt *ttm);
74
-
75
- /**
76
- * struct ttm_backend_func member destroy
77
- *
78
- * @ttm: Pointer to a struct ttm_tt.
79
- *
80
- * Destroy the backend. This will be call back from ttm_tt_destroy so
81
- * don't call ttm_tt_destroy from the callback or infinite loop.
82
- */
83
- void (*destroy) (struct ttm_tt *ttm);
84
-};
85
-
8653 /**
8754 * struct ttm_tt
8855 *
89
- * @bdev: Pointer to a struct ttm_bo_device.
90
- * @func: Pointer to a struct ttm_backend_func that describes
91
- * the backend methods.
92
- * pointer.
9356 * @pages: Array of pages backing the data.
9457 * @num_pages: Number of pages in the page array.
9558 * @bdev: Pointer to the current struct ttm_bo_device.
....@@ -103,20 +66,28 @@
10366 * memory.
10467 */
10568 struct ttm_tt {
106
- struct ttm_bo_device *bdev;
107
- struct ttm_backend_func *func;
10869 struct page **pages;
10970 uint32_t page_flags;
11071 unsigned long num_pages;
11172 struct sg_table *sg; /* for SG objects via dma-buf */
11273 struct file *swap_storage;
11374 enum ttm_caching_state caching_state;
114
- enum {
115
- tt_bound,
116
- tt_unbound,
117
- tt_unpopulated,
118
- } state;
11975 };
76
+
77
+static inline bool ttm_tt_is_populated(struct ttm_tt *tt)
78
+{
79
+ return tt->page_flags & TTM_PAGE_FLAG_PRIV_POPULATED;
80
+}
81
+
82
+static inline void ttm_tt_set_unpopulated(struct ttm_tt *tt)
83
+{
84
+ tt->page_flags &= ~TTM_PAGE_FLAG_PRIV_POPULATED;
85
+}
86
+
87
+static inline void ttm_tt_set_populated(struct ttm_tt *tt)
88
+{
89
+ tt->page_flags |= TTM_PAGE_FLAG_PRIV_POPULATED;
90
+}
12091
12192 /**
12293 * struct ttm_dma_tt
....@@ -176,33 +147,20 @@
176147 void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma);
177148
178149 /**
179
- * ttm_ttm_bind:
180
- *
181
- * @ttm: The struct ttm_tt containing backing pages.
182
- * @bo_mem: The struct ttm_mem_reg identifying the binding location.
183
- *
184
- * Bind the pages of @ttm to an aperture location identified by @bo_mem
185
- */
186
-int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem,
187
- struct ttm_operation_ctx *ctx);
188
-
189
-/**
190150 * ttm_ttm_destroy:
191151 *
192152 * @ttm: The struct ttm_tt.
193153 *
194154 * Unbind, unpopulate and destroy common struct ttm_tt.
195155 */
196
-void ttm_tt_destroy(struct ttm_tt *ttm);
156
+void ttm_tt_destroy(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
197157
198158 /**
199
- * ttm_ttm_unbind:
159
+ * ttm_tt_destroy_common:
200160 *
201
- * @ttm: The struct ttm_tt.
202
- *
203
- * Unbind a struct ttm_tt.
161
+ * Called from driver to destroy common path.
204162 */
205
-void ttm_tt_unbind(struct ttm_tt *ttm);
163
+void ttm_tt_destroy_common(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
206164
207165 /**
208166 * ttm_tt_swapin:
....@@ -227,7 +185,7 @@
227185 * and cache flushes and potential page splitting / combining.
228186 */
229187 int ttm_tt_set_placement_caching(struct ttm_tt *ttm, uint32_t placement);
230
-int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage);
188
+int ttm_tt_swapout(struct ttm_bo_device *bdev, struct ttm_tt *ttm, struct file *persistent_swap_storage);
231189
232190 /**
233191 * ttm_tt_populate - allocate pages for a ttm
....@@ -236,7 +194,7 @@
236194 *
237195 * Calls the driver method to allocate pages for a ttm
238196 */
239
-int ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx);
197
+int ttm_tt_populate(struct ttm_bo_device *bdev, struct ttm_tt *ttm, struct ttm_operation_ctx *ctx);
240198
241199 /**
242200 * ttm_tt_unpopulate - free pages from a ttm
....@@ -245,7 +203,7 @@
245203 *
246204 * Calls the driver method to free all pages from a ttm
247205 */
248
-void ttm_tt_unpopulate(struct ttm_tt *ttm);
206
+void ttm_tt_unpopulate(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
249207
250208 #if IS_ENABLED(CONFIG_AGP)
251209 #include <linux/agp_backend.h>
....@@ -265,8 +223,10 @@
265223 struct ttm_tt *ttm_agp_tt_create(struct ttm_buffer_object *bo,
266224 struct agp_bridge_data *bridge,
267225 uint32_t page_flags);
268
-int ttm_agp_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx);
269
-void ttm_agp_tt_unpopulate(struct ttm_tt *ttm);
226
+int ttm_agp_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem);
227
+void ttm_agp_unbind(struct ttm_tt *ttm);
228
+void ttm_agp_destroy(struct ttm_tt *ttm);
229
+bool ttm_agp_is_bound(struct ttm_tt *ttm);
270230 #endif
271231
272232 #endif