drm/ttm: flip tt destroy ordering.
authorDave Airlie <airlied@redhat.com>
Thu, 17 Sep 2020 03:20:48 +0000 (13:20 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 17 Sep 2020 20:14:41 +0000 (06:14 +1000)
Call the driver first and have it call the common code cleanup.

This is useful later to fix unbind.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200917043040.146575-3-airlied@gmail.com
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
drivers/gpu/drm/drm_gem_vram_helper.c
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/nouveau/nouveau_sgdma.c
drivers/gpu/drm/qxl/qxl_ttm.c
drivers/gpu/drm/radeon/radeon_ttm.c
drivers/gpu/drm/ttm/ttm_tt.c
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
include/drm/ttm/ttm_tt.h

index 2851cf30091a89a83451332406bd96ce12895d8a..dbe3f90a0cf60436e1628f77a6f724cab063f49b 100644 (file)
@@ -1267,6 +1267,7 @@ static void amdgpu_ttm_backend_destroy(struct ttm_bo_device *bdev,
 {
        struct amdgpu_ttm_tt *gtt = (void *)ttm;
 
+       ttm_tt_destroy_common(bdev, ttm);
        if (gtt->usertask)
                put_task_struct(gtt->usertask);
 
index f96321509d7eb3c7b4eec196ed704d7ccab701d0..50cad0e4a92e381677a181be89d2155c05fc4d4f 100644 (file)
@@ -922,6 +922,7 @@ static const struct drm_gem_object_funcs drm_gem_vram_object_funcs = {
 
 static void bo_driver_ttm_tt_destroy(struct ttm_bo_device *bdev, struct ttm_tt *tt)
 {
+       ttm_tt_destroy_common(bdev, tt);
        ttm_tt_fini(tt);
        kfree(tt);
 }
index 616d8844ba973c77ad64c2a959731f4ea88afb91..b239381498c3f8b9afdc559d1bd289a9ab82be16 100644 (file)
@@ -1372,6 +1372,7 @@ nouveau_ttm_tt_destroy(struct ttm_bo_device *bdev,
 #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;
        }
index 21fb92770ea206cec8648f44ec7211009d12841d..0dfaa6fb536ec800e57c40fb4a2590b8f7d04590 100644 (file)
@@ -20,6 +20,7 @@ nouveau_sgdma_destroy(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
        struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
 
        if (ttm) {
+               ttm_tt_destroy_common(bdev, ttm);
                ttm_dma_tt_fini(&nvbe->ttm);
                kfree(nvbe);
        }
index bf3b091d0e2ae3d092fa8319c3c7394c0217b788..fd691fff8394b847cd10d0862c7380c52cc5d7d4 100644 (file)
@@ -130,6 +130,7 @@ static void qxl_ttm_backend_destroy(struct ttm_bo_device *bdev,
 {
        struct qxl_ttm_tt *gtt = (void *)ttm;
 
+       ttm_tt_destroy_common(bdev, ttm);
        ttm_tt_fini(&gtt->ttm);
        kfree(gtt);
 }
index fc8bbca28b345667a12241d6905ba9a77e076a65..76e24c6058fff8fe02377dd428fcb3da0a53d0f5 100644 (file)
@@ -576,6 +576,8 @@ static void radeon_ttm_backend_destroy(struct ttm_bo_device *bdev, struct ttm_tt
 {
        struct radeon_ttm_tt *gtt = (void *)ttm;
 
+       ttm_tt_destroy_common(bdev, ttm);
+
        ttm_dma_tt_fini(&gtt->ttm);
        kfree(gtt);
 }
@@ -755,6 +757,7 @@ static void radeon_ttm_tt_destroy(struct ttm_bo_device *bdev,
        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;
        }
index a4f0296effaca95a8c0e33f630f6aa8f49e54145..f43fa69a1e65081448e8eeebf159268209d96697 100644 (file)
@@ -207,7 +207,7 @@ int ttm_tt_set_placement_caching(struct ttm_tt *ttm, uint32_t placement)
 }
 EXPORT_SYMBOL(ttm_tt_set_placement_caching);
 
-void ttm_tt_destroy(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
+void ttm_tt_destroy_common(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
 {
        ttm_tt_unpopulate(bdev, ttm);
 
@@ -216,6 +216,11 @@ void ttm_tt_destroy(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
                fput(ttm->swap_storage);
 
        ttm->swap_storage = NULL;
+}
+EXPORT_SYMBOL(ttm_tt_destroy_common);
+
+void ttm_tt_destroy(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
+{
        bdev->driver->ttm_tt_destroy(bdev, ttm);
 }
 
index 01146b27c9a1d0d323e816d41d4ba809f63199a9..d46426164577cb0345fd8cdec95e255e62b54f84 100644 (file)
@@ -636,6 +636,7 @@ static void vmw_ttm_destroy(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
        struct vmw_ttm_tt *vmw_be =
                container_of(ttm, struct vmw_ttm_tt, dma_ttm.ttm);
 
+       ttm_tt_destroy_common(bdev, ttm);
        vmw_ttm_unmap_dma(vmw_be);
        if (vmw_be->dev_priv->map_mode == vmw_dma_alloc_coherent)
                ttm_dma_tt_fini(&vmw_be->dma_ttm);
index 4e906e32d08cc27422eadcf3619c67ccd6ce1a65..75208c0a0cac0c98c7902c889cad0c7dd3914670 100644 (file)
@@ -155,6 +155,13 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma);
  */
 void ttm_tt_destroy(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
 
+/**
+ * ttm_tt_destroy_common:
+ *
+ * Called from driver to destroy common path.
+ */
+void ttm_tt_destroy_common(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
+
 /**
  * ttm_tt_swapin:
  *