[PATCH v3 9/9] drm/xe: Implement DRM_XE_EXEC_QUEUE_SET_HANG_REPLAY_STATE
Maarten Lankhorst
maarten.lankhorst at linux.intel.com
Tue Mar 25 10:25:31 UTC 2025
On 2025-03-20 20:28, Matthew Brost wrote:
> Implement DRM_XE_EXEC_QUEUE_SET_HANG_REPLAY_STATE which sets the exec
> queue default state to user data passed in. The intent is for a Mesa
> tool to use this replay GPU hangs.
>
> v2:
> - Enable the flag DRM_XE_EXEC_QUEUE_SET_HANG_REPLAY_STATE
> - Fix the page size math calculation to avoid a crash
>
> Cc: José Roberto de Souza <jose.souza at intel.com>
> Signed-off-by: Matthew Brost <matthew.brost at intel.com>
> ---
> drivers/gpu/drm/xe/xe_exec_queue.c | 32 ++++++++++++++++--
> drivers/gpu/drm/xe/xe_exec_queue_types.h | 3 ++
> drivers/gpu/drm/xe/xe_execlist.c | 2 +-
> drivers/gpu/drm/xe/xe_lrc.c | 42 +++++++++++++++++-------
> drivers/gpu/drm/xe/xe_lrc.h | 3 +-
> 5 files changed, 67 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c
> index 606922d9dd73..4d8c0aae6f55 100644
> --- a/drivers/gpu/drm/xe/xe_exec_queue.c
> +++ b/drivers/gpu/drm/xe/xe_exec_queue.c
> @@ -47,6 +47,7 @@ static void __xe_exec_queue_free(struct xe_exec_queue *q)
> if (q->xef)
> xe_file_put(q->xef);
>
> + kvfree(q->replay_state);
> kfree(q);
> }
>
> @@ -139,7 +140,8 @@ static int __xe_exec_queue_init(struct xe_exec_queue *q)
> }
>
> for (i = 0; i < q->width; ++i) {
> - q->lrc[i] = xe_lrc_create(q->hwe, q->vm, SZ_16K, q->msix_vec, flags);
> + q->lrc[i] = xe_lrc_create(q->hwe, q->vm, q->replay_state,
> + SZ_16K, q->msix_vec, flags);
> if (IS_ERR(q->lrc[i])) {
> err = PTR_ERR(q->lrc[i]);
> goto err_unlock;
> @@ -460,6 +462,30 @@ exec_queue_set_pxp_type(struct xe_device *xe, struct xe_exec_queue *q, u64 value
> return xe_pxp_exec_queue_set_type(xe->pxp, q, DRM_XE_PXP_TYPE_HWDRM);
> }
>
> +static int exec_queue_set_hang_replay_state(struct xe_device *xe,
> + struct xe_exec_queue *q,
> + u64 value)
> +{
> + size_t size = xe_gt_lrc_hang_replay_size(q->gt, q->class);
> + u64 __user *address = u64_to_user_ptr(value);
> + void *ptr;
> + int err;
> +
> + ptr = kvmalloc(size, GFP_KERNEL);
> + if (!ptr)
> + return -ENOMEM;
> +
> + err = __copy_from_user(ptr, address, size);
> + if (XE_IOCTL_DBG(xe, err)) {
> + kvfree(ptr);
> + return -EFAULT;
> + }
> +
> + q->replay_state = ptr;
Seems this can be replaced with a call to vmemdup_user ?
With the changes to this patch, stolen mem and ack from userspace side:
Reviewed-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Best regards,
~Maarten
More information about the Intel-xe
mailing list