Hello Christian, Alex and Cascardo,

This v3 waits uninterruptibly for explicit sync and root KERNEL move
fences in CPU prepare. Allocation commits the old phase and prepares
another phase before writes resume; CPU update no longer scans the
reservation for every PTE batch.

Changes since v2:
- Use intr=false for both CPU waits. Drop the result check for the
  infinite reservation wait, following the MMU-notifier unmap contract.
- Reuse Cascardo's void-commit cleanup [1] and the existing PT teardown
  fix [2] as prerequisites. Remove our duplicate teardown submission.
- Adapt Cascardo's context job-ID proposal [3], including SDMA prepare,
  initial allocation and IB rollover, while preserving his authorship.
- Keep internal SDMA completion tracking before partial-range cleanup.
  Fold nested-clear finalization into the allocation-phase change.
- Explain the same-entity finished-fence ordering and owned-reference
  transfers in the completion-tracking commit description.

Why one internal completion is enough for a range:

A range prefix, its nested clear and its resumed phase all preserve
immediate and select the same VM entity. That entity keeps its engine
while work is unfinished, and SDMA submissions execute in queue order.
amdgpu_job_submit() returns a finished fence, so the latest such fence
covers those submissions. This relies on no cross-entity global order.

Each context owns its last_update reference. Submission replaces it;
missing/empty commits retain it. Nested clear transfers its reference
with a swap and puts the displaced reference. TLB finalization takes
its own reference before the context releases its private reference.
The optional public output and DONT_PIPELINE policy stay unchanged.

Dependency and application order:

The native base is identified below. The November 17 public refs still
lack the three prerequisites carried in the source backup:
  A. Cascardo's missing/empty SDMA job handling (posted as v2 patch 1/6).
  B. Cascardo's void-commit cleanup [1].
  C. The existing publicly posted PT teardown fix [2].

These are native adaptations with original authors and sign-offs. I have
not identified the exact queued reviewed PT-fix commit, so I have not
inferred a Reviewed-by from equivalent public code. The prerequisites
are not resubmitted as new patches in this five-patch series.



The complete stack is backed up here (source backup, not a pull request):
  
https://github.com/zihaomu/amdgpu/tree/fix/vm-prepare-uninterruptible-v3-polished

To reproduce from a disposable checkout with the native base available:
  git fetch https://github.com/zihaomu/amdgpu.git \
      fix/vm-prepare-uninterruptible-v3-polished
  vm_prereq_tip=adc41aaa1cb5e3103cad42ed9180d68fc384ffc9
  git switch --detach "$vm_prereq_tip"
  git am /path/to/v3/outgoing/v3-000[1-5]-*.patch

That checkout contains prerequisites A-C only. Do not apply them again if
they are already present; port onto the maintainer's queued versions when
the corresponding commits become available. The cover is not a patch.

The five patches are context job ID, internal completion tracking,
partial-range finalization, allocation-phase restart, and CPU prepare
waits, in that order. Original sync and job ID survive allocation.

Validation:
- GCC 13.3.0 compiled the four relevant VM objects at all eight commit
  states, with CONFIG_DRM_AMDGPU=m. Applicable offline checks also ran
  at each of the five outgoing source states.
- The lifecycle fixture executes extracted native walker, cursor, PTE
  flags, free-list, backend, explicit-sync and TLB-worker bodies. On the
  final state it checks 96 range cases, 54 allocation failures, four
  free-list paths and two PDE paths. Unlocked walks do not allocate.
- Pending-signal checks include 16 CPU unmap and four CPU allocation
  restart cases, plus corresponding SDMA cases in the scheduler model.
  Separate CPU/reservation checks cover 960 normal and 960 signal
  combinations, eight signal/unmap cases and two missing-wait controls.
- Nine broken controls are detected, including removed SDMA KERNEL
  dependencies, allocation in unlocked walks, lost original sync,
  lost clear completion and a completion from the wrong entity.
- Nine direct backend/scheduler unit cases are counted separately.
  Two explicit contract controls confirm the unchanged native walker
  still ignores a backend update error; they are not successful unmaps.
- Strict checkpatch passes for the five patches and cover. ASCII EML
  extraction, default git am and per-commit full-tree application match
  the exact sources and authors. ASan/UBSan reported no runtime errors.

The model is bounded to a two-level PT fixture. Hardware encoding,
BO/TTM, scheduler, GPU, list and fence primitives are simulated; this
is not live fault injection or a kernel concurrency proof. Operation
counts are not measured performance gains. SDMA allocation failures,
the complete no-fail unmap conversion and the original queue-stall
cause remain unresolved. The independent fast-path proposal is excluded.

Please review the revised wait contract and phase/fence ordering.
I can rebase onto the queued prerequisite commits when they are known.

[1]
https://lore.kernel.org/amd-gfx/20260924-amdgpu_vm_update_funcs_commit_void-v1-1-9ad7a8283...@igalia.com/
[2]
https://lore.kernel.org/amd-gfx/[email protected]/
[3]
https://lore.kernel.org/amd-gfx/[email protected]/

Thanks,
Zihao

---
base-commit: a6836fcbb5b22968019256025321d655b78bc49c
prerequisite-patch-id: 8b58a9b82460d152ba8dbbd77cacb733c73221bd
prerequisite-patch-id: c6ccf9fd4659ee004f8af666adc985bfe4a05de4
prerequisite-patch-id: 6eec44dc54d47d900a5172c4aed842e66e8ce868
-- 
2.43.0

Reply via email to