aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_drv.c')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index f390f5f9cb68..ee24d216aa85 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -38,6 +38,10 @@
38#define VMWGFX_CHIP_SVGAII 0 38#define VMWGFX_CHIP_SVGAII 0
39#define VMW_FB_RESERVATION 0 39#define VMW_FB_RESERVATION 0
40 40
41#define VMW_MIN_INITIAL_WIDTH 800
42#define VMW_MIN_INITIAL_HEIGHT 600
43
44
41/** 45/**
42 * Fully encoded drm commands. Might move to vmw_drm.h 46 * Fully encoded drm commands. Might move to vmw_drm.h
43 */ 47 */
@@ -387,6 +391,41 @@ void vmw_3d_resource_dec(struct vmw_private *dev_priv,
387 BUG_ON(n3d < 0); 391 BUG_ON(n3d < 0);
388} 392}
389 393
394/**
395 * Sets the initial_[width|height] fields on the given vmw_private.
396 *
397 * It does so by reading SVGA_REG_[WIDTH|HEIGHT] regs and then
398 * clamping the value to fb_max_[width|height] fields and the
399 * VMW_MIN_INITIAL_[WIDTH|HEIGHT].
400 * If the values appear to be invalid, set them to
401 * VMW_MIN_INITIAL_[WIDTH|HEIGHT].
402 */
403static void vmw_get_initial_size(struct vmw_private *dev_priv)
404{
405 uint32_t width;
406 uint32_t height;
407
408 width = vmw_read(dev_priv, SVGA_REG_WIDTH);
409 height = vmw_read(dev_priv, SVGA_REG_HEIGHT);
410
411 width = max_t(uint32_t, width, VMW_MIN_INITIAL_WIDTH);
412 height = max_t(uint32_t, height, VMW_MIN_INITIAL_HEIGHT);
413
414 if (width > dev_priv->fb_max_width ||
415 height > dev_priv->fb_max_height) {
416
417 /*
418 * This is a host error and shouldn't occur.
419 */
420
421 width = VMW_MIN_INITIAL_WIDTH;
422 height = VMW_MIN_INITIAL_HEIGHT;
423 }
424
425 dev_priv->initial_width = width;
426 dev_priv->initial_height = height;
427}
428
390static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) 429static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
391{ 430{
392 struct vmw_private *dev_priv; 431 struct vmw_private *dev_priv;
@@ -400,6 +439,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
400 } 439 }
401 memset(dev_priv, 0, sizeof(*dev_priv)); 440 memset(dev_priv, 0, sizeof(*dev_priv));
402 441
442 pci_set_master(dev->pdev);
443
403 dev_priv->dev = dev; 444 dev_priv->dev = dev;
404 dev_priv->vmw_chipset = chipset; 445 dev_priv->vmw_chipset = chipset;
405 dev_priv->last_read_seqno = (uint32_t) -100; 446 dev_priv->last_read_seqno = (uint32_t) -100;
@@ -430,7 +471,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
430 svga_id = vmw_read(dev_priv, SVGA_REG_ID); 471 svga_id = vmw_read(dev_priv, SVGA_REG_ID);
431 if (svga_id != SVGA_ID_2) { 472 if (svga_id != SVGA_ID_2) {
432 ret = -ENOSYS; 473 ret = -ENOSYS;
433 DRM_ERROR("Unsuported SVGA ID 0x%x\n", svga_id); 474 DRM_ERROR("Unsupported SVGA ID 0x%x\n", svga_id);
434 mutex_unlock(&dev_priv->hw_mutex); 475 mutex_unlock(&dev_priv->hw_mutex);
435 goto out_err0; 476 goto out_err0;
436 } 477 }
@@ -441,6 +482,9 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
441 dev_priv->mmio_size = vmw_read(dev_priv, SVGA_REG_MEM_SIZE); 482 dev_priv->mmio_size = vmw_read(dev_priv, SVGA_REG_MEM_SIZE);
442 dev_priv->fb_max_width = vmw_read(dev_priv, SVGA_REG_MAX_WIDTH); 483 dev_priv->fb_max_width = vmw_read(dev_priv, SVGA_REG_MAX_WIDTH);
443 dev_priv->fb_max_height = vmw_read(dev_priv, SVGA_REG_MAX_HEIGHT); 484 dev_priv->fb_max_height = vmw_read(dev_priv, SVGA_REG_MAX_HEIGHT);
485
486 vmw_get_initial_size(dev_priv);
487
444 if (dev_priv->capabilities & SVGA_CAP_GMR) { 488 if (dev_priv->capabilities & SVGA_CAP_GMR) {
445 dev_priv->max_gmr_descriptors = 489 dev_priv->max_gmr_descriptors =
446 vmw_read(dev_priv, 490 vmw_read(dev_priv,
@@ -688,6 +732,15 @@ static int vmw_driver_unload(struct drm_device *dev)
688 return 0; 732 return 0;
689} 733}
690 734
735static void vmw_preclose(struct drm_device *dev,
736 struct drm_file *file_priv)
737{
738 struct vmw_fpriv *vmw_fp = vmw_fpriv(file_priv);
739 struct vmw_private *dev_priv = vmw_priv(dev);
740
741 vmw_event_fence_fpriv_gone(dev_priv->fman, &vmw_fp->fence_events);
742}
743
691static void vmw_postclose(struct drm_device *dev, 744static void vmw_postclose(struct drm_device *dev,
692 struct drm_file *file_priv) 745 struct drm_file *file_priv)
693{ 746{
@@ -710,6 +763,7 @@ static int vmw_driver_open(struct drm_device *dev, struct drm_file *file_priv)
710 if (unlikely(vmw_fp == NULL)) 763 if (unlikely(vmw_fp == NULL))
711 return ret; 764 return ret;
712 765
766 INIT_LIST_HEAD(&vmw_fp->fence_events);
713 vmw_fp->tfile = ttm_object_file_init(dev_priv->tdev, 10); 767 vmw_fp->tfile = ttm_object_file_init(dev_priv->tdev, 10);
714 if (unlikely(vmw_fp->tfile == NULL)) 768 if (unlikely(vmw_fp->tfile == NULL))
715 goto out_no_tfile; 769 goto out_no_tfile;
@@ -1102,6 +1156,7 @@ static struct drm_driver driver = {
1102 .master_set = vmw_master_set, 1156 .master_set = vmw_master_set,
1103 .master_drop = vmw_master_drop, 1157 .master_drop = vmw_master_drop,
1104 .open = vmw_driver_open, 1158 .open = vmw_driver_open,
1159 .preclose = vmw_preclose,
1105 .postclose = vmw_postclose, 1160 .postclose = vmw_postclose,
1106 .fops = &vmwgfx_driver_fops, 1161 .fops = &vmwgfx_driver_fops,
1107 .name = VMWGFX_DRIVER_NAME, 1162 .name = VMWGFX_DRIVER_NAME,