[PATCH 5/5] drm/ttm: revert "flip tt destroy ordering."

Christian König ckoenig.leichtzumerken at gmail.com
Thu Jul 22 09:19:03 UTC 2021


Am 22.07.21 um 11:11 schrieb Daniel Vetter:
> On Thu, Jul 22, 2021 at 10:55:54AM +0200, Christian König wrote:
>> It turned out that this is not a good idea at all because it leaves pointers
>> to freed up system memory pages in the GART tables of the drivers.
>>
>> Instead change the drivers to unbind their page tables during unpopulate and
>> merge those things back into ttm_tt_destroy() again.
>>
>> This reverts commit 7626168fd132009c79a0457bccc58014abc738f5.
> Can you pls duplicate this in each of the driver commit messages so it's a
> bit clearer what is going on?
>
> Usually the cover letter is first, not last :-)

Ah, yes of course. Actually wanted to do this, but then forgot about it.

Christian.

> -Daniel
>   
>> Signed-off-by: Christian König <christian.koenig at amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 1 -
>>   drivers/gpu/drm/drm_gem_vram_helper.c      | 1 -
>>   drivers/gpu/drm/i915/gem/i915_gem_ttm.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        | 2 --
>>   drivers/gpu/drm/ttm/ttm_tt.c               | 7 +------
>>   drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 1 -
>>   include/drm/ttm/ttm_tt.h                   | 7 -------
>>   10 files changed, 1 insertion(+), 22 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> index 42b5162814b1..6a6e04b64a80 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> @@ -1070,7 +1070,6 @@ static void amdgpu_ttm_backend_destroy(struct ttm_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 1e9b82e51a07..cc81fbac1a13 100644
>> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
>> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
>> @@ -846,7 +846,6 @@ static const struct drm_gem_object_funcs drm_gem_vram_object_funcs = {
>>   
>>   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);
>>   }
>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>> index bf33724bed5c..e646aac9d7a4 100644
>> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>> @@ -118,7 +118,6 @@ static void i915_ttm_tt_destroy(struct ttm_device *bdev, struct ttm_tt *ttm)
>>   {
>>   	struct i915_ttm_tt *i915_tt = container_of(ttm, typeof(*i915_tt), ttm);
>>   
>> -	ttm_tt_destroy_common(bdev, ttm);
>>   	kfree(i915_tt);
>>   }
>>   
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
>> index 5f309a4ec211..3177f89cf000 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
>> @@ -1291,7 +1291,6 @@ nouveau_ttm_tt_destroy(struct ttm_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 bde92a9dae7a..85c03c83259b 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
>> @@ -21,7 +21,6 @@ nouveau_sgdma_destroy(struct ttm_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_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 19fd39d9a00c..e91d8154143e 100644
>> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
>> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
>> @@ -101,7 +101,6 @@ int qxl_ttm_io_mem_reserve(struct ttm_device *bdev,
>>    */
>>   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);
>>   }
>> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
>> index ee343b76db54..7793249bc549 100644
>> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
>> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
>> @@ -488,7 +488,6 @@ static void radeon_ttm_backend_destroy(struct ttm_device *bdev, struct ttm_tt *t
>>   {
>>   	struct radeon_ttm_tt *gtt = (void *)ttm;
>>   
>> -	ttm_tt_destroy_common(bdev, ttm);
>>   	ttm_tt_fini(&gtt->ttm);
>>   	kfree(gtt);
>>   }
>> @@ -651,7 +650,6 @@ static void radeon_ttm_tt_destroy(struct ttm_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 24031a8acd2d..41f38d9c3e1c 100644
>> --- a/drivers/gpu/drm/ttm/ttm_tt.c
>> +++ b/drivers/gpu/drm/ttm/ttm_tt.c
>> @@ -123,7 +123,7 @@ static int ttm_sg_tt_alloc_page_directory(struct ttm_tt *ttm)
>>   	return 0;
>>   }
>>   
>> -void ttm_tt_destroy_common(struct ttm_device *bdev, struct ttm_tt *ttm)
>> +void ttm_tt_destroy(struct ttm_device *bdev, struct ttm_tt *ttm)
>>   {
>>   	ttm_tt_unpopulate(bdev, ttm);
>>   
>> @@ -131,11 +131,6 @@ void ttm_tt_destroy_common(struct ttm_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_device *bdev, struct ttm_tt *ttm)
>> -{
>>   	bdev->funcs->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 904031d03dbe..f35bdc1cb197 100644
>> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
>> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
>> @@ -526,7 +526,6 @@ static void vmw_ttm_destroy(struct ttm_device *bdev, struct ttm_tt *ttm)
>>   	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)
>> diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h
>> index 818680c6a8ed..e402dab1d0f6 100644
>> --- a/include/drm/ttm/ttm_tt.h
>> +++ b/include/drm/ttm/ttm_tt.h
>> @@ -134,13 +134,6 @@ void ttm_tt_fini(struct ttm_tt *ttm);
>>    */
>>   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:
>>    *
>> -- 
>> 2.25.1
>>



More information about the dri-devel mailing list