[PATCH 1/6] drm/amdgpu: move taking mmap_sem into get_user_pages

Felix Kuehling felix.kuehling at amd.com
Tue Sep 5 22:02:57 UTC 2017


I found another problem as I was looking at adapting KFD's userptr code.


On 2017-09-05 11:37 AM, Christian König wrote:
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -622,6 +622,8 @@ int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages)
>  	if (!(gtt->userflags & AMDGPU_GEM_USERPTR_READONLY))
>  		flags |= FOLL_WRITE;
>  
> +	down_read(&current->mm->mmap_sem);
> +
>  	if (gtt->userflags & AMDGPU_GEM_USERPTR_ANONONLY) {
>  		/* check that we only use anonymous memory
>  		   to prevent problems with writeback */
> @@ -657,6 +659,8 @@ int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages)
>  
>  	} while (pinned < ttm->num_pages);
>  
> +	up_read(&current->mm->mmap_sem);
> +
>  	return 0;
>  
>  release_pages:

You need another up_read in the release_pages error handing path.

Regards,
  Felix


More information about the amd-gfx mailing list