On 9/28/26 20:57, Sunil Khatri wrote:
> The SPM reservation borrowed a VMID from the GFXHUB round-robin pool
> shared with normal graphics contexts (VMIDs 1-7). SPM streams its output
> through the selected VMID's page tables, so sharing that slot with
> dynamically scheduled contexts is a poor isolation boundary and makes
> the profiling VMID non-deterministic.
> 
> Reservation now uses the VMID a hub dedicates to it. When
> vm_manager.spm_vmid is set, amdgpu_vmid_alloc_reserved() hands out that
> fixed VMID directly; when it is unset the reservation is rejected with
> -ENOENT rather than borrowing a pool VMID, so a reserved submission can
> never end up on VMID 0 (the kernel VM) or on a slot shared with graphics
> contexts. The dedicated VMID is not part of the round-robin LRU, so it
> is given an initialized active-fence sync on every GFXHUB instance in
> amdgpu_vmid_mgr_init() and amdgpu_vmid_free_reserved() has nothing to
> return to the LRU.
> 
> The behaviour is gated on spm_vmid, so hubs that do not dedicate a VMID
> simply do not support reservation.

That won't work like this. The SPM VMID would still be used round robin with 
that.

You need to take the VMID completely out of the mask. Take a look at when 
amdgpu_vmid_mgr_set_vmid_mask() is called.

Regards,
Christian.

> 
> Signed-off-by: Sunil Khatri <[email protected]>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> index 5e424e3b6e71f..c8cbd0851d478 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> @@ -551,9 +551,12 @@ int amdgpu_vmid_alloc_reserved(struct amdgpu_device 
> *adev, struct amdgpu_vm *vm,
>               r = -ENOENT;
>               goto unlock;
>       }
> -     /* Remove from normal round robin handling */
> -     id = list_first_entry(&id_mgr->ids_lru, struct amdgpu_vmid, list);
> -     list_del_init(&id->list);
> +     if (!adev->vm_manager.spm_vmid) {
> +             r = -ENOENT;
> +             goto unlock;
> +     }
> +
> +     id = &id_mgr->ids[adev->vm_manager.spm_vmid];
>       vm->reserved_vmid[vmhub] = id;
>       id_mgr->reserved_vmid = true;
>       mutex_unlock(&id_mgr->lock);
> @@ -577,8 +580,6 @@ void amdgpu_vmid_free_reserved(struct amdgpu_device 
> *adev, struct amdgpu_vm *vm,
>  
>       mutex_lock(&id_mgr->lock);
>       if (vm->reserved_vmid[vmhub]) {
> -             list_add(&vm->reserved_vmid[vmhub]->list,
> -                     &id_mgr->ids_lru);
>               vm->reserved_vmid[vmhub] = NULL;
>               id_mgr->reserved_vmid = false;
>       }
> @@ -670,6 +671,10 @@ void amdgpu_vmid_mgr_init(struct amdgpu_device *adev)
>                       amdgpu_sync_create(&id_mgr->ids[j].active);
>                       list_add_tail(&id_mgr->ids[j].list, &id_mgr->ids_lru);
>               }
> +
> +             /* out-of-pool VMID; create its sync here */
> +             if (adev->vm_manager.spm_vmid && AMDGPU_IS_GFXHUB(i))
> +                     
> amdgpu_sync_create(&id_mgr->ids[adev->vm_manager.spm_vmid].active);
>       }
>  }
>  

Reply via email to