From: "Timur Kristóf" <timur.kristof@gmail.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
"Huang Yu" <yhuang13@amd.com>
Cc: Yu Huang <Yu.Huang@amd.com>, Honglei Huang <honghuan@amd.com>,
Ray Huang <ray.huang@amd.com>, Shen Junhua <junhshen@amd.com>,
Lingshan Zhu <lingszhu@amd.com>,
Natalie Vock <natalie.vock@gmx.de>,
AMD-GFX <amd-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 03/13] drm/amdgpu: allocate and fill dummy PDs/PTs
Date: Mon, 21 Sep 2026 13:37:50 +0200 [thread overview]
Message-ID: <P8HWfzzXTSi7EfI0L9PzAA@gmail.com> (raw)
In-Reply-To: <20260917110158.296198-4-yhuang13@amd.com>
On Thursday, September 17, 2026 1:01:48 PM Central European Summer Time Huang
Yu wrote:
> From: Christian König <ckoenig.leichtzumerken@gmail.com>
>
> 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>
Makes good sense.
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 | 5 +-
> .../gpu/drm/amd/amdgpu/amdgpu_vm_internal.h | 2 +
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 57 +++++++++++++++++++
> 4 files changed, 73 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 517490946a9c..5675925ca656
> 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -2843,8 +2843,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.
> */
> @@ -2856,6 +2858,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
> */
> @@ -2875,6 +2881,8 @@ void amdgpu_vm_manager_init(struct amdgpu_device
> *adev) #else
> adev->vm_manager.vm_update_mode = 0;
> #endif
> +
> + return 0;
> }
>
> /**
> @@ -2886,6 +2894,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 ac3b8e8525c1..826406522b24
> 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> @@ -409,6 +409,9 @@ struct amdgpu_vm_manager {
>
> /* Global registration of recent page fault information */
> struct amdgpu_vm_fault_info fault_info;
> +
> + struct amdgpu_bo *dummy_pd[AMDGPU_VM_PTB + 1];
> + uint64_t dummy_dst[AMDGPU_VM_PTB + 1];
> };
>
> struct amdgpu_bo_va_mapping;
> @@ -420,7 +423,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
> 447195cc4593..16cc0d5f5894 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h
> @@ -125,6 +125,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);
>
> /*
> * vm eviction_lock can be taken in MMU notifiers. Make sure no reclaim-FS
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c index
> b85b70a1a428..3a6449d60988 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> @@ -963,3 +963,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);
> + }
> +
> + 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-21 11:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 11:01 [PATCH 00/13] drm/amdgpu: fixes for the VM critical section and page fault rework Huang Yu
2026-09-17 11:01 ` [PATCH 01/13] drm/amdgpu: start to move VM internals into amdgpu_vm_internal.h Huang Yu
2026-09-21 11:36 ` Timur Kristóf
2026-09-17 11:01 ` [PATCH 02/13] drm/amdgpu: remove unecessary parameters from trace_amdgpu_vm_update_ptes Huang Yu
2026-09-21 11:37 ` Timur Kristóf
2026-09-17 11:01 ` [PATCH 03/13] drm/amdgpu: allocate and fill dummy PDs/PTs Huang Yu
2026-09-21 11:37 ` Timur Kristóf [this message]
2026-09-17 11:01 ` [PATCH 04/13] drm/amdgpu: add amdgpu_vm_pt_leaves() Huang Yu
2026-09-21 11:39 ` Timur Kristóf
2026-09-17 11:01 ` [PATCH 05/13] drm/amdgpu: drop immediate updates from amdgpu_vm_update_range Huang Yu
2026-09-17 11:01 ` [PATCH 06/13] drm/amdgpu: split amdgpu_vm_update_range Huang Yu
2026-09-17 11:01 ` [PATCH 07/13] drm/amdgpu: nuke most amdgpu_vm_eviction_(try)lock uses Huang Yu
2026-09-17 11:01 ` [PATCH 08/13] drm/amdgpu: rework eviction lock handling into critical section v2 Huang Yu
2026-09-17 11:01 ` [PATCH 09/13] drm/amdgpu: free PT when VM critical section cannot resume Huang Yu
2026-09-17 11:01 ` [PATCH 10/13] drm/amdgpu: fix the HMM range handling for KFD SVM Huang Yu
2026-09-17 11:01 ` [PATCH 11/13] drm/amdgpu: update the PTB itself in amdgpu_vm_pt_leaves() Huang Yu
2026-09-17 11:01 ` [PATCH 12/13] drm/amdgpu: pass an exclusive end to amdgpu_vm_pt_leaves() Huang Yu
2026-09-17 11:01 ` [PATCH 13/13] drm/amdgpu: use directory flags for dummy PDEs Huang Yu
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=P8HWfzzXTSi7EfI0L9PzAA@gmail.com \
--to=timur.kristof@gmail.com \
--cc=Yu.Huang@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=honghuan@amd.com \
--cc=junhshen@amd.com \
--cc=lingszhu@amd.com \
--cc=natalie.vock@gmx.de \
--cc=ray.huang@amd.com \
--cc=yhuang13@amd.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