diff mbox series

[18/49] drm/vmwgfx: takedown vram manager

Message ID 20200731040520.3701599-19-airlied@gmail.com (mailing list archive)
State New, archived
Headers show
Series ttm mem manager refactoring. | expand

Commit Message

Dave Airlie July 31, 2020, 4:04 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

Don't bother returning EBUSY, nobody cares enough,
if the driver has a problem, it should deal with it.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 13 ++++++++++++-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 23 +++++++++++++----------
 3 files changed, 26 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 5ee5aa0aaa6a..7d65f9121cd7 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -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:
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 8f319dd6cdb4..b20056fdd042 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -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
 
 /**
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
index c4a9bee932c9..3591a93dad37 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
@@ -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