Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Matthew Brost <matthew.brost@intel.com>, intel-xe@lists.freedesktop.org
Cc: jose.souza@intel.com, carlos.santa@intel.com
Subject: Re: [PATCH v3 9/9] drm/xe: Implement DRM_XE_EXEC_QUEUE_SET_HANG_REPLAY_STATE
Date: Tue, 25 Mar 2025 11:25:31 +0100	[thread overview]
Message-ID: <1bf95838-054f-4a9c-97fb-960be8c2562e@linux.intel.com> (raw)
In-Reply-To: <20250320192831.3842138-10-matthew.brost@intel.com>



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@intel.com>
> Signed-off-by: Matthew Brost <matthew.brost@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@linux.intel.com>

Best regards,
~Maarten

  reply	other threads:[~2025-03-25 10:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-20 19:28 [PATCH v3 0/9] Add support for Mesa GPU hang replay tool Matthew Brost
2025-03-20 19:28 ` [PATCH v3 1/9] drm/xe: Add properties line to VM snapshot capture Matthew Brost
2025-03-20 19:28 ` [PATCH v3 2/9] drm/xe: Add "null_sparse" type to VM snap properties Matthew Brost
2025-03-20 19:28 ` [PATCH v3 3/9] drm/xe: Add mem_region to properties line in VM snapshot capture Matthew Brost
2025-03-25  9:41   ` Maarten Lankhorst
2025-03-20 19:28 ` [PATCH v3 4/9] drm/xe: Add pat_index " Matthew Brost
2025-03-20 19:28 ` [PATCH v3 5/9] drm/xe: Add cpu_caching " Matthew Brost
2025-03-20 19:28 ` [PATCH v3 6/9] drm/xe: Add VM.uapi_flags to " Matthew Brost
2025-03-20 19:28 ` [PATCH v3 7/9] drm/xe/uapi: Add DRM_XE_EXEC_QUEUE_SET_HANG_REPLAY_STATE Matthew Brost
2025-03-20 19:28 ` [PATCH v3 8/9] drm/xe: Add replay_offset and replay_length lines to LRC HWCTX snapshot Matthew Brost
2025-03-20 19:28 ` [PATCH v3 9/9] drm/xe: Implement DRM_XE_EXEC_QUEUE_SET_HANG_REPLAY_STATE Matthew Brost
2025-03-25 10:25   ` Maarten Lankhorst [this message]
2025-03-20 19:32 ` ✓ CI.Patch_applied: success for Add support for Mesa GPU hang replay tool (rev3) Patchwork
2025-03-20 19:32 ` ✗ CI.checkpatch: warning " Patchwork
2025-03-20 19:34 ` ✓ CI.KUnit: success " Patchwork
2025-03-20 19:50 ` ✓ CI.Build: " Patchwork
2025-03-20 19:52 ` ✓ CI.Hooks: " Patchwork
2025-03-20 19:54 ` ✓ CI.checksparse: " Patchwork
2025-03-20 20:13 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-03-20 21:18 ` ✗ Xe.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1bf95838-054f-4a9c-97fb-960be8c2562e@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=carlos.santa@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jose.souza@intel.com \
    --cc=matthew.brost@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox