aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vmwgfx
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-07-26 03:26:29 -0400
committerDave Airlie <airlied@redhat.com>2016-07-26 03:26:29 -0400
commit5e580523d9128a4d8364fe89d36c38fc7819c8dd (patch)
tree852fb2427d980830ae8686a91e4ca5873f259ab9 /drivers/gpu/drm/vmwgfx
parentc11dea5b0290984fa48111957ba3fdc5b3bdae5a (diff)
parent523d939ef98fd712632d93a5a2b588e477a7565e (diff)
Backmerge tag 'v4.7' into drm-next
Linux 4.7 As requested by Daniel Vetter as the conflicts were getting messy.
Diffstat (limited to 'drivers/gpu/drm/vmwgfx')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c25
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c12
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.h1
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_fb.c47
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c10
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_msg.c3
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c8
7 files changed, 70 insertions, 36 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
index 9b078a493996..0cd889015dc5 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
@@ -49,6 +49,7 @@ int vmw_dmabuf_pin_in_placement(struct vmw_private *dev_priv,
49{ 49{
50 struct ttm_buffer_object *bo = &buf->base; 50 struct ttm_buffer_object *bo = &buf->base;
51 int ret; 51 int ret;
52 uint32_t new_flags;
52 53
53 ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible); 54 ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible);
54 if (unlikely(ret != 0)) 55 if (unlikely(ret != 0))
@@ -60,7 +61,12 @@ int vmw_dmabuf_pin_in_placement(struct vmw_private *dev_priv,
60 if (unlikely(ret != 0)) 61 if (unlikely(ret != 0))
61 goto err; 62 goto err;
62 63
63 ret = ttm_bo_validate(bo, placement, interruptible, false); 64 if (buf->pin_count > 0)
65 ret = ttm_bo_mem_compat(placement, &bo->mem,
66 &new_flags) == true ? 0 : -EINVAL;
67 else
68 ret = ttm_bo_validate(bo, placement, interruptible, false);
69
64 if (!ret) 70 if (!ret)
65 vmw_bo_pin_reserved(buf, true); 71 vmw_bo_pin_reserved(buf, true);
66 72
@@ -91,6 +97,7 @@ int vmw_dmabuf_pin_in_vram_or_gmr(struct vmw_private *dev_priv,
91{ 97{
92 struct ttm_buffer_object *bo = &buf->base; 98 struct ttm_buffer_object *bo = &buf->base;
93 int ret; 99 int ret;
100 uint32_t new_flags;
94 101
95 ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible); 102 ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible);
96 if (unlikely(ret != 0)) 103 if (unlikely(ret != 0))
@@ -102,6 +109,12 @@ int vmw_dmabuf_pin_in_vram_or_gmr(struct vmw_private *dev_priv,
102 if (unlikely(ret != 0)) 109 if (unlikely(ret != 0))
103 goto err; 110 goto err;
104 111
112 if (buf->pin_count > 0) {
113 ret = ttm_bo_mem_compat(&vmw_vram_gmr_placement, &bo->mem,
114 &new_flags) == true ? 0 : -EINVAL;
115 goto out_unreserve;
116 }
117
105 ret = ttm_bo_validate(bo, &vmw_vram_gmr_placement, interruptible, 118 ret = ttm_bo_validate(bo, &vmw_vram_gmr_placement, interruptible,
106 false); 119 false);
107 if (likely(ret == 0) || ret == -ERESTARTSYS) 120 if (likely(ret == 0) || ret == -ERESTARTSYS)
@@ -161,6 +174,7 @@ int vmw_dmabuf_pin_in_start_of_vram(struct vmw_private *dev_priv,
161 struct ttm_placement placement; 174 struct ttm_placement placement;
162 struct ttm_place place; 175 struct ttm_place place;
163 int ret = 0; 176 int ret = 0;
177 uint32_t new_flags;
164 178
165 place = vmw_vram_placement.placement[0]; 179 place = vmw_vram_placement.placement[0];
166 place.lpfn = bo->num_pages; 180 place.lpfn = bo->num_pages;
@@ -185,10 +199,15 @@ int vmw_dmabuf_pin_in_start_of_vram(struct vmw_private *dev_priv,
185 */ 199 */
186 if (bo->mem.mem_type == TTM_PL_VRAM && 200 if (bo->mem.mem_type == TTM_PL_VRAM &&
187 bo->mem.start < bo->num_pages && 201 bo->mem.start < bo->num_pages &&
188 bo->mem.start > 0) 202 bo->mem.start > 0 &&
203 buf->pin_count == 0)
189 (void) ttm_bo_validate(bo, &vmw_sys_placement, false, false); 204 (void) ttm_bo_validate(bo, &vmw_sys_placement, false, false);
190 205
191 ret = ttm_bo_validate(bo, &placement, interruptible, false); 206 if (buf->pin_count > 0)
207 ret = ttm_bo_mem_compat(&placement, &bo->mem,
208 &new_flags) == true ? 0 : -EINVAL;
209 else
210 ret = ttm_bo_validate(bo, &placement, interruptible, false);
192 211
193 /* For some reason we didn't end up at the start of vram */ 212 /* For some reason we didn't end up at the start of vram */
194 WARN_ON(ret == 0 && bo->offset != 0); 213 WARN_ON(ret == 0 && bo->offset != 0);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 5d5c9515618d..e8ae3dc476d1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -233,6 +233,7 @@ static int vmw_force_iommu;
233static int vmw_restrict_iommu; 233static int vmw_restrict_iommu;
234static int vmw_force_coherent; 234static int vmw_force_coherent;
235static int vmw_restrict_dma_mask; 235static int vmw_restrict_dma_mask;
236static int vmw_assume_16bpp;
236 237
237static int vmw_probe(struct pci_dev *, const struct pci_device_id *); 238static int vmw_probe(struct pci_dev *, const struct pci_device_id *);
238static void vmw_master_init(struct vmw_master *); 239static void vmw_master_init(struct vmw_master *);
@@ -249,6 +250,8 @@ MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages");
249module_param_named(force_coherent, vmw_force_coherent, int, 0600); 250module_param_named(force_coherent, vmw_force_coherent, int, 0600);
250MODULE_PARM_DESC(restrict_dma_mask, "Restrict DMA mask to 44 bits with IOMMU"); 251MODULE_PARM_DESC(restrict_dma_mask, "Restrict DMA mask to 44 bits with IOMMU");
251module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, 0600); 252module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, 0600);
253MODULE_PARM_DESC(assume_16bpp, "Assume 16-bpp when filtering modes");
254module_param_named(assume_16bpp, vmw_assume_16bpp, int, 0600);
252 255
253 256
254static void vmw_print_capabilities(uint32_t capabilities) 257static void vmw_print_capabilities(uint32_t capabilities)
@@ -660,6 +663,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
660 dev_priv->vram_start = pci_resource_start(dev->pdev, 1); 663 dev_priv->vram_start = pci_resource_start(dev->pdev, 1);
661 dev_priv->mmio_start = pci_resource_start(dev->pdev, 2); 664 dev_priv->mmio_start = pci_resource_start(dev->pdev, 2);
662 665
666 dev_priv->assume_16bpp = !!vmw_assume_16bpp;
667
663 dev_priv->enable_fb = enable_fbdev; 668 dev_priv->enable_fb = enable_fbdev;
664 669
665 vmw_write(dev_priv, SVGA_REG_ID, SVGA_ID_2); 670 vmw_write(dev_priv, SVGA_REG_ID, SVGA_ID_2);
@@ -706,6 +711,13 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
706 vmw_read(dev_priv, 711 vmw_read(dev_priv,
707 SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB); 712 SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB);
708 713
714 /*
715 * Workaround for low memory 2D VMs to compensate for the
716 * allocation taken by fbdev
717 */
718 if (!(dev_priv->capabilities & SVGA_CAP_3D))
719 mem_size *= 2;
720
709 dev_priv->max_mob_pages = mem_size * 1024 / PAGE_SIZE; 721 dev_priv->max_mob_pages = mem_size * 1024 / PAGE_SIZE;
710 dev_priv->prim_bb_mem = 722 dev_priv->prim_bb_mem =
711 vmw_read(dev_priv, 723 vmw_read(dev_priv,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 9a90f824814e..74304b03f9d4 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -387,6 +387,7 @@ struct vmw_private {
387 spinlock_t hw_lock; 387 spinlock_t hw_lock;
388 spinlock_t cap_lock; 388 spinlock_t cap_lock;
389 bool has_dx; 389 bool has_dx;
390 bool assume_16bpp;
390 391
391 /* 392 /*
392 * VGA registers. 393 * VGA registers.
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index 679a4cb98ee3..d2d93959b119 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -517,28 +517,6 @@ static int vmw_fb_kms_framebuffer(struct fb_info *info)
517 517
518 par->set_fb = &vfb->base; 518 par->set_fb = &vfb->base;
519 519
520 if (!par->bo_ptr) {
521 /*
522 * Pin before mapping. Since we don't know in what placement
523 * to pin, call into KMS to do it for us.
524 */
525 ret = vfb->pin(vfb);
526 if (ret) {
527 DRM_ERROR("Could not pin the fbdev framebuffer.\n");
528 return ret;
529 }
530
531 ret = ttm_bo_kmap(&par->vmw_bo->base, 0,
532 par->vmw_bo->base.num_pages, &par->map);
533 if (ret) {
534 vfb->unpin(vfb);
535 DRM_ERROR("Could not map the fbdev framebuffer.\n");
536 return ret;
537 }
538
539 par->bo_ptr = ttm_kmap_obj_virtual(&par->map, &par->bo_iowrite);
540 }
541
542 return 0; 520 return 0;
543} 521}
544 522
@@ -601,6 +579,31 @@ static int vmw_fb_set_par(struct fb_info *info)
601 if (ret) 579 if (ret)
602 goto out_unlock; 580 goto out_unlock;
603 581
582 if (!par->bo_ptr) {
583 struct vmw_framebuffer *vfb = vmw_framebuffer_to_vfb(set.fb);
584
585 /*
586 * Pin before mapping. Since we don't know in what placement
587 * to pin, call into KMS to do it for us.
588 */
589 ret = vfb->pin(vfb);
590 if (ret) {
591 DRM_ERROR("Could not pin the fbdev framebuffer.\n");
592 goto out_unlock;
593 }
594
595 ret = ttm_bo_kmap(&par->vmw_bo->base, 0,
596 par->vmw_bo->base.num_pages, &par->map);
597 if (ret) {
598 vfb->unpin(vfb);
599 DRM_ERROR("Could not map the fbdev framebuffer.\n");
600 goto out_unlock;
601 }
602
603 par->bo_ptr = ttm_kmap_obj_virtual(&par->map, &par->bo_iowrite);
604 }
605
606
604 vmw_fb_dirty_mark(par, par->fb_x, par->fb_y, 607 vmw_fb_dirty_mark(par, par->fb_x, par->fb_y,
605 par->set_fb->width, par->set_fb->height); 608 par->set_fb->width, par->set_fb->height);
606 609
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 8a69d4da40b5..bf28ccc150df 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -1555,14 +1555,10 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
1555 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) 1555 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC)
1556 }; 1556 };
1557 int i; 1557 int i;
1558 u32 assumed_bpp = 2; 1558 u32 assumed_bpp = 4;
1559 1559
1560 /* 1560 if (dev_priv->assume_16bpp)
1561 * If using screen objects, then assume 32-bpp because that's what the 1561 assumed_bpp = 2;
1562 * SVGA device is assuming
1563 */
1564 if (dev_priv->active_display_unit == vmw_du_screen_object)
1565 assumed_bpp = 4;
1566 1562
1567 if (dev_priv->active_display_unit == vmw_du_screen_target) { 1563 if (dev_priv->active_display_unit == vmw_du_screen_target) {
1568 max_width = min(max_width, dev_priv->stdu_max_width); 1564 max_width = min(max_width, dev_priv->stdu_max_width);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
index f0374f9b56ca..e57a0bad7a62 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -300,6 +300,9 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg,
300 break; 300 break;
301 } 301 }
302 302
303 if (retries == RETRIES)
304 return -EINVAL;
305
303 *msg_len = reply_len; 306 *msg_len = reply_len;
304 *msg = reply; 307 *msg = reply;
305 308
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
index 9ca818fb034c..41932a7c4f79 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
@@ -399,8 +399,10 @@ static int vmw_stdu_bind_fb(struct vmw_private *dev_priv,
399 399
400 WARN_ON_ONCE(!stdu->defined); 400 WARN_ON_ONCE(!stdu->defined);
401 401
402 if (!vfb->dmabuf && new_fb->width == mode->hdisplay && 402 new_vfbs = (vfb->dmabuf) ? NULL : vmw_framebuffer_to_vfbs(new_fb);
403 new_fb->height == mode->vdisplay) 403
404 if (new_vfbs && new_vfbs->surface->base_size.width == mode->hdisplay &&
405 new_vfbs->surface->base_size.height == mode->vdisplay)
404 new_content_type = SAME_AS_DISPLAY; 406 new_content_type = SAME_AS_DISPLAY;
405 else if (vfb->dmabuf) 407 else if (vfb->dmabuf)
406 new_content_type = SEPARATE_DMA; 408 new_content_type = SEPARATE_DMA;
@@ -444,7 +446,6 @@ static int vmw_stdu_bind_fb(struct vmw_private *dev_priv,
444 content_srf.mip_levels[0] = 1; 446 content_srf.mip_levels[0] = 1;
445 content_srf.multisample_count = 0; 447 content_srf.multisample_count = 0;
446 } else { 448 } else {
447 new_vfbs = vmw_framebuffer_to_vfbs(new_fb);
448 content_srf = *new_vfbs->surface; 449 content_srf = *new_vfbs->surface;
449 } 450 }
450 451
@@ -464,7 +465,6 @@ static int vmw_stdu_bind_fb(struct vmw_private *dev_priv,
464 return ret; 465 return ret;
465 } 466 }
466 } else if (new_content_type == SAME_AS_DISPLAY) { 467 } else if (new_content_type == SAME_AS_DISPLAY) {
467 new_vfbs = vmw_framebuffer_to_vfbs(new_fb);
468 new_display_srf = vmw_surface_reference(new_vfbs->surface); 468 new_display_srf = vmw_surface_reference(new_vfbs->surface);
469 } 469 }
470 470