Rev 5078 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4075 | Serge | 1 | /************************************************************************** |
2 | * |
||
6296 | serge | 3 | * Copyright © 2009-2015 VMware, Inc., Palo Alto, CA., USA |
4075 | Serge | 4 | * All Rights Reserved. |
5 | * |
||
6 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
7 | * copy of this software and associated documentation files (the |
||
8 | * "Software"), to deal in the Software without restriction, including |
||
9 | * without limitation the rights to use, copy, modify, merge, publish, |
||
10 | * distribute, sub license, and/or sell copies of the Software, and to |
||
11 | * permit persons to whom the Software is furnished to do so, subject to |
||
12 | * the following conditions: |
||
13 | * |
||
14 | * The above copyright notice and this permission notice (including the |
||
15 | * next paragraph) shall be included in all copies or substantial portions |
||
16 | * of the Software. |
||
17 | * |
||
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
||
21 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
||
22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
||
23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
||
24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
25 | * |
||
26 | **************************************************************************/ |
||
27 | |||
28 | #ifndef _VMWGFX_DRV_H_ |
||
29 | #define _VMWGFX_DRV_H_ |
||
30 | |||
31 | #include "vmwgfx_reg.h" |
||
32 | #include |
||
33 | #include |
||
34 | #include |
||
35 | //#include |
||
36 | #include |
||
37 | #include |
||
5078 | serge | 38 | #include |
4075 | Serge | 39 | #include |
40 | //#include |
||
41 | #include "vmwgfx_fence.h" |
||
42 | |||
6296 | serge | 43 | #define VMWGFX_DRIVER_DATE "20150810" |
4075 | Serge | 44 | #define VMWGFX_DRIVER_MAJOR 2 |
6296 | serge | 45 | #define VMWGFX_DRIVER_MINOR 9 |
46 | #define VMWGFX_DRIVER_PATCHLEVEL 0 |
||
4075 | Serge | 47 | #define VMWGFX_FILE_PAGE_OFFSET 0x00100000 |
48 | #define VMWGFX_FIFO_STATIC_SIZE (1024*1024) |
||
49 | #define VMWGFX_MAX_RELOCATIONS 2048 |
||
50 | #define VMWGFX_MAX_VALIDATIONS 2048 |
||
51 | #define VMWGFX_MAX_DISPLAYS 16 |
||
52 | #define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768 |
||
6296 | serge | 53 | #define VMWGFX_ENABLE_SCREEN_TARGET_OTABLE 1 |
4075 | Serge | 54 | |
4569 | Serge | 55 | /* |
56 | * Perhaps we should have sysfs entries for these. |
||
57 | */ |
||
58 | #define VMWGFX_NUM_GB_CONTEXT 256 |
||
59 | #define VMWGFX_NUM_GB_SHADER 20000 |
||
60 | #define VMWGFX_NUM_GB_SURFACE 32768 |
||
61 | #define VMWGFX_NUM_GB_SCREEN_TARGET VMWGFX_MAX_DISPLAYS |
||
6296 | serge | 62 | #define VMWGFX_NUM_DXCONTEXT 256 |
63 | #define VMWGFX_NUM_DXQUERY 512 |
||
4569 | Serge | 64 | #define VMWGFX_NUM_MOB (VMWGFX_NUM_GB_CONTEXT +\ |
65 | VMWGFX_NUM_GB_SHADER +\ |
||
66 | VMWGFX_NUM_GB_SURFACE +\ |
||
67 | VMWGFX_NUM_GB_SCREEN_TARGET) |
||
68 | |||
4075 | Serge | 69 | #define VMW_PL_GMR TTM_PL_PRIV0 |
70 | #define VMW_PL_FLAG_GMR TTM_PL_FLAG_PRIV0 |
||
4569 | Serge | 71 | #define VMW_PL_MOB TTM_PL_PRIV1 |
72 | #define VMW_PL_FLAG_MOB TTM_PL_FLAG_PRIV1 |
||
4075 | Serge | 73 | |
74 | #define VMW_RES_CONTEXT ttm_driver_type0 |
||
75 | #define VMW_RES_SURFACE ttm_driver_type1 |
||
76 | #define VMW_RES_STREAM ttm_driver_type2 |
||
77 | #define VMW_RES_FENCE ttm_driver_type3 |
||
4569 | Serge | 78 | #define VMW_RES_SHADER ttm_driver_type4 |
4075 | Serge | 79 | |
80 | static inline void outl(u32 v, u16 port) |
||
81 | { |
||
82 | asm volatile("outl %0,%1" : : "a" (v), "dN" (port)); |
||
83 | } |
||
84 | static inline u32 inl(u16 port) |
||
85 | { |
||
86 | u32 v; |
||
87 | asm volatile("inl %1,%0" : "=a" (v) : "dN" (port)); |
||
88 | return v; |
||
89 | } |
||
90 | struct vmw_fpriv { |
||
6296 | serge | 91 | struct drm_master *locked_master; |
92 | struct ttm_object_file *tfile; |
||
93 | struct list_head fence_events; |
||
5078 | serge | 94 | bool gb_aware; |
4075 | Serge | 95 | }; |
96 | |||
97 | struct vmw_dma_buffer { |
||
6296 | serge | 98 | struct ttm_buffer_object base; |
99 | struct list_head res_list; |
||
100 | s32 pin_count; |
||
101 | /* Not ref-counted. Protected by binding_mutex */ |
||
102 | struct vmw_resource *dx_query_ctx; |
||
4075 | Serge | 103 | }; |
104 | |||
105 | /** |
||
106 | * struct vmw_validate_buffer - Carries validation info about buffers. |
||
107 | * |
||
108 | * @base: Validation info for TTM. |
||
109 | * @hash: Hash entry for quick lookup of the TTM buffer object. |
||
110 | * |
||
111 | * This structure contains also driver private validation info |
||
112 | * on top of the info needed by TTM. |
||
113 | */ |
||
114 | struct vmw_validate_buffer { |
||
6296 | serge | 115 | struct ttm_validate_buffer base; |
116 | struct drm_hash_item hash; |
||
4569 | Serge | 117 | bool validate_as_mob; |
4075 | Serge | 118 | }; |
119 | |||
120 | struct vmw_res_func; |
||
121 | struct vmw_resource { |
||
122 | struct kref kref; |
||
123 | struct vmw_private *dev_priv; |
||
124 | int id; |
||
125 | bool avail; |
||
126 | unsigned long backup_size; |
||
127 | bool res_dirty; /* Protected by backup buffer reserved */ |
||
128 | bool backup_dirty; /* Protected by backup buffer reserved */ |
||
6296 | serge | 129 | struct vmw_dma_buffer *backup; |
4075 | Serge | 130 | unsigned long backup_offset; |
6296 | serge | 131 | unsigned long pin_count; /* Protected by resource reserved */ |
4075 | Serge | 132 | const struct vmw_res_func *func; |
133 | struct list_head lru_head; /* Protected by the resource lock */ |
||
134 | struct list_head mob_head; /* Protected by @backup reserved */ |
||
4569 | Serge | 135 | struct list_head binding_head; /* Protected by binding_mutex */ |
4075 | Serge | 136 | void (*res_free) (struct vmw_resource *res); |
137 | void (*hw_destroy) (struct vmw_resource *res); |
||
138 | }; |
||
139 | |||
5078 | serge | 140 | |
141 | /* |
||
142 | * Resources that are managed using ioctls. |
||
143 | */ |
||
4075 | Serge | 144 | enum vmw_res_type { |
145 | vmw_res_context, |
||
146 | vmw_res_surface, |
||
147 | vmw_res_stream, |
||
4569 | Serge | 148 | vmw_res_shader, |
6296 | serge | 149 | vmw_res_dx_context, |
150 | vmw_res_cotable, |
||
151 | vmw_res_view, |
||
4075 | Serge | 152 | vmw_res_max |
153 | }; |
||
154 | |||
5078 | serge | 155 | /* |
156 | * Resources that are managed using command streams. |
||
157 | */ |
||
158 | enum vmw_cmdbuf_res_type { |
||
6296 | serge | 159 | vmw_cmdbuf_res_shader, |
160 | vmw_cmdbuf_res_view |
||
5078 | serge | 161 | }; |
162 | |||
163 | struct vmw_cmdbuf_res_manager; |
||
164 | |||
4075 | Serge | 165 | struct vmw_cursor_snooper { |
166 | struct drm_crtc *crtc; |
||
167 | size_t age; |
||
168 | uint32_t *image; |
||
169 | }; |
||
170 | |||
171 | struct vmw_framebuffer; |
||
172 | struct vmw_surface_offset; |
||
173 | |||
174 | struct vmw_surface { |
||
6296 | serge | 175 | struct vmw_resource res; |
4075 | Serge | 176 | uint32_t flags; |
177 | uint32_t format; |
||
178 | uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES]; |
||
179 | struct drm_vmw_size base_size; |
||
180 | struct drm_vmw_size *sizes; |
||
181 | uint32_t num_sizes; |
||
182 | bool scanout; |
||
6296 | serge | 183 | uint32_t array_size; |
4075 | Serge | 184 | /* TODO so far just a extra pointer */ |
185 | struct vmw_cursor_snooper snooper; |
||
186 | struct vmw_surface_offset *offsets; |
||
187 | SVGA3dTextureFilter autogen_filter; |
||
188 | uint32_t multisample_count; |
||
6296 | serge | 189 | struct list_head view_list; |
4075 | Serge | 190 | }; |
191 | |||
192 | struct vmw_marker_queue { |
||
193 | struct list_head head; |
||
5078 | serge | 194 | u64 lag; |
195 | u64 lag_time; |
||
4075 | Serge | 196 | spinlock_t lock; |
197 | }; |
||
198 | |||
199 | struct vmw_fifo_state { |
||
200 | unsigned long reserved_size; |
||
6296 | serge | 201 | u32 *dynamic_buffer; |
202 | u32 *static_buffer; |
||
4075 | Serge | 203 | unsigned long static_buffer_size; |
204 | bool using_bounce_buffer; |
||
205 | uint32_t capabilities; |
||
206 | struct mutex fifo_mutex; |
||
207 | struct rw_semaphore rwsem; |
||
208 | struct vmw_marker_queue marker_queue; |
||
6296 | serge | 209 | bool dx; |
4075 | Serge | 210 | }; |
211 | |||
212 | struct vmw_relocation { |
||
4569 | Serge | 213 | SVGAMobId *mob_loc; |
4075 | Serge | 214 | SVGAGuestPtr *location; |
215 | uint32_t index; |
||
216 | }; |
||
217 | |||
218 | /** |
||
219 | * struct vmw_res_cache_entry - resource information cache entry |
||
220 | * |
||
221 | * @valid: Whether the entry is valid, which also implies that the execbuf |
||
222 | * code holds a reference to the resource, and it's placed on the |
||
223 | * validation list. |
||
224 | * @handle: User-space handle of a resource. |
||
225 | * @res: Non-ref-counted pointer to the resource. |
||
226 | * |
||
227 | * Used to avoid frequent repeated user-space handle lookups of the |
||
228 | * same resource. |
||
229 | */ |
||
230 | struct vmw_res_cache_entry { |
||
231 | bool valid; |
||
232 | uint32_t handle; |
||
233 | struct vmw_resource *res; |
||
234 | struct vmw_resource_val_node *node; |
||
235 | }; |
||
236 | |||
4569 | Serge | 237 | /** |
238 | * enum vmw_dma_map_mode - indicate how to perform TTM page dma mappings. |
||
239 | */ |
||
240 | enum vmw_dma_map_mode { |
||
241 | vmw_dma_phys, /* Use physical page addresses */ |
||
242 | vmw_dma_alloc_coherent, /* Use TTM coherent pages */ |
||
243 | vmw_dma_map_populate, /* Unmap from DMA just after unpopulate */ |
||
244 | vmw_dma_map_bind, /* Unmap from DMA just before unbind */ |
||
245 | vmw_dma_map_max |
||
246 | }; |
||
247 | |||
248 | /** |
||
249 | * struct vmw_sg_table - Scatter/gather table for binding, with additional |
||
250 | * device-specific information. |
||
251 | * |
||
252 | * @sgt: Pointer to a struct sg_table with binding information |
||
6296 | serge | 253 | * @num_regions: Number of regions with device-address contiguous pages |
4569 | Serge | 254 | */ |
255 | struct vmw_sg_table { |
||
256 | enum vmw_dma_map_mode mode; |
||
257 | struct page **pages; |
||
258 | const dma_addr_t *addrs; |
||
259 | struct sg_table *sgt; |
||
260 | unsigned long num_regions; |
||
261 | unsigned long num_pages; |
||
262 | }; |
||
263 | |||
264 | /** |
||
265 | * struct vmw_piter - Page iterator that iterates over a list of pages |
||
266 | * and DMA addresses that could be either a scatter-gather list or |
||
267 | * arrays |
||
268 | * |
||
269 | * @pages: Array of page pointers to the pages. |
||
270 | * @addrs: DMA addresses to the pages if coherent pages are used. |
||
271 | * @iter: Scatter-gather page iterator. Current position in SG list. |
||
272 | * @i: Current position in arrays. |
||
273 | * @num_pages: Number of pages total. |
||
274 | * @next: Function to advance the iterator. Returns false if past the list |
||
275 | * of pages, true otherwise. |
||
276 | * @dma_address: Function to return the DMA address of the current page. |
||
277 | */ |
||
278 | struct vmw_piter { |
||
279 | struct page **pages; |
||
280 | const dma_addr_t *addrs; |
||
281 | struct sg_page_iter iter; |
||
282 | unsigned long i; |
||
283 | unsigned long num_pages; |
||
284 | bool (*next)(struct vmw_piter *); |
||
285 | dma_addr_t (*dma_address)(struct vmw_piter *); |
||
286 | struct page *(*page)(struct vmw_piter *); |
||
287 | }; |
||
288 | |||
289 | /* |
||
6296 | serge | 290 | * enum vmw_display_unit_type - Describes the display unit |
4569 | Serge | 291 | */ |
6296 | serge | 292 | enum vmw_display_unit_type { |
293 | vmw_du_invalid = 0, |
||
294 | vmw_du_legacy, |
||
295 | vmw_du_screen_object, |
||
296 | vmw_du_screen_target |
||
4569 | Serge | 297 | }; |
298 | |||
299 | |||
4075 | Serge | 300 | struct vmw_sw_context{ |
301 | struct drm_open_hash res_ht; |
||
302 | bool res_ht_initialized; |
||
303 | bool kernel; /**< is the called made from the kernel */ |
||
5078 | serge | 304 | struct vmw_fpriv *fp; |
4075 | Serge | 305 | struct list_head validate_nodes; |
306 | struct vmw_relocation relocs[VMWGFX_MAX_RELOCATIONS]; |
||
307 | uint32_t cur_reloc; |
||
6296 | serge | 308 | struct vmw_validate_buffer val_bufs[VMWGFX_MAX_VALIDATIONS]; |
4075 | Serge | 309 | uint32_t cur_val_buf; |
310 | uint32_t *cmd_bounce; |
||
311 | uint32_t cmd_bounce_size; |
||
312 | struct list_head resource_list; |
||
6296 | serge | 313 | struct list_head ctx_resource_list; /* For contexts and cotables */ |
314 | struct vmw_dma_buffer *cur_query_bo; |
||
4075 | Serge | 315 | struct list_head res_relocations; |
316 | uint32_t *buf_start; |
||
317 | struct vmw_res_cache_entry res_cache[vmw_res_max]; |
||
318 | struct vmw_resource *last_query_ctx; |
||
319 | bool needs_post_query_barrier; |
||
320 | struct vmw_resource *error_resource; |
||
6296 | serge | 321 | struct vmw_ctx_binding_state *staged_bindings; |
322 | bool staged_bindings_inuse; |
||
5078 | serge | 323 | struct list_head staged_cmd_res; |
6296 | serge | 324 | struct vmw_resource_val_node *dx_ctx_node; |
325 | struct vmw_dma_buffer *dx_query_mob; |
||
326 | struct vmw_resource *dx_query_ctx; |
||
327 | struct vmw_cmdbuf_res_manager *man; |
||
4075 | Serge | 328 | }; |
329 | |||
330 | struct vmw_legacy_display; |
||
331 | struct vmw_overlay; |
||
332 | |||
333 | struct vmw_master { |
||
6296 | serge | 334 | struct ttm_lock lock; |
4075 | Serge | 335 | }; |
336 | |||
337 | struct vmw_vga_topology_state { |
||
338 | uint32_t width; |
||
339 | uint32_t height; |
||
340 | uint32_t primary; |
||
341 | uint32_t pos_x; |
||
342 | uint32_t pos_y; |
||
343 | }; |
||
344 | |||
6296 | serge | 345 | |
346 | /* |
||
347 | * struct vmw_otable - Guest Memory OBject table metadata |
||
348 | * |
||
349 | * @size: Size of the table (page-aligned). |
||
350 | * @page_table: Pointer to a struct vmw_mob holding the page table. |
||
351 | */ |
||
352 | struct vmw_otable { |
||
353 | unsigned long size; |
||
354 | struct vmw_mob *page_table; |
||
355 | bool enabled; |
||
356 | }; |
||
357 | |||
358 | struct vmw_otable_batch { |
||
359 | unsigned num_otables; |
||
360 | struct vmw_otable *otables; |
||
361 | struct vmw_resource *context; |
||
362 | struct ttm_buffer_object *otable_bo; |
||
363 | }; |
||
364 | |||
4075 | Serge | 365 | struct vmw_private { |
6296 | serge | 366 | struct ttm_bo_device bdev; |
367 | struct ttm_bo_global_ref bo_global_ref; |
||
368 | struct drm_global_reference mem_global_ref; |
||
4075 | Serge | 369 | |
370 | struct vmw_fifo_state fifo; |
||
371 | |||
372 | struct drm_device *dev; |
||
373 | unsigned long vmw_chipset; |
||
374 | unsigned int io_start; |
||
375 | uint32_t vram_start; |
||
376 | uint32_t vram_size; |
||
4569 | Serge | 377 | uint32_t prim_bb_mem; |
4075 | Serge | 378 | uint32_t mmio_start; |
379 | uint32_t mmio_size; |
||
380 | uint32_t fb_max_width; |
||
381 | uint32_t fb_max_height; |
||
6296 | serge | 382 | uint32_t texture_max_width; |
383 | uint32_t texture_max_height; |
||
384 | uint32_t stdu_max_width; |
||
385 | uint32_t stdu_max_height; |
||
4075 | Serge | 386 | uint32_t initial_width; |
387 | uint32_t initial_height; |
||
6296 | serge | 388 | u32 *mmio_virt; |
4075 | Serge | 389 | uint32_t capabilities; |
390 | uint32_t max_gmr_ids; |
||
391 | uint32_t max_gmr_pages; |
||
4569 | Serge | 392 | uint32_t max_mob_pages; |
5078 | serge | 393 | uint32_t max_mob_size; |
4075 | Serge | 394 | uint32_t memory_size; |
395 | bool has_gmr; |
||
4569 | Serge | 396 | bool has_mob; |
6296 | serge | 397 | spinlock_t hw_lock; |
398 | spinlock_t cap_lock; |
||
399 | bool has_dx; |
||
4075 | Serge | 400 | |
401 | /* |
||
402 | * VGA registers. |
||
403 | */ |
||
404 | |||
405 | struct vmw_vga_topology_state vga_save[VMWGFX_MAX_DISPLAYS]; |
||
406 | uint32_t vga_width; |
||
407 | uint32_t vga_height; |
||
408 | uint32_t vga_bpp; |
||
409 | uint32_t vga_bpl; |
||
410 | uint32_t vga_pitchlock; |
||
411 | |||
412 | uint32_t num_displays; |
||
413 | |||
414 | /* |
||
415 | * Framebuffer info. |
||
416 | */ |
||
417 | |||
418 | void *fb_info; |
||
6296 | serge | 419 | enum vmw_display_unit_type active_display_unit; |
4075 | Serge | 420 | struct vmw_legacy_display *ldu_priv; |
421 | struct vmw_screen_object_display *sou_priv; |
||
422 | struct vmw_overlay *overlay_priv; |
||
423 | |||
424 | /* |
||
425 | * Context and surface management. |
||
426 | */ |
||
427 | |||
428 | rwlock_t resource_lock; |
||
429 | struct idr res_idr[vmw_res_max]; |
||
430 | /* |
||
431 | * Block lastclose from racing with firstopen. |
||
432 | */ |
||
433 | |||
434 | struct mutex init_mutex; |
||
435 | |||
436 | /* |
||
437 | * A resource manager for kernel-only surfaces and |
||
438 | * contexts. |
||
439 | */ |
||
440 | |||
441 | struct ttm_object_device *tdev; |
||
442 | |||
443 | /* |
||
444 | * Fencing and IRQs. |
||
445 | */ |
||
446 | |||
447 | atomic_t marker_seq; |
||
448 | wait_queue_head_t fence_queue; |
||
449 | wait_queue_head_t fifo_queue; |
||
6296 | serge | 450 | spinlock_t waiter_lock; |
451 | int fence_queue_waiters; /* Protected by waiter_lock */ |
||
452 | int goal_queue_waiters; /* Protected by waiter_lock */ |
||
453 | int cmdbuf_waiters; /* Protected by waiter_lock */ |
||
454 | int error_waiters; /* Protected by waiter_lock */ |
||
455 | int fifo_queue_waiters; /* Protected by waiter_lock */ |
||
4075 | Serge | 456 | uint32_t last_read_seqno; |
457 | struct vmw_fence_manager *fman; |
||
6296 | serge | 458 | uint32_t irq_mask; /* Updates protected by waiter_lock */ |
4075 | Serge | 459 | |
460 | /* |
||
461 | * Device state |
||
462 | */ |
||
463 | |||
464 | uint32_t traces_state; |
||
465 | uint32_t enable_state; |
||
466 | uint32_t config_done_state; |
||
467 | |||
468 | /** |
||
469 | * Execbuf |
||
470 | */ |
||
471 | /** |
||
472 | * Protected by the cmdbuf mutex. |
||
473 | */ |
||
474 | |||
475 | struct vmw_sw_context ctx; |
||
476 | struct mutex cmdbuf_mutex; |
||
4569 | Serge | 477 | struct mutex binding_mutex; |
4075 | Serge | 478 | |
479 | /** |
||
480 | * Operating mode. |
||
481 | */ |
||
482 | |||
483 | bool stealth; |
||
484 | bool enable_fb; |
||
6296 | serge | 485 | spinlock_t svga_lock; |
4075 | Serge | 486 | |
487 | /** |
||
488 | * Master management. |
||
489 | */ |
||
490 | |||
4569 | Serge | 491 | struct vmw_master *active_master; |
492 | struct vmw_master fbdev_master; |
||
4075 | Serge | 493 | bool suspended; |
6296 | serge | 494 | bool refuse_hibernation; |
4075 | Serge | 495 | |
496 | struct mutex release_mutex; |
||
6296 | serge | 497 | atomic_t num_fifo_resources; |
4075 | Serge | 498 | |
499 | /* |
||
5078 | serge | 500 | * Replace this with an rwsem as soon as we have down_xx_interruptible() |
501 | */ |
||
502 | struct ttm_lock reservation_sem; |
||
503 | |||
504 | /* |
||
4075 | Serge | 505 | * Query processing. These members |
506 | * are protected by the cmdbuf mutex. |
||
507 | */ |
||
508 | |||
6296 | serge | 509 | struct vmw_dma_buffer *dummy_query_bo; |
510 | struct vmw_dma_buffer *pinned_bo; |
||
4075 | Serge | 511 | uint32_t query_cid; |
512 | uint32_t query_cid_valid; |
||
513 | bool dummy_query_bo_pinned; |
||
514 | |||
515 | /* |
||
516 | * Surface swapping. The "surface_lru" list is protected by the |
||
517 | * resource lock in order to be able to destroy a surface and take |
||
518 | * it off the lru atomically. "used_memory_size" is currently |
||
519 | * protected by the cmdbuf mutex for simplicity. |
||
520 | */ |
||
521 | |||
522 | struct list_head res_lru[vmw_res_max]; |
||
523 | uint32_t used_memory_size; |
||
4569 | Serge | 524 | |
525 | /* |
||
526 | * DMA mapping stuff. |
||
527 | */ |
||
528 | enum vmw_dma_map_mode map_mode; |
||
529 | |||
530 | /* |
||
531 | * Guest Backed stuff |
||
532 | */ |
||
6296 | serge | 533 | struct vmw_otable_batch otable_batch; |
534 | |||
535 | struct vmw_cmdbuf_man *cman; |
||
4075 | Serge | 536 | }; |
537 | |||
538 | static inline struct vmw_surface *vmw_res_to_srf(struct vmw_resource *res) |
||
539 | { |
||
540 | return container_of(res, struct vmw_surface, res); |
||
541 | } |
||
542 | |||
543 | static inline struct vmw_private *vmw_priv(struct drm_device *dev) |
||
544 | { |
||
545 | return (struct vmw_private *)dev->dev_private; |
||
546 | } |
||
547 | |||
548 | static inline struct vmw_fpriv *vmw_fpriv(struct drm_file *file_priv) |
||
549 | { |
||
550 | return (struct vmw_fpriv *)file_priv->driver_priv; |
||
551 | } |
||
552 | |||
553 | static inline struct vmw_master *vmw_master(struct drm_master *master) |
||
554 | { |
||
555 | return (struct vmw_master *) master->driver_priv; |
||
556 | } |
||
557 | |||
6296 | serge | 558 | /* |
559 | * The locking here is fine-grained, so that it is performed once |
||
560 | * for every read- and write operation. This is of course costly, but we |
||
561 | * don't perform much register access in the timing critical paths anyway. |
||
562 | * Instead we have the extra benefit of being sure that we don't forget |
||
563 | * the hw lock around register accesses. |
||
564 | */ |
||
4075 | Serge | 565 | static inline void vmw_write(struct vmw_private *dev_priv, |
566 | unsigned int offset, uint32_t value) |
||
567 | { |
||
6296 | serge | 568 | unsigned long irq_flags; |
569 | |||
570 | spin_lock_irqsave(&dev_priv->hw_lock, irq_flags); |
||
4075 | Serge | 571 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); |
572 | outl(value, dev_priv->io_start + VMWGFX_VALUE_PORT); |
||
6296 | serge | 573 | spin_unlock_irqrestore(&dev_priv->hw_lock, irq_flags); |
4075 | Serge | 574 | } |
575 | |||
576 | static inline uint32_t vmw_read(struct vmw_private *dev_priv, |
||
577 | unsigned int offset) |
||
578 | { |
||
6296 | serge | 579 | unsigned long irq_flags; |
580 | u32 val; |
||
4075 | Serge | 581 | |
6296 | serge | 582 | spin_lock_irqsave(&dev_priv->hw_lock, irq_flags); |
4075 | Serge | 583 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); |
584 | val = inl(dev_priv->io_start + VMWGFX_VALUE_PORT); |
||
6296 | serge | 585 | spin_unlock_irqrestore(&dev_priv->hw_lock, irq_flags); |
586 | |||
4075 | Serge | 587 | return val; |
588 | } |
||
589 | |||
6296 | serge | 590 | extern void vmw_svga_enable(struct vmw_private *dev_priv); |
591 | extern void vmw_svga_disable(struct vmw_private *dev_priv); |
||
4075 | Serge | 592 | |
6296 | serge | 593 | |
4075 | Serge | 594 | /** |
595 | * GMR utilities - vmwgfx_gmr.c |
||
596 | */ |
||
597 | |||
598 | extern int vmw_gmr_bind(struct vmw_private *dev_priv, |
||
4569 | Serge | 599 | const struct vmw_sg_table *vsgt, |
4075 | Serge | 600 | unsigned long num_pages, |
601 | int gmr_id); |
||
602 | extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id); |
||
603 | |||
604 | /** |
||
605 | * Resource utilities - vmwgfx_resource.c |
||
606 | */ |
||
607 | struct vmw_user_resource_conv; |
||
608 | |||
609 | extern void vmw_resource_unreference(struct vmw_resource **p_res); |
||
610 | extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res); |
||
5078 | serge | 611 | extern struct vmw_resource * |
612 | vmw_resource_reference_unless_doomed(struct vmw_resource *res); |
||
4075 | Serge | 613 | extern int vmw_resource_validate(struct vmw_resource *res); |
6296 | serge | 614 | extern int vmw_resource_reserve(struct vmw_resource *res, bool interruptible, |
615 | bool no_backup); |
||
4075 | Serge | 616 | extern bool vmw_resource_needs_backup(const struct vmw_resource *res); |
617 | extern int vmw_user_lookup_handle(struct vmw_private *dev_priv, |
||
618 | struct ttm_object_file *tfile, |
||
619 | uint32_t handle, |
||
620 | struct vmw_surface **out_surf, |
||
621 | struct vmw_dma_buffer **out_buf); |
||
622 | extern int vmw_user_resource_lookup_handle( |
||
623 | struct vmw_private *dev_priv, |
||
624 | struct ttm_object_file *tfile, |
||
625 | uint32_t handle, |
||
626 | const struct vmw_user_resource_conv *converter, |
||
627 | struct vmw_resource **p_res); |
||
628 | extern void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo); |
||
629 | extern int vmw_dmabuf_init(struct vmw_private *dev_priv, |
||
630 | struct vmw_dma_buffer *vmw_bo, |
||
631 | size_t size, struct ttm_placement *placement, |
||
632 | bool interuptable, |
||
633 | void (*bo_free) (struct ttm_buffer_object *bo)); |
||
634 | extern int vmw_user_dmabuf_verify_access(struct ttm_buffer_object *bo, |
||
635 | struct ttm_object_file *tfile); |
||
4569 | Serge | 636 | extern int vmw_user_dmabuf_alloc(struct vmw_private *dev_priv, |
637 | struct ttm_object_file *tfile, |
||
638 | uint32_t size, |
||
639 | bool shareable, |
||
640 | uint32_t *handle, |
||
6296 | serge | 641 | struct vmw_dma_buffer **p_dma_buf, |
642 | struct ttm_base_object **p_base); |
||
4569 | Serge | 643 | extern int vmw_user_dmabuf_reference(struct ttm_object_file *tfile, |
644 | struct vmw_dma_buffer *dma_buf, |
||
645 | uint32_t *handle); |
||
4075 | Serge | 646 | extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, |
647 | struct drm_file *file_priv); |
||
648 | extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data, |
||
649 | struct drm_file *file_priv); |
||
4569 | Serge | 650 | extern int vmw_user_dmabuf_synccpu_ioctl(struct drm_device *dev, void *data, |
651 | struct drm_file *file_priv); |
||
4075 | Serge | 652 | extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo, |
653 | uint32_t cur_validate_node); |
||
654 | extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo); |
||
655 | extern int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile, |
||
6296 | serge | 656 | uint32_t id, struct vmw_dma_buffer **out, |
657 | struct ttm_base_object **base); |
||
4075 | Serge | 658 | extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data, |
659 | struct drm_file *file_priv); |
||
660 | extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data, |
||
661 | struct drm_file *file_priv); |
||
662 | extern int vmw_user_stream_lookup(struct vmw_private *dev_priv, |
||
663 | struct ttm_object_file *tfile, |
||
664 | uint32_t *inout_id, |
||
665 | struct vmw_resource **out); |
||
666 | extern void vmw_resource_unreserve(struct vmw_resource *res, |
||
6296 | serge | 667 | bool switch_backup, |
4075 | Serge | 668 | struct vmw_dma_buffer *new_backup, |
669 | unsigned long new_backup_offset); |
||
670 | extern void vmw_resource_move_notify(struct ttm_buffer_object *bo, |
||
671 | struct ttm_mem_reg *mem); |
||
6296 | serge | 672 | extern void vmw_query_move_notify(struct ttm_buffer_object *bo, |
673 | struct ttm_mem_reg *mem); |
||
674 | extern int vmw_query_readback_all(struct vmw_dma_buffer *dx_query_mob); |
||
4075 | Serge | 675 | extern void vmw_fence_single_bo(struct ttm_buffer_object *bo, |
676 | struct vmw_fence_obj *fence); |
||
677 | extern void vmw_resource_evict_all(struct vmw_private *dev_priv); |
||
678 | |||
679 | /** |
||
680 | * DMA buffer helper routines - vmwgfx_dmabuf.c |
||
681 | */ |
||
6296 | serge | 682 | extern int vmw_dmabuf_pin_in_placement(struct vmw_private *vmw_priv, |
4075 | Serge | 683 | struct vmw_dma_buffer *bo, |
6296 | serge | 684 | struct ttm_placement *placement, |
685 | bool interruptible); |
||
686 | extern int vmw_dmabuf_pin_in_vram(struct vmw_private *dev_priv, |
||
687 | struct vmw_dma_buffer *buf, |
||
688 | bool interruptible); |
||
689 | extern int vmw_dmabuf_pin_in_vram_or_gmr(struct vmw_private *dev_priv, |
||
690 | struct vmw_dma_buffer *buf, |
||
691 | bool interruptible); |
||
692 | extern int vmw_dmabuf_pin_in_start_of_vram(struct vmw_private *vmw_priv, |
||
693 | struct vmw_dma_buffer *bo, |
||
694 | bool interruptible); |
||
4075 | Serge | 695 | extern int vmw_dmabuf_unpin(struct vmw_private *vmw_priv, |
696 | struct vmw_dma_buffer *bo, |
||
697 | bool interruptible); |
||
698 | extern void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *buf, |
||
699 | SVGAGuestPtr *ptr); |
||
6296 | serge | 700 | extern void vmw_bo_pin_reserved(struct vmw_dma_buffer *bo, bool pin); |
4075 | Serge | 701 | |
702 | /** |
||
703 | * Misc Ioctl functionality - vmwgfx_ioctl.c |
||
704 | */ |
||
705 | |||
706 | extern int vmw_getparam_ioctl(struct drm_device *dev, void *data, |
||
707 | struct drm_file *file_priv); |
||
708 | extern int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data, |
||
709 | struct drm_file *file_priv); |
||
710 | extern int vmw_present_ioctl(struct drm_device *dev, void *data, |
||
711 | struct drm_file *file_priv); |
||
712 | extern int vmw_present_readback_ioctl(struct drm_device *dev, void *data, |
||
713 | struct drm_file *file_priv); |
||
6296 | serge | 714 | extern unsigned int vmw_fops_poll(struct file *filp, |
715 | struct poll_table_struct *wait); |
||
4075 | Serge | 716 | extern ssize_t vmw_fops_read(struct file *filp, char __user *buffer, |
717 | size_t count, loff_t *offset); |
||
718 | |||
719 | /** |
||
720 | * Fifo utilities - vmwgfx_fifo.c |
||
721 | */ |
||
722 | |||
723 | extern int vmw_fifo_init(struct vmw_private *dev_priv, |
||
724 | struct vmw_fifo_state *fifo); |
||
725 | extern void vmw_fifo_release(struct vmw_private *dev_priv, |
||
726 | struct vmw_fifo_state *fifo); |
||
727 | extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes); |
||
6296 | serge | 728 | extern void * |
729 | vmw_fifo_reserve_dx(struct vmw_private *dev_priv, uint32_t bytes, int ctx_id); |
||
4075 | Serge | 730 | extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes); |
6296 | serge | 731 | extern void vmw_fifo_commit_flush(struct vmw_private *dev_priv, uint32_t bytes); |
4075 | Serge | 732 | extern int vmw_fifo_send_fence(struct vmw_private *dev_priv, |
733 | uint32_t *seqno); |
||
6296 | serge | 734 | extern void vmw_fifo_ping_host_locked(struct vmw_private *, uint32_t reason); |
4075 | Serge | 735 | extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason); |
736 | extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv); |
||
737 | extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv); |
||
738 | extern int vmw_fifo_emit_dummy_query(struct vmw_private *dev_priv, |
||
739 | uint32_t cid); |
||
6296 | serge | 740 | extern int vmw_fifo_flush(struct vmw_private *dev_priv, |
741 | bool interruptible); |
||
4075 | Serge | 742 | |
743 | /** |
||
744 | * TTM glue - vmwgfx_ttm_glue.c |
||
745 | */ |
||
746 | |||
747 | extern int vmw_ttm_global_init(struct vmw_private *dev_priv); |
||
748 | extern void vmw_ttm_global_release(struct vmw_private *dev_priv); |
||
749 | extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma); |
||
750 | |||
751 | /** |
||
752 | * TTM buffer object driver - vmwgfx_buffer.c |
||
753 | */ |
||
754 | |||
4569 | Serge | 755 | extern const size_t vmw_tt_size; |
4075 | Serge | 756 | extern struct ttm_placement vmw_vram_placement; |
757 | extern struct ttm_placement vmw_vram_ne_placement; |
||
758 | extern struct ttm_placement vmw_vram_sys_placement; |
||
759 | extern struct ttm_placement vmw_vram_gmr_placement; |
||
760 | extern struct ttm_placement vmw_vram_gmr_ne_placement; |
||
761 | extern struct ttm_placement vmw_sys_placement; |
||
4569 | Serge | 762 | extern struct ttm_placement vmw_sys_ne_placement; |
4075 | Serge | 763 | extern struct ttm_placement vmw_evictable_placement; |
764 | extern struct ttm_placement vmw_srf_placement; |
||
4569 | Serge | 765 | extern struct ttm_placement vmw_mob_placement; |
6296 | serge | 766 | extern struct ttm_placement vmw_mob_ne_placement; |
4075 | Serge | 767 | extern struct ttm_bo_driver vmw_bo_driver; |
768 | extern int vmw_dma_quiescent(struct drm_device *dev); |
||
4569 | Serge | 769 | extern int vmw_bo_map_dma(struct ttm_buffer_object *bo); |
770 | extern void vmw_bo_unmap_dma(struct ttm_buffer_object *bo); |
||
771 | extern const struct vmw_sg_table * |
||
772 | vmw_bo_sg_table(struct ttm_buffer_object *bo); |
||
773 | extern void vmw_piter_start(struct vmw_piter *viter, |
||
774 | const struct vmw_sg_table *vsgt, |
||
775 | unsigned long p_offs); |
||
4075 | Serge | 776 | |
777 | /** |
||
4569 | Serge | 778 | * vmw_piter_next - Advance the iterator one page. |
779 | * |
||
780 | * @viter: Pointer to the iterator to advance. |
||
781 | * |
||
782 | * Returns false if past the list of pages, true otherwise. |
||
783 | */ |
||
784 | static inline bool vmw_piter_next(struct vmw_piter *viter) |
||
785 | { |
||
786 | return viter->next(viter); |
||
787 | } |
||
788 | |||
789 | /** |
||
790 | * vmw_piter_dma_addr - Return the DMA address of the current page. |
||
791 | * |
||
792 | * @viter: Pointer to the iterator |
||
793 | * |
||
794 | * Returns the DMA address of the page pointed to by @viter. |
||
795 | */ |
||
796 | static inline dma_addr_t vmw_piter_dma_addr(struct vmw_piter *viter) |
||
797 | { |
||
798 | return viter->dma_address(viter); |
||
799 | } |
||
800 | |||
801 | /** |
||
802 | * vmw_piter_page - Return a pointer to the current page. |
||
803 | * |
||
804 | * @viter: Pointer to the iterator |
||
805 | * |
||
806 | * Returns the DMA address of the page pointed to by @viter. |
||
807 | */ |
||
808 | static inline struct page *vmw_piter_page(struct vmw_piter *viter) |
||
809 | { |
||
810 | return viter->page(viter); |
||
811 | } |
||
812 | |||
813 | /** |
||
4075 | Serge | 814 | * Command submission - vmwgfx_execbuf.c |
815 | */ |
||
816 | |||
6296 | serge | 817 | extern int vmw_execbuf_ioctl(struct drm_device *dev, unsigned long data, |
818 | struct drm_file *file_priv, size_t size); |
||
4075 | Serge | 819 | extern int vmw_execbuf_process(struct drm_file *file_priv, |
820 | struct vmw_private *dev_priv, |
||
821 | void __user *user_commands, |
||
822 | void *kernel_commands, |
||
823 | uint32_t command_size, |
||
824 | uint64_t throttle_us, |
||
6296 | serge | 825 | uint32_t dx_context_handle, |
4075 | Serge | 826 | struct drm_vmw_fence_rep __user |
827 | *user_fence_rep, |
||
828 | struct vmw_fence_obj **out_fence); |
||
829 | extern void __vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv, |
||
830 | struct vmw_fence_obj *fence); |
||
831 | extern void vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv); |
||
832 | |||
833 | extern int vmw_execbuf_fence_commands(struct drm_file *file_priv, |
||
834 | struct vmw_private *dev_priv, |
||
835 | struct vmw_fence_obj **p_fence, |
||
836 | uint32_t *p_handle); |
||
837 | extern void vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv, |
||
838 | struct vmw_fpriv *vmw_fp, |
||
839 | int ret, |
||
840 | struct drm_vmw_fence_rep __user |
||
841 | *user_fence_rep, |
||
842 | struct vmw_fence_obj *fence, |
||
843 | uint32_t fence_handle); |
||
6296 | serge | 844 | extern int vmw_validate_single_buffer(struct vmw_private *dev_priv, |
845 | struct ttm_buffer_object *bo, |
||
846 | bool interruptible, |
||
847 | bool validate_as_mob); |
||
4075 | Serge | 848 | |
6296 | serge | 849 | |
4075 | Serge | 850 | /** |
851 | * IRQs and wating - vmwgfx_irq.c |
||
852 | */ |
||
853 | |||
4569 | Serge | 854 | extern irqreturn_t vmw_irq_handler(int irq, void *arg); |
4075 | Serge | 855 | extern int vmw_wait_seqno(struct vmw_private *dev_priv, bool lazy, |
6296 | serge | 856 | uint32_t seqno, bool interruptible, |
857 | unsigned long timeout); |
||
4075 | Serge | 858 | extern void vmw_irq_preinstall(struct drm_device *dev); |
859 | extern int vmw_irq_postinstall(struct drm_device *dev); |
||
860 | extern void vmw_irq_uninstall(struct drm_device *dev); |
||
861 | extern bool vmw_seqno_passed(struct vmw_private *dev_priv, |
||
862 | uint32_t seqno); |
||
863 | extern int vmw_fallback_wait(struct vmw_private *dev_priv, |
||
864 | bool lazy, |
||
865 | bool fifo_idle, |
||
866 | uint32_t seqno, |
||
867 | bool interruptible, |
||
868 | unsigned long timeout); |
||
869 | extern void vmw_update_seqno(struct vmw_private *dev_priv, |
||
870 | struct vmw_fifo_state *fifo_state); |
||
871 | extern void vmw_seqno_waiter_add(struct vmw_private *dev_priv); |
||
872 | extern void vmw_seqno_waiter_remove(struct vmw_private *dev_priv); |
||
873 | extern void vmw_goal_waiter_add(struct vmw_private *dev_priv); |
||
874 | extern void vmw_goal_waiter_remove(struct vmw_private *dev_priv); |
||
6296 | serge | 875 | extern void vmw_generic_waiter_add(struct vmw_private *dev_priv, u32 flag, |
876 | int *waiter_count); |
||
877 | extern void vmw_generic_waiter_remove(struct vmw_private *dev_priv, |
||
878 | u32 flag, int *waiter_count); |
||
4075 | Serge | 879 | |
880 | /** |
||
881 | * Rudimentary fence-like objects currently used only for throttling - |
||
882 | * vmwgfx_marker.c |
||
883 | */ |
||
884 | |||
885 | extern void vmw_marker_queue_init(struct vmw_marker_queue *queue); |
||
886 | extern void vmw_marker_queue_takedown(struct vmw_marker_queue *queue); |
||
887 | extern int vmw_marker_push(struct vmw_marker_queue *queue, |
||
6296 | serge | 888 | uint32_t seqno); |
4075 | Serge | 889 | extern int vmw_marker_pull(struct vmw_marker_queue *queue, |
6296 | serge | 890 | uint32_t signaled_seqno); |
4075 | Serge | 891 | extern int vmw_wait_lag(struct vmw_private *dev_priv, |
892 | struct vmw_marker_queue *queue, uint32_t us); |
||
893 | |||
894 | /** |
||
895 | * Kernel framebuffer - vmwgfx_fb.c |
||
896 | */ |
||
897 | |||
898 | int vmw_fb_init(struct vmw_private *vmw_priv); |
||
899 | int vmw_fb_close(struct vmw_private *dev_priv); |
||
900 | int vmw_fb_off(struct vmw_private *vmw_priv); |
||
901 | int vmw_fb_on(struct vmw_private *vmw_priv); |
||
902 | |||
903 | /** |
||
904 | * Kernel modesetting - vmwgfx_kms.c |
||
905 | */ |
||
906 | |||
907 | int vmw_kms_init(struct vmw_private *dev_priv); |
||
908 | int vmw_kms_close(struct vmw_private *dev_priv); |
||
909 | int vmw_kms_save_vga(struct vmw_private *vmw_priv); |
||
910 | int vmw_kms_restore_vga(struct vmw_private *vmw_priv); |
||
911 | int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data, |
||
912 | struct drm_file *file_priv); |
||
913 | void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv); |
||
914 | void vmw_kms_cursor_snoop(struct vmw_surface *srf, |
||
915 | struct ttm_object_file *tfile, |
||
916 | struct ttm_buffer_object *bo, |
||
917 | SVGA3dCmdHeader *header); |
||
918 | int vmw_kms_write_svga(struct vmw_private *vmw_priv, |
||
919 | unsigned width, unsigned height, unsigned pitch, |
||
920 | unsigned bpp, unsigned depth); |
||
921 | void vmw_kms_idle_workqueues(struct vmw_master *vmaster); |
||
922 | bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv, |
||
923 | uint32_t pitch, |
||
924 | uint32_t height); |
||
6296 | serge | 925 | u32 vmw_get_vblank_counter(struct drm_device *dev, unsigned int pipe); |
926 | int vmw_enable_vblank(struct drm_device *dev, unsigned int pipe); |
||
927 | void vmw_disable_vblank(struct drm_device *dev, unsigned int pipe); |
||
4075 | Serge | 928 | int vmw_kms_present(struct vmw_private *dev_priv, |
929 | struct drm_file *file_priv, |
||
930 | struct vmw_framebuffer *vfb, |
||
931 | struct vmw_surface *surface, |
||
932 | uint32_t sid, int32_t destX, int32_t destY, |
||
933 | struct drm_vmw_rect *clips, |
||
934 | uint32_t num_clips); |
||
935 | int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data, |
||
936 | struct drm_file *file_priv); |
||
6296 | serge | 937 | void vmw_kms_legacy_hotspot_clear(struct vmw_private *dev_priv); |
4075 | Serge | 938 | |
939 | int vmw_dumb_create(struct drm_file *file_priv, |
||
940 | struct drm_device *dev, |
||
941 | struct drm_mode_create_dumb *args); |
||
942 | |||
943 | int vmw_dumb_map_offset(struct drm_file *file_priv, |
||
944 | struct drm_device *dev, uint32_t handle, |
||
945 | uint64_t *offset); |
||
946 | int vmw_dumb_destroy(struct drm_file *file_priv, |
||
947 | struct drm_device *dev, |
||
948 | uint32_t handle); |
||
6296 | serge | 949 | extern int vmw_resource_pin(struct vmw_resource *res, bool interruptible); |
950 | extern void vmw_resource_unpin(struct vmw_resource *res); |
||
951 | extern enum vmw_res_type vmw_res_type(const struct vmw_resource *res); |
||
952 | |||
4075 | Serge | 953 | /** |
954 | * Overlay control - vmwgfx_overlay.c |
||
955 | */ |
||
956 | |||
957 | int vmw_overlay_init(struct vmw_private *dev_priv); |
||
958 | int vmw_overlay_close(struct vmw_private *dev_priv); |
||
959 | int vmw_overlay_ioctl(struct drm_device *dev, void *data, |
||
960 | struct drm_file *file_priv); |
||
961 | int vmw_overlay_stop_all(struct vmw_private *dev_priv); |
||
962 | int vmw_overlay_resume_all(struct vmw_private *dev_priv); |
||
963 | int vmw_overlay_pause_all(struct vmw_private *dev_priv); |
||
964 | int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out); |
||
965 | int vmw_overlay_unref(struct vmw_private *dev_priv, uint32_t stream_id); |
||
966 | int vmw_overlay_num_overlays(struct vmw_private *dev_priv); |
||
967 | int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv); |
||
968 | |||
969 | /** |
||
970 | * GMR Id manager |
||
971 | */ |
||
972 | |||
973 | extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; |
||
974 | |||
975 | /** |
||
6296 | serge | 976 | * Prime - vmwgfx_prime.c |
977 | */ |
||
978 | |||
979 | extern const struct dma_buf_ops vmw_prime_dmabuf_ops; |
||
980 | extern int vmw_prime_fd_to_handle(struct drm_device *dev, |
||
981 | struct drm_file *file_priv, |
||
982 | int fd, u32 *handle); |
||
983 | extern int vmw_prime_handle_to_fd(struct drm_device *dev, |
||
984 | struct drm_file *file_priv, |
||
985 | uint32_t handle, uint32_t flags, |
||
986 | int *prime_fd); |
||
987 | |||
4569 | Serge | 988 | /* |
989 | * MemoryOBject management - vmwgfx_mob.c |
||
990 | */ |
||
991 | struct vmw_mob; |
||
992 | extern int vmw_mob_bind(struct vmw_private *dev_priv, struct vmw_mob *mob, |
||
993 | const struct vmw_sg_table *vsgt, |
||
994 | unsigned long num_data_pages, int32_t mob_id); |
||
995 | extern void vmw_mob_unbind(struct vmw_private *dev_priv, |
||
996 | struct vmw_mob *mob); |
||
997 | extern void vmw_mob_destroy(struct vmw_mob *mob); |
||
998 | extern struct vmw_mob *vmw_mob_create(unsigned long data_pages); |
||
999 | extern int vmw_otables_setup(struct vmw_private *dev_priv); |
||
1000 | extern void vmw_otables_takedown(struct vmw_private *dev_priv); |
||
1001 | |||
1002 | /* |
||
1003 | * Context management - vmwgfx_context.c |
||
1004 | */ |
||
1005 | |||
1006 | extern const struct vmw_user_resource_conv *user_context_converter; |
||
1007 | |||
1008 | extern int vmw_context_check(struct vmw_private *dev_priv, |
||
1009 | struct ttm_object_file *tfile, |
||
1010 | int id, |
||
1011 | struct vmw_resource **p_res); |
||
1012 | extern int vmw_context_define_ioctl(struct drm_device *dev, void *data, |
||
1013 | struct drm_file *file_priv); |
||
6296 | serge | 1014 | extern int vmw_extended_context_define_ioctl(struct drm_device *dev, void *data, |
1015 | struct drm_file *file_priv); |
||
4569 | Serge | 1016 | extern int vmw_context_destroy_ioctl(struct drm_device *dev, void *data, |
1017 | struct drm_file *file_priv); |
||
5078 | serge | 1018 | extern struct list_head *vmw_context_binding_list(struct vmw_resource *ctx); |
6296 | serge | 1019 | extern struct vmw_cmdbuf_res_manager * |
1020 | vmw_context_res_man(struct vmw_resource *ctx); |
||
1021 | extern struct vmw_resource *vmw_context_cotable(struct vmw_resource *ctx, |
||
1022 | SVGACOTableType cotable_type); |
||
1023 | extern struct list_head *vmw_context_binding_list(struct vmw_resource *ctx); |
||
1024 | struct vmw_ctx_binding_state; |
||
1025 | extern struct vmw_ctx_binding_state * |
||
1026 | vmw_context_binding_state(struct vmw_resource *ctx); |
||
1027 | extern void vmw_dx_context_scrub_cotables(struct vmw_resource *ctx, |
||
1028 | bool readback); |
||
1029 | extern int vmw_context_bind_dx_query(struct vmw_resource *ctx_res, |
||
1030 | struct vmw_dma_buffer *mob); |
||
1031 | extern struct vmw_dma_buffer * |
||
1032 | vmw_context_get_dx_query_mob(struct vmw_resource *ctx_res); |
||
4569 | Serge | 1033 | |
6296 | serge | 1034 | |
4569 | Serge | 1035 | /* |
1036 | * Surface management - vmwgfx_surface.c |
||
1037 | */ |
||
1038 | |||
1039 | extern const struct vmw_user_resource_conv *user_surface_converter; |
||
1040 | |||
1041 | extern void vmw_surface_res_free(struct vmw_resource *res); |
||
6296 | serge | 1042 | extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data, |
1043 | struct drm_file *file_priv); |
||
1044 | extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data, |
||
1045 | struct drm_file *file_priv); |
||
1046 | extern int vmw_surface_reference_ioctl(struct drm_device *dev, void *data, |
||
1047 | struct drm_file *file_priv); |
||
1048 | extern int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data, |
||
1049 | struct drm_file *file_priv); |
||
1050 | extern int vmw_gb_surface_reference_ioctl(struct drm_device *dev, void *data, |
||
1051 | struct drm_file *file_priv); |
||
4569 | Serge | 1052 | extern int vmw_surface_check(struct vmw_private *dev_priv, |
1053 | struct ttm_object_file *tfile, |
||
1054 | uint32_t handle, int *id); |
||
1055 | extern int vmw_surface_validate(struct vmw_private *dev_priv, |
||
1056 | struct vmw_surface *srf); |
||
6296 | serge | 1057 | int vmw_surface_gb_priv_define(struct drm_device *dev, |
1058 | uint32_t user_accounting_size, |
||
1059 | uint32_t svga3d_flags, |
||
1060 | SVGA3dSurfaceFormat format, |
||
1061 | bool for_scanout, |
||
1062 | uint32_t num_mip_levels, |
||
1063 | uint32_t multisample_count, |
||
1064 | uint32_t array_size, |
||
1065 | struct drm_vmw_size size, |
||
1066 | struct vmw_surface **srf_out); |
||
4569 | Serge | 1067 | |
1068 | /* |
||
1069 | * Shader management - vmwgfx_shader.c |
||
1070 | */ |
||
1071 | |||
1072 | extern const struct vmw_user_resource_conv *user_shader_converter; |
||
6296 | serge | 1073 | |
1074 | extern int vmw_shader_define_ioctl(struct drm_device *dev, void *data, |
||
1075 | struct drm_file *file_priv); |
||
1076 | extern int vmw_shader_destroy_ioctl(struct drm_device *dev, void *data, |
||
1077 | struct drm_file *file_priv); |
||
1078 | extern int vmw_compat_shader_add(struct vmw_private *dev_priv, |
||
1079 | struct vmw_cmdbuf_res_manager *man, |
||
1080 | u32 user_key, const void *bytecode, |
||
1081 | SVGA3dShaderType shader_type, |
||
1082 | size_t size, |
||
1083 | struct list_head *list); |
||
1084 | extern int vmw_shader_remove(struct vmw_cmdbuf_res_manager *man, |
||
1085 | u32 user_key, SVGA3dShaderType shader_type, |
||
1086 | struct list_head *list); |
||
1087 | extern int vmw_dx_shader_add(struct vmw_cmdbuf_res_manager *man, |
||
1088 | struct vmw_resource *ctx, |
||
1089 | u32 user_key, |
||
1090 | SVGA3dShaderType shader_type, |
||
1091 | struct list_head *list); |
||
1092 | extern void vmw_dx_shader_cotable_list_scrub(struct vmw_private *dev_priv, |
||
1093 | struct list_head *list, |
||
1094 | bool readback); |
||
1095 | |||
1096 | extern struct vmw_resource * |
||
1097 | vmw_shader_lookup(struct vmw_cmdbuf_res_manager *man, |
||
1098 | u32 user_key, SVGA3dShaderType shader_type); |
||
1099 | |||
1100 | /* |
||
1101 | * Command buffer managed resources - vmwgfx_cmdbuf_res.c |
||
1102 | */ |
||
1103 | |||
5078 | serge | 1104 | extern struct vmw_cmdbuf_res_manager * |
1105 | vmw_cmdbuf_res_man_create(struct vmw_private *dev_priv); |
||
1106 | extern void vmw_cmdbuf_res_man_destroy(struct vmw_cmdbuf_res_manager *man); |
||
1107 | extern size_t vmw_cmdbuf_res_man_size(void); |
||
1108 | extern struct vmw_resource * |
||
1109 | vmw_cmdbuf_res_lookup(struct vmw_cmdbuf_res_manager *man, |
||
1110 | enum vmw_cmdbuf_res_type res_type, |
||
1111 | u32 user_key); |
||
1112 | extern void vmw_cmdbuf_res_revert(struct list_head *list); |
||
1113 | extern void vmw_cmdbuf_res_commit(struct list_head *list); |
||
1114 | extern int vmw_cmdbuf_res_add(struct vmw_cmdbuf_res_manager *man, |
||
1115 | enum vmw_cmdbuf_res_type res_type, |
||
1116 | u32 user_key, |
||
1117 | struct vmw_resource *res, |
||
1118 | struct list_head *list); |
||
1119 | extern int vmw_cmdbuf_res_remove(struct vmw_cmdbuf_res_manager *man, |
||
1120 | enum vmw_cmdbuf_res_type res_type, |
||
1121 | u32 user_key, |
||
6296 | serge | 1122 | struct list_head *list, |
1123 | struct vmw_resource **res); |
||
5078 | serge | 1124 | |
6296 | serge | 1125 | /* |
1126 | * COTable management - vmwgfx_cotable.c |
||
1127 | */ |
||
1128 | extern const SVGACOTableType vmw_cotable_scrub_order[]; |
||
1129 | extern struct vmw_resource *vmw_cotable_alloc(struct vmw_private *dev_priv, |
||
1130 | struct vmw_resource *ctx, |
||
1131 | u32 type); |
||
1132 | extern int vmw_cotable_notify(struct vmw_resource *res, int id); |
||
1133 | extern int vmw_cotable_scrub(struct vmw_resource *res, bool readback); |
||
1134 | extern void vmw_cotable_add_resource(struct vmw_resource *ctx, |
||
1135 | struct list_head *head); |
||
5078 | serge | 1136 | |
6296 | serge | 1137 | /* |
1138 | * Command buffer managerment vmwgfx_cmdbuf.c |
||
1139 | */ |
||
1140 | struct vmw_cmdbuf_man; |
||
1141 | struct vmw_cmdbuf_header; |
||
1142 | |||
1143 | extern struct vmw_cmdbuf_man * |
||
1144 | vmw_cmdbuf_man_create(struct vmw_private *dev_priv); |
||
1145 | extern int vmw_cmdbuf_set_pool_size(struct vmw_cmdbuf_man *man, |
||
1146 | size_t size, size_t default_size); |
||
1147 | extern void vmw_cmdbuf_remove_pool(struct vmw_cmdbuf_man *man); |
||
1148 | extern void vmw_cmdbuf_man_destroy(struct vmw_cmdbuf_man *man); |
||
1149 | extern int vmw_cmdbuf_idle(struct vmw_cmdbuf_man *man, bool interruptible, |
||
1150 | unsigned long timeout); |
||
1151 | extern void *vmw_cmdbuf_reserve(struct vmw_cmdbuf_man *man, size_t size, |
||
1152 | int ctx_id, bool interruptible, |
||
1153 | struct vmw_cmdbuf_header *header); |
||
1154 | extern void vmw_cmdbuf_commit(struct vmw_cmdbuf_man *man, size_t size, |
||
1155 | struct vmw_cmdbuf_header *header, |
||
1156 | bool flush); |
||
1157 | extern void vmw_cmdbuf_tasklet_schedule(struct vmw_cmdbuf_man *man); |
||
1158 | extern void *vmw_cmdbuf_alloc(struct vmw_cmdbuf_man *man, |
||
1159 | size_t size, bool interruptible, |
||
1160 | struct vmw_cmdbuf_header **p_header); |
||
1161 | extern void vmw_cmdbuf_header_free(struct vmw_cmdbuf_header *header); |
||
1162 | extern int vmw_cmdbuf_cur_flush(struct vmw_cmdbuf_man *man, |
||
1163 | bool interruptible); |
||
1164 | |||
1165 | |||
4569 | Serge | 1166 | /** |
4075 | Serge | 1167 | * Inline helper functions |
1168 | */ |
||
1169 | |||
1170 | static inline void vmw_surface_unreference(struct vmw_surface **srf) |
||
1171 | { |
||
1172 | struct vmw_surface *tmp_srf = *srf; |
||
1173 | struct vmw_resource *res = &tmp_srf->res; |
||
1174 | *srf = NULL; |
||
1175 | |||
1176 | vmw_resource_unreference(&res); |
||
1177 | } |
||
1178 | |||
1179 | static inline struct vmw_surface *vmw_surface_reference(struct vmw_surface *srf) |
||
1180 | { |
||
1181 | (void) vmw_resource_reference(&srf->res); |
||
1182 | return srf; |
||
1183 | } |
||
1184 | |||
1185 | static inline void vmw_dmabuf_unreference(struct vmw_dma_buffer **buf) |
||
1186 | { |
||
1187 | struct vmw_dma_buffer *tmp_buf = *buf; |
||
1188 | |||
1189 | *buf = NULL; |
||
1190 | if (tmp_buf != NULL) { |
||
1191 | struct ttm_buffer_object *bo = &tmp_buf->base; |
||
1192 | |||
1193 | ttm_bo_unref(&bo); |
||
1194 | } |
||
1195 | } |
||
1196 | |||
1197 | static inline struct vmw_dma_buffer *vmw_dmabuf_reference(struct vmw_dma_buffer *buf) |
||
1198 | { |
||
6296 | serge | 1199 | if (ttm_bo_reference(&buf->base)) |
4075 | Serge | 1200 | return buf; |
1201 | return NULL; |
||
1202 | } |
||
1203 | |||
1204 | static inline struct ttm_mem_global *vmw_mem_glob(struct vmw_private *dev_priv) |
||
1205 | { |
||
1206 | return (struct ttm_mem_global *) dev_priv->mem_global_ref.object; |
||
1207 | } |
||
1208 | |||
6296 | serge | 1209 | static inline void vmw_fifo_resource_inc(struct vmw_private *dev_priv) |
1210 | { |
||
1211 | atomic_inc(&dev_priv->num_fifo_resources); |
||
1212 | } |
||
4111 | Serge | 1213 | |
6296 | serge | 1214 | static inline void vmw_fifo_resource_dec(struct vmw_private *dev_priv) |
4080 | Serge | 1215 | { |
6296 | serge | 1216 | atomic_dec(&dev_priv->num_fifo_resources); |
1217 | } |
||
4075 | Serge | 1218 | |
6296 | serge | 1219 | /** |
1220 | * vmw_mmio_read - Perform a MMIO read from volatile memory |
||
1221 | * |
||
1222 | * @addr: The address to read from |
||
1223 | * |
||
1224 | * This function is intended to be equivalent to ioread32() on |
||
1225 | * memremap'd memory, but without byteswapping. |
||
1226 | */ |
||
1227 | static inline u32 vmw_mmio_read(u32 *addr) |
||
1228 | { |
||
1229 | return READ_ONCE(*addr); |
||
1230 | } |
||
1231 | |||
1232 | /** |
||
1233 | * vmw_mmio_write - Perform a MMIO write to volatile memory |
||
1234 | * |
||
1235 | * @addr: The address to write to |
||
1236 | * |
||
1237 | * This function is intended to be equivalent to iowrite32 on |
||
1238 | * memremap'd memory, but without byteswapping. |
||
1239 | */ |
||
1240 | static inline void vmw_mmio_write(u32 value, u32 *addr) |
||
1241 | { |
||
1242 | WRITE_ONCE(*addr, value); |
||
1243 | } |
||
4075 | Serge | 1244 | #endif> |