diff mbox series

[2/7] drm/ttm: flip tt destroy ordering.

Message ID 20200917043040.146575-3-airlied@gmail.com
State New, archived
Headers show
Series drm/ttm: bind/unbind + cleanups | expand

Commit Message

Dave Airlie Sept. 17, 2020, 4:30 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

Call the driver first and have it call the common code cleanup.

This is useful later to fix unbind.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 1 +
 drivers/gpu/drm/drm_gem_vram_helper.c      | 1 +
 drivers/gpu/drm/nouveau/nouveau_bo.c       | 1 +
 drivers/gpu/drm/nouveau/nouveau_sgdma.c    | 1 +
 drivers/gpu/drm/qxl/qxl_ttm.c              | 1 +
 drivers/gpu/drm/radeon/radeon_ttm.c        | 3 +++
 drivers/gpu/drm/ttm/ttm_tt.c               | 7 ++++++-
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 1 +
 include/drm/ttm/ttm_tt.h                   | 7 +++++++
 9 files changed, 22 insertions(+), 1 deletion(-)

Comments

Christian König Sept. 17, 2020, 7:47 a.m. UTC | #1
Am 17.09.20 um 06:30 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> Call the driver first and have it call the common code cleanup.
>
> This is useful later to fix unbind.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 1 +
>   drivers/gpu/drm/drm_gem_vram_helper.c      | 1 +
>   drivers/gpu/drm/nouveau/nouveau_bo.c       | 1 +
>   drivers/gpu/drm/nouveau/nouveau_sgdma.c    | 1 +
>   drivers/gpu/drm/qxl/qxl_ttm.c              | 1 +
>   drivers/gpu/drm/radeon/radeon_ttm.c        | 3 +++
>   drivers/gpu/drm/ttm/ttm_tt.c               | 7 ++++++-
>   drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 1 +
>   include/drm/ttm/ttm_tt.h                   | 7 +++++++
>   9 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 2851cf30091a..dbe3f90a0cf6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -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);
>   
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index f96321509d7e..50cad0e4a92e 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -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);
>   }
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index 616d8844ba97..b239381498c3 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -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;
>   	}
> diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> index 21fb92770ea2..0dfaa6fb536e 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> @@ -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);
>   	}
> diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> index bf3b091d0e2a..fd691fff8394 100644
> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> @@ -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);
>   }
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index fc8bbca28b34..76e24c6058ff 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -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;
>   	}
> diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> index a4f0296effac..f43fa69a1e65 100644
> --- a/drivers/gpu/drm/ttm/ttm_tt.c
> +++ b/drivers/gpu/drm/ttm/ttm_tt.c
> @@ -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);
>   }
>   
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> index 01146b27c9a1..d46426164577 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> @@ -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);
> diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h
> index 4e906e32d08c..75208c0a0cac 100644
> --- a/include/drm/ttm/ttm_tt.h
> +++ b/include/drm/ttm/ttm_tt.h
> @@ -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:
>    *
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 2851cf30091a..dbe3f90a0cf6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -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);
 
diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index f96321509d7e..50cad0e4a92e 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -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);
 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 616d8844ba97..b239381498c3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -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;
 	}
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
index 21fb92770ea2..0dfaa6fb536e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
@@ -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);
 	}
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index bf3b091d0e2a..fd691fff8394 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -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);
 }
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index fc8bbca28b34..76e24c6058ff 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -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;
 	}
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index a4f0296effac..f43fa69a1e65 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -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);
 }
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
index 01146b27c9a1..d46426164577 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
@@ -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);
diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h
index 4e906e32d08c..75208c0a0cac 100644
--- a/include/drm/ttm/ttm_tt.h
+++ b/include/drm/ttm/ttm_tt.h
@@ -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:
  *