[PATCH v2 1/1] drm/amdgpu: cleanup gart tlb flush logic
Das, Nirmoy
nirmoy.das at amd.com
Fri May 28 14:51:40 UTC 2021
On 5/28/2021 4:48 PM, Christian König wrote:
> Am 28.05.21 um 16:44 schrieb Nirmoy Das:
>> Don't flush gpu tlb after recovering each BO instead
>> do it after receovering all the BOs.
>>
>> v2: abstract out gart tlb flushing logic to amdgpu_gart.c
>>
>> Signed-off-by: Nirmoy Das <nirmoy.das at amd.com>
>> ---
>> Is there a better way to get adev in amdgpu_gtt_mgr_recover()?
>>
>> drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 20 +++++++++++++++-----
>> drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h | 2 +-
>> drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 6 ++++++
>> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 1 +
>> 4 files changed, 23 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
>> index 5562b5c90c03..e2059f7ed639 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
>> @@ -322,16 +322,26 @@ int amdgpu_gart_bind(struct amdgpu_device
>> *adev, uint64_t offset,
>> if (!adev->gart.ptr)
>> return 0;
>>
>> - r = amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
>> - adev->gart.ptr);
>> - if (r)
>> - return r;
>> + return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
>> + adev->gart.ptr);
>> +}
>> +
>> +/**
>> + * amdgpu_gart_tlb_flush - flush gart TLB
>
> Either change the description like "flush GART changes" and drop the
> _tlb_ part of the name orr rename the function to
> amdgpu_gart_invalidate_tlb.
>
> Since we flush gart changes by invalidating the TLB. Otherwise we have
> a mixup in the name.
Thanks! amdgpu_gart_invalidate_tlb() sounds better to me, I will resend.
Nirmoy
>
> Sorry didn't though about that before, apart from that the patch looks
> good to me.
>
> Christian.
>
>
>> + *
>> + * @adev: amdgpu device driver pointer
>> + *
>> + * Flush TLB of gart page table.
>> + *
>> + */
>> +void amdgpu_gart_tlb_flush(struct amdgpu_device *adev)
>> +{
>> + int i;
>>
>> mb();
>> amdgpu_asic_flush_hdp(adev, NULL);
>> for (i = 0; i < adev->num_vmhubs; i++)
>> amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
>> - return 0;
>> }
>>
>> /**
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
>> index a25fe97b0196..c853b70a24cf 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
>> @@ -66,5 +66,5 @@ int amdgpu_gart_map(struct amdgpu_device *adev,
>> uint64_t offset,
>> int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
>> int pages, struct page **pagelist,
>> dma_addr_t *dma_addr, uint64_t flags);
>> -
>> +void amdgpu_gart_tlb_flush(struct amdgpu_device *adev);
>> #endif
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
>> index 8860545344c7..b61a54f6d95d 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
>> @@ -205,6 +205,7 @@ uint64_t amdgpu_gtt_mgr_usage(struct
>> ttm_resource_manager *man)
>> */
>> int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man)
>> {
>> + struct amdgpu_device *adev = NULL;
>> struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
>> struct amdgpu_gtt_node *node;
>> struct drm_mm_node *mm_node;
>> @@ -216,9 +217,14 @@ int amdgpu_gtt_mgr_recover(struct
>> ttm_resource_manager *man)
>> r = amdgpu_ttm_recover_gart(node->tbo);
>> if (r)
>> break;
>> + if (!adev)
>> + adev = amdgpu_ttm_adev(node->tbo->bdev);
>> }
>> spin_unlock(&mgr->lock);
>>
>> + if (adev)
>> + amdgpu_gart_tlb_flush(adev);
>> +
>> return r;
>> }
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> index c0aef327292a..5e514759d319 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> @@ -1014,6 +1014,7 @@ int amdgpu_ttm_alloc_gart(struct
>> ttm_buffer_object *bo)
>> return r;
>> }
>>
>> + amdgpu_gart_tlb_flush(adev);
>> ttm_resource_free(bo, &bo->mem);
>> bo->mem = tmp;
>> }
>> --
>> 2.31.1
>>
>
More information about the amd-gfx
mailing list