[PATCH] drm/amdgpu: Fix the EPERM error when get user pages

Ma, Jun majun at amd.com
Tue May 16 06:44:13 UTC 2023



On 5/16/2023 5:03 AM, Deucher, Alexander wrote:
> [AMD Official Use Only - General]
> 
>> -----Original Message-----
>> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Ma
>> Jun
>> Sent: Monday, May 15, 2023 2:14 AM
>> To: amd-gfx at lists.freedesktop.org
>> Cc: Sierra Guiza, Alejandro (Alex) <Alex.Sierra at amd.com>; Ma, Jun
>> <Jun.Ma2 at amd.com>; Kuehling, Felix <Felix.Kuehling at amd.com>; Koenig,
>> Christian <Christian.Koenig at amd.com>
>> Subject: [PATCH] drm/amdgpu: Fix the EPERM error when get user pages
>>
>> Check and pass the readonly flags when set amdgpu_ttm_tt flags
>>
>> for readonly ptr pages. Otherwise, there is EPERM error returned
>>
>> during the KFDExceptionTest.PermissionFaultUserPointer test on
>>
>> ploaris10.
>>
>> Signed-off-by: Ma Jun <Jun.Ma2 at amd.com>
>> ---
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 9 ++++++++-
>>  1 file changed, 8 insertions(+), 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 d426333e865a..85d1087439c0 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
>> @@ -1036,10 +1036,17 @@ static int init_user_pages(struct kgd_mem
>> *mem, uint64_t user_addr,
>>  	struct ttm_operation_ctx ctx = { true, false };
>>  	struct hmm_range *range;
>>  	int ret = 0;
>> +	uint32_t tt_flags = 0;
>>
>>  	mutex_lock(&process_info->lock);
>>
>> -	ret = amdgpu_ttm_tt_set_userptr(&bo->tbo, user_addr, 0);
>> +	if(!(mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE))
> 
> Space between the if and (.  E.g., if (

Thanks, will fix in next version.

Regards,
Ma Jun
> 
> Alex
> 
>> +		tt_flags |= AMDGPU_GEM_USERPTR_READONLY;
>> +	else
>> +		tt_flags = 0;
>> +
>> +
>> +	ret = amdgpu_ttm_tt_set_userptr(&bo->tbo, user_addr, tt_flags);
>>  	if (ret) {
>>  		pr_err("%s: Failed to set userptr: %d\n", __func__, ret);
>>  		goto out;
>> --
>> 2.34.1


More information about the amd-gfx mailing list