All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bernatowicz, Marcin" <marcin.bernatowicz@linux.intel.com>
To: Lukasz Laguna <lukasz.laguna@intel.com>, igt-dev@lists.freedesktop.org
Cc: marcin.bernatowicz@intel.com, raag.jadav@intel.com
Subject: Re: [PATCH v1 1/2] lib/xe/xe_device: Add helper for device healthcheck
Date: Tue, 18 Aug 2026 17:04:45 +0200	[thread overview]
Message-ID: <f7f17d6f-9723-469e-9ae3-0e37e9f8d30e@linux.intel.com> (raw)
In-Reply-To: <20260811141426.1642321-2-lukasz.laguna@intel.com>


On 8/11/2026 4:14 PM, Lukasz Laguna wrote:
> Add helper for a basic Xe device health check. It performs a minimal
> bind, exec, wait and unbind sequence on a BO to verify that the command
> submission path works.
>
> Co-developed-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
> Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com>
> ---
>   lib/meson.build    |  1 +
>   lib/xe/xe_device.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++
>   lib/xe/xe_device.h | 11 +++++++
>   3 files changed, 85 insertions(+)
>   create mode 100644 lib/xe/xe_device.c
>   create mode 100644 lib/xe/xe_device.h
>
> diff --git a/lib/meson.build b/lib/meson.build
> index 3001b473e..7408da963 100644
> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -126,6 +126,7 @@ lib_sources = [
>   	'igt_msm.c',
>   	'igt_dsc.c',
>   	'igt_hook.c',
> +	'xe/xe_device.c',
>   	'xe/xe_ggtt.c',
>   	'xe/xe_gt.c',
>   	'xe/xe_ioctl.c',
> diff --git a/lib/xe/xe_device.c b/lib/xe/xe_device.c
> new file mode 100644
> index 000000000..74d85b097
> --- /dev/null
> +++ b/lib/xe/xe_device.c
> @@ -0,0 +1,73 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright(c) 2026 Intel Corporation. All rights reserved.
> + */
> +
> +#include "igt.h"
> +#include "igt_syncobj.h"
> +#include "xe/xe_device.h"
> +#include "xe/xe_ioctl.h"
> +#include "xe/xe_query.h"
> +
> +/**
> + * xe_healthcheck:
> + * @fd: Xe DRM file descriptor
> + *
> + * Basic check for the Xe execution path.
> + * It binds a BO into VM address space, executes a minimal batch,
> + * waits for completion, and then unbinds the BO.
> + */
> +void xe_healthcheck(int fd)
> +{
> +	struct drm_xe_engine_class_instance *hwe = NULL;
> +	struct drm_xe_sync sync = {
> +		.type = DRM_XE_SYNC_TYPE_SYNCOBJ,
> +		.flags = DRM_XE_SYNC_FLAG_SIGNAL,
> +	};
> +	struct drm_xe_exec exec = {
> +		.num_batch_buffer = 1,
> +		.num_syncs = 1,
> +		.syncs = to_user_pointer(&sync),
> +	};
> +	uint64_t addr = 0x1a0000;
> +	uint32_t vm;
> +	uint32_t exec_queue;
> +	uint32_t bo;
> +	uint32_t *batch;
> +	size_t bo_size;
> +
> +	xe_for_each_engine(fd, hwe)
> +		break;
> +
> +	igt_assert(hwe);
> +
> +	vm = xe_vm_create(fd, 0, 0);
> +	bo_size = xe_bb_size(fd, sizeof(*batch));
> +	bo = xe_bo_create(fd, vm, bo_size,
> +			  vram_if_possible(fd, hwe->gt_id),
> +			  DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
> +	batch = xe_bo_map(fd, bo, bo_size);
> +	exec_queue = xe_exec_queue_create(fd, vm, hwe, 0);
> +	sync.handle = syncobj_create(fd, 0);
> +
> +	xe_vm_bind_async(fd, vm, 0, bo, 0, addr, bo_size, &sync, 1);
> +	igt_assert(syncobj_wait(fd, &sync.handle, 1, INT64_MAX, 0, NULL));
> +
> +	batch[0] = MI_BATCH_BUFFER_END;
> +
> +	syncobj_reset(fd, &sync.handle, 1);
> +	exec.exec_queue_id = exec_queue;
> +	exec.address = addr;
> +	xe_exec(fd, &exec);
> +	igt_assert(syncobj_wait(fd, &sync.handle, 1, INT64_MAX, 0, NULL));
> +
> +	syncobj_reset(fd, &sync.handle, 1);
> +	xe_vm_unbind_async(fd, vm, 0, 0, addr, bo_size, &sync, 1);
> +	igt_assert(syncobj_wait(fd, &sync.handle, 1, INT64_MAX, 0, NULL));
> +
> +	syncobj_destroy(fd, sync.handle);
> +	xe_exec_queue_destroy(fd, exec_queue);
> +	munmap(batch, bo_size);
> +	gem_close(fd, bo);
> +	xe_vm_destroy(fd, vm);
> +}
> diff --git a/lib/xe/xe_device.h b/lib/xe/xe_device.h
> new file mode 100644
> index 000000000..f1b6f887b
> --- /dev/null
> +++ b/lib/xe/xe_device.h
> @@ -0,0 +1,11 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright(c) 2026 Intel Corporation. All rights reserved.
> + */
> +
> +#ifndef __XE_DEVICE_H__
> +#define __XE_DEVICE_H__
> +
> +void xe_healthcheck(int fd);
> +
LGTM. One nit: maybe rename it to xe_device_exec_healthcheck()

Reviewed-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
> +#endif /* __XE_DEVICE_H__ */

  reply	other threads:[~2026-08-18 15:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11 14:14 [PATCH v1 0/2] tests/device_reset: Add Xe healthcheck to post-reset validation Lukasz Laguna
2026-08-11 14:14 ` [PATCH v1 1/2] lib/xe/xe_device: Add helper for device healthcheck Lukasz Laguna
2026-08-18 15:04   ` Bernatowicz, Marcin [this message]
2026-08-11 14:14 ` [PATCH v1 2/2] tests/device_reset: Add Xe healthcheck to post-reset validation Lukasz Laguna
2026-08-18 15:05   ` Bernatowicz, Marcin
2026-08-11 15:53 ` ✓ Xe.CI.BAT: success for " Patchwork
2026-08-11 16:08 ` ✗ i915.CI.BAT: failure " Patchwork
2026-08-11 18:00 ` ✓ Xe.CI.FULL: success " 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=f7f17d6f-9723-469e-9ae3-0e37e9f8d30e@linux.intel.com \
    --to=marcin.bernatowicz@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=lukasz.laguna@intel.com \
    --cc=marcin.bernatowicz@intel.com \
    --cc=raag.jadav@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.