.. | .. |
---|
28 | 28 | #ifndef _VMWGFX_DRV_H_ |
---|
29 | 29 | #define _VMWGFX_DRV_H_ |
---|
30 | 30 | |
---|
31 | | -#include "vmwgfx_reg.h" |
---|
32 | | -#include <drm/drmP.h> |
---|
33 | | -#include <drm/vmwgfx_drm.h> |
---|
34 | | -#include <drm/drm_hashtab.h> |
---|
35 | | -#include <drm/drm_auth.h> |
---|
36 | 31 | #include <linux/suspend.h> |
---|
37 | | -#include <drm/ttm/ttm_bo_driver.h> |
---|
38 | | -#include <drm/ttm/ttm_object.h> |
---|
39 | | -#include <drm/ttm/ttm_lock.h> |
---|
40 | | -#include <drm/ttm/ttm_execbuf_util.h> |
---|
41 | | -#include <drm/ttm/ttm_module.h> |
---|
42 | | -#include "vmwgfx_fence.h" |
---|
43 | 32 | #include <linux/sync_file.h> |
---|
44 | 33 | |
---|
| 34 | +#include <drm/drm_auth.h> |
---|
| 35 | +#include <drm/drm_device.h> |
---|
| 36 | +#include <drm/drm_file.h> |
---|
| 37 | +#include <drm/drm_hashtab.h> |
---|
| 38 | +#include <drm/drm_rect.h> |
---|
| 39 | + |
---|
| 40 | +#include <drm/ttm/ttm_bo_driver.h> |
---|
| 41 | +#include <drm/ttm/ttm_execbuf_util.h> |
---|
| 42 | +#include <drm/ttm/ttm_module.h> |
---|
| 43 | + |
---|
| 44 | +#include "ttm_lock.h" |
---|
| 45 | +#include "ttm_object.h" |
---|
| 46 | + |
---|
| 47 | +#include "vmwgfx_fence.h" |
---|
| 48 | +#include "vmwgfx_reg.h" |
---|
| 49 | +#include "vmwgfx_validation.h" |
---|
| 50 | + |
---|
| 51 | +/* |
---|
| 52 | + * FIXME: vmwgfx_drm.h needs to be last due to dependencies. |
---|
| 53 | + * uapi headers should not depend on header files outside uapi/. |
---|
| 54 | + */ |
---|
| 55 | +#include <drm/vmwgfx_drm.h> |
---|
| 56 | + |
---|
| 57 | + |
---|
45 | 58 | #define VMWGFX_DRIVER_NAME "vmwgfx" |
---|
46 | | -#define VMWGFX_DRIVER_DATE "20180704" |
---|
| 59 | +#define VMWGFX_DRIVER_DATE "20200114" |
---|
47 | 60 | #define VMWGFX_DRIVER_MAJOR 2 |
---|
48 | | -#define VMWGFX_DRIVER_MINOR 15 |
---|
| 61 | +#define VMWGFX_DRIVER_MINOR 18 |
---|
49 | 62 | #define VMWGFX_DRIVER_PATCHLEVEL 0 |
---|
50 | | -#define VMWGFX_FILE_PAGE_OFFSET 0x00100000 |
---|
51 | 63 | #define VMWGFX_FIFO_STATIC_SIZE (1024*1024) |
---|
52 | 64 | #define VMWGFX_MAX_RELOCATIONS 2048 |
---|
53 | 65 | #define VMWGFX_MAX_VALIDATIONS 2048 |
---|
.. | .. |
---|
70 | 82 | VMWGFX_NUM_GB_SCREEN_TARGET) |
---|
71 | 83 | |
---|
72 | 84 | #define VMW_PL_GMR (TTM_PL_PRIV + 0) |
---|
73 | | -#define VMW_PL_FLAG_GMR (TTM_PL_FLAG_PRIV << 0) |
---|
74 | 85 | #define VMW_PL_MOB (TTM_PL_PRIV + 1) |
---|
75 | | -#define VMW_PL_FLAG_MOB (TTM_PL_FLAG_PRIV << 1) |
---|
76 | 86 | |
---|
77 | 87 | #define VMW_RES_CONTEXT ttm_driver_type0 |
---|
78 | 88 | #define VMW_RES_SURFACE ttm_driver_type1 |
---|
.. | .. |
---|
81 | 91 | #define VMW_RES_SHADER ttm_driver_type4 |
---|
82 | 92 | |
---|
83 | 93 | struct vmw_fpriv { |
---|
84 | | - struct drm_master *locked_master; |
---|
85 | 94 | struct ttm_object_file *tfile; |
---|
86 | 95 | bool gb_aware; /* user-space is guest-backed aware */ |
---|
87 | 96 | }; |
---|
88 | 97 | |
---|
| 98 | +/** |
---|
| 99 | + * struct vmw_buffer_object - TTM buffer object with vmwgfx additions |
---|
| 100 | + * @base: The TTM buffer object |
---|
| 101 | + * @res_tree: RB tree of resources using this buffer object as a backing MOB |
---|
| 102 | + * @pin_count: pin depth |
---|
| 103 | + * @cpu_writers: Number of synccpu write grabs. Protected by reservation when |
---|
| 104 | + * increased. May be decreased without reservation. |
---|
| 105 | + * @dx_query_ctx: DX context if this buffer object is used as a DX query MOB |
---|
| 106 | + * @map: Kmap object for semi-persistent mappings |
---|
| 107 | + * @res_prios: Eviction priority counts for attached resources |
---|
| 108 | + * @dirty: structure for user-space dirty-tracking |
---|
| 109 | + */ |
---|
89 | 110 | struct vmw_buffer_object { |
---|
90 | 111 | struct ttm_buffer_object base; |
---|
91 | | - struct list_head res_list; |
---|
| 112 | + struct rb_root res_tree; |
---|
92 | 113 | s32 pin_count; |
---|
| 114 | + atomic_t cpu_writers; |
---|
93 | 115 | /* Not ref-counted. Protected by binding_mutex */ |
---|
94 | 116 | struct vmw_resource *dx_query_ctx; |
---|
95 | 117 | /* Protected by reservation */ |
---|
96 | 118 | struct ttm_bo_kmap_obj map; |
---|
| 119 | + u32 res_prios[TTM_MAX_BO_PRIORITY]; |
---|
| 120 | + struct vmw_bo_dirty *dirty; |
---|
97 | 121 | }; |
---|
98 | 122 | |
---|
99 | 123 | /** |
---|
.. | .. |
---|
112 | 136 | }; |
---|
113 | 137 | |
---|
114 | 138 | struct vmw_res_func; |
---|
| 139 | + |
---|
| 140 | + |
---|
| 141 | +/** |
---|
| 142 | + * struct vmw-resource - base class for hardware resources |
---|
| 143 | + * |
---|
| 144 | + * @kref: For refcounting. |
---|
| 145 | + * @dev_priv: Pointer to the device private for this resource. Immutable. |
---|
| 146 | + * @id: Device id. Protected by @dev_priv::resource_lock. |
---|
| 147 | + * @backup_size: Backup buffer size. Immutable. |
---|
| 148 | + * @res_dirty: Resource contains data not yet in the backup buffer. Protected |
---|
| 149 | + * by resource reserved. |
---|
| 150 | + * @backup_dirty: Backup buffer contains data not yet in the HW resource. |
---|
| 151 | + * Protected by resource reserved. |
---|
| 152 | + * @coherent: Emulate coherency by tracking vm accesses. |
---|
| 153 | + * @backup: The backup buffer if any. Protected by resource reserved. |
---|
| 154 | + * @backup_offset: Offset into the backup buffer if any. Protected by resource |
---|
| 155 | + * reserved. Note that only a few resource types can have a @backup_offset |
---|
| 156 | + * different from zero. |
---|
| 157 | + * @pin_count: The pin count for this resource. A pinned resource has a |
---|
| 158 | + * pin-count greater than zero. It is not on the resource LRU lists and its |
---|
| 159 | + * backup buffer is pinned. Hence it can't be evicted. |
---|
| 160 | + * @func: Method vtable for this resource. Immutable. |
---|
| 161 | + * @mob_node; Node for the MOB backup rbtree. Protected by @backup reserved. |
---|
| 162 | + * @lru_head: List head for the LRU list. Protected by @dev_priv::resource_lock. |
---|
| 163 | + * @binding_head: List head for the context binding list. Protected by |
---|
| 164 | + * the @dev_priv::binding_mutex |
---|
| 165 | + * @res_free: The resource destructor. |
---|
| 166 | + * @hw_destroy: Callback to destroy the resource on the device, as part of |
---|
| 167 | + * resource destruction. |
---|
| 168 | + */ |
---|
| 169 | +struct vmw_resource_dirty; |
---|
115 | 170 | struct vmw_resource { |
---|
116 | 171 | struct kref kref; |
---|
117 | 172 | struct vmw_private *dev_priv; |
---|
118 | 173 | int id; |
---|
119 | | - bool avail; |
---|
| 174 | + u32 used_prio; |
---|
120 | 175 | unsigned long backup_size; |
---|
121 | | - bool res_dirty; /* Protected by backup buffer reserved */ |
---|
122 | | - bool backup_dirty; /* Protected by backup buffer reserved */ |
---|
| 176 | + u32 res_dirty : 1; |
---|
| 177 | + u32 backup_dirty : 1; |
---|
| 178 | + u32 coherent : 1; |
---|
123 | 179 | struct vmw_buffer_object *backup; |
---|
124 | 180 | unsigned long backup_offset; |
---|
125 | | - unsigned long pin_count; /* Protected by resource reserved */ |
---|
| 181 | + unsigned long pin_count; |
---|
126 | 182 | const struct vmw_res_func *func; |
---|
127 | | - struct list_head lru_head; /* Protected by the resource lock */ |
---|
128 | | - struct list_head mob_head; /* Protected by @backup reserved */ |
---|
129 | | - struct list_head binding_head; /* Protected by binding_mutex */ |
---|
| 183 | + struct rb_node mob_node; |
---|
| 184 | + struct list_head lru_head; |
---|
| 185 | + struct list_head binding_head; |
---|
| 186 | + struct vmw_resource_dirty *dirty; |
---|
130 | 187 | void (*res_free) (struct vmw_resource *res); |
---|
131 | 188 | void (*hw_destroy) (struct vmw_resource *res); |
---|
132 | 189 | }; |
---|
.. | .. |
---|
143 | 200 | vmw_res_dx_context, |
---|
144 | 201 | vmw_res_cotable, |
---|
145 | 202 | vmw_res_view, |
---|
| 203 | + vmw_res_streamoutput, |
---|
146 | 204 | vmw_res_max |
---|
147 | 205 | }; |
---|
148 | 206 | |
---|
.. | .. |
---|
151 | 209 | */ |
---|
152 | 210 | enum vmw_cmdbuf_res_type { |
---|
153 | 211 | vmw_cmdbuf_res_shader, |
---|
154 | | - vmw_cmdbuf_res_view |
---|
| 212 | + vmw_cmdbuf_res_view, |
---|
| 213 | + vmw_cmdbuf_res_streamoutput |
---|
155 | 214 | }; |
---|
156 | 215 | |
---|
157 | 216 | struct vmw_cmdbuf_res_manager; |
---|
.. | .. |
---|
164 | 223 | struct vmw_framebuffer; |
---|
165 | 224 | struct vmw_surface_offset; |
---|
166 | 225 | |
---|
167 | | -struct vmw_surface { |
---|
168 | | - struct vmw_resource res; |
---|
169 | | - SVGA3dSurfaceAllFlags flags; |
---|
170 | | - uint32_t format; |
---|
171 | | - uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES]; |
---|
| 226 | +/** |
---|
| 227 | + * struct vmw_surface_metadata - Metadata describing a surface. |
---|
| 228 | + * |
---|
| 229 | + * @flags: Device flags. |
---|
| 230 | + * @format: Surface SVGA3D_x format. |
---|
| 231 | + * @mip_levels: Mip level for each face. For GB first index is used only. |
---|
| 232 | + * @multisample_count: Sample count. |
---|
| 233 | + * @multisample_pattern: Sample patterns. |
---|
| 234 | + * @quality_level: Quality level. |
---|
| 235 | + * @autogen_filter: Filter for automatically generated mipmaps. |
---|
| 236 | + * @array_size: Number of array elements for a 1D/2D texture. For cubemap |
---|
| 237 | + texture number of faces * array_size. This should be 0 for pre |
---|
| 238 | + SM4 device. |
---|
| 239 | + * @buffer_byte_stride: Buffer byte stride. |
---|
| 240 | + * @num_sizes: Size of @sizes. For GB surface this should always be 1. |
---|
| 241 | + * @base_size: Surface dimension. |
---|
| 242 | + * @sizes: Array representing mip sizes. Legacy only. |
---|
| 243 | + * @scanout: Whether this surface will be used for scanout. |
---|
| 244 | + * |
---|
| 245 | + * This tracks metadata for both legacy and guest backed surface. |
---|
| 246 | + */ |
---|
| 247 | +struct vmw_surface_metadata { |
---|
| 248 | + u64 flags; |
---|
| 249 | + u32 format; |
---|
| 250 | + u32 mip_levels[DRM_VMW_MAX_SURFACE_FACES]; |
---|
| 251 | + u32 multisample_count; |
---|
| 252 | + u32 multisample_pattern; |
---|
| 253 | + u32 quality_level; |
---|
| 254 | + u32 autogen_filter; |
---|
| 255 | + u32 array_size; |
---|
| 256 | + u32 num_sizes; |
---|
| 257 | + u32 buffer_byte_stride; |
---|
172 | 258 | struct drm_vmw_size base_size; |
---|
173 | 259 | struct drm_vmw_size *sizes; |
---|
174 | | - uint32_t num_sizes; |
---|
175 | 260 | bool scanout; |
---|
176 | | - uint32_t array_size; |
---|
177 | | - /* TODO so far just a extra pointer */ |
---|
| 261 | +}; |
---|
| 262 | + |
---|
| 263 | +/** |
---|
| 264 | + * struct vmw_surface: Resource structure for a surface. |
---|
| 265 | + * |
---|
| 266 | + * @res: The base resource for this surface. |
---|
| 267 | + * @metadata: Metadata for this surface resource. |
---|
| 268 | + * @snooper: Cursor data. Legacy surface only. |
---|
| 269 | + * @offsets: Legacy surface only. |
---|
| 270 | + * @view_list: List of views bound to this surface. |
---|
| 271 | + */ |
---|
| 272 | +struct vmw_surface { |
---|
| 273 | + struct vmw_resource res; |
---|
| 274 | + struct vmw_surface_metadata metadata; |
---|
178 | 275 | struct vmw_cursor_snooper snooper; |
---|
179 | 276 | struct vmw_surface_offset *offsets; |
---|
180 | | - SVGA3dTextureFilter autogen_filter; |
---|
181 | | - uint32_t multisample_count; |
---|
182 | 277 | struct list_head view_list; |
---|
183 | | - SVGA3dMSPattern multisample_pattern; |
---|
184 | | - SVGA3dMSQualityLevel quality_level; |
---|
185 | 278 | }; |
---|
186 | 279 | |
---|
187 | 280 | struct vmw_marker_queue { |
---|
.. | .. |
---|
204 | 297 | bool dx; |
---|
205 | 298 | }; |
---|
206 | 299 | |
---|
207 | | -struct vmw_relocation { |
---|
208 | | - SVGAMobId *mob_loc; |
---|
209 | | - SVGAGuestPtr *location; |
---|
210 | | - uint32_t index; |
---|
211 | | -}; |
---|
212 | | - |
---|
213 | 300 | /** |
---|
214 | 301 | * struct vmw_res_cache_entry - resource information cache entry |
---|
215 | | - * |
---|
| 302 | + * @handle: User-space handle of a resource. |
---|
| 303 | + * @res: Non-ref-counted pointer to the resource. |
---|
| 304 | + * @valid_handle: Whether the @handle member is valid. |
---|
216 | 305 | * @valid: Whether the entry is valid, which also implies that the execbuf |
---|
217 | 306 | * code holds a reference to the resource, and it's placed on the |
---|
218 | 307 | * validation list. |
---|
219 | | - * @handle: User-space handle of a resource. |
---|
220 | | - * @res: Non-ref-counted pointer to the resource. |
---|
221 | 308 | * |
---|
222 | 309 | * Used to avoid frequent repeated user-space handle lookups of the |
---|
223 | 310 | * same resource. |
---|
224 | 311 | */ |
---|
225 | 312 | struct vmw_res_cache_entry { |
---|
226 | | - bool valid; |
---|
227 | 313 | uint32_t handle; |
---|
228 | 314 | struct vmw_resource *res; |
---|
229 | | - struct vmw_resource_val_node *node; |
---|
| 315 | + void *private; |
---|
| 316 | + unsigned short valid_handle; |
---|
| 317 | + unsigned short valid; |
---|
230 | 318 | }; |
---|
231 | 319 | |
---|
232 | 320 | /** |
---|
.. | .. |
---|
273 | 361 | struct vmw_piter { |
---|
274 | 362 | struct page **pages; |
---|
275 | 363 | const dma_addr_t *addrs; |
---|
276 | | - struct sg_page_iter iter; |
---|
| 364 | + struct sg_dma_page_iter iter; |
---|
277 | 365 | unsigned long i; |
---|
278 | 366 | unsigned long num_pages; |
---|
279 | 367 | bool (*next)(struct vmw_piter *); |
---|
.. | .. |
---|
291 | 379 | vmw_du_screen_target |
---|
292 | 380 | }; |
---|
293 | 381 | |
---|
| 382 | +struct vmw_validation_context; |
---|
| 383 | +struct vmw_ctx_validation_info; |
---|
294 | 384 | |
---|
| 385 | +/** |
---|
| 386 | + * struct vmw_sw_context - Command submission context |
---|
| 387 | + * @res_ht: Pointer hash table used to find validation duplicates |
---|
| 388 | + * @kernel: Whether the command buffer originates from kernel code rather |
---|
| 389 | + * than from user-space |
---|
| 390 | + * @fp: If @kernel is false, points to the file of the client. Otherwise |
---|
| 391 | + * NULL |
---|
| 392 | + * @cmd_bounce: Command bounce buffer used for command validation before |
---|
| 393 | + * copying to fifo space |
---|
| 394 | + * @cmd_bounce_size: Current command bounce buffer size |
---|
| 395 | + * @cur_query_bo: Current buffer object used as query result buffer |
---|
| 396 | + * @bo_relocations: List of buffer object relocations |
---|
| 397 | + * @res_relocations: List of resource relocations |
---|
| 398 | + * @buf_start: Pointer to start of memory where command validation takes |
---|
| 399 | + * place |
---|
| 400 | + * @res_cache: Cache of recently looked up resources |
---|
| 401 | + * @last_query_ctx: Last context that submitted a query |
---|
| 402 | + * @needs_post_query_barrier: Whether a query barrier is needed after |
---|
| 403 | + * command submission |
---|
| 404 | + * @staged_bindings: Cached per-context binding tracker |
---|
| 405 | + * @staged_bindings_inuse: Whether the cached per-context binding tracker |
---|
| 406 | + * is in use |
---|
| 407 | + * @staged_cmd_res: List of staged command buffer managed resources in this |
---|
| 408 | + * command buffer |
---|
| 409 | + * @ctx_list: List of context resources referenced in this command buffer |
---|
| 410 | + * @dx_ctx_node: Validation metadata of the current DX context |
---|
| 411 | + * @dx_query_mob: The MOB used for DX queries |
---|
| 412 | + * @dx_query_ctx: The DX context used for the last DX query |
---|
| 413 | + * @man: Pointer to the command buffer managed resource manager |
---|
| 414 | + * @ctx: The validation context |
---|
| 415 | + */ |
---|
295 | 416 | struct vmw_sw_context{ |
---|
296 | 417 | struct drm_open_hash res_ht; |
---|
297 | 418 | bool res_ht_initialized; |
---|
298 | | - bool kernel; /**< is the called made from the kernel */ |
---|
| 419 | + bool kernel; |
---|
299 | 420 | struct vmw_fpriv *fp; |
---|
300 | | - struct list_head validate_nodes; |
---|
301 | | - struct vmw_relocation relocs[VMWGFX_MAX_RELOCATIONS]; |
---|
302 | | - uint32_t cur_reloc; |
---|
303 | | - struct vmw_validate_buffer val_bufs[VMWGFX_MAX_VALIDATIONS]; |
---|
304 | | - uint32_t cur_val_buf; |
---|
305 | 421 | uint32_t *cmd_bounce; |
---|
306 | 422 | uint32_t cmd_bounce_size; |
---|
307 | | - struct list_head resource_list; |
---|
308 | | - struct list_head ctx_resource_list; /* For contexts and cotables */ |
---|
309 | 423 | struct vmw_buffer_object *cur_query_bo; |
---|
| 424 | + struct list_head bo_relocations; |
---|
310 | 425 | struct list_head res_relocations; |
---|
311 | 426 | uint32_t *buf_start; |
---|
312 | 427 | struct vmw_res_cache_entry res_cache[vmw_res_max]; |
---|
313 | 428 | struct vmw_resource *last_query_ctx; |
---|
314 | 429 | bool needs_post_query_barrier; |
---|
315 | | - struct vmw_resource *error_resource; |
---|
316 | 430 | struct vmw_ctx_binding_state *staged_bindings; |
---|
317 | 431 | bool staged_bindings_inuse; |
---|
318 | 432 | struct list_head staged_cmd_res; |
---|
319 | | - struct vmw_resource_val_node *dx_ctx_node; |
---|
| 433 | + struct list_head ctx_list; |
---|
| 434 | + struct vmw_ctx_validation_info *dx_ctx_node; |
---|
320 | 435 | struct vmw_buffer_object *dx_query_mob; |
---|
321 | 436 | struct vmw_resource *dx_query_ctx; |
---|
322 | 437 | struct vmw_cmdbuf_res_manager *man; |
---|
| 438 | + struct vmw_validation_context *ctx; |
---|
323 | 439 | }; |
---|
324 | 440 | |
---|
325 | 441 | struct vmw_legacy_display; |
---|
326 | 442 | struct vmw_overlay; |
---|
327 | | - |
---|
328 | | -struct vmw_master { |
---|
329 | | - struct ttm_lock lock; |
---|
330 | | -}; |
---|
331 | 443 | |
---|
332 | 444 | struct vmw_vga_topology_state { |
---|
333 | 445 | uint32_t width; |
---|
.. | .. |
---|
363 | 475 | VMW_IRQTHREAD_MAX |
---|
364 | 476 | }; |
---|
365 | 477 | |
---|
| 478 | +/** |
---|
| 479 | + * enum vmw_sm_type - Graphics context capability supported by device. |
---|
| 480 | + * @VMW_SM_LEGACY: Pre DX context. |
---|
| 481 | + * @VMW_SM_4: Context support upto SM4. |
---|
| 482 | + * @VMW_SM_4_1: Context support upto SM4_1. |
---|
| 483 | + * @VMW_SM_5: Context support up to SM5. |
---|
| 484 | + * @VMW_SM_MAX: Should be the last. |
---|
| 485 | + */ |
---|
| 486 | +enum vmw_sm_type { |
---|
| 487 | + VMW_SM_LEGACY = 0, |
---|
| 488 | + VMW_SM_4, |
---|
| 489 | + VMW_SM_4_1, |
---|
| 490 | + VMW_SM_5, |
---|
| 491 | + VMW_SM_MAX |
---|
| 492 | +}; |
---|
| 493 | + |
---|
366 | 494 | struct vmw_private { |
---|
367 | 495 | struct ttm_bo_device bdev; |
---|
368 | | - struct ttm_bo_global_ref bo_global_ref; |
---|
369 | | - struct drm_global_reference mem_global_ref; |
---|
370 | 496 | |
---|
371 | 497 | struct vmw_fifo_state fifo; |
---|
372 | 498 | |
---|
373 | 499 | struct drm_device *dev; |
---|
| 500 | + struct drm_vma_offset_manager vma_manager; |
---|
374 | 501 | unsigned long vmw_chipset; |
---|
375 | 502 | unsigned int io_start; |
---|
376 | 503 | uint32_t vram_start; |
---|
.. | .. |
---|
398 | 525 | bool has_mob; |
---|
399 | 526 | spinlock_t hw_lock; |
---|
400 | 527 | spinlock_t cap_lock; |
---|
401 | | - bool has_dx; |
---|
402 | 528 | bool assume_16bpp; |
---|
403 | | - bool has_sm4_1; |
---|
404 | 529 | |
---|
405 | | - /* |
---|
406 | | - * VGA registers. |
---|
407 | | - */ |
---|
408 | | - |
---|
409 | | - struct vmw_vga_topology_state vga_save[VMWGFX_MAX_DISPLAYS]; |
---|
410 | | - uint32_t vga_width; |
---|
411 | | - uint32_t vga_height; |
---|
412 | | - uint32_t vga_bpp; |
---|
413 | | - uint32_t vga_bpl; |
---|
414 | | - uint32_t vga_pitchlock; |
---|
415 | | - |
---|
416 | | - uint32_t num_displays; |
---|
417 | | - |
---|
418 | | - /* |
---|
419 | | - * Currently requested_layout_mutex is used to protect the gui |
---|
420 | | - * positionig state in display unit. With that use case currently this |
---|
421 | | - * mutex is only taken during layout ioctl and atomic check_modeset. |
---|
422 | | - * Other display unit state can be protected with this mutex but that |
---|
423 | | - * needs careful consideration. |
---|
424 | | - */ |
---|
425 | | - struct mutex requested_layout_mutex; |
---|
| 530 | + enum vmw_sm_type sm_type; |
---|
426 | 531 | |
---|
427 | 532 | /* |
---|
428 | 533 | * Framebuffer info. |
---|
.. | .. |
---|
434 | 539 | struct vmw_overlay *overlay_priv; |
---|
435 | 540 | struct drm_property *hotplug_mode_update_property; |
---|
436 | 541 | struct drm_property *implicit_placement_property; |
---|
437 | | - unsigned num_implicit; |
---|
438 | | - struct vmw_framebuffer *implicit_fb; |
---|
439 | 542 | struct mutex global_kms_state_mutex; |
---|
440 | 543 | spinlock_t cursor_lock; |
---|
441 | 544 | struct drm_atomic_state *suspend_state; |
---|
.. | .. |
---|
444 | 547 | * Context and surface management. |
---|
445 | 548 | */ |
---|
446 | 549 | |
---|
447 | | - rwlock_t resource_lock; |
---|
| 550 | + spinlock_t resource_lock; |
---|
448 | 551 | struct idr res_idr[vmw_res_max]; |
---|
449 | | - /* |
---|
450 | | - * Block lastclose from racing with firstopen. |
---|
451 | | - */ |
---|
452 | | - |
---|
453 | | - struct mutex init_mutex; |
---|
454 | 552 | |
---|
455 | 553 | /* |
---|
456 | 554 | * A resource manager for kernel-only surfaces and |
---|
.. | .. |
---|
504 | 602 | spinlock_t svga_lock; |
---|
505 | 603 | |
---|
506 | 604 | /** |
---|
507 | | - * Master management. |
---|
| 605 | + * PM management. |
---|
508 | 606 | */ |
---|
509 | | - |
---|
510 | | - struct vmw_master *active_master; |
---|
511 | | - struct vmw_master fbdev_master; |
---|
512 | 607 | struct notifier_block pm_nb; |
---|
513 | 608 | bool refuse_hibernation; |
---|
514 | 609 | bool suspend_locked; |
---|
.. | .. |
---|
554 | 649 | |
---|
555 | 650 | struct vmw_cmdbuf_man *cman; |
---|
556 | 651 | DECLARE_BITMAP(irqthread_pending, VMW_IRQTHREAD_MAX); |
---|
| 652 | + |
---|
| 653 | + /* Validation memory reservation */ |
---|
| 654 | + struct vmw_validation_mem vvm; |
---|
557 | 655 | }; |
---|
558 | 656 | |
---|
559 | 657 | static inline struct vmw_surface *vmw_res_to_srf(struct vmw_resource *res) |
---|
.. | .. |
---|
569 | 667 | static inline struct vmw_fpriv *vmw_fpriv(struct drm_file *file_priv) |
---|
570 | 668 | { |
---|
571 | 669 | return (struct vmw_fpriv *)file_priv->driver_priv; |
---|
572 | | -} |
---|
573 | | - |
---|
574 | | -static inline struct vmw_master *vmw_master(struct drm_master *master) |
---|
575 | | -{ |
---|
576 | | - return (struct vmw_master *) master->driver_priv; |
---|
577 | 670 | } |
---|
578 | 671 | |
---|
579 | 672 | /* |
---|
.. | .. |
---|
605 | 698 | return val; |
---|
606 | 699 | } |
---|
607 | 700 | |
---|
| 701 | +/** |
---|
| 702 | + * has_sm4_context - Does the device support SM4 context. |
---|
| 703 | + * @dev_priv: Device private. |
---|
| 704 | + * |
---|
| 705 | + * Return: Bool value if device support SM4 context or not. |
---|
| 706 | + */ |
---|
| 707 | +static inline bool has_sm4_context(const struct vmw_private *dev_priv) |
---|
| 708 | +{ |
---|
| 709 | + return (dev_priv->sm_type >= VMW_SM_4); |
---|
| 710 | +} |
---|
| 711 | + |
---|
| 712 | +/** |
---|
| 713 | + * has_sm4_1_context - Does the device support SM4_1 context. |
---|
| 714 | + * @dev_priv: Device private. |
---|
| 715 | + * |
---|
| 716 | + * Return: Bool value if device support SM4_1 context or not. |
---|
| 717 | + */ |
---|
| 718 | +static inline bool has_sm4_1_context(const struct vmw_private *dev_priv) |
---|
| 719 | +{ |
---|
| 720 | + return (dev_priv->sm_type >= VMW_SM_4_1); |
---|
| 721 | +} |
---|
| 722 | + |
---|
| 723 | +/** |
---|
| 724 | + * has_sm5_context - Does the device support SM5 context. |
---|
| 725 | + * @dev_priv: Device private. |
---|
| 726 | + * |
---|
| 727 | + * Return: Bool value if device support SM5 context or not. |
---|
| 728 | + */ |
---|
| 729 | +static inline bool has_sm5_context(const struct vmw_private *dev_priv) |
---|
| 730 | +{ |
---|
| 731 | + return (dev_priv->sm_type >= VMW_SM_5); |
---|
| 732 | +} |
---|
| 733 | + |
---|
608 | 734 | extern void vmw_svga_enable(struct vmw_private *dev_priv); |
---|
609 | 735 | extern void vmw_svga_disable(struct vmw_private *dev_priv); |
---|
610 | 736 | |
---|
.. | .. |
---|
628 | 754 | extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res); |
---|
629 | 755 | extern struct vmw_resource * |
---|
630 | 756 | vmw_resource_reference_unless_doomed(struct vmw_resource *res); |
---|
631 | | -extern int vmw_resource_validate(struct vmw_resource *res); |
---|
| 757 | +extern int vmw_resource_validate(struct vmw_resource *res, bool intr, |
---|
| 758 | + bool dirtying); |
---|
632 | 759 | extern int vmw_resource_reserve(struct vmw_resource *res, bool interruptible, |
---|
633 | 760 | bool no_backup); |
---|
634 | 761 | extern bool vmw_resource_needs_backup(const struct vmw_resource *res); |
---|
.. | .. |
---|
643 | 770 | uint32_t handle, |
---|
644 | 771 | const struct vmw_user_resource_conv *converter, |
---|
645 | 772 | struct vmw_resource **p_res); |
---|
| 773 | +extern struct vmw_resource * |
---|
| 774 | +vmw_user_resource_noref_lookup_handle(struct vmw_private *dev_priv, |
---|
| 775 | + struct ttm_object_file *tfile, |
---|
| 776 | + uint32_t handle, |
---|
| 777 | + const struct vmw_user_resource_conv * |
---|
| 778 | + converter); |
---|
646 | 779 | extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data, |
---|
647 | 780 | struct drm_file *file_priv); |
---|
648 | 781 | extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data, |
---|
.. | .. |
---|
652 | 785 | uint32_t *inout_id, |
---|
653 | 786 | struct vmw_resource **out); |
---|
654 | 787 | extern void vmw_resource_unreserve(struct vmw_resource *res, |
---|
| 788 | + bool dirty_set, |
---|
| 789 | + bool dirty, |
---|
655 | 790 | bool switch_backup, |
---|
656 | 791 | struct vmw_buffer_object *new_backup, |
---|
657 | 792 | unsigned long new_backup_offset); |
---|
658 | 793 | extern void vmw_query_move_notify(struct ttm_buffer_object *bo, |
---|
659 | | - struct ttm_mem_reg *mem); |
---|
| 794 | + struct ttm_resource *mem); |
---|
660 | 795 | extern int vmw_query_readback_all(struct vmw_buffer_object *dx_query_mob); |
---|
661 | 796 | extern void vmw_resource_evict_all(struct vmw_private *dev_priv); |
---|
662 | 797 | extern void vmw_resource_unbind_list(struct vmw_buffer_object *vbo); |
---|
| 798 | +void vmw_resource_mob_attach(struct vmw_resource *res); |
---|
| 799 | +void vmw_resource_mob_detach(struct vmw_resource *res); |
---|
| 800 | +void vmw_resource_dirty_update(struct vmw_resource *res, pgoff_t start, |
---|
| 801 | + pgoff_t end); |
---|
| 802 | +int vmw_resources_clean(struct vmw_buffer_object *vbo, pgoff_t start, |
---|
| 803 | + pgoff_t end, pgoff_t *num_prefault); |
---|
| 804 | + |
---|
| 805 | +/** |
---|
| 806 | + * vmw_resource_mob_attached - Whether a resource currently has a mob attached |
---|
| 807 | + * @res: The resource |
---|
| 808 | + * |
---|
| 809 | + * Return: true if the resource has a mob attached, false otherwise. |
---|
| 810 | + */ |
---|
| 811 | +static inline bool vmw_resource_mob_attached(const struct vmw_resource *res) |
---|
| 812 | +{ |
---|
| 813 | + return !RB_EMPTY_NODE(&res->mob_node); |
---|
| 814 | +} |
---|
| 815 | + |
---|
| 816 | +/** |
---|
| 817 | + * vmw_user_resource_noref_release - release a user resource pointer looked up |
---|
| 818 | + * without reference |
---|
| 819 | + */ |
---|
| 820 | +static inline void vmw_user_resource_noref_release(void) |
---|
| 821 | +{ |
---|
| 822 | + ttm_base_object_noref_release(); |
---|
| 823 | +} |
---|
663 | 824 | |
---|
664 | 825 | /** |
---|
665 | 826 | * Buffer object helper functions - vmwgfx_bo.c |
---|
.. | .. |
---|
687 | 848 | extern int vmw_bo_init(struct vmw_private *dev_priv, |
---|
688 | 849 | struct vmw_buffer_object *vmw_bo, |
---|
689 | 850 | size_t size, struct ttm_placement *placement, |
---|
690 | | - bool interuptable, |
---|
| 851 | + bool interruptible, |
---|
691 | 852 | void (*bo_free)(struct ttm_buffer_object *bo)); |
---|
692 | 853 | extern int vmw_user_bo_verify_access(struct ttm_buffer_object *bo, |
---|
693 | 854 | struct ttm_object_file *tfile); |
---|
.. | .. |
---|
715 | 876 | extern void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo); |
---|
716 | 877 | extern void vmw_bo_unmap(struct vmw_buffer_object *vbo); |
---|
717 | 878 | extern void vmw_bo_move_notify(struct ttm_buffer_object *bo, |
---|
718 | | - struct ttm_mem_reg *mem); |
---|
| 879 | + struct ttm_resource *mem); |
---|
719 | 880 | extern void vmw_bo_swap_notify(struct ttm_buffer_object *bo); |
---|
| 881 | +extern struct vmw_buffer_object * |
---|
| 882 | +vmw_user_bo_noref_lookup(struct ttm_object_file *tfile, u32 handle); |
---|
| 883 | + |
---|
| 884 | +/** |
---|
| 885 | + * vmw_user_bo_noref_release - release a buffer object pointer looked up |
---|
| 886 | + * without reference |
---|
| 887 | + */ |
---|
| 888 | +static inline void vmw_user_bo_noref_release(void) |
---|
| 889 | +{ |
---|
| 890 | + ttm_base_object_noref_release(); |
---|
| 891 | +} |
---|
| 892 | + |
---|
| 893 | +/** |
---|
| 894 | + * vmw_bo_adjust_prio - Adjust the buffer object eviction priority |
---|
| 895 | + * according to attached resources |
---|
| 896 | + * @vbo: The struct vmw_buffer_object |
---|
| 897 | + */ |
---|
| 898 | +static inline void vmw_bo_prio_adjust(struct vmw_buffer_object *vbo) |
---|
| 899 | +{ |
---|
| 900 | + int i = ARRAY_SIZE(vbo->res_prios); |
---|
| 901 | + |
---|
| 902 | + while (i--) { |
---|
| 903 | + if (vbo->res_prios[i]) { |
---|
| 904 | + vbo->base.priority = i; |
---|
| 905 | + return; |
---|
| 906 | + } |
---|
| 907 | + } |
---|
| 908 | + |
---|
| 909 | + vbo->base.priority = 3; |
---|
| 910 | +} |
---|
| 911 | + |
---|
| 912 | +/** |
---|
| 913 | + * vmw_bo_prio_add - Notify a buffer object of a newly attached resource |
---|
| 914 | + * eviction priority |
---|
| 915 | + * @vbo: The struct vmw_buffer_object |
---|
| 916 | + * @prio: The resource priority |
---|
| 917 | + * |
---|
| 918 | + * After being notified, the code assigns the highest resource eviction priority |
---|
| 919 | + * to the backing buffer object (mob). |
---|
| 920 | + */ |
---|
| 921 | +static inline void vmw_bo_prio_add(struct vmw_buffer_object *vbo, int prio) |
---|
| 922 | +{ |
---|
| 923 | + if (vbo->res_prios[prio]++ == 0) |
---|
| 924 | + vmw_bo_prio_adjust(vbo); |
---|
| 925 | +} |
---|
| 926 | + |
---|
| 927 | +/** |
---|
| 928 | + * vmw_bo_prio_del - Notify a buffer object of a resource with a certain |
---|
| 929 | + * priority being removed |
---|
| 930 | + * @vbo: The struct vmw_buffer_object |
---|
| 931 | + * @prio: The resource priority |
---|
| 932 | + * |
---|
| 933 | + * After being notified, the code assigns the highest resource eviction priority |
---|
| 934 | + * to the backing buffer object (mob). |
---|
| 935 | + */ |
---|
| 936 | +static inline void vmw_bo_prio_del(struct vmw_buffer_object *vbo, int prio) |
---|
| 937 | +{ |
---|
| 938 | + if (--vbo->res_prios[prio] == 0) |
---|
| 939 | + vmw_bo_prio_adjust(vbo); |
---|
| 940 | +} |
---|
720 | 941 | |
---|
721 | 942 | /** |
---|
722 | 943 | * Misc Ioctl functionality - vmwgfx_ioctl.c |
---|
.. | .. |
---|
743 | 964 | struct vmw_fifo_state *fifo); |
---|
744 | 965 | extern void vmw_fifo_release(struct vmw_private *dev_priv, |
---|
745 | 966 | struct vmw_fifo_state *fifo); |
---|
746 | | -extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes); |
---|
747 | 967 | extern void * |
---|
748 | 968 | vmw_fifo_reserve_dx(struct vmw_private *dev_priv, uint32_t bytes, int ctx_id); |
---|
749 | 969 | extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes); |
---|
750 | 970 | extern void vmw_fifo_commit_flush(struct vmw_private *dev_priv, uint32_t bytes); |
---|
751 | 971 | extern int vmw_fifo_send_fence(struct vmw_private *dev_priv, |
---|
752 | 972 | uint32_t *seqno); |
---|
753 | | -extern void vmw_fifo_ping_host_locked(struct vmw_private *, uint32_t reason); |
---|
754 | 973 | extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason); |
---|
755 | 974 | extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv); |
---|
756 | 975 | extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv); |
---|
.. | .. |
---|
759 | 978 | extern int vmw_fifo_flush(struct vmw_private *dev_priv, |
---|
760 | 979 | bool interruptible); |
---|
761 | 980 | |
---|
| 981 | +#define VMW_FIFO_RESERVE_DX(__priv, __bytes, __ctx_id) \ |
---|
| 982 | +({ \ |
---|
| 983 | + vmw_fifo_reserve_dx(__priv, __bytes, __ctx_id) ? : ({ \ |
---|
| 984 | + DRM_ERROR("FIFO reserve failed at %s for %u bytes\n", \ |
---|
| 985 | + __func__, (unsigned int) __bytes); \ |
---|
| 986 | + NULL; \ |
---|
| 987 | + }); \ |
---|
| 988 | +}) |
---|
| 989 | + |
---|
| 990 | +#define VMW_FIFO_RESERVE(__priv, __bytes) \ |
---|
| 991 | + VMW_FIFO_RESERVE_DX(__priv, __bytes, SVGA3D_INVALID_ID) |
---|
| 992 | + |
---|
762 | 993 | /** |
---|
763 | 994 | * TTM glue - vmwgfx_ttm_glue.c |
---|
764 | 995 | */ |
---|
765 | 996 | |
---|
766 | | -extern int vmw_ttm_global_init(struct vmw_private *dev_priv); |
---|
767 | | -extern void vmw_ttm_global_release(struct vmw_private *dev_priv); |
---|
768 | 997 | extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma); |
---|
| 998 | + |
---|
| 999 | +extern void vmw_validation_mem_init_ttm(struct vmw_private *dev_priv, |
---|
| 1000 | + size_t gran); |
---|
769 | 1001 | |
---|
770 | 1002 | /** |
---|
771 | 1003 | * TTM buffer object driver - vmwgfx_ttm_buffer.c |
---|
.. | .. |
---|
785 | 1017 | extern struct ttm_placement vmw_mob_ne_placement; |
---|
786 | 1018 | extern struct ttm_placement vmw_nonfixed_placement; |
---|
787 | 1019 | extern struct ttm_bo_driver vmw_bo_driver; |
---|
788 | | -extern int vmw_dma_quiescent(struct drm_device *dev); |
---|
789 | | -extern int vmw_bo_map_dma(struct ttm_buffer_object *bo); |
---|
790 | | -extern void vmw_bo_unmap_dma(struct ttm_buffer_object *bo); |
---|
791 | 1020 | extern const struct vmw_sg_table * |
---|
792 | 1021 | vmw_bo_sg_table(struct ttm_buffer_object *bo); |
---|
| 1022 | +extern int vmw_bo_create_and_populate(struct vmw_private *dev_priv, |
---|
| 1023 | + unsigned long bo_size, |
---|
| 1024 | + struct ttm_buffer_object **bo_p); |
---|
| 1025 | + |
---|
793 | 1026 | extern void vmw_piter_start(struct vmw_piter *viter, |
---|
794 | 1027 | const struct vmw_sg_table *vsgt, |
---|
795 | 1028 | unsigned long p_offs); |
---|
.. | .. |
---|
834 | 1067 | * Command submission - vmwgfx_execbuf.c |
---|
835 | 1068 | */ |
---|
836 | 1069 | |
---|
837 | | -extern int vmw_execbuf_ioctl(struct drm_device *dev, unsigned long data, |
---|
838 | | - struct drm_file *file_priv, size_t size); |
---|
| 1070 | +extern int vmw_execbuf_ioctl(struct drm_device *dev, void *data, |
---|
| 1071 | + struct drm_file *file_priv); |
---|
839 | 1072 | extern int vmw_execbuf_process(struct drm_file *file_priv, |
---|
840 | 1073 | struct vmw_private *dev_priv, |
---|
841 | 1074 | void __user *user_commands, |
---|
.. | .. |
---|
863 | 1096 | struct vmw_fence_obj *fence, |
---|
864 | 1097 | uint32_t fence_handle, |
---|
865 | 1098 | int32_t out_fence_fd); |
---|
866 | | -extern int vmw_validate_single_buffer(struct vmw_private *dev_priv, |
---|
867 | | - struct ttm_buffer_object *bo, |
---|
868 | | - bool interruptible, |
---|
869 | | - bool validate_as_mob); |
---|
870 | 1099 | bool vmw_cmd_describe(const void *buf, u32 *size, char const **cmd); |
---|
871 | 1100 | |
---|
872 | 1101 | /** |
---|
.. | .. |
---|
926 | 1155 | |
---|
927 | 1156 | int vmw_kms_init(struct vmw_private *dev_priv); |
---|
928 | 1157 | int vmw_kms_close(struct vmw_private *dev_priv); |
---|
929 | | -int vmw_kms_save_vga(struct vmw_private *vmw_priv); |
---|
930 | | -int vmw_kms_restore_vga(struct vmw_private *vmw_priv); |
---|
931 | 1158 | int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data, |
---|
932 | 1159 | struct drm_file *file_priv); |
---|
933 | 1160 | void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv); |
---|
.. | .. |
---|
938 | 1165 | int vmw_kms_write_svga(struct vmw_private *vmw_priv, |
---|
939 | 1166 | unsigned width, unsigned height, unsigned pitch, |
---|
940 | 1167 | unsigned bpp, unsigned depth); |
---|
941 | | -void vmw_kms_idle_workqueues(struct vmw_master *vmaster); |
---|
942 | 1168 | bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv, |
---|
943 | 1169 | uint32_t pitch, |
---|
944 | 1170 | uint32_t height); |
---|
945 | | -u32 vmw_get_vblank_counter(struct drm_device *dev, unsigned int pipe); |
---|
946 | | -int vmw_enable_vblank(struct drm_device *dev, unsigned int pipe); |
---|
947 | | -void vmw_disable_vblank(struct drm_device *dev, unsigned int pipe); |
---|
| 1171 | +u32 vmw_get_vblank_counter(struct drm_crtc *crtc); |
---|
| 1172 | +int vmw_enable_vblank(struct drm_crtc *crtc); |
---|
| 1173 | +void vmw_disable_vblank(struct drm_crtc *crtc); |
---|
948 | 1174 | int vmw_kms_present(struct vmw_private *dev_priv, |
---|
949 | 1175 | struct drm_file *file_priv, |
---|
950 | 1176 | struct vmw_framebuffer *vfb, |
---|
.. | .. |
---|
981 | 1207 | int vmw_overlay_close(struct vmw_private *dev_priv); |
---|
982 | 1208 | int vmw_overlay_ioctl(struct drm_device *dev, void *data, |
---|
983 | 1209 | struct drm_file *file_priv); |
---|
984 | | -int vmw_overlay_stop_all(struct vmw_private *dev_priv); |
---|
985 | 1210 | int vmw_overlay_resume_all(struct vmw_private *dev_priv); |
---|
986 | 1211 | int vmw_overlay_pause_all(struct vmw_private *dev_priv); |
---|
987 | 1212 | int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out); |
---|
.. | .. |
---|
993 | 1218 | * GMR Id manager |
---|
994 | 1219 | */ |
---|
995 | 1220 | |
---|
996 | | -extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; |
---|
| 1221 | +int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type); |
---|
| 1222 | +void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type); |
---|
997 | 1223 | |
---|
998 | 1224 | /** |
---|
999 | 1225 | * Prime - vmwgfx_prime.c |
---|
.. | .. |
---|
1028 | 1254 | |
---|
1029 | 1255 | extern const struct vmw_user_resource_conv *user_context_converter; |
---|
1030 | 1256 | |
---|
1031 | | -extern int vmw_context_check(struct vmw_private *dev_priv, |
---|
1032 | | - struct ttm_object_file *tfile, |
---|
1033 | | - int id, |
---|
1034 | | - struct vmw_resource **p_res); |
---|
1035 | 1257 | extern int vmw_context_define_ioctl(struct drm_device *dev, void *data, |
---|
1036 | 1258 | struct drm_file *file_priv); |
---|
1037 | 1259 | extern int vmw_extended_context_define_ioctl(struct drm_device *dev, void *data, |
---|
.. | .. |
---|
1061 | 1283 | |
---|
1062 | 1284 | extern const struct vmw_user_resource_conv *user_surface_converter; |
---|
1063 | 1285 | |
---|
1064 | | -extern void vmw_surface_res_free(struct vmw_resource *res); |
---|
1065 | 1286 | extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data, |
---|
1066 | 1287 | struct drm_file *file_priv); |
---|
1067 | 1288 | extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data, |
---|
.. | .. |
---|
1072 | 1293 | struct drm_file *file_priv); |
---|
1073 | 1294 | extern int vmw_gb_surface_reference_ioctl(struct drm_device *dev, void *data, |
---|
1074 | 1295 | struct drm_file *file_priv); |
---|
1075 | | -extern int vmw_surface_check(struct vmw_private *dev_priv, |
---|
1076 | | - struct ttm_object_file *tfile, |
---|
1077 | | - uint32_t handle, int *id); |
---|
1078 | | -extern int vmw_surface_validate(struct vmw_private *dev_priv, |
---|
1079 | | - struct vmw_surface *srf); |
---|
1080 | 1296 | int vmw_surface_gb_priv_define(struct drm_device *dev, |
---|
1081 | 1297 | uint32_t user_accounting_size, |
---|
1082 | 1298 | SVGA3dSurfaceAllFlags svga3d_flags, |
---|
.. | .. |
---|
1095 | 1311 | extern int vmw_gb_surface_reference_ext_ioctl(struct drm_device *dev, |
---|
1096 | 1312 | void *data, |
---|
1097 | 1313 | struct drm_file *file_priv); |
---|
| 1314 | + |
---|
| 1315 | +int vmw_gb_surface_define(struct vmw_private *dev_priv, |
---|
| 1316 | + uint32_t user_accounting_size, |
---|
| 1317 | + const struct vmw_surface_metadata *req, |
---|
| 1318 | + struct vmw_surface **srf_out); |
---|
1098 | 1319 | |
---|
1099 | 1320 | /* |
---|
1100 | 1321 | * Shader management - vmwgfx_shader.c |
---|
.. | .. |
---|
1127 | 1348 | extern struct vmw_resource * |
---|
1128 | 1349 | vmw_shader_lookup(struct vmw_cmdbuf_res_manager *man, |
---|
1129 | 1350 | u32 user_key, SVGA3dShaderType shader_type); |
---|
| 1351 | + |
---|
| 1352 | +/* |
---|
| 1353 | + * Streamoutput management |
---|
| 1354 | + */ |
---|
| 1355 | +struct vmw_resource * |
---|
| 1356 | +vmw_dx_streamoutput_lookup(struct vmw_cmdbuf_res_manager *man, |
---|
| 1357 | + u32 user_key); |
---|
| 1358 | +int vmw_dx_streamoutput_add(struct vmw_cmdbuf_res_manager *man, |
---|
| 1359 | + struct vmw_resource *ctx, |
---|
| 1360 | + SVGA3dStreamOutputId user_key, |
---|
| 1361 | + struct list_head *list); |
---|
| 1362 | +void vmw_dx_streamoutput_set_size(struct vmw_resource *res, u32 size); |
---|
| 1363 | +int vmw_dx_streamoutput_remove(struct vmw_cmdbuf_res_manager *man, |
---|
| 1364 | + SVGA3dStreamOutputId user_key, |
---|
| 1365 | + struct list_head *list); |
---|
| 1366 | +void vmw_dx_streamoutput_cotable_list_scrub(struct vmw_private *dev_priv, |
---|
| 1367 | + struct list_head *list, |
---|
| 1368 | + bool readback); |
---|
1130 | 1369 | |
---|
1131 | 1370 | /* |
---|
1132 | 1371 | * Command buffer managed resources - vmwgfx_cmdbuf_res.c |
---|
.. | .. |
---|
1245 | 1484 | int vmw_host_get_guestinfo(const char *guest_info_param, |
---|
1246 | 1485 | char *buffer, size_t *length); |
---|
1247 | 1486 | int vmw_host_log(const char *log); |
---|
| 1487 | +int vmw_msg_ioctl(struct drm_device *dev, void *data, |
---|
| 1488 | + struct drm_file *file_priv); |
---|
| 1489 | + |
---|
| 1490 | +/* VMW logging */ |
---|
| 1491 | + |
---|
| 1492 | +/** |
---|
| 1493 | + * VMW_DEBUG_USER - Debug output for user-space debugging. |
---|
| 1494 | + * |
---|
| 1495 | + * @fmt: printf() like format string. |
---|
| 1496 | + * |
---|
| 1497 | + * This macro is for logging user-space error and debugging messages for e.g. |
---|
| 1498 | + * command buffer execution errors due to malformed commands, invalid context, |
---|
| 1499 | + * etc. |
---|
| 1500 | + */ |
---|
| 1501 | +#define VMW_DEBUG_USER(fmt, ...) \ |
---|
| 1502 | + DRM_DEBUG_DRIVER(fmt, ##__VA_ARGS__) |
---|
| 1503 | + |
---|
| 1504 | +/* Resource dirtying - vmwgfx_page_dirty.c */ |
---|
| 1505 | +void vmw_bo_dirty_scan(struct vmw_buffer_object *vbo); |
---|
| 1506 | +int vmw_bo_dirty_add(struct vmw_buffer_object *vbo); |
---|
| 1507 | +void vmw_bo_dirty_transfer_to_res(struct vmw_resource *res); |
---|
| 1508 | +void vmw_bo_dirty_clear_res(struct vmw_resource *res); |
---|
| 1509 | +void vmw_bo_dirty_release(struct vmw_buffer_object *vbo); |
---|
| 1510 | +void vmw_bo_dirty_unmap(struct vmw_buffer_object *vbo, |
---|
| 1511 | + pgoff_t start, pgoff_t end); |
---|
| 1512 | +vm_fault_t vmw_bo_vm_fault(struct vm_fault *vmf); |
---|
| 1513 | +vm_fault_t vmw_bo_vm_mkwrite(struct vm_fault *vmf); |
---|
| 1514 | +#ifdef CONFIG_TRANSPARENT_HUGEPAGE |
---|
| 1515 | +vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf, |
---|
| 1516 | + enum page_entry_size pe_size); |
---|
| 1517 | +#endif |
---|
| 1518 | + |
---|
| 1519 | +/* Transparent hugepage support - vmwgfx_thp.c */ |
---|
| 1520 | +#ifdef CONFIG_TRANSPARENT_HUGEPAGE |
---|
| 1521 | +extern int vmw_thp_init(struct vmw_private *dev_priv); |
---|
| 1522 | +void vmw_thp_fini(struct vmw_private *dev_priv); |
---|
| 1523 | +#endif |
---|
| 1524 | + |
---|
| 1525 | +/** |
---|
| 1526 | + * VMW_DEBUG_KMS - Debug output for kernel mode-setting |
---|
| 1527 | + * |
---|
| 1528 | + * This macro is for debugging vmwgfx mode-setting code. |
---|
| 1529 | + */ |
---|
| 1530 | +#define VMW_DEBUG_KMS(fmt, ...) \ |
---|
| 1531 | + DRM_DEBUG_DRIVER(fmt, ##__VA_ARGS__) |
---|
1248 | 1532 | |
---|
1249 | 1533 | /** |
---|
1250 | 1534 | * Inline helper functions |
---|
.. | .. |
---|
1271 | 1555 | |
---|
1272 | 1556 | *buf = NULL; |
---|
1273 | 1557 | if (tmp_buf != NULL) { |
---|
1274 | | - struct ttm_buffer_object *bo = &tmp_buf->base; |
---|
1275 | | - |
---|
1276 | | - ttm_bo_unref(&bo); |
---|
| 1558 | + ttm_bo_put(&tmp_buf->base); |
---|
1277 | 1559 | } |
---|
1278 | 1560 | } |
---|
1279 | 1561 | |
---|
1280 | 1562 | static inline struct vmw_buffer_object * |
---|
1281 | 1563 | vmw_bo_reference(struct vmw_buffer_object *buf) |
---|
1282 | 1564 | { |
---|
1283 | | - if (ttm_bo_reference(&buf->base)) |
---|
1284 | | - return buf; |
---|
1285 | | - return NULL; |
---|
| 1565 | + ttm_bo_get(&buf->base); |
---|
| 1566 | + return buf; |
---|
1286 | 1567 | } |
---|
1287 | 1568 | |
---|
1288 | 1569 | static inline struct ttm_mem_global *vmw_mem_glob(struct vmw_private *dev_priv) |
---|
1289 | 1570 | { |
---|
1290 | | - return (struct ttm_mem_global *) dev_priv->mem_global_ref.object; |
---|
| 1571 | + return &ttm_mem_glob; |
---|
1291 | 1572 | } |
---|
1292 | 1573 | |
---|
1293 | 1574 | static inline void vmw_fifo_resource_inc(struct vmw_private *dev_priv) |
---|
.. | .. |
---|
1325 | 1606 | { |
---|
1326 | 1607 | WRITE_ONCE(*addr, value); |
---|
1327 | 1608 | } |
---|
| 1609 | + |
---|
| 1610 | +static inline bool vmw_shadertype_is_valid(enum vmw_sm_type shader_model, |
---|
| 1611 | + u32 shader_type) |
---|
| 1612 | +{ |
---|
| 1613 | + SVGA3dShaderType max_allowed = SVGA3D_SHADERTYPE_PREDX_MAX; |
---|
| 1614 | + |
---|
| 1615 | + if (shader_model >= VMW_SM_5) |
---|
| 1616 | + max_allowed = SVGA3D_SHADERTYPE_MAX; |
---|
| 1617 | + else if (shader_model >= VMW_SM_4) |
---|
| 1618 | + max_allowed = SVGA3D_SHADERTYPE_DX10_MAX; |
---|
| 1619 | + return shader_type >= SVGA3D_SHADERTYPE_MIN && shader_type < max_allowed; |
---|
| 1620 | +} |
---|
| 1621 | + |
---|
1328 | 1622 | #endif |
---|