[PATCH v2.5] drm/xe/eudebug: implement userptr_vma access

Andrzej Hajda andrzej.hajda at intel.com
Mon Aug 26 16:45:34 UTC 2024



On 26.08.2024 16:40, Andrzej Hajda wrote:
> Debugger needs to read/write program's vmas including userptr_vma.
>
> v2.5: use access_process_vm
>
> Signed-off-by: Andrzej Hajda <andrzej.hajda at intel.com>

> Signed-off-by: Maciej Patelczyk <maciej.patelczyk at intel.com>
> Signed-off-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>
> Reviewed-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
Ups, these three tags are not valid in this case.

Regards
Andrzej
> ---
> Hi Matthew,
>
> With recent changes in drm(?) v1 and v2 versions do not work anymore.
> I am wondering if using access_process_vm could be alternative approach,
> at least igt tests do not fail :)
>
> Regards
> Andrzej
> ---
>   drivers/gpu/drm/xe/xe_eudebug.c |  2 +-
>   drivers/gpu/drm/xe/xe_vm.c      | 12 ++++++++++++
>   drivers/gpu/drm/xe/xe_vm.h      |  3 +++
>   3 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_eudebug.c b/drivers/gpu/drm/xe/xe_eudebug.c
> index 7e62b0ffca83..39b33bb7893d 100644
> --- a/drivers/gpu/drm/xe/xe_eudebug.c
> +++ b/drivers/gpu/drm/xe/xe_eudebug.c
> @@ -3392,7 +3392,7 @@ static int xe_eudebug_vma_access(struct xe_vma *vma, u64 offset,
>   	if (bo)
>   		return xe_eudebug_bovma_access(bo, offset, buf, bytes, write);
>   
> -	return -EOPNOTSUPP;
> +	return xe_uvma_access(to_userptr_vma(vma), offset, buf, bytes, write);
>   }
>   
>   static int xe_eudebug_vm_access(struct xe_vm *vm, u64 offset,
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index ec4dd2c611d3..ee6e2ee078f9 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -3607,3 +3607,15 @@ void xe_vm_snapshot_free(struct xe_vm_snapshot *snap)
>   	}
>   	kvfree(snap);
>   }
> +
> +int xe_uvma_access(struct xe_userptr_vma *uvma, u64 offset,
> +		   void *buf, u64 len, bool write)
> +{
> +	struct mm_struct *mm = uvma->userptr.notifier.mm;
> +	unsigned long addr = uvma->vma.gpuva.gem.offset;
> +
> +	if (!mm || !mm->owner)
> +		return -EINVAL;
> +
> +	return access_process_vm(mm->owner, addr, buf, len, write ? FOLL_WRITE : 0);
> +}
> diff --git a/drivers/gpu/drm/xe/xe_vm.h b/drivers/gpu/drm/xe/xe_vm.h
> index c864dba35e1d..99b9a9b011de 100644
> --- a/drivers/gpu/drm/xe/xe_vm.h
> +++ b/drivers/gpu/drm/xe/xe_vm.h
> @@ -281,3 +281,6 @@ struct xe_vm_snapshot *xe_vm_snapshot_capture(struct xe_vm *vm);
>   void xe_vm_snapshot_capture_delayed(struct xe_vm_snapshot *snap);
>   void xe_vm_snapshot_print(struct xe_vm_snapshot *snap, struct drm_printer *p);
>   void xe_vm_snapshot_free(struct xe_vm_snapshot *snap);
> +
> +int xe_uvma_access(struct xe_userptr_vma *uvma, u64 offset,
> +		   void *buf, u64 len, bool write);



More information about the Intel-xe mailing list