On 6/12/26 07:52, Srinivasan Shanmugam wrote:
> Signal MEMORY_EXCEPTION EVENTFD subscriptions from the VM fault
> interrupt path.
> 
> The VM fault path already detects GPU memory exceptions by decoding the
> fault address and status. Use that point to wake up matching EVENTFD
> subscribers.
> 
> MEMORY_EXCEPTION is GPU-scoped, so no queue object is used.
> 
> EVENTFD remains notification-only.
> 
> Cc: Alex Deucher <[email protected]>
> Cc: Christian König <[email protected]>
> Signed-off-by: Srinivasan Shanmugam <[email protected]>
> ---
>  drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
> index 8eb9847d9e1e..2635fd308324 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
> @@ -122,6 +122,9 @@ static int gmc_v11_0_process_interrupt(struct 
> amdgpu_device *adev,
>       }
>  
>       if (!amdgpu_sriov_vf(adev)) {
> +             struct drm_device *ddev = adev_to_drm(adev);
> +             struct drm_file *file;
> +
>               /*
>                * Issue a dummy read to wait for the status register to
>                * be updated to avoid reading an incorrect value due to
> @@ -135,6 +138,17 @@ static int gmc_v11_0_process_interrupt(struct 
> amdgpu_device *adev,
>  
>               amdgpu_vm_update_fault_cache(adev, entry->pasid, addr, status,
>                                            entry->vmid_src ? AMDGPU_MMHUB0(0) 
> : AMDGPU_GFXHUB(0));
> +
> +             mutex_lock(&ddev->filelist_mutex);

Big no-no, we are in an interrupt handler here.

> +             list_for_each_entry(file, &ddev->filelist, lhead) {
> +                     struct amdgpu_fpriv *fpriv = file->driver_priv;
> +
> +                     if (fpriv)
> +                             amdgpu_eventfd_signal(&fpriv->eventfd_mgr,
> +                                                   
> DRM_AMDGPU_EVENT_TYPE_MEMORY_EXCEPTION,
> +                                                   NULL);
> +             }
> +             mutex_unlock(&ddev->filelist_mutex);

This should probably go into amdgpu_vm_update_fault_cache().

We might want to rework the VM faulting code completely. Currently we map pasid 
to vm, but that means that we can't access the eventfd object.

Now that the KFD doesn't own the pasid any more I think we could change that to 
pasid to fpriv mapping (which fpriv->vm for the page table handling).

@Alex, Felix and Philip opinions?

Thanks,
Christian.

>       }
>  
>       if (printk_ratelimit()) {

Reply via email to