drm/amdgpu: Fix the EPERM error when get user pages
Subsystems (3)
PATCH 1/1 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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +8 -1
@@ -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 )) + 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;
Signature · 1 line
2.34.1
Deucher, Alexander
maintainer[AMD Official Use Only - General]
Quoted 29 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Ma Jun
Sent: Monday, May 15, 2023 2:14 AM
To: [email protected]
Cc: Sierra Guiza, Alejandro (Alex) <[email protected]>; Ma, Jun <[email protected]>; Kuehling, Felix <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix the EPERM error when get user pagesCheck and pass the readonly flags when set
amdgpu_ttm_ttflagsfor readonly ptr pages. Otherwise, there is EPERM error returned
during the KFDExceptionTest.PermissionFaultUserPointer test on
ploaris10.
Signed-off-by Ma Jun <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c static int init_user_pages(struct kgd_mem · line 1044
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2
-1@@ -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 (
Alex
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +6
-0+ 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
Quoted 37 lines · Alexander
[AMD Official Use Only - General]
Quoted 35 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Ma Jun
Sent: Monday, May 15, 2023 2:14 AM
To: [email protected]
Cc: Sierra Guiza, Alejandro (Alex) <[email protected]>; Ma, Jun <[email protected]>; Kuehling, Felix <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix the EPERM error when get user pagesCheck and pass the readonly flags when set
amdgpu_ttm_ttflagsfor readonly ptr pages. Otherwise, there is EPERM error returned
during the KFDExceptionTest.PermissionFaultUserPointer test on
ploaris10.
Signed-off-by Ma Jun <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-0@@ -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 ;
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c static int init_user_pages(struct kgd_mem *mem, uint64_t user_addr, · line 1043
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-1mutex_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
Quoted 14 lines
Alex
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +6
-0+ 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