[PATCH] drm/amdgpu: Use dma_resv_lock instead in BO release_notify

Christian König christian.koenig at amd.com
Fri May 21 18:27:03 UTC 2021


Am 21.05.21 um 20:24 schrieb Felix Kuehling:
> Am 2021-05-21 um 1:26 a.m. schrieb xinhui pan:
>> The reservation object might be locked again by evict/swap after
>> individualized. The race is like below.
>> cpu 0					cpu 1
>> BO release				BO evict or swap
>> ttm_bo_individualize_resv {resv = &_resv}
>> 					ttm_bo_evict_swapout_allowable
>> 						dma_resv_trylock(resv)
>> ->release_notify() {BUG_ON(!trylock(resv))}
>> 					if (!ttm_bo_get_unless_zero))
>> 						dma_resv_unlock(resv)
>> Actually this is not a bug if trylock fails. So use dma_resv_lock
>> instead.
> Please test this with LOCKDEP enabled. I believe the trylock here was
> needed to avoid potential deadlocks. Maybe Christian can fill in more
> details.

Unfortunately I don't remember why trylock was needed here either.

But yes, testing with lockdep enabled is a really good idea.

Regards,
Christian.

>
> Regards,
>    Felix
>
>
>> Signed-off-by: xinhui pan <xinhui.pan at amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
>> index 928e8d57cd08..beacb46265f8 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
>> @@ -318,7 +318,7 @@ int amdgpu_amdkfd_remove_fence_on_pt_pd_bos(struct amdgpu_bo *bo)
>>   	ef = container_of(dma_fence_get(&info->eviction_fence->base),
>>   			struct amdgpu_amdkfd_fence, base);
>>   
>> -	BUG_ON(!dma_resv_trylock(bo->tbo.base.resv));
>> +	dma_resv_lock(bo->tbo.base.resv, NULL);
>>   	ret = amdgpu_amdkfd_remove_eviction_fence(bo, ef);
>>   	dma_resv_unlock(bo->tbo.base.resv);
>>   



More information about the amd-gfx mailing list