From: Felix Kuehling Date: Sat, 29 Jun 2019 05:50:35 +0000 (-0400) Subject: drm/amdgpu: Fix tracking of invalid userptrs X-Git-Tag: microblaze-v5.4-rc1~229^2~7^2~25 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=f4fd28b6c78cef054daf8d8b8dff8ef614ddfc00;p=linux-2.6-microblaze.git drm/amdgpu: Fix tracking of invalid userptrs Restore the code that resets mem->invalid. Othewise so mapping userptrs after they got an MMU notifiers would always be skipped. This also avoids unnecessarily calling get_user_pages on BOs that have not been invalidated since the last try. Signed-off-by: Felix Kuehling Reviewed-by: Philip Yang Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 764c8efad372..d02750cb5446 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -1740,6 +1740,12 @@ static int update_invalid_user_pages(struct amdkfd_process_info *process_info, } amdgpu_ttm_tt_get_user_pages_done(bo->tbo.ttm); + + /* Mark the BO as valid unless it was invalidated + * again concurrently. + */ + if (atomic_cmpxchg(&mem->invalid, invalid, 0) != invalid) + return -EAGAIN; } return 0;