On 6/23/26 10:12, Srinivasan Shanmugam wrote:
> Current VM fault handling resolves PASIDs through VM state:
> 
>       PASID -> VM
> 
> That is sufficient for VM fault handling, but process-scoped event
> delivery paths need a different semantic mapping:
> 
>       PASID -> amdgpu_fpriv
> 
> Although both mappings are indexed by PASID, they serve different
> purposes:
> 
>       vm_manager.pasids
>               PASID -> VM fault handling
> 
>       vm_manager.pasid_fprivs
>               PASID -> process-scoped DRM file-private owner
> 
> Add a PASID fpriv xarray beside the existing PASID to VM xarray.
> 
> Cc: Alex Deucher <[email protected]>
> Cc: Christian König <[email protected]>
> Signed-off-by: Srinivasan Shanmugam <[email protected]>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |  5 +++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 13 +++++++++++++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 450bd9dc6bc0..3141ae1383b0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -2869,6 +2869,8 @@ void amdgpu_vm_manager_init(struct amdgpu_device *adev)
>  #endif
>  
>       xa_init_flags(&adev->vm_manager.pasids, XA_FLAGS_LOCK_IRQ);
> +     xa_init_flags(&adev->vm_manager.pasid_fprivs,
> +                   XA_FLAGS_LOCK_IRQ);

I think we should completely remove &adev->vm_manager.pasids.

Take a look at amdgpu_pasid_alloc(), we already store the PASIDs in the global 
amdgpu_pasid_xa xarray.

But instead of a real value we just give xa_mk_value(0) as dummy for the entry.

I think we can re-use that array to store pasid->fpriv mapping. It just needs 
proper locking and interface to retrive the fpriv for a pasid (while holding 
the XA lock irqsave).

Let me know when you have more questions.

Regards,
Christian.

>  }
>  
>  /**
> @@ -2881,7 +2883,10 @@ void amdgpu_vm_manager_init(struct amdgpu_device *adev)
>  void amdgpu_vm_manager_fini(struct amdgpu_device *adev)
>  {
>       WARN_ON(!xa_empty(&adev->vm_manager.pasids));
> +     WARN_ON(!xa_empty(&adev->vm_manager.pasid_fprivs));
> +
>       xa_destroy(&adev->vm_manager.pasids);
> +     xa_destroy(&adev->vm_manager.pasid_fprivs);
>  
>       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 4d96bb8c2c6d..5318e833bd97 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> @@ -450,6 +450,8 @@ struct amdgpu_vm {
>       struct amdgpu_vm_fault_info fault_info;
>  };
>  
> +struct amdgpu_fpriv;
> +
>  struct amdgpu_vm_manager {
>       /* Handling of VMIDs */
>       struct amdgpu_vmid_mgr                  id_mgr[AMDGPU_MAX_VMHUBS];
> @@ -484,6 +486,17 @@ struct amdgpu_vm_manager {
>        * look up VM of a page fault
>        */
>       struct xarray                           pasids;
> +
> +     /*
> +      * PASID to DRM file-private mapping.
> +      *
> +      * This is separate from @pasids. @pasids answers which VM
> +      * should be used for VM fault handling, while @pasid_fprivs
> +      * answers which DRM file-private owner should receive
> +      * process-scoped events.
> +      */
> +     struct xarray pasid_fprivs;
> +
>       /* Global registration of recent page fault information */
>       struct amdgpu_vm_fault_info     fault_info;
>  };

Reply via email to