diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2011-10-04 14:13:33 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-10-05 05:17:31 -0400 |
commit | 5bb39e818169783ee17ddbbefbd7bd16a4383fec (patch) | |
tree | a4af9f982e0c75e19b7e31bfdbaebc30e25b0bdc /drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | |
parent | 90ff18bc3a1ff56e3948ccf7ae4031b8e9662981 (diff) |
vmwgfx: Handle device surface memory limit
Make surfaces swappable. Make sure we honor the maximum amount of surface
memory the device accepts. This is done by potentially reading back surface
contents not used by the current command submission and storing it
locally in buffer objects.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_drv.c')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 7b88104144ca..a98ee19bd682 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | |||
@@ -402,6 +402,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) | |||
402 | init_waitqueue_head(&dev_priv->fifo_queue); | 402 | init_waitqueue_head(&dev_priv->fifo_queue); |
403 | dev_priv->fence_queue_waiters = 0; | 403 | dev_priv->fence_queue_waiters = 0; |
404 | atomic_set(&dev_priv->fifo_queue_waiters, 0); | 404 | atomic_set(&dev_priv->fifo_queue_waiters, 0); |
405 | INIT_LIST_HEAD(&dev_priv->surface_lru); | ||
406 | dev_priv->used_memory_size = 0; | ||
405 | 407 | ||
406 | dev_priv->io_start = pci_resource_start(dev->pdev, 0); | 408 | dev_priv->io_start = pci_resource_start(dev->pdev, 0); |
407 | dev_priv->vram_start = pci_resource_start(dev->pdev, 1); | 409 | dev_priv->vram_start = pci_resource_start(dev->pdev, 1); |
@@ -422,6 +424,10 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) | |||
422 | 424 | ||
423 | dev_priv->capabilities = vmw_read(dev_priv, SVGA_REG_CAPABILITIES); | 425 | dev_priv->capabilities = vmw_read(dev_priv, SVGA_REG_CAPABILITIES); |
424 | 426 | ||
427 | dev_priv->vram_size = vmw_read(dev_priv, SVGA_REG_VRAM_SIZE); | ||
428 | dev_priv->mmio_size = vmw_read(dev_priv, SVGA_REG_MEM_SIZE); | ||
429 | dev_priv->fb_max_width = vmw_read(dev_priv, SVGA_REG_MAX_WIDTH); | ||
430 | dev_priv->fb_max_height = vmw_read(dev_priv, SVGA_REG_MAX_HEIGHT); | ||
425 | if (dev_priv->capabilities & SVGA_CAP_GMR) { | 431 | if (dev_priv->capabilities & SVGA_CAP_GMR) { |
426 | dev_priv->max_gmr_descriptors = | 432 | dev_priv->max_gmr_descriptors = |
427 | vmw_read(dev_priv, | 433 | vmw_read(dev_priv, |
@@ -434,13 +440,15 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) | |||
434 | vmw_read(dev_priv, SVGA_REG_GMRS_MAX_PAGES); | 440 | vmw_read(dev_priv, SVGA_REG_GMRS_MAX_PAGES); |
435 | dev_priv->memory_size = | 441 | dev_priv->memory_size = |
436 | vmw_read(dev_priv, SVGA_REG_MEMORY_SIZE); | 442 | vmw_read(dev_priv, SVGA_REG_MEMORY_SIZE); |
443 | dev_priv->memory_size -= dev_priv->vram_size; | ||
444 | } else { | ||
445 | /* | ||
446 | * An arbitrary limit of 512MiB on surface | ||
447 | * memory. But all HWV8 hardware supports GMR2. | ||
448 | */ | ||
449 | dev_priv->memory_size = 512*1024*1024; | ||
437 | } | 450 | } |
438 | 451 | ||
439 | dev_priv->vram_size = vmw_read(dev_priv, SVGA_REG_VRAM_SIZE); | ||
440 | dev_priv->mmio_size = vmw_read(dev_priv, SVGA_REG_MEM_SIZE); | ||
441 | dev_priv->fb_max_width = vmw_read(dev_priv, SVGA_REG_MAX_WIDTH); | ||
442 | dev_priv->fb_max_height = vmw_read(dev_priv, SVGA_REG_MAX_HEIGHT); | ||
443 | |||
444 | mutex_unlock(&dev_priv->hw_mutex); | 452 | mutex_unlock(&dev_priv->hw_mutex); |
445 | 453 | ||
446 | vmw_print_capabilities(dev_priv->capabilities); | 454 | vmw_print_capabilities(dev_priv->capabilities); |
@@ -454,8 +462,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) | |||
454 | if (dev_priv->capabilities & SVGA_CAP_GMR2) { | 462 | if (dev_priv->capabilities & SVGA_CAP_GMR2) { |
455 | DRM_INFO("Max number of GMR pages is %u\n", | 463 | DRM_INFO("Max number of GMR pages is %u\n", |
456 | (unsigned)dev_priv->max_gmr_pages); | 464 | (unsigned)dev_priv->max_gmr_pages); |
457 | DRM_INFO("Max dedicated hypervisor graphics memory is %u\n", | 465 | DRM_INFO("Max dedicated hypervisor surface memory is %u kiB\n", |
458 | (unsigned)dev_priv->memory_size); | 466 | (unsigned)dev_priv->memory_size / 1024); |
459 | } | 467 | } |
460 | DRM_INFO("VRAM at 0x%08x size is %u kiB\n", | 468 | DRM_INFO("VRAM at 0x%08x size is %u kiB\n", |
461 | dev_priv->vram_start, dev_priv->vram_size / 1024); | 469 | dev_priv->vram_start, dev_priv->vram_size / 1024); |