static int vmw_driver_unload(struct drm_device *dev) { struct vmw_private *dev_priv = vmw_priv(dev); enum vmw_res_type i; unregister_pm_notifier(&dev_priv->pm_nb); if (dev_priv->ctx.res_ht_initialized) drm_ht_remove(&dev_priv->ctx.res_ht); vfree(dev_priv->ctx.cmd_bounce); if (dev_priv->enable_fb) { vmw_fb_off(dev_priv); vmw_fb_close(dev_priv); vmw_fifo_resource_dec(dev_priv); vmw_svga_disable(dev_priv); } vmw_kms_close(dev_priv); vmw_overlay_close(dev_priv); if (dev_priv->has_gmr) (void)ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR); (void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM); vmw_release_device_early(dev_priv); if (dev_priv->has_mob) (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB); (void) ttm_bo_device_release(&dev_priv->bdev); vmw_release_device_late(dev_priv); vmw_fence_manager_takedown(dev_priv->fman); if (dev_priv->capabilities & SVGA_CAP_IRQMASK) drm_irq_uninstall(dev_priv->dev); if (dev_priv->stealth) pci_release_region(dev->pdev, 2); else pci_release_regions(dev->pdev); ttm_object_device_release(&dev_priv->tdev); iounmap(dev_priv->mmio_virt); arch_phys_wc_del(dev_priv->mmio_mtrr); if (dev_priv->ctx.staged_bindings) vmw_binding_state_free(dev_priv->ctx.staged_bindings); vmw_ttm_global_release(dev_priv); for (i = vmw_res_context; i < vmw_res_max; ++i) idr_destroy(&dev_priv->res_idr[i]); kfree(dev_priv); return 0; }
static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val, void *ptr) { struct vmw_private *dev_priv = container_of(nb, struct vmw_private, pm_nb); switch (val) { case PM_HIBERNATION_PREPARE: if (dev_priv->enable_fb) vmw_fb_off(dev_priv); ttm_suspend_lock(&dev_priv->reservation_sem); /* * This empties VRAM and unbinds all GMR bindings. * Buffer contents is moved to swappable memory. */ vmw_execbuf_release_pinned_bo(dev_priv); vmw_resource_evict_all(dev_priv); vmw_release_device_early(dev_priv); ttm_bo_swapout_all(&dev_priv->bdev); vmw_fence_fifo_down(dev_priv->fman); break; case PM_POST_HIBERNATION: case PM_POST_RESTORE: vmw_fence_fifo_up(dev_priv->fman); ttm_suspend_unlock(&dev_priv->reservation_sem); if (dev_priv->enable_fb) vmw_fb_on(dev_priv); break; case PM_RESTORE_PREPARE: break; default: break; } return 0; }
static int vmw_sou_crtc_set_config(struct drm_mode_set *set) { struct vmw_private *dev_priv; struct vmw_screen_object_unit *sou; struct drm_connector *connector; struct drm_display_mode *mode; struct drm_encoder *encoder; struct vmw_framebuffer *vfb; struct drm_framebuffer *fb; struct drm_crtc *crtc; int ret = 0; if (!set) return -EINVAL; if (!set->crtc) return -EINVAL; /* get the sou */ crtc = set->crtc; sou = vmw_crtc_to_sou(crtc); vfb = set->fb ? vmw_framebuffer_to_vfb(set->fb) : NULL; dev_priv = vmw_priv(crtc->dev); if (set->num_connectors > 1) { DRM_ERROR("to many connectors\n"); return -EINVAL; } if (set->num_connectors == 1 && set->connectors[0] != &sou->base.connector) { DRM_ERROR("connector doesn't match %p %p\n", set->connectors[0], &sou->base.connector); return -EINVAL; } /* sou only supports one fb active at the time */ if (sou->base.is_implicit && dev_priv->sou_priv->implicit_fb && vfb && !(dev_priv->sou_priv->num_implicit == 1 && sou->active_implicit) && dev_priv->sou_priv->implicit_fb != vfb) { DRM_ERROR("Multiple framebuffers not supported\n"); return -EINVAL; } /* since they always map one to one these are safe */ connector = &sou->base.connector; encoder = &sou->base.encoder; /* should we turn the crtc off */ if (set->num_connectors == 0 || !set->mode || !set->fb) { ret = vmw_sou_fifo_destroy(dev_priv, sou); /* the hardware has hung don't do anything more */ if (unlikely(ret != 0)) return ret; connector->encoder = NULL; encoder->crtc = NULL; crtc->fb = NULL; crtc->x = 0; crtc->y = 0; crtc->enabled = false; vmw_sou_del_active(dev_priv, sou); vmw_sou_backing_free(dev_priv, sou); return 0; } /* we now know we want to set a mode */ mode = set->mode; fb = set->fb; if (set->x + mode->hdisplay > fb->width || set->y + mode->vdisplay > fb->height) { DRM_ERROR("set outside of framebuffer\n"); return -EINVAL; } vmw_fb_off(dev_priv); if (mode->hdisplay != crtc->mode.hdisplay || mode->vdisplay != crtc->mode.vdisplay) { /* no need to check if depth is different, because backing * store depth is forced to 4 by the device. */ ret = vmw_sou_fifo_destroy(dev_priv, sou); /* the hardware has hung don't do anything more */ if (unlikely(ret != 0)) return ret; vmw_sou_backing_free(dev_priv, sou); } if (!sou->buffer) { /* forced to depth 4 by the device */ size_t size = mode->hdisplay * mode->vdisplay * 4; ret = vmw_sou_backing_alloc(dev_priv, sou, size); if (unlikely(ret != 0)) return ret; } ret = vmw_sou_fifo_create(dev_priv, sou, set->x, set->y, mode); if (unlikely(ret != 0)) { /* * We are in a bit of a situation here, the hardware has * hung and we may or may not have a buffer hanging of * the screen object, best thing to do is not do anything * if we where defined, if not just turn the crtc of. * Not what userspace wants but it needs to htfu. */ if (sou->defined) return ret; connector->encoder = NULL; encoder->crtc = NULL; crtc->fb = NULL; crtc->x = 0; crtc->y = 0; crtc->enabled = false; return ret; } vmw_sou_add_active(dev_priv, sou, vfb); connector->encoder = encoder; encoder->crtc = crtc; crtc->mode = *mode; crtc->fb = fb; crtc->x = set->x; crtc->y = set->y; crtc->enabled = true; return 0; }