The control stack and MQD sizes of a CRIU restored queue come from the
checkpoint image, and get_wave_state() builds its returned sizes and the
user header from raw MQD fields. This series bounds both.

1. Size the restored control stack from topology, as create-queue does,
   reject images that carry more, and keep the gfx9 MQD control stack
   size and offset within the allocation.
2. Fix the gfx9 checkpoint control stack bound, which stayed 0 because
   the MQD manager is created before the node is in topology.
3. Derive the wave state header and used sizes from clamped values on
   gfx8 through gfx12.1, so none of them can wrap.
4. Accept the one-MQD-per-XCC image that checkpoint writes on multi-XCC
   nodes, restore the MQD stride of the new allocation, and only restore
   MQD types that can be checkpointed.

Tested on gfx942 (8 XCC) and gfx1036 with synthetic restore images:
out-of-range sizes are rejected with -EINVAL, inconsistent MQD fields
give a consistent header, and a driver-written 8-XCC checkpoint (control
stack 98304 bytes, was 0) restores in a fresh process with each XCC's
MQD in place.

William Palacek (4):
  drm/amdkfd: Size restored queues from topology
  drm/amdkfd: Set the v9 checkpoint control stack bound after topology
  drm/amdkfd: Report only clamped wave state sizes in get_wave_state()
  drm/amdkfd: Expect one MQD per XCC when restoring a queue

 .../drm/amd/amdkfd/kfd_device_queue_manager.c | 15 ++++---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h  | 16 +++++++
 .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c  | 19 +++-----
 .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v11.c  | 18 +++-----
 .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v12.c  | 14 ++----
 .../drm/amd/amdkfd/kfd_mqd_manager_v12_1.c    | 23 +++-------
 .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c   | 45 ++++++-------------
 .../gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c   |  9 ++--
 .../amd/amdkfd/kfd_process_queue_manager.c    | 33 ++++++++++----
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c     |  4 ++
 10 files changed, 94 insertions(+), 102 deletions(-)

-- 
2.43.0

Reply via email to