.. | .. |
---|
30 | 30 | #include <linux/types.h> |
---|
31 | 31 | |
---|
32 | 32 | struct ttm_tt; |
---|
33 | | -struct ttm_mem_reg; |
---|
| 33 | +struct ttm_resource; |
---|
34 | 34 | struct ttm_buffer_object; |
---|
35 | 35 | struct ttm_operation_ctx; |
---|
36 | 36 | |
---|
.. | .. |
---|
42 | 42 | #define TTM_PAGE_FLAG_SG (1 << 8) |
---|
43 | 43 | #define TTM_PAGE_FLAG_NO_RETRY (1 << 9) |
---|
44 | 44 | |
---|
| 45 | +#define TTM_PAGE_FLAG_PRIV_POPULATED (1 << 31) |
---|
| 46 | + |
---|
45 | 47 | enum ttm_caching_state { |
---|
46 | 48 | tt_uncached, |
---|
47 | 49 | tt_wc, |
---|
48 | 50 | tt_cached |
---|
49 | 51 | }; |
---|
50 | 52 | |
---|
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 | | - |
---|
86 | 53 | /** |
---|
87 | 54 | * struct ttm_tt |
---|
88 | 55 | * |
---|
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. |
---|
93 | 56 | * @pages: Array of pages backing the data. |
---|
94 | 57 | * @num_pages: Number of pages in the page array. |
---|
95 | 58 | * @bdev: Pointer to the current struct ttm_bo_device. |
---|
.. | .. |
---|
103 | 66 | * memory. |
---|
104 | 67 | */ |
---|
105 | 68 | struct ttm_tt { |
---|
106 | | - struct ttm_bo_device *bdev; |
---|
107 | | - struct ttm_backend_func *func; |
---|
108 | 69 | struct page **pages; |
---|
109 | 70 | uint32_t page_flags; |
---|
110 | 71 | unsigned long num_pages; |
---|
111 | 72 | struct sg_table *sg; /* for SG objects via dma-buf */ |
---|
112 | 73 | struct file *swap_storage; |
---|
113 | 74 | enum ttm_caching_state caching_state; |
---|
114 | | - enum { |
---|
115 | | - tt_bound, |
---|
116 | | - tt_unbound, |
---|
117 | | - tt_unpopulated, |
---|
118 | | - } state; |
---|
119 | 75 | }; |
---|
| 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 | +} |
---|
120 | 91 | |
---|
121 | 92 | /** |
---|
122 | 93 | * struct ttm_dma_tt |
---|
.. | .. |
---|
176 | 147 | void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma); |
---|
177 | 148 | |
---|
178 | 149 | /** |
---|
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 | | -/** |
---|
190 | 150 | * ttm_ttm_destroy: |
---|
191 | 151 | * |
---|
192 | 152 | * @ttm: The struct ttm_tt. |
---|
193 | 153 | * |
---|
194 | 154 | * Unbind, unpopulate and destroy common struct ttm_tt. |
---|
195 | 155 | */ |
---|
196 | | -void ttm_tt_destroy(struct ttm_tt *ttm); |
---|
| 156 | +void ttm_tt_destroy(struct ttm_bo_device *bdev, struct ttm_tt *ttm); |
---|
197 | 157 | |
---|
198 | 158 | /** |
---|
199 | | - * ttm_ttm_unbind: |
---|
| 159 | + * ttm_tt_destroy_common: |
---|
200 | 160 | * |
---|
201 | | - * @ttm: The struct ttm_tt. |
---|
202 | | - * |
---|
203 | | - * Unbind a struct ttm_tt. |
---|
| 161 | + * Called from driver to destroy common path. |
---|
204 | 162 | */ |
---|
205 | | -void ttm_tt_unbind(struct ttm_tt *ttm); |
---|
| 163 | +void ttm_tt_destroy_common(struct ttm_bo_device *bdev, struct ttm_tt *ttm); |
---|
206 | 164 | |
---|
207 | 165 | /** |
---|
208 | 166 | * ttm_tt_swapin: |
---|
.. | .. |
---|
227 | 185 | * and cache flushes and potential page splitting / combining. |
---|
228 | 186 | */ |
---|
229 | 187 | 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); |
---|
231 | 189 | |
---|
232 | 190 | /** |
---|
233 | 191 | * ttm_tt_populate - allocate pages for a ttm |
---|
.. | .. |
---|
236 | 194 | * |
---|
237 | 195 | * Calls the driver method to allocate pages for a ttm |
---|
238 | 196 | */ |
---|
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); |
---|
240 | 198 | |
---|
241 | 199 | /** |
---|
242 | 200 | * ttm_tt_unpopulate - free pages from a ttm |
---|
.. | .. |
---|
245 | 203 | * |
---|
246 | 204 | * Calls the driver method to free all pages from a ttm |
---|
247 | 205 | */ |
---|
248 | | -void ttm_tt_unpopulate(struct ttm_tt *ttm); |
---|
| 206 | +void ttm_tt_unpopulate(struct ttm_bo_device *bdev, struct ttm_tt *ttm); |
---|
249 | 207 | |
---|
250 | 208 | #if IS_ENABLED(CONFIG_AGP) |
---|
251 | 209 | #include <linux/agp_backend.h> |
---|
.. | .. |
---|
265 | 223 | struct ttm_tt *ttm_agp_tt_create(struct ttm_buffer_object *bo, |
---|
266 | 224 | struct agp_bridge_data *bridge, |
---|
267 | 225 | 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); |
---|
270 | 230 | #endif |
---|
271 | 231 | |
---|
272 | 232 | #endif |
---|