AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/amdgpu: Fix the EPERM error when get user pages
@ 2023-05-19 12:02 Ma Jun
  2023-05-19 20:37 ` Felix Kuehling
  0 siblings, 1 reply; 2+ messages in thread
From: Ma Jun @ 2023-05-19 12:02 UTC (permalink / raw)
  To: amd-gfx
  Cc: alex.sierra, felix.kuehling, Ma Jun, Alexander.Deucher,
	christian.koenig

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@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))
+		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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-19 20:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-19 12:02 [PATCH v2] drm/amdgpu: Fix the EPERM error when get user pages Ma Jun
2023-05-19 20:37 ` Felix Kuehling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox