On 10/12/26 11:24, Sunil Khatri wrote:
> Use the spm vmid which is dedicated for the SPM only and update
> the function paths accordingly.
> 
> Signed-off-by: Sunil Khatri <[email protected]>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 19 ++++++++++++++-----
>  1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> index ed1efde29a9a5..3617de2368d5a 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;
>       }
> @@ -627,6 +628,10 @@ void amdgpu_vmid_reset_all(struct amdgpu_device *adev)
>                       &adev->vm_manager.id_mgr[i];
>               for_each_set_bit(j, id_mgr->vmid_mask, AMDGPU_NUM_VMID)
>                       amdgpu_vmid_reset(adev, i, j);
> +
> +             /* out-of-pool VMID, not covered by vmid_mask */

Better write "The SPM VMID is not part of the normal kernel pool, reset it 
anyway in case it is used with kernel queues.".

> +             if (adev->vm_manager.spm_vmid && AMDGPU_IS_GFXHUB(i))

If would be nice if we could rather come up with a loop over the GFXHUBs only.

E.g. something like this:

for (i = AMDGPU_GFXHUB_START; i < AMDGPU_MMHUB0_START; ++i)

> +                     amdgpu_vmid_reset(adev, i, adev->vm_manager.spm_vmid);
>       }
>  }
>  
> @@ -711,6 +716,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 */

Something similar here.

> +             if (adev->vm_manager.spm_vmid && AMDGPU_IS_GFXHUB(i))

Same for loop here as well.

Regards,
Christian.

> +                     
> amdgpu_sync_create(&id_mgr->ids[adev->vm_manager.spm_vmid].active);
>       }
>  }
>  

Reply via email to