From: "Kuehling, Felix" <felix.kuehling@amd.com>
To: "Christian König" <christian.koenig@amd.com>,
"Timur Kristóf" <timur.kristof@gmail.com>,
natalie.vock@gmx.de, honghuan@amd.com, Alexander.Deucher@amd.com,
Philip.Yang@amd.com, cascardo@igalia.com,
tvrtko.ursulin@igalia.com, "Joshi, Mukul" <mukul.joshi@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/9] drm/amdgpu: fix cleared PDE/PTE flag generation
Date: Wed, 30 Sep 2026 12:12:48 -0400 [thread overview]
Message-ID: <33693b8d-ed0a-4910-af87-eb29e887a1d5@amd.com> (raw)
In-Reply-To: <9b181f91-4de1-4c0d-8a38-dfd75c8eb98c@amd.com>
On 2026-09-30 10:59, Christian König wrote:
> On 9/30/26 16:44, Kuehling, Felix wrote:
>> [+Mukul]
>>
>> On 2026-09-30 05:02, Christian König wrote:
>>> @Felix and @Philip any objections to this patch?
>>>
>>> It is actually a bug fix for the NPA support.
>> As I understand it, this fixes the flags used when unmapping memory from the NPA VM. We passed adev->gmc.noretry_flags from amdgpu_ualink_unmap_npa_addr to amdgpu_vm_update_range explicitly in the flags parameter. I guess that's no longer needed with your fix. But I think the end result would be the same, right?
> Not quite, passing adev->gmc.noretry_flags to amdgpu_vm_update_range() is completely broken as well and also need fixing.
>
> The flags parameter to amdgpu_vm_update_range() can't contain the AMDGPU_PTE_TF nor the AMDGPU_PDE_PTE flag because those are overwritten by the PTE callbacks.
I'm pretty sure Mukul tested this and got something that worked as
expected, at least for a time. I'm not sure if it regressed since, maybe
during upstreaming. @Mukul, can you comment?
>
> That's why setting the AMDGPU_PTE_IS_PTE for gfx12 through the init_pte_flags is completely broken as well.
>
> We seriously need to stop doing such hacks.
Is there any documentation that tells us what flags can be used where.
This isn't obvious at all.
Thanks,
Felix
>
> Regards,
> Christian.
>
>> Regards,
>> Felix
>>
>>
>>> Regards,
>>> Christian.
>>>
>>> On 9/28/26 21:08, Timur Kristóf wrote:
>>>> On 2026. szeptember 28., hétfő 11:10:34 keleti államokbeli nyári idő Christian
>>>> König wrote:
>>>>> That was broken since adding the NPA support.
>>>>>
>>>>> Signed-off-by: Christian König <christian.koenig@amd.com>
>>>> Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
>>>>
>>>>> ---
>>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 64 ++++++++++++-----------
>>>>> 1 file changed, 33 insertions(+), 31 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
>>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c index
>>>>> c03327f1242d3..e8f441e018839 100644
>>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
>>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
>>>>> @@ -346,6 +346,33 @@ static void amdgpu_vm_pt_next_dfs(struct amdgpu_device
>>>>> *adev, amdgpu_vm_pt_continue_dfs((start), (entry));
>>>> \
>>>>> (entry) = (cursor).entry, amdgpu_vm_pt_next_dfs((adev),
>>>> &(cursor)))
>>>>> +/* Return the flags used for cleared PDEs/PTES */
>>>>> +static uint64_t amdgpu_vm_pt_clear_flags(struct amdgpu_device *adev,
>>>>> + struct amdgpu_vm *vm,
>>>>> + unsigned int level)
>>>>> +{
>>>>> + uint64_t flags;
>>>>> +
>>>>> + if (adev->asic_type < CHIP_VEGA10)
>>>>> + return 0;
>>>>> +
>>>>> + if (level != AMDGPU_VM_PTB) {
>>>>> + uint64_t value = 0;
>>>>> +
>>>>> + flags = AMDGPU_PDE_PTE_FLAG(adev);
>>>>> + if (vm->is_npa)
>>>>> + flags |= adev->gmc.noretry_flags;
>>>>> + amdgpu_gmc_get_vm_pde(adev, level, &value, &flags);
>>>>> + } else if (vm->is_npa) {
>>>>> + flags = adev->gmc.noretry_flags;
>>>>> + } else {
>>>>> + /* Workaround for fault priority problem on GMC9 */
>>>>> + flags = AMDGPU_PTE_EXECUTABLE | adev->gmc.init_pte_flags;
>>>>> + }
>>>>> +
>>>>> + return flags;
>>>>> +}
>>>>> +
>>>>> /**
>>>>> * amdgpu_vm_pt_clear - initially clear the PDs/PTs
>>>>> *
>>>>> @@ -366,10 +393,9 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev,
>>>>> struct amdgpu_vm *vm, struct ttm_operation_ctx ctx = { true, false };
>>>>> struct amdgpu_vm_update_params params;
>>>>> struct amdgpu_bo *ancestor = &vmbo->bo;
>>>>> - unsigned int entries;
>>>>> struct amdgpu_bo *bo = &vmbo->bo;
>>>>> - uint64_t value = 0, flags = 0;
>>>>> - uint64_t addr;
>>>>> + unsigned int entries;
>>>>> + uint64_t flags;
>>>>> int r, idx;
>>>>>
>>>>> /* Figure out our place in the hierarchy */
>>>>> @@ -404,26 +430,8 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev,
>>>>> struct amdgpu_vm *vm, if (r)
>>>>> goto exit;
>>>>>
>>>>> - addr = 0;
>>>>> -
>>>>> - if (adev->asic_type >= CHIP_VEGA10) {
>>>>> - if (level != AMDGPU_VM_PTB) {
>>>>> - if (vm->is_npa)
>>>>> - flags = adev->gmc.noretry_flags;
>>>>> - /* Handle leaf PDEs as PTEs */
>>>>> - flags |= AMDGPU_PDE_PTE_FLAG(adev);
>>>>> - amdgpu_gmc_get_vm_pde(adev, level,
>>>>> - &value, &flags);
>>>>> - } else if (vm->is_npa) {
>>>>> - flags = adev->gmc.noretry_flags;
>>>>> - } else {
>>>>> - /* Workaround for fault priority problem on
>>>> GMC9 */
>>>>> - flags = AMDGPU_PTE_EXECUTABLE | adev-
>>>>> gmc.init_pte_flags;
>>>>> - }
>>>>> - }
>>>>> -
>>>>> - r = vm->update_funcs->update(¶ms, vmbo, addr, 0, entries,
>>>>> - value, flags);
>>>>> + flags = amdgpu_vm_pt_clear_flags(adev, vm, level);
>>>>> + r = vm->update_funcs->update(¶ms, vmbo, 0, 0, entries, 0,
>>>> flags);
>>>>> if (r)
>>>>> goto exit;
>>>>>
>>>>> @@ -712,15 +720,9 @@ static void amdgpu_vm_pte_update_flags(struct
>>>>> amdgpu_vm_update_params *params, flags |=
>>>>> AMDGPU_PDE_PTE_FLAG(params->adev);
>>>>> amdgpu_gmc_get_vm_pde(adev, level, &addr, &flags);
>>>>>
>>>>> - } else if (adev->asic_type >= CHIP_VEGA10 &&
>>>>> - !(flags & AMDGPU_PTE_VALID) &&
>>>>> + } else if (!(flags & AMDGPU_PTE_VALID) &&
>>>>> !(flags & AMDGPU_PTE_PRT_FLAG(params->adev))) {
>>>>> -
>>>>> - /* Workaround for fault priority problem on GMC9 and
>>>> GFX12,
>>>>> - * EXECUTABLE for GMC9 fault priority and init_pte_flags
>>>>> - * (e.g. AMDGPU_PTE_IS_PTE on GFX12)
>>>>> - */
>>>>> - flags |= AMDGPU_PTE_EXECUTABLE | adev-
>>>>> gmc.init_pte_flags;
>>>>> + flags |= amdgpu_vm_pt_clear_flags(adev, params->vm,
>>>> level);
>>>>> }
>>>>>
>>>>> /*
>>>>
>>>>
next prev parent reply other threads:[~2026-09-30 16:12 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 15:10 [PATCH 1/9] drm/amdgpu: rework eviction lock handling into critical section v3 Christian König
2026-09-28 15:10 ` [PATCH 2/9] drm/amdgpu: fix cleared PDE/PTE flag generation Christian König
2026-09-28 19:08 ` Timur Kristóf
2026-09-30 9:02 ` Christian König
2026-09-30 14:44 ` Kuehling, Felix
2026-09-30 14:59 ` Christian König
2026-09-30 16:12 ` Kuehling, Felix [this message]
2026-10-01 6:24 ` Christian König
2026-10-01 13:36 ` Mukul Joshi
2026-10-01 13:49 ` Joshi, Mukul
2026-09-28 15:10 ` [PATCH 3/9] drm/amdgpu: allocate and fill dummy PDs/PTs Christian König
2026-09-28 19:02 ` Timur Kristóf
2026-09-28 15:10 ` [PATCH 4/9] drm/amdgpu: add amdgpu_vm_pt_leaves() v2 Christian König
2026-09-28 19:07 ` Timur Kristóf
2026-09-28 15:10 ` [PATCH 5/9] drm/amdgpu: drop immediate updates from amdgpu_vm_update_range Christian König
2026-09-28 15:10 ` [PATCH 6/9] drm/amdgpu: drop immediate updates from amdgpu_vm_update_pdes Christian König
2026-09-28 19:09 ` Timur Kristóf
2026-09-28 15:10 ` [PATCH 7/9] drm/amdgpu: split amdgpu_vm_update_range v3 Christian König
2026-09-30 16:30 ` Kuehling, Felix
2026-09-28 15:10 ` [PATCH 8/9] drm/amdgpu: fix the HMM range handling for KFD SVM v2 Christian König
2026-09-30 16:44 ` Kuehling, Felix
2026-10-01 20:30 ` Olivier Kaloudoff
2026-09-28 15:10 ` [PATCH 9/9] drm/amdgpu: use range unmap in amdgpu_vm_clear_freed Christian König
2026-09-28 19:08 ` [PATCH 1/9] drm/amdgpu: rework eviction lock handling into critical section v3 Timur Kristóf
2026-09-29 14:07 ` Huang, Honglei
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=33693b8d-ed0a-4910-af87-eb29e887a1d5@amd.com \
--to=felix.kuehling@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Philip.Yang@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=cascardo@igalia.com \
--cc=christian.koenig@amd.com \
--cc=honghuan@amd.com \
--cc=mukul.joshi@amd.com \
--cc=natalie.vock@gmx.de \
--cc=timur.kristof@gmail.com \
--cc=tvrtko.ursulin@igalia.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