@@ -637,6 +637,17 @@ static int vmw_init_vram_manager(struct vmw_private *dev_priv)
dev_priv->bdev.man[TTM_PL_VRAM].use_type = false;
return ret;
}
+
+static void vmw_takedown_vram_manager(struct vmw_private *dev_priv)
+{
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+ vmw_thp_takedown(dev_priv);
+#else
+ ttm_bo_man_takedown(&dev_priv->bdev,
+ &dev_priv->bdev.man[TTM_PL_VRAM]);
+#endif
+}
+
static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
{
struct vmw_private *dev_priv;
@@ -986,7 +997,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
(void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB);
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_takedown_vram_manager(dev_priv);
out_no_vram:
(void)ttm_bo_device_release(&dev_priv->bdev);
out_no_bdev:
@@ -1521,6 +1521,7 @@ vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf,
/* Transparent hugepage support - vmwgfx_thp.c */
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
extern int vmw_thp_init(struct vmw_private *dev_priv);
+void vmw_thp_takedown(struct vmw_private *dev_priv);
#endif
/**
@@ -135,21 +135,25 @@ int vmw_thp_init(struct vmw_private *dev_priv)
return 0;
}
-static int vmw_thp_takedown(struct ttm_mem_type_manager *man)
+void vmw_thp_takedown(struct vmw_private *dev_priv)
{
+ struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;
struct drm_mm *mm = &rman->mm;
+ int ret;
+
+ ttm_bo_disable_mm(man);
+ ret = ttm_bo_force_list_clean(&dev_priv->bdev, man);
+ if (ret)
+ return;
spin_lock(&rman->lock);
- if (drm_mm_clean(mm)) {
- drm_mm_takedown(mm);
- spin_unlock(&rman->lock);
- kfree(rman);
- man->priv = NULL;
- return 0;
- }
+ drm_mm_clean(mm);
+ drm_mm_takedown(mm);
spin_unlock(&rman->lock);
- return -EBUSY;
+ kfree(rman);
+ man->priv = NULL;
+ ttm_bo_man_cleanup(man);
}
static void vmw_thp_debug(struct ttm_mem_type_manager *man,
@@ -163,7 +167,6 @@ static void vmw_thp_debug(struct ttm_mem_type_manager *man,
}
const struct ttm_mem_type_manager_func vmw_thp_func = {
- .takedown = vmw_thp_takedown,
.get_node = vmw_thp_get_node,
.put_node = vmw_thp_put_node,
.debug = vmw_thp_debug