aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2014-01-19 19:03:27 -0500
committerDave Airlie <airlied@redhat.com>2014-01-19 19:03:27 -0500
commit9354eafd893f45320a37da360e1728104e49cc2f (patch)
tree8cd82ac2ff70ea3a9fd97b432f10c880b1d97a4c /drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
parent53dac830537b51df555ba5e7ebb236705b7eaa7c (diff)
parent1985f99987ff04e1bb0405101dd8e25cf1b6b037 (diff)
Merge tag 'vmwgfx-next-2014-01-17' of git://people.freedesktop.org/~thomash/linux into drm-next
Pull request of 2014-01-17 Pull request for 3.14. One not so urgent fix, One huge device update. The pull request corresponds to the patches sent out on dri-devel, except: [PATCH 02/33], review tag typo pointed out by Matt Turner. [PATCH 04/33], dropped. The new surface formats are never used. The upcoming vmware svga2 hardware version 11 will introduce the concept of "guest backed objects" or -resources. The device will in principle get all of its memory from the guest, which has big advantages from the device point of view. This means that vmwgfx contexts, shaders and surfaces need to be backed by guest memory in the form of buffer objects called MOBs, presumably short for MemoryOBjects, which are bound to the device in a special way. This patch series introduces guest backed object support. Some new IOCTLs are added to allocate these new guest backed object, and to optionally provide them with a backing MOB. There is an update to the gallium driver that comes with this update, and it will be pushed in the near timeframe presumably to a separate mesa branch before merged to master. * tag 'vmwgfx-next-2014-01-17' of git://people.freedesktop.org/~thomash/linux: (33 commits) drm/vmwgfx: Invalidate surface on non-readback unbind drm/vmwgfx: Silence the device command verifier drm/vmwgfx: Implement 64-bit Otable- and MOB binding v2 drm/vmwgfx: Fix surface framebuffer check for guest-backed surfaces drm/vmwgfx: Update otable definitions drm/vmwgfx: Use the linux DMA api also for MOBs drm/vmwgfx: Ditch the vmw_dummy_query_bo_prepare function drm/vmwgfx: Persistent tracking of context bindings drm/vmwgfx: Track context bindings and scrub them upon exiting execbuf drm/vmwgfx: Block the BIND_SHADERCONSTS command drm/vmwgfx: Add a parameter to get max MOB memory size drm/vmwgfx: Implement a buffer object synccpu ioctl. drm/vmwgfx: Make sure that the multisampling is off drm/vmwgfx: Extend the command verifier to handle guest-backed on / off drm/vmwgfx: Fix up the vmwgfx_drv.h header for new files drm/vmwgfx: Enable 3D for new hardware version drm/vmwgfx: Add new unused (by user-space) commands to the verifier drm/vmwgfx: Validate guest-backed shader const commands drm/vmwgfx: Add guest-backed shaders drm/vmwgfx: Hook up guest-backed surfaces ...
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_drv.h')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.h211
1 files changed, 185 insertions, 26 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 036629dd992a..554e7fa33082 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -40,9 +40,9 @@
40#include <drm/ttm/ttm_module.h> 40#include <drm/ttm/ttm_module.h>
41#include "vmwgfx_fence.h" 41#include "vmwgfx_fence.h"
42 42
43#define VMWGFX_DRIVER_DATE "20120209" 43#define VMWGFX_DRIVER_DATE "20121114"
44#define VMWGFX_DRIVER_MAJOR 2 44#define VMWGFX_DRIVER_MAJOR 2
45#define VMWGFX_DRIVER_MINOR 4 45#define VMWGFX_DRIVER_MINOR 5
46#define VMWGFX_DRIVER_PATCHLEVEL 0 46#define VMWGFX_DRIVER_PATCHLEVEL 0
47#define VMWGFX_FILE_PAGE_OFFSET 0x00100000 47#define VMWGFX_FILE_PAGE_OFFSET 0x00100000
48#define VMWGFX_FIFO_STATIC_SIZE (1024*1024) 48#define VMWGFX_FIFO_STATIC_SIZE (1024*1024)
@@ -50,14 +50,30 @@
50#define VMWGFX_MAX_VALIDATIONS 2048 50#define VMWGFX_MAX_VALIDATIONS 2048
51#define VMWGFX_MAX_DISPLAYS 16 51#define VMWGFX_MAX_DISPLAYS 16
52#define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768 52#define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768
53#define VMWGFX_ENABLE_SCREEN_TARGET_OTABLE 0
54
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
62#define VMWGFX_NUM_MOB (VMWGFX_NUM_GB_CONTEXT +\
63 VMWGFX_NUM_GB_SHADER +\
64 VMWGFX_NUM_GB_SURFACE +\
65 VMWGFX_NUM_GB_SCREEN_TARGET)
53 66
54#define VMW_PL_GMR TTM_PL_PRIV0 67#define VMW_PL_GMR TTM_PL_PRIV0
55#define VMW_PL_FLAG_GMR TTM_PL_FLAG_PRIV0 68#define VMW_PL_FLAG_GMR TTM_PL_FLAG_PRIV0
69#define VMW_PL_MOB TTM_PL_PRIV1
70#define VMW_PL_FLAG_MOB TTM_PL_FLAG_PRIV1
56 71
57#define VMW_RES_CONTEXT ttm_driver_type0 72#define VMW_RES_CONTEXT ttm_driver_type0
58#define VMW_RES_SURFACE ttm_driver_type1 73#define VMW_RES_SURFACE ttm_driver_type1
59#define VMW_RES_STREAM ttm_driver_type2 74#define VMW_RES_STREAM ttm_driver_type2
60#define VMW_RES_FENCE ttm_driver_type3 75#define VMW_RES_FENCE ttm_driver_type3
76#define VMW_RES_SHADER ttm_driver_type4
61 77
62struct vmw_fpriv { 78struct vmw_fpriv {
63 struct drm_master *locked_master; 79 struct drm_master *locked_master;
@@ -82,6 +98,7 @@ struct vmw_dma_buffer {
82struct vmw_validate_buffer { 98struct vmw_validate_buffer {
83 struct ttm_validate_buffer base; 99 struct ttm_validate_buffer base;
84 struct drm_hash_item hash; 100 struct drm_hash_item hash;
101 bool validate_as_mob;
85}; 102};
86 103
87struct vmw_res_func; 104struct vmw_res_func;
@@ -98,6 +115,7 @@ struct vmw_resource {
98 const struct vmw_res_func *func; 115 const struct vmw_res_func *func;
99 struct list_head lru_head; /* Protected by the resource lock */ 116 struct list_head lru_head; /* Protected by the resource lock */
100 struct list_head mob_head; /* Protected by @backup reserved */ 117 struct list_head mob_head; /* Protected by @backup reserved */
118 struct list_head binding_head; /* Protected by binding_mutex */
101 void (*res_free) (struct vmw_resource *res); 119 void (*res_free) (struct vmw_resource *res);
102 void (*hw_destroy) (struct vmw_resource *res); 120 void (*hw_destroy) (struct vmw_resource *res);
103}; 121};
@@ -106,6 +124,7 @@ enum vmw_res_type {
106 vmw_res_context, 124 vmw_res_context,
107 vmw_res_surface, 125 vmw_res_surface,
108 vmw_res_stream, 126 vmw_res_stream,
127 vmw_res_shader,
109 vmw_res_max 128 vmw_res_max
110}; 129};
111 130
@@ -154,6 +173,7 @@ struct vmw_fifo_state {
154}; 173};
155 174
156struct vmw_relocation { 175struct vmw_relocation {
176 SVGAMobId *mob_loc;
157 SVGAGuestPtr *location; 177 SVGAGuestPtr *location;
158 uint32_t index; 178 uint32_t index;
159}; 179};
@@ -229,6 +249,71 @@ struct vmw_piter {
229 struct page *(*page)(struct vmw_piter *); 249 struct page *(*page)(struct vmw_piter *);
230}; 250};
231 251
252/*
253 * enum vmw_ctx_binding_type - abstract resource to context binding types
254 */
255enum vmw_ctx_binding_type {
256 vmw_ctx_binding_shader,
257 vmw_ctx_binding_rt,
258 vmw_ctx_binding_tex,
259 vmw_ctx_binding_max
260};
261
262/**
263 * struct vmw_ctx_bindinfo - structure representing a single context binding
264 *
265 * @ctx: Pointer to the context structure. NULL means the binding is not
266 * active.
267 * @res: Non ref-counted pointer to the bound resource.
268 * @bt: The binding type.
269 * @i1: Union of information needed to unbind.
270 */
271struct vmw_ctx_bindinfo {
272 struct vmw_resource *ctx;
273 struct vmw_resource *res;
274 enum vmw_ctx_binding_type bt;
275 union {
276 SVGA3dShaderType shader_type;
277 SVGA3dRenderTargetType rt_type;
278 uint32 texture_stage;
279 } i1;
280};
281
282/**
283 * struct vmw_ctx_binding - structure representing a single context binding
284 * - suitable for tracking in a context
285 *
286 * @ctx_list: List head for context.
287 * @res_list: List head for bound resource.
288 * @bi: Binding info
289 */
290struct vmw_ctx_binding {
291 struct list_head ctx_list;
292 struct list_head res_list;
293 struct vmw_ctx_bindinfo bi;
294};
295
296
297/**
298 * struct vmw_ctx_binding_state - context binding state
299 *
300 * @list: linked list of individual bindings.
301 * @render_targets: Render target bindings.
302 * @texture_units: Texture units/samplers bindings.
303 * @shaders: Shader bindings.
304 *
305 * Note that this structure also provides storage space for the individual
306 * struct vmw_ctx_binding objects, so that no dynamic allocation is needed
307 * for individual bindings.
308 *
309 */
310struct vmw_ctx_binding_state {
311 struct list_head list;
312 struct vmw_ctx_binding render_targets[SVGA3D_RT_MAX];
313 struct vmw_ctx_binding texture_units[SVGA3D_NUM_TEXTURE_UNITS];
314 struct vmw_ctx_binding shaders[SVGA3D_SHADERTYPE_MAX];
315};
316
232struct vmw_sw_context{ 317struct vmw_sw_context{
233 struct drm_open_hash res_ht; 318 struct drm_open_hash res_ht;
234 bool res_ht_initialized; 319 bool res_ht_initialized;
@@ -250,6 +335,7 @@ struct vmw_sw_context{
250 struct vmw_resource *last_query_ctx; 335 struct vmw_resource *last_query_ctx;
251 bool needs_post_query_barrier; 336 bool needs_post_query_barrier;
252 struct vmw_resource *error_resource; 337 struct vmw_resource *error_resource;
338 struct vmw_ctx_binding_state staged_bindings;
253}; 339};
254 340
255struct vmw_legacy_display; 341struct vmw_legacy_display;
@@ -281,6 +367,7 @@ struct vmw_private {
281 unsigned int io_start; 367 unsigned int io_start;
282 uint32_t vram_start; 368 uint32_t vram_start;
283 uint32_t vram_size; 369 uint32_t vram_size;
370 uint32_t prim_bb_mem;
284 uint32_t mmio_start; 371 uint32_t mmio_start;
285 uint32_t mmio_size; 372 uint32_t mmio_size;
286 uint32_t fb_max_width; 373 uint32_t fb_max_width;
@@ -290,11 +377,12 @@ struct vmw_private {
290 __le32 __iomem *mmio_virt; 377 __le32 __iomem *mmio_virt;
291 int mmio_mtrr; 378 int mmio_mtrr;
292 uint32_t capabilities; 379 uint32_t capabilities;
293 uint32_t max_gmr_descriptors;
294 uint32_t max_gmr_ids; 380 uint32_t max_gmr_ids;
295 uint32_t max_gmr_pages; 381 uint32_t max_gmr_pages;
382 uint32_t max_mob_pages;
296 uint32_t memory_size; 383 uint32_t memory_size;
297 bool has_gmr; 384 bool has_gmr;
385 bool has_mob;
298 struct mutex hw_mutex; 386 struct mutex hw_mutex;
299 387
300 /* 388 /*
@@ -370,6 +458,7 @@ struct vmw_private {
370 458
371 struct vmw_sw_context ctx; 459 struct vmw_sw_context ctx;
372 struct mutex cmdbuf_mutex; 460 struct mutex cmdbuf_mutex;
461 struct mutex binding_mutex;
373 462
374 /** 463 /**
375 * Operating mode. 464 * Operating mode.
@@ -415,6 +504,12 @@ struct vmw_private {
415 * DMA mapping stuff. 504 * DMA mapping stuff.
416 */ 505 */
417 enum vmw_dma_map_mode map_mode; 506 enum vmw_dma_map_mode map_mode;
507
508 /*
509 * Guest Backed stuff
510 */
511 struct ttm_buffer_object *otable_bo;
512 struct vmw_otable *otables;
418}; 513};
419 514
420static inline struct vmw_surface *vmw_res_to_srf(struct vmw_resource *res) 515static inline struct vmw_surface *vmw_res_to_srf(struct vmw_resource *res)
@@ -471,23 +566,12 @@ extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id);
471 * Resource utilities - vmwgfx_resource.c 566 * Resource utilities - vmwgfx_resource.c
472 */ 567 */
473struct vmw_user_resource_conv; 568struct vmw_user_resource_conv;
474extern const struct vmw_user_resource_conv *user_surface_converter;
475extern const struct vmw_user_resource_conv *user_context_converter;
476 569
477extern struct vmw_resource *vmw_context_alloc(struct vmw_private *dev_priv);
478extern void vmw_resource_unreference(struct vmw_resource **p_res); 570extern void vmw_resource_unreference(struct vmw_resource **p_res);
479extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res); 571extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res);
480extern int vmw_resource_validate(struct vmw_resource *res); 572extern int vmw_resource_validate(struct vmw_resource *res);
481extern int vmw_resource_reserve(struct vmw_resource *res, bool no_backup); 573extern int vmw_resource_reserve(struct vmw_resource *res, bool no_backup);
482extern bool vmw_resource_needs_backup(const struct vmw_resource *res); 574extern bool vmw_resource_needs_backup(const struct vmw_resource *res);
483extern int vmw_context_destroy_ioctl(struct drm_device *dev, void *data,
484 struct drm_file *file_priv);
485extern int vmw_context_define_ioctl(struct drm_device *dev, void *data,
486 struct drm_file *file_priv);
487extern int vmw_context_check(struct vmw_private *dev_priv,
488 struct ttm_object_file *tfile,
489 int id,
490 struct vmw_resource **p_res);
491extern int vmw_user_lookup_handle(struct vmw_private *dev_priv, 575extern int vmw_user_lookup_handle(struct vmw_private *dev_priv,
492 struct ttm_object_file *tfile, 576 struct ttm_object_file *tfile,
493 uint32_t handle, 577 uint32_t handle,
@@ -499,18 +583,6 @@ extern int vmw_user_resource_lookup_handle(
499 uint32_t handle, 583 uint32_t handle,
500 const struct vmw_user_resource_conv *converter, 584 const struct vmw_user_resource_conv *converter,
501 struct vmw_resource **p_res); 585 struct vmw_resource **p_res);
502extern void vmw_surface_res_free(struct vmw_resource *res);
503extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data,
504 struct drm_file *file_priv);
505extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
506 struct drm_file *file_priv);
507extern int vmw_surface_reference_ioctl(struct drm_device *dev, void *data,
508 struct drm_file *file_priv);
509extern int vmw_surface_check(struct vmw_private *dev_priv,
510 struct ttm_object_file *tfile,
511 uint32_t handle, int *id);
512extern int vmw_surface_validate(struct vmw_private *dev_priv,
513 struct vmw_surface *srf);
514extern void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo); 586extern void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo);
515extern int vmw_dmabuf_init(struct vmw_private *dev_priv, 587extern int vmw_dmabuf_init(struct vmw_private *dev_priv,
516 struct vmw_dma_buffer *vmw_bo, 588 struct vmw_dma_buffer *vmw_bo,
@@ -519,10 +591,21 @@ extern int vmw_dmabuf_init(struct vmw_private *dev_priv,
519 void (*bo_free) (struct ttm_buffer_object *bo)); 591 void (*bo_free) (struct ttm_buffer_object *bo));
520extern int vmw_user_dmabuf_verify_access(struct ttm_buffer_object *bo, 592extern int vmw_user_dmabuf_verify_access(struct ttm_buffer_object *bo,
521 struct ttm_object_file *tfile); 593 struct ttm_object_file *tfile);
594extern int vmw_user_dmabuf_alloc(struct vmw_private *dev_priv,
595 struct ttm_object_file *tfile,
596 uint32_t size,
597 bool shareable,
598 uint32_t *handle,
599 struct vmw_dma_buffer **p_dma_buf);
600extern int vmw_user_dmabuf_reference(struct ttm_object_file *tfile,
601 struct vmw_dma_buffer *dma_buf,
602 uint32_t *handle);
522extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, 603extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data,
523 struct drm_file *file_priv); 604 struct drm_file *file_priv);
524extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data, 605extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data,
525 struct drm_file *file_priv); 606 struct drm_file *file_priv);
607extern int vmw_user_dmabuf_synccpu_ioctl(struct drm_device *dev, void *data,
608 struct drm_file *file_priv);
526extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo, 609extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo,
527 uint32_t cur_validate_node); 610 uint32_t cur_validate_node);
528extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo); 611extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo);
@@ -622,10 +705,16 @@ extern struct ttm_placement vmw_vram_sys_placement;
622extern struct ttm_placement vmw_vram_gmr_placement; 705extern struct ttm_placement vmw_vram_gmr_placement;
623extern struct ttm_placement vmw_vram_gmr_ne_placement; 706extern struct ttm_placement vmw_vram_gmr_ne_placement;
624extern struct ttm_placement vmw_sys_placement; 707extern struct ttm_placement vmw_sys_placement;
708extern struct ttm_placement vmw_sys_ne_placement;
625extern struct ttm_placement vmw_evictable_placement; 709extern struct ttm_placement vmw_evictable_placement;
626extern struct ttm_placement vmw_srf_placement; 710extern struct ttm_placement vmw_srf_placement;
711extern struct ttm_placement vmw_mob_placement;
627extern struct ttm_bo_driver vmw_bo_driver; 712extern struct ttm_bo_driver vmw_bo_driver;
628extern int vmw_dma_quiescent(struct drm_device *dev); 713extern int vmw_dma_quiescent(struct drm_device *dev);
714extern int vmw_bo_map_dma(struct ttm_buffer_object *bo);
715extern void vmw_bo_unmap_dma(struct ttm_buffer_object *bo);
716extern const struct vmw_sg_table *
717vmw_bo_sg_table(struct ttm_buffer_object *bo);
629extern void vmw_piter_start(struct vmw_piter *viter, 718extern void vmw_piter_start(struct vmw_piter *viter,
630 const struct vmw_sg_table *vsgt, 719 const struct vmw_sg_table *vsgt,
631 unsigned long p_offs); 720 unsigned long p_offs);
@@ -832,6 +921,76 @@ extern int vmw_prime_handle_to_fd(struct drm_device *dev,
832 uint32_t handle, uint32_t flags, 921 uint32_t handle, uint32_t flags,
833 int *prime_fd); 922 int *prime_fd);
834 923
924/*
925 * MemoryOBject management - vmwgfx_mob.c
926 */
927struct vmw_mob;
928extern int vmw_mob_bind(struct vmw_private *dev_priv, struct vmw_mob *mob,
929 const struct vmw_sg_table *vsgt,
930 unsigned long num_data_pages, int32_t mob_id);
931extern void vmw_mob_unbind(struct vmw_private *dev_priv,
932 struct vmw_mob *mob);
933extern void vmw_mob_destroy(struct vmw_mob *mob);
934extern struct vmw_mob *vmw_mob_create(unsigned long data_pages);
935extern int vmw_otables_setup(struct vmw_private *dev_priv);
936extern void vmw_otables_takedown(struct vmw_private *dev_priv);
937
938/*
939 * Context management - vmwgfx_context.c
940 */
941
942extern const struct vmw_user_resource_conv *user_context_converter;
943
944extern struct vmw_resource *vmw_context_alloc(struct vmw_private *dev_priv);
945
946extern int vmw_context_check(struct vmw_private *dev_priv,
947 struct ttm_object_file *tfile,
948 int id,
949 struct vmw_resource **p_res);
950extern int vmw_context_define_ioctl(struct drm_device *dev, void *data,
951 struct drm_file *file_priv);
952extern int vmw_context_destroy_ioctl(struct drm_device *dev, void *data,
953 struct drm_file *file_priv);
954extern int vmw_context_binding_add(struct vmw_ctx_binding_state *cbs,
955 const struct vmw_ctx_bindinfo *ci);
956extern void
957vmw_context_binding_state_transfer(struct vmw_resource *res,
958 struct vmw_ctx_binding_state *cbs);
959extern void vmw_context_binding_res_list_kill(struct list_head *head);
960
961/*
962 * Surface management - vmwgfx_surface.c
963 */
964
965extern const struct vmw_user_resource_conv *user_surface_converter;
966
967extern void vmw_surface_res_free(struct vmw_resource *res);
968extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data,
969 struct drm_file *file_priv);
970extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
971 struct drm_file *file_priv);
972extern int vmw_surface_reference_ioctl(struct drm_device *dev, void *data,
973 struct drm_file *file_priv);
974extern int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data,
975 struct drm_file *file_priv);
976extern int vmw_gb_surface_reference_ioctl(struct drm_device *dev, void *data,
977 struct drm_file *file_priv);
978extern int vmw_surface_check(struct vmw_private *dev_priv,
979 struct ttm_object_file *tfile,
980 uint32_t handle, int *id);
981extern int vmw_surface_validate(struct vmw_private *dev_priv,
982 struct vmw_surface *srf);
983
984/*
985 * Shader management - vmwgfx_shader.c
986 */
987
988extern const struct vmw_user_resource_conv *user_shader_converter;
989
990extern int vmw_shader_define_ioctl(struct drm_device *dev, void *data,
991 struct drm_file *file_priv);
992extern int vmw_shader_destroy_ioctl(struct drm_device *dev, void *data,
993 struct drm_file *file_priv);
835 994
836/** 995/**
837 * Inline helper functions 996 * Inline helper functions