From: "Christian König" <christian.koenig@amd.com>
To: Matthew Brost <matthew.brost@intel.com>
Cc: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Huang Rui" <ray.huang@amd.com>,
intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
matthew.auld@intel.com
Subject: Re: [PATCH v6 2/8] drm/ttm: Add ttm_bo_access
Date: Thu, 7 Nov 2024 10:44:33 +0100 [thread overview]
Message-ID: <85859dc3-cca3-4396-8c75-a726437fb81e@amd.com> (raw)
In-Reply-To: <ZyugmXt7v+JeKuN9@lstrano-desk.jf.intel.com>
[-- Attachment #1: Type: text/plain, Size: 3748 bytes --]
Am 06.11.24 um 18:00 schrieb Matthew Brost:
> [SNIP]
> This is not a generic interface that anyone can freely access. The same
> permissions used by ptrace are checked when opening such an interface.
> See [1] [2].
>
> [1]https://patchwork.freedesktop.org/patch/617470/?series=136572&rev=2
> [2]https://patchwork.freedesktop.org/patch/617471/?series=136572&rev=2
Thanks a lot for those pointers, that is exactly what I was looking for.
And yeah, it is what I feared. You are re-implementing existing
functionality, but see below.
>>> kmap/vmap are used everywhere in the DRM subsystem to access BOs, so I’m
>>> failing to see the problem with adding a simple helper based on existing
>>> code.
>> What#s possible and often done is to do kmap/vmap if you need to implement a
>> CPU copy for scanout for example or for copying/validating command buffers.
>> But that usually requires accessing the whole BO and has separate security
>> checks.
>>
>> When you want to access only a few bytes of a BO that sounds massively like
>> a peek/poke like interface and we have already rejected that more than once.
>> There even used to be standardized GEM IOCTLs for that which have been
>> removed by now.
>>
>> If you need to access BOs which are placed in not CPU accessible memory then
>> implement the access callback for ptrace, see amdgpu_ttm_access_memory for
>> an example how to do this.
>>
> Ptrace access via vm_operations_struct.access → ttm_bo_vm_access.
>
> This series renames ttm_bo_vm_access to ttm_bo_access, with no code changes.
>
> The above function accesses a BO via kmap if it is in SYSTEM / TT,
> which is existing code.
>
> This function is only exposed to user space via ptrace permissions.
> In this series, we implement a function [3] similar to
> amdgpu_ttm_access_memory for the TTM vfunc access_memory. What is
> missing is non-visible CPU memory access, similar to
> amdgpu_ttm_access_memory_sdma. This will be addressed in a follow-up and
> was omitted in this series given its complexity.
>
> So, this looks more or less identical to AMD's ptrace implementation,
> but in GPU address space. Again, I fail to see what the problem is here.
> What am I missing?
The main question is why can't you use the existing interfaces directly?
Additional to the peek/poke interface of ptrace Linux has the
pidfd_getfd system call, see here
https://man7.org/linux/man-pages/man2/pidfd_getfd.2.html.
The pidfd_getfd() allows to dup() the render node file descriptor into
your gdb process. That in turn gives you all the access you need from
gdb, including mapping BOs and command submission on behalf of the
application.
As far as I can see that allows for the same functionality as the
eudebug interface, just without any driver specific code messing with
ptrace permissions and peek/poke interfaces.
So the question is still why do you need the whole eudebug interface in
the first place? I might be missing something, but that seems to be
superfluous from a high level view.
It's true that the AMD KFD part has still similar functionality, but
that is because of the broken KFD design of tying driver state to the
CPU process (which makes it inaccessible for gdb even with imported
render node fd).
Both Sima and I (and partially Dave as well) have pushed back on the KFD
approach. And the long term plan is to get rid of such device driver
specific interface which re-implement existing functionality just
differently.
So you need to have a really really good explanation why the eudebug
interface is actually necessary.
Regards,
Christian.
>
> Matt
>
> [3]https://patchwork.freedesktop.org/patch/622520/?series=140200&rev=6
>
>> Regards,
>> Christian.
>>
>>> Matt
>>>
>>>> Regards,
>>>> Christian.
[-- Attachment #2: Type: text/html, Size: 5707 bytes --]
next prev parent reply other threads:[~2024-11-07 9:44 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-31 18:10 [PATCH v6 0/8] Fix non-contiguous VRAM BO access in Xe Matthew Brost
2024-10-31 18:10 ` [PATCH v6 1/8] drm/xe: Add xe_bo_vm_access Matthew Brost
2024-10-31 18:10 ` [PATCH v6 2/8] drm/ttm: Add ttm_bo_access Matthew Brost
2024-10-31 23:43 ` Matthew Brost
2024-11-04 17:34 ` Rodrigo Vivi
2024-11-04 19:28 ` Christian König
2024-11-04 21:49 ` Matthew Brost
2024-11-05 7:41 ` Christian König
2024-11-05 18:35 ` Matthew Brost
2024-11-06 9:48 ` Christian König
2024-11-06 15:25 ` Matthew Brost
2024-11-06 15:44 ` Christian König
2024-11-06 17:00 ` Matthew Brost
2024-11-07 9:44 ` Christian König [this message]
2024-11-11 8:00 ` Joonas Lahtinen
2024-11-11 10:10 ` Simona Vetter
2024-11-11 11:34 ` Christian König
2024-11-11 14:00 ` Joonas Lahtinen
2024-11-11 15:54 ` Christian König
2024-11-11 22:45 ` Matthew Brost
2024-11-12 9:23 ` Christian König
2024-11-12 13:41 ` Joonas Lahtinen
2024-11-12 16:22 ` Thomas Hellström
2024-11-12 16:25 ` Christian König
2024-11-12 16:33 ` Thomas Hellström
2024-11-13 8:37 ` Christian König
2024-11-13 10:44 ` Thomas Hellström
2024-11-13 11:42 ` Christian König
2024-11-15 18:27 ` Matthew Brost
2024-11-25 15:29 ` Matthew Brost
2024-11-25 16:19 ` Christian König
2024-11-25 17:27 ` Matthew Brost
2024-11-26 8:19 ` Christian König
2024-11-26 17:49 ` Matthew Brost
2024-11-27 13:21 ` Christian König
2024-11-12 8:28 ` Simona Vetter
2024-11-12 8:58 ` Christian König
2024-11-12 13:30 ` Joonas Lahtinen
2024-11-11 11:27 ` Christian König
2024-11-04 19:47 ` Christian König
2024-11-04 21:30 ` Matthew Brost
2024-11-04 22:26 ` Rodrigo Vivi
2024-10-31 18:10 ` [PATCH v6 3/8] drm/xe: Add xe_ttm_access_memory Matthew Brost
2024-10-31 18:10 ` [PATCH v6 4/8] drm/xe: Take PM ref in delayed snapshot capture worker Matthew Brost
2024-10-31 18:10 ` [PATCH v6 5/8] drm/xe/display: Update intel_bo_read_from_page to use ttm_bo_access Matthew Brost
2024-10-31 18:10 ` [PATCH v6 6/8] drm/xe: Use ttm_bo_access in xe_vm_snapshot_capture_delayed Matthew Brost
2024-10-31 18:10 ` [PATCH v6 7/8] drm/xe: Set XE_BO_FLAG_PINNED in migrate selftest BOs Matthew Brost
2024-10-31 18:10 ` [PATCH v6 8/8] drm/xe: Only allow contiguous BOs to use xe_bo_vmap Matthew Brost
2024-10-31 18:15 ` ✓ CI.Patch_applied: success for Fix non-contiguous VRAM BO access in Xe (rev6) Patchwork
2024-10-31 18:15 ` ✗ CI.checkpatch: warning " Patchwork
2024-10-31 18:17 ` ✓ CI.KUnit: success " Patchwork
2024-10-31 18:28 ` ✓ CI.Build: " Patchwork
2024-10-31 18:31 ` ✓ CI.Hooks: " Patchwork
2024-10-31 18:32 ` ✗ CI.checksparse: warning " Patchwork
2024-10-31 18:57 ` ✓ CI.BAT: success " Patchwork
2024-10-31 21:27 ` ✗ CI.FULL: failure " Patchwork
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=85859dc3-cca3-4396-8c75-a726437fb81e@amd.com \
--to=christian.koenig@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=ray.huang@amd.com \
--cc=rodrigo.vivi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox