Rev 1125 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1125 | Rev 1126 | ||
---|---|---|---|
Line 33... | Line 33... | ||
33 | #include |
33 | #include |
Line 34... | Line 34... | ||
34 | 34 | ||
35 | #include "radeon_drm.h" |
35 | #include "radeon_drm.h" |
36 | #include "radeon.h" |
36 | #include "radeon.h" |
- | 37 | #include |
|
Line 37... | Line 38... | ||
37 | #include |
38 | #include "radeon_object.h" |
38 | 39 | ||
Line 39... | Line -... | ||
39 | int radeon_gart_bind(struct radeon_device *rdev, unsigned offset, |
- | |
40 | int pages, u32_t *pagelist); |
- | |
41 | - | ||
42 | - | ||
43 | #define TTM_PL_SYSTEM 0 |
- | |
44 | #define TTM_PL_TT 1 |
- | |
45 | #define TTM_PL_VRAM 2 |
- | |
46 | #define TTM_PL_PRIV0 3 |
- | |
47 | #define TTM_PL_PRIV1 4 |
- | |
48 | #define TTM_PL_PRIV2 5 |
- | |
49 | #define TTM_PL_PRIV3 6 |
- | |
50 | #define TTM_PL_PRIV4 7 |
- | |
51 | #define TTM_PL_PRIV5 8 |
- | |
52 | #define TTM_PL_SWAPPED 15 |
- | |
53 | - | ||
54 | #define TTM_PL_FLAG_SYSTEM (1 << TTM_PL_SYSTEM) |
- | |
55 | #define TTM_PL_FLAG_TT (1 << TTM_PL_TT) |
- | |
56 | #define TTM_PL_FLAG_VRAM (1 << TTM_PL_VRAM) |
- | |
57 | #define TTM_PL_FLAG_PRIV0 (1 << TTM_PL_PRIV0) |
- | |
58 | #define TTM_PL_FLAG_PRIV1 (1 << TTM_PL_PRIV1) |
- | |
59 | #define TTM_PL_FLAG_PRIV2 (1 << TTM_PL_PRIV2) |
- | |
60 | #define TTM_PL_FLAG_PRIV3 (1 << TTM_PL_PRIV3) |
- | |
61 | #define TTM_PL_FLAG_PRIV4 (1 << TTM_PL_PRIV4) |
- | |
62 | #define TTM_PL_FLAG_PRIV5 (1 << TTM_PL_PRIV5) |
- | |
63 | #define TTM_PL_FLAG_SWAPPED (1 << TTM_PL_SWAPPED) |
- | |
64 | #define TTM_PL_MASK_MEM 0x0000FFFF |
- | |
65 | - | ||
66 | - | ||
67 | struct ttm_mem_type_manager { |
- | |
68 | - | ||
69 | /* |
- | |
70 | * No protection. Constant from start. |
- | |
71 | */ |
- | |
72 | - | ||
73 | bool has_type; |
- | |
74 | bool use_type; |
- | |
75 | uint32_t flags; |
- | |
76 | unsigned long gpu_offset; |
- | |
77 | unsigned long io_offset; |
- | |
78 | unsigned long io_size; |
- | |
79 | void *io_addr; |
- | |
80 | uint64_t size; |
- | |
81 | uint32_t available_caching; |
- | |
82 | uint32_t default_caching; |
- | |
83 | - | ||
84 | /* |
- | |
85 | * Protected by the bdev->lru_lock. |
- | |
86 | * TODO: Consider one lru_lock per ttm_mem_type_manager. |
- | |
87 | * Plays ill with list removal, though. |
- | |
88 | */ |
- | |
89 | - | ||
90 | struct drm_mm manager; |
- | |
91 | struct list_head lru; |
- | |
92 | }; |
- | |
93 | - | ||
94 | struct ttm_bo_driver { |
- | |
95 | const uint32_t *mem_type_prio; |
- | |
96 | const uint32_t *mem_busy_prio; |
- | |
97 | uint32_t num_mem_type_prio; |
- | |
98 | uint32_t num_mem_busy_prio; |
- | |
99 | - | ||
100 | /** |
- | |
101 | * struct ttm_bo_driver member create_ttm_backend_entry |
- | |
102 | * |
- | |
103 | * @bdev: The buffer object device. |
- | |
104 | * |
- | |
105 | * Create a driver specific struct ttm_backend. |
- | |
106 | */ |
- | |
107 | - | ||
108 | // struct ttm_backend *(*create_ttm_backend_entry)(struct ttm_bo_device *bdev); |
- | |
109 | - | ||
110 | /** |
- | |
111 | * struct ttm_bo_driver member invalidate_caches |
- | |
112 | * |
- | |
113 | * @bdev: the buffer object device. |
- | |
114 | * @flags: new placement of the rebound buffer object. |
- | |
115 | * |
- | |
116 | * A previosly evicted buffer has been rebound in a |
- | |
117 | * potentially new location. Tell the driver that it might |
- | |
118 | * consider invalidating read (texture) caches on the next command |
- | |
119 | * submission as a consequence. |
- | |
120 | */ |
- | |
121 | - | ||
122 | // int (*invalidate_caches) (struct ttm_bo_device *bdev, uint32_t flags); |
- | |
123 | // int (*init_mem_type) (struct ttm_bo_device *bdev, uint32_t type, |
- | |
124 | // struct ttm_mem_type_manager *man); |
- | |
125 | /** |
- | |
126 | * struct ttm_bo_driver member evict_flags: |
- | |
127 | * |
- | |
128 | * @bo: the buffer object to be evicted |
- | |
129 | * |
- | |
130 | * Return the bo flags for a buffer which is not mapped to the hardware. |
- | |
131 | * These will be placed in proposed_flags so that when the move is |
- | |
132 | * finished, they'll end up in bo->mem.flags |
- | |
133 | */ |
- | |
134 | - | ||
135 | // uint32_t(*evict_flags) (struct ttm_buffer_object *bo); |
- | |
136 | /** |
- | |
137 | * struct ttm_bo_driver member move: |
- | |
138 | * |
- | |
139 | * @bo: the buffer to move |
- | |
140 | * @evict: whether this motion is evicting the buffer from |
- | |
141 | * the graphics address space |
- | |
142 | * @interruptible: Use interruptible sleeps if possible when sleeping. |
- | |
143 | * @no_wait: whether this should give up and return -EBUSY |
- | |
144 | * if this move would require sleeping |
- | |
145 | * @new_mem: the new memory region receiving the buffer |
- | |
146 | * |
- | |
147 | * Move a buffer between two memory regions. |
- | |
148 | */ |
- | |
149 | // int (*move) (struct ttm_buffer_object *bo, |
- | |
150 | // bool evict, bool interruptible, |
- | |
151 | // bool no_wait, struct ttm_mem_reg *new_mem); |
- | |
152 | - | ||
153 | /** |
- | |
154 | * struct ttm_bo_driver_member verify_access |
- | |
155 | * |
- | |
156 | * @bo: Pointer to a buffer object. |
- | |
157 | * @filp: Pointer to a struct file trying to access the object. |
- | |
158 | * |
- | |
159 | * Called from the map / write / read methods to verify that the |
- | |
160 | * caller is permitted to access the buffer object. |
- | |
161 | * This member may be set to NULL, which will refuse this kind of |
- | |
162 | * access for all buffer objects. |
- | |
163 | * This function should return 0 if access is granted, -EPERM otherwise. |
- | |
164 | */ |
- | |
165 | // int (*verify_access) (struct ttm_buffer_object *bo, |
- | |
166 | // struct file *filp); |
- | |
167 | - | ||
168 | /** |
- | |
169 | * In case a driver writer dislikes the TTM fence objects, |
- | |
170 | * the driver writer can replace those with sync objects of |
- | |
171 | * his / her own. If it turns out that no driver writer is |
- | |
172 | * using these. I suggest we remove these hooks and plug in |
- | |
173 | * fences directly. The bo driver needs the following functionality: |
- | |
174 | * See the corresponding functions in the fence object API |
- | |
175 | * documentation. |
- | |
176 | */ |
- | |
177 | - | ||
178 | // bool (*sync_obj_signaled) (void *sync_obj, void *sync_arg); |
- | |
179 | // int (*sync_obj_wait) (void *sync_obj, void *sync_arg, |
- | |
180 | // bool lazy, bool interruptible); |
- | |
181 | // int (*sync_obj_flush) (void *sync_obj, void *sync_arg); |
- | |
182 | // void (*sync_obj_unref) (void **sync_obj); |
- | |
183 | // void *(*sync_obj_ref) (void *sync_obj); |
- | |
184 | }; |
- | |
185 | - | ||
186 | #define TTM_NUM_MEM_TYPES 8 |
- | |
187 | - | ||
188 | - | ||
189 | struct ttm_bo_device { |
- | |
190 | - | ||
191 | /* |
- | |
192 | * Constant after bo device init / atomic. |
- | |
193 | */ |
- | |
194 | - | ||
195 | // struct ttm_mem_global *mem_glob; |
- | |
196 | struct ttm_bo_driver *driver; |
- | |
197 | // struct page *dummy_read_page; |
- | |
198 | // struct ttm_mem_shrink shrink; |
- | |
199 | - | ||
200 | size_t ttm_bo_extra_size; |
- | |
201 | size_t ttm_bo_size; |
- | |
202 | - | ||
203 | // rwlock_t vm_lock; |
- | |
204 | /* |
- | |
205 | * Protected by the vm lock. |
- | |
206 | */ |
- | |
207 | struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES]; |
- | |
208 | // struct rb_root addr_space_rb; |
- | |
209 | struct drm_mm addr_space_mm; |
- | |
210 | - | ||
211 | /* |
- | |
212 | * Might want to change this to one lock per manager. |
- | |
213 | */ |
- | |
214 | // spinlock_t lru_lock; |
- | |
215 | /* |
- | |
216 | * Protected by the lru lock. |
- | |
217 | */ |
- | |
218 | struct list_head ddestroy; |
- | |
219 | struct list_head swap_lru; |
- | |
220 | - | ||
221 | /* |
- | |
222 | * Protected by load / firstopen / lastclose /unload sync. |
- | |
223 | */ |
- | |
224 | - | ||
225 | bool nice_mode; |
- | |
226 | // struct address_space *dev_mapping; |
- | |
227 | - | ||
228 | /* |
- | |
229 | * Internal protection. |
- | |
230 | */ |
- | |
231 | - | ||
232 | // struct delayed_work wq; |
- | |
233 | }; |
- | |
234 | - | ||
235 | struct ttm_mem_reg { |
- | |
236 | struct drm_mm_node *mm_node; |
- | |
237 | unsigned long size; |
- | |
238 | unsigned long num_pages; |
- | |
239 | uint32_t page_alignment; |
- | |
240 | uint32_t mem_type; |
- | |
241 | uint32_t placement; |
- | |
242 | }; |
- | |
243 | - | ||
244 | enum ttm_bo_type { |
- | |
245 | ttm_bo_type_device, |
- | |
246 | ttm_bo_type_user, |
- | |
247 | ttm_bo_type_kernel |
- | |
248 | }; |
- | |
249 | - | ||
250 | struct ttm_buffer_object { |
- | |
251 | /** |
- | |
252 | * Members constant at init. |
- | |
253 | */ |
- | |
254 | - | ||
255 | struct ttm_bo_device *bdev; |
- | |
256 | unsigned long buffer_start; |
- | |
257 | enum ttm_bo_type type; |
- | |
258 | void (*destroy) (struct ttm_buffer_object *); |
- | |
259 | unsigned long num_pages; |
- | |
260 | uint64_t addr_space_offset; |
- | |
261 | size_t acc_size; |
- | |
262 | - | ||
263 | /** |
- | |
264 | * Members not needing protection. |
- | |
265 | */ |
- | |
266 | - | ||
267 | // struct kref kref; |
- | |
268 | // struct kref list_kref; |
- | |
269 | // wait_queue_head_t event_queue; |
- | |
270 | // spinlock_t lock; |
- | |
271 | - | ||
272 | /** |
- | |
273 | * Members protected by the bo::reserved lock. |
- | |
274 | */ |
- | |
275 | - | ||
276 | uint32_t proposed_placement; |
- | |
277 | struct ttm_mem_reg mem; |
- | |
278 | // struct file *persistant_swap_storage; |
- | |
279 | // struct ttm_tt *ttm; |
- | |
280 | bool evicted; |
- | |
281 | - | ||
282 | /** |
- | |
283 | * Members protected by the bo::reserved lock only when written to. |
- | |
284 | */ |
- | |
285 | - | ||
286 | // atomic_t cpu_writers; |
- | |
287 | - | ||
288 | /** |
- | |
289 | * Members protected by the bdev::lru_lock. |
- | |
290 | */ |
- | |
291 | - | ||
292 | struct list_head lru; |
- | |
293 | struct list_head ddestroy; |
- | |
294 | struct list_head swap; |
- | |
295 | uint32_t val_seq; |
- | |
296 | bool seq_valid; |
- | |
297 | - | ||
298 | /** |
- | |
299 | * Members protected by the bdev::lru_lock |
- | |
300 | * only when written to. |
- | |
301 | */ |
- | |
302 | - | ||
303 | // atomic_t reserved; |
- | |
304 | - | ||
305 | - | ||
306 | /** |
- | |
307 | * Members protected by the bo::lock |
- | |
308 | */ |
- | |
309 | - | ||
310 | void *sync_obj_arg; |
- | |
311 | void *sync_obj; |
- | |
312 | unsigned long priv_flags; |
- | |
313 | - | ||
314 | /** |
- | |
315 | * Members protected by the bdev::vm_lock |
- | |
316 | */ |
- | |
317 | - | ||
318 | // struct rb_node vm_rb; |
- | |
319 | struct drm_mm_node *vm_node; |
- | |
320 | - | ||
321 | - | ||
322 | /** |
- | |
323 | * Special members that are protected by the reserve lock |
- | |
324 | * and the bo::lock when written to. Can be read with |
- | |
325 | * either of these locks held. |
- | |
326 | */ |
- | |
327 | - | ||
328 | unsigned long offset; |
- | |
329 | uint32_t cur_placement; |
- | |
330 | }; |
- | |
331 | - | ||
332 | struct radeon_object |
- | |
333 | { |
- | |
334 | struct ttm_buffer_object tobj; |
- | |
335 | struct list_head list; |
- | |
336 | struct radeon_device *rdev; |
- | |
337 | // struct drm_gem_object *gobj; |
- | |
338 | // struct ttm_bo_kmap_obj kmap; |
- | |
339 | - | ||
340 | unsigned pin_count; |
- | |
341 | uint64_t gpu_addr; |
- | |
342 | void *kptr; |
- | |
343 | bool is_iomem; |
- | |
344 | - | ||
345 | struct drm_mm_node *mm_node; |
- | |
346 | u32_t vm_addr; |
- | |
347 | u32_t cpu_addr; |
- | |
Line 348... | Line 40... | ||
348 | u32_t flags; |
40 | int radeon_gart_bind(struct radeon_device *rdev, unsigned offset, |
349 | }; |
41 | int pages, u32_t *pagelist); |