From: "Christian König" <christian.koenig@amd.com>
To: "SHANMUGAM, SRINIVASAN" <SRINIVASAN.SHANMUGAM@amd.com>,
Natalie Vock <nat@pixelcluster.dev>,
"Deucher, Alexander" <Alexander.Deucher@amd.com>
Cc: "amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
"Kuehling, Felix" <Felix.Kuehling@amd.com>,
"Zhu, James" <James.Zhu@amd.com>,
"Lazar, Lijo" <Lijo.Lazar@amd.com>,
"Six, Lancelot" <Lancelot.Six@amd.com>,
"Pelloux-Prayer,
Pierre-Eric" <Pierre-eric.Pelloux-prayer@amd.com>,
"Timur Kristóf" <timur.kristof@gmail.com>,
"Samuel Pitoiset" <hakzsam@gmail.com>
Subject: Re: [RFC PATCH 1/3] drm/amdgpu/uapi: Add second-level trap handler ops to VM ioctl
Date: Tue, 25 Aug 2026 09:34:11 +0200 [thread overview]
Message-ID: <44857ea2-7f39-4088-9209-ce21ddaf8987@amd.com> (raw)
In-Reply-To: <IA0PR12MB82080BCDF88122DD4E767E1390AF2@IA0PR12MB8208.namprd12.prod.outlook.com>
On 8/25/26 07:05, SHANMUGAM, SRINIVASAN wrote:
> AMD General
>
>> -----Original Message-----
>> From: Natalie Vock <nat@pixelcluster.dev>
>> Sent: Thursday, August 20, 2026 3:29 PM
>> To: SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM@amd.com>;
>> Koenig, Christian <Christian.Koenig@amd.com>; Deucher, Alexander
>> <Alexander.Deucher@amd.com>
>> Cc: amd-gfx@lists.freedesktop.org; Kuehling, Felix <Felix.Kuehling@amd.com>;
>> Zhu, James <James.Zhu@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>; Six,
>> Lancelot <Lancelot.Six@amd.com>; Pelloux-Prayer, Pierre-Eric <Pierre-
>> eric.Pelloux-prayer@amd.com>; Timur Kristóf <timur.kristof@gmail.com>; Samuel
>> Pitoiset <hakzsam@gmail.com>
>> Subject: Re: [RFC PATCH 1/3] drm/amdgpu/uapi: Add second-level trap handler
>> ops to VM ioctl
>>
>> Hi,
>>
>> first of all: Thanks for working on this! It's great seeing trap handler support come
>> together.
>>
>> On 8/20/26 09:01, Srinivasan Shanmugam wrote:
>>> When a GPU shader hits an exception, memory fault, or debug
>>> breakpoint, the hardware jumps to the first-level trap handler. The
>>> first-level handler (managed by the kernel via CWSR) checks the TMA
>>> buffer for a second-level handler address. If one is installed, it
>>> forwards the trap to that userspace handler, allowing the runtime or
>>> debugger to handle shader exceptions without modifying the kernel trap handler.
>>>
>>> KFD already supports this for compute workloads. Render-node user
>>> queues had no equivalent mechanism. Add it.
>>>
>>> The second-level handler is a per-VM setting — it applies to all
>>> shader waves executing under that VMID regardless of queue type. GFX
>>> and compute queues from the same process share the same VMID, so one
>>> SET_L2_TRAP call covers all queue types for that process. This
>>> configuration is not CWSR-specific; CWSR is only the first-level
>>> handler mechanism. The correct home for this setting is the VM ioctl
>>> (DRM_AMDGPU_VM), following the same pattern as
>>> AMDGPU_VM_OP_RESERVE_VMID.
>>>
>>> Add two new VM ioctl operations:
>>> AMDGPU_VM_OP_SET_L2_TRAP (op = 3) — install second-level handler
>>> AMDGPU_VM_OP_CLEAR_L2_TRAP (op = 4) — remove second-level
>> handler
>>>
>>> Extend drm_amdgpu_vm_in with a 32-byte union for op-specific data. The
>>> l2trap member carries the GPU virtual addresses and sizes of the TBA
>>> (handler code) and TMA (handler scratch memory).
>>
>> This should be a BO handle and offset+size, instead. The BOs associated with the
>> TBA/TMA must be tracked as used by every submission from the VM that has this
>> trap handler installed, otherwise you introduce a ton of race conditions. Off the top
>> of my head, here are a few:
>> 1. The GEM VA ioctl can spuriously fail to actually update page tables.
>> This is okay and intentional, and BOs with outdated page tables will
>> be updated on the next submit if they're used by the submission. If
>> the TBA/TMA BOs aren't marked in the set of used buffers, the PTs may
>> end up never being updated and subsequent accesses will fault.
>> 2. The TBA/TMA may be evicted/moved around concurrently with executing
>> submissions if these submissions didn't add their fences to the
>> TBA/TMA resv, which would likely randomly corrupt things or hang.
>>
>> A simpler solution could be requiring the TBA/TMA buffers to be
>> VM_ALWAYS_VALID, in which case synchronization to all submissions in the VM
>> is taken care of automagically. This prevents exporting the TBA/TMA to an fd, but I
>> don't expect anyone would want to do this.
>
> Hi Natalie,
>
> Thanks for the feedback.
>
> We will update the UAPI in v2 to pass BO handles alongside
> the GPU VA for TBA/TMA. This ensures the kernel can properly
> track and pin the buffers.
Please don't. It is the responsibility of userspace to make sure that the BOs are either in the used list or valid per VM.
Regards,
Christian.
>
> Thanks,
> Srini
>
>>
>> Regards,
>> Natalie
next prev parent reply other threads:[~2026-08-25 7:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 7:01 [RFC PATCH 0/3] drm/amdgpu: Render-node second-level trap handler Srinivasan Shanmugam
2026-08-20 7:01 ` [RFC PATCH 1/3] drm/amdgpu/uapi: Add second-level trap handler ops to VM ioctl Srinivasan Shanmugam
2026-08-20 9:59 ` Natalie Vock
2026-08-25 5:05 ` SHANMUGAM, SRINIVASAN
2026-08-25 7:34 ` Christian König [this message]
2026-08-25 10:13 ` Natalie Vock
2026-08-20 7:01 ` [RFC PATCH 2/3] drm/amdgpu: Add VM ioctl handlers for second-level trap handler Srinivasan Shanmugam
2026-08-20 10:38 ` Natalie Vock
2026-08-25 5:12 ` SHANMUGAM, SRINIVASAN
2026-08-20 7:01 ` [RFC PATCH 3/3] drm/amdgpu: Disable L2 trap handler when its VA range is unmapped Srinivasan Shanmugam
2026-08-20 9:28 ` [RFC PATCH 0/3] drm/amdgpu: Render-node second-level trap handler Timur Kristóf
2026-08-25 4:59 ` SHANMUGAM, SRINIVASAN
2026-08-25 9:56 ` Timur Kristóf
2026-08-25 13:59 ` Alex Deucher
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=44857ea2-7f39-4088-9209-ce21ddaf8987@amd.com \
--to=christian.koenig@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Felix.Kuehling@amd.com \
--cc=James.Zhu@amd.com \
--cc=Lancelot.Six@amd.com \
--cc=Lijo.Lazar@amd.com \
--cc=Pierre-eric.Pelloux-prayer@amd.com \
--cc=SRINIVASAN.SHANMUGAM@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=hakzsam@gmail.com \
--cc=nat@pixelcluster.dev \
--cc=timur.kristof@gmail.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.