AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ma Jun <Jun.Ma2@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: alex.sierra@amd.com, felix.kuehling@amd.com,
	Ma Jun <Jun.Ma2@amd.com>,
	Alexander.Deucher@amd.com, christian.koenig@amd.com
Subject: [PATCH v2] drm/amdgpu: Fix the EPERM error when get user pages
Date: Fri, 19 May 2023 20:02:51 +0800	[thread overview]
Message-ID: <20230519120252.3383090-1-Jun.Ma2@amd.com> (raw)

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


             reply	other threads:[~2023-05-19 12:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-19 12:02 Ma Jun [this message]
2023-05-19 20:37 ` [PATCH v2] drm/amdgpu: Fix the EPERM error when get user pages Felix Kuehling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230519120252.3383090-1-Jun.Ma2@amd.com \
    --to=jun.ma2@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=alex.sierra@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=felix.kuehling@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox