From: "Timur Kristóf" <timur.kristof@gmail.com>
To: natalie.vock@gmx.de, honghuan@amd.com, Alexander.Deucher@amd.com,
Felix.Kuehling@amd.com, Philip.Yang@amd.com, cascardo@igalia.com,
tvrtko.ursulin@igalia.com, christian.koenig@amd.com
Cc: amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 3/9] drm/amdgpu: allocate and fill dummy PDs/PTs
Date: Mon, 28 Sep 2026 15:02:57 -0400 [thread overview]
Message-ID: <jk4Y4GIRRPCeG-hxXaxSXg@gmail.com> (raw)
In-Reply-To: <20260928151041.1857-3-christian.koenig@amd.com>
On 2026. szeptember 28., hétfő 11:10:35 keleti államokbeli nyári idő Christian
König wrote:
> Allocate some PDs/PTs which just point to the dummy page.
>
> Those can be used in page faults to redirect recoverable page faults
> to the dummy page.
>
> 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.c | 11 +++-
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 7 ++-
> .../gpu/drm/amd/amdgpu/amdgpu_vm_internal.h | 2 +
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 57 +++++++++++++++++++
> 4 files changed, 74 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 7b9494375649f..f02a99b753c22
> 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -2908,8 +2908,10 @@ void amdgpu_vm_fini(struct amdgpu_device *adev,
> struct amdgpu_vm *vm) *
> * Initialize the VM manager structures
> */
> -void amdgpu_vm_manager_init(struct amdgpu_device *adev)
> +int amdgpu_vm_manager_init(struct amdgpu_device *adev)
> {
> + int r;
> +
> /* Concurrent flushes are only possible starting with Vega10 and
> * are broken on Navi10 and Navi14.
> */
> @@ -2921,6 +2923,10 @@ void amdgpu_vm_manager_init(struct amdgpu_device
> *adev) spin_lock_init(&adev->vm_manager.prt_lock);
> atomic_set(&adev->vm_manager.num_prt_users, 0);
>
> + r = amdgpu_vm_pt_alloc_dummies(adev);
> + if (r)
> + return r;
> +
> /* If not overridden by the user, by default, only in large BAR
systems
> * Compute VM tables will be updated by CPU
> */
> @@ -2940,6 +2946,8 @@ void amdgpu_vm_manager_init(struct amdgpu_device
> *adev) #else
> adev->vm_manager.vm_update_mode = 0;
> #endif
> +
> + return 0;
> }
>
> /**
> @@ -2951,6 +2959,7 @@ void amdgpu_vm_manager_init(struct amdgpu_device
> *adev) */
> void amdgpu_vm_manager_fini(struct amdgpu_device *adev)
> {
> + amdgpu_vm_pt_free_dummies(adev);
> amdgpu_vmid_mgr_fini(adev);
> amdgpu_pasid_mgr_cleanup();
> }
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index 98cdd7e3475fb..c59647554b416
> 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> @@ -411,8 +411,11 @@ struct amdgpu_vm_manager {
> int
vm_update_mode;
>
> /* Global registration of recent page fault information */
> - struct amdgpu_vm_fault_info fault_info;
> + struct amdgpu_vm_fault_info fault_info;
> unsigned int npa_vmid;
> +
> + struct amdgpu_bo *dummy_pd[AMDGPU_VM_PTB
+ 1];
> + uint64_t
dummy_dst[AMDGPU_VM_PTB + 1];
> };
>
> struct amdgpu_bo_va_mapping;
> @@ -424,7 +427,7 @@ struct amdgpu_bo_va_mapping;
> extern const struct amdgpu_vm_update_funcs amdgpu_vm_cpu_funcs;
> extern const struct amdgpu_vm_update_funcs amdgpu_vm_sdma_funcs;
>
> -void amdgpu_vm_manager_init(struct amdgpu_device *adev);
> +int amdgpu_vm_manager_init(struct amdgpu_device *adev);
> void amdgpu_vm_manager_fini(struct amdgpu_device *adev);
>
> long amdgpu_vm_wait_idle(struct amdgpu_vm *vm, long timeout);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h index
> 8ebb0b033291e..3c48a3401e2a4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h
> @@ -130,6 +130,8 @@ void amdgpu_vm_pt_free_work(struct work_struct *work);
> void amdgpu_vm_pt_free_list(struct amdgpu_device *adev,
> struct amdgpu_vm_update_params *params);
> int amdgpu_vm_pt_map_tables(struct amdgpu_device *adev, struct amdgpu_vm
> *vm); +int amdgpu_vm_pt_alloc_dummies(struct amdgpu_device *adev);
> +void amdgpu_vm_pt_free_dummies(struct amdgpu_device *adev);
>
> /**
> * amdgpu_vm_begin_critical - start the critical section of the update
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c index
> e8f441e018839..285f17c7705b4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> @@ -990,3 +990,60 @@ int amdgpu_vm_pt_map_tables(struct amdgpu_device *adev,
> struct amdgpu_vm *vm)
>
> return 0;
> }
> +
> +/* amdgpu_vm_pt_alloc_dummies - allocate dummy PDs/PTs
> + *
> + * @adev: the amdgpu device pointer
> + *
> + * Allocate some dummy PDs/PTs which can be used to redirect page faults to
> the + * dummy page.
> + */
> +int amdgpu_vm_pt_alloc_dummies(struct amdgpu_device *adev)
> +{
> + struct amdgpu_vm_manager *vm_mgr = &adev->vm_manager;
> + int r;
> +
> + for (int level = AMDGPU_VM_PTB; level != vm_mgr->root_level;
level--) {
> + size_t size = amdgpu_vm_pt_size(adev, level);
> + uint64_t addr, flags;
> + void *ptr;
> +
> + r = amdgpu_bo_create_kernel(adev, size, 0,
> +
AMDGPU_GEM_DOMAIN_VRAM,
> + &vm_mgr-
>dummy_pd[level],
> + &vm_mgr-
>dummy_dst[level],
> + &ptr);
> + if (r)
> + return r;
> +
> + if (level == AMDGPU_VM_PTB) {
> + addr = adev->dummy_page_addr;
> + /*
> + * TODO: We want to have separate dummies for
reads and
> + * writes.
> + */
> + flags = AMDGPU_PTE_VALID | AMDGPU_PTE_SNOOPED
|
> + AMDGPU_PTE_SYSTEM |
AMDGPU_PTE_EXECUTABLE |
> + AMDGPU_PTE_READABLE |
AMDGPU_PTE_WRITEABLE;
> + } else {
> + amdgpu_gmc_get_pde_for_bo(vm_mgr-
>dummy_pd[level + 1],
> + level,
&addr, &flags);
> + }
The AMDGPU_PTE_IS_PTE flag is missing for GFX12.
I think we should either set that flag for GFX12 here, or use init_pte_flags.
Otherwise retry faults will regress on GFX12 after this refactor.
> +
> + for (int i = 0; i < amdgpu_vm_pt_num_entries(adev,
level); i++)
> + amdgpu_gmc_set_pte_pde(adev, ptr, i, addr,
flags);
> + }
> +
> + return 0;
> +}
> +
> +void amdgpu_vm_pt_free_dummies(struct amdgpu_device *adev)
> +{
> + struct amdgpu_vm_manager *vm_mgr = &adev->vm_manager;
> + void *ptr;
> +
> + for (int level = AMDGPU_VM_PTB; level != vm_mgr->root_level;
level--)
> + amdgpu_bo_free_kernel(&vm_mgr->dummy_pd[level],
> + &vm_mgr->dummy_dst[level],
> + &ptr);
> +}
next prev parent reply other threads:[~2026-09-28 19:03 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
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 [this message]
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=jk4Y4GIRRPCeG-hxXaxSXg@gmail.com \
--to=timur.kristof@gmail.com \
--cc=Alexander.Deucher@amd.com \
--cc=Felix.Kuehling@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=natalie.vock@gmx.de \
--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