Move the functionality into ttm_tt_fini and ttm_bo_tt_destroy instead.
We don't need this any more since we removed the unbind from the destroy
code paths in the drivers.
Also add a warning to ttm_tt_fini() if we try to fini a still populated TT
object.
v2: instead of reverting the patch move the functionality to different
places.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210728130552.2074-5-christian.koenig@amd.com
 
 {
        struct amdgpu_ttm_tt *gtt = (void *)ttm;
 
-       ttm_tt_destroy_common(bdev, ttm);
        if (gtt->usertask)
                put_task_struct(gtt->usertask);
 
 
 
 static void bo_driver_ttm_tt_destroy(struct ttm_device *bdev, struct ttm_tt *tt)
 {
-       ttm_tt_destroy_common(bdev, tt);
        ttm_tt_fini(tt);
        kfree(tt);
 }
 
 {
        struct i915_ttm_tt *i915_tt = container_of(ttm, typeof(*i915_tt), ttm);
 
-       ttm_tt_destroy_common(bdev, ttm);
        kfree(i915_tt);
 }
 
 
 #if IS_ENABLED(CONFIG_AGP)
        struct nouveau_drm *drm = nouveau_bdev(bdev);
        if (drm->agp.bridge) {
-               ttm_tt_destroy_common(bdev, ttm);
                ttm_agp_destroy(ttm);
                return;
        }
 
        struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
 
        if (ttm) {
-               ttm_tt_destroy_common(bdev, ttm);
                ttm_tt_fini(&nvbe->ttm);
                kfree(nvbe);
        }
 
  */
 static void qxl_ttm_backend_destroy(struct ttm_device *bdev, struct ttm_tt *ttm)
 {
-       ttm_tt_destroy_common(bdev, ttm);
        ttm_tt_fini(ttm);
        kfree(ttm);
 }
 
 {
        struct radeon_ttm_tt *gtt = (void *)ttm;
 
-       ttm_tt_destroy_common(bdev, ttm);
        ttm_tt_fini(>t->ttm);
        kfree(gtt);
 }
        struct radeon_device *rdev = radeon_get_rdev(bdev);
 
        if (rdev->flags & RADEON_IS_AGP) {
-               ttm_tt_destroy_common(bdev, ttm);
                ttm_agp_destroy(ttm);
                return;
        }
 
        if (bo->ttm == NULL)
                return;
 
+       ttm_tt_unpopulate(bo->bdev, bo->ttm);
        ttm_tt_destroy(bo->bdev, bo->ttm);
        bo->ttm = NULL;
 }
 
        return 0;
 }
 
-void ttm_tt_destroy_common(struct ttm_device *bdev, struct ttm_tt *ttm)
-{
-       ttm_tt_unpopulate(bdev, ttm);
-
-       if (ttm->swap_storage)
-               fput(ttm->swap_storage);
-
-       ttm->swap_storage = NULL;
-}
-EXPORT_SYMBOL(ttm_tt_destroy_common);
-
 void ttm_tt_destroy(struct ttm_device *bdev, struct ttm_tt *ttm)
 {
        bdev->funcs->ttm_tt_destroy(bdev, ttm);
 
 void ttm_tt_fini(struct ttm_tt *ttm)
 {
+       WARN_ON(ttm->page_flags & TTM_PAGE_FLAG_PRIV_POPULATED);
+
+       if (ttm->swap_storage)
+               fput(ttm->swap_storage);
+       ttm->swap_storage = NULL;
+
        if (ttm->pages)
                kvfree(ttm->pages);
        else
 
        struct vmw_ttm_tt *vmw_be =
                container_of(ttm, struct vmw_ttm_tt, dma_ttm);
 
-       ttm_tt_destroy_common(bdev, ttm);
        vmw_ttm_unmap_dma(vmw_be);
        ttm_tt_fini(ttm);
        if (vmw_be->mob)
 
  */
 void ttm_tt_destroy(struct ttm_device *bdev, struct ttm_tt *ttm);
 
-/**
- * ttm_tt_destroy_common:
- *
- * Called from driver to destroy common path.
- */
-void ttm_tt_destroy_common(struct ttm_device *bdev, struct ttm_tt *ttm);
-
 /**
  * ttm_tt_swapin:
  *