From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org,
"Mika Kuoppala" <mika.kuoppala@linux.intel.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Andrzej Hajda" <andrzej.hajda@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Dominik Grzegorzek" <dominik.grzegorzek@intel.com>,
"Christian König" <christian.koenig@amd.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Simona Vetter" <simona@ffwll.ch>
Subject: [PATCH 14/27] drm/xe/eudebug: userptr vm access pread/pwrite
Date: Mon, 13 Jan 2025 15:26:19 +0200 [thread overview]
Message-ID: <20250113132619.373502-1-mika.kuoppala@linux.intel.com> (raw)
Implement debugger vm access for userptrs.
When userptr bind is done, mmu notifier is added by core xe.
Later when debugger wants to access the target memory, this
notifier can be used as it carries the struct mm of target.
Implement userptr vm access, for debugger pread/pwrite
using notifier mm passed to access_remote_vm().
This is based on suggestions from Thomas, Joonas and Simona.
v2: need to add offset into vma (Dominik)
v3: use exported access_remote_vm (Thomas)
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Simona Vetter <simona@ffwll.ch>
Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
drivers/gpu/drm/xe/xe_eudebug.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_eudebug.c b/drivers/gpu/drm/xe/xe_eudebug.c
index 210d9eeab1a7..25f18aa5447b 100644
--- a/drivers/gpu/drm/xe/xe_eudebug.c
+++ b/drivers/gpu/drm/xe/xe_eudebug.c
@@ -3077,6 +3077,27 @@ static int xe_eudebug_vma_access(struct xe_vma *vma,
xe_bo_put(bo);
+ return ret;
+ } else if (xe_vma_is_userptr(vma)) {
+ struct xe_userptr *userptr = &to_userptr_vma(vma)->userptr;
+ struct xe_vm *vm = xe_vma_vm(vma);
+ struct mm_struct *mm = NULL;
+ int ret;
+
+ down_read(&vm->userptr.notifier_lock);
+ if (mmget_not_zero(userptr->notifier.mm))
+ mm = userptr->notifier.mm;
+ up_read(&vm->userptr.notifier_lock);
+
+ if (!mm)
+ return -EFAULT;
+
+ ret = access_remote_vm(mm,
+ xe_vma_userptr(vma) + offset_in_vma,
+ buf, bytes,
+ write ? FOLL_WRITE : 0);
+ mmput(mm);
+
return ret;
}
--
2.43.0
next reply other threads:[~2025-01-13 13:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 13:26 Mika Kuoppala [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-12-23 10:31 [PATCH 13/26] RFC drm/xe/eudebug: userptr vm pread/pwrite Thomas Hellström
2025-01-13 13:32 ` [PATCH 14/27] drm/xe/eudebug: userptr vm access pread/pwrite Mika Kuoppala
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=20250113132619.373502-1-mika.kuoppala@linux.intel.com \
--to=mika.kuoppala@linux.intel.com \
--cc=andrzej.hajda@intel.com \
--cc=christian.koenig@amd.com \
--cc=dominik.grzegorzek@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=joonas.lahtinen@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.