All of lore.kernel.org
 help / color / mirror / Atom feed
From: Francois Dugast <francois.dugast@intel.com>
To: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Cc: <igt-dev@lists.freedesktop.org>
Subject: Re: [PATCH i-g-t 3/3] lib/intel_compute: use post-sync write to detect command level preemption
Date: Fri, 4 Jul 2025 10:02:20 +0200	[thread overview]
Message-ID: <aGeKjDZeLvwxOTFA@fdugast-desk> (raw)
In-Reply-To: <20250703063032.553963-8-zbigniew.kempczynski@intel.com>

On Thu, Jul 03, 2025 at 08:30:36AM +0200, Zbigniew Kempczyński wrote:
> At command level when long job compute walker is finished we might
> be immediately switched to short job. This defers signalling of long
> job user-fence giving false impression this job is still ongoing.
> 
> Add post-sync write to compute walker to allow detect this situation
> and fail if command level preemption occurred instead TG preemption.
> 
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
> Cc: Francois Dugast <francois.dugast@intel.com>

Reviewed-by: Francois Dugast <francois.dugast@intel.com>

> ---
>  lib/intel_compute.c | 23 +++++++++++++++++------
>  1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/intel_compute.c b/lib/intel_compute.c
> index 9549b58fdf..6126bdb3f7 100644
> --- a/lib/intel_compute.c
> +++ b/lib/intel_compute.c
> @@ -53,6 +53,7 @@
>  #define OFFSET_STATE_SIP			0xFFFF0000
>  
>  #define USER_FENCE_VALUE			0xdeadbeefdeadbeefull
> +#define POST_SYNC_VALUE			0xabcdabcdcdefcdefull
>  #define MAGIC_LOOP_STOP			0x12341234
>  
>  #define THREADS_PER_GROUP		32
> @@ -63,6 +64,7 @@
>  #define ENQUEUED_LOCAL_SIZE_Z		1
>  #define DP_SS_CACHE_FLUSH		(1 << 12)
>  #define DP_PIPELINE_FLUSH		(1 << 2)
> +#define WRITE_IMM_DATA			(1 << 0)
>  #define WRITE_TIMESTAMP		(3 << 0)
>  
>  /*
> @@ -1557,7 +1559,7 @@ static void xe2lpg_compute_exec_compute(int fd,
>  					bool	 threadgroup_preemption,
>  					uint32_t work_size)
>  {
> -	uint8_t wb_mocs = intel_get_wb_mocs_index(fd);
> +	uint8_t uc_mocs = intel_get_uc_mocs_index(fd);
>  	int b = 0;
>  
>  	igt_debug("general   state base: %"PRIx64"\n", addr_general_state_base);
> @@ -1617,7 +1619,7 @@ static void xe2lpg_compute_exec_compute(int fd,
>  	addr_bo_buffer_batch[b++] = addr_surface_state_base >> 32;
>  	addr_bo_buffer_batch[b++] = 0x001ff000;
>  
> -	if (sip_start_pointer) {
> +	if (sip_start_pointer && !threadgroup_preemption) {
>  		addr_bo_buffer_batch[b++] = XE2_STATE_SIP | 0x1;
>  		addr_bo_buffer_batch[b++] = sip_start_pointer;
>  		addr_bo_buffer_batch[b++] = 0x00000000;
> @@ -1665,12 +1667,12 @@ static void xe2lpg_compute_exec_compute(int fd,
>  	addr_bo_buffer_batch[b++] = 0x0c000000 | THREADS_PER_GROUP;
>  	addr_bo_buffer_batch[b++] = 0x00000000;
>  	addr_bo_buffer_batch[b++] = 0x00000000;
> -	addr_bo_buffer_batch[b++] = DP_SS_CACHE_FLUSH | wb_mocs << 4 |
> -				    DP_PIPELINE_FLUSH | WRITE_TIMESTAMP;
> +	addr_bo_buffer_batch[b++] = DP_SS_CACHE_FLUSH | uc_mocs << 4 |
> +				    DP_PIPELINE_FLUSH | WRITE_IMM_DATA;
>  	addr_bo_buffer_batch[b++] = ADDR_BATCH;
>  	addr_bo_buffer_batch[b++] = ADDR_BATCH >> 32;
> -	addr_bo_buffer_batch[b++] = 0x00000000;
> -	addr_bo_buffer_batch[b++] = 0x00000000;
> +	addr_bo_buffer_batch[b++] = (uint32_t) POST_SYNC_VALUE;
> +	addr_bo_buffer_batch[b++] = (uint32_t) (POST_SYNC_VALUE >> 32);
>  	addr_bo_buffer_batch[b++] = 0x00000000;
>  	addr_bo_buffer_batch[b++] = 0x00000000;
>  	addr_bo_buffer_batch[b++] = 0x00000000;
> @@ -2117,6 +2119,7 @@ static void xe2lpg_compute_preempt_exec(int fd, const unsigned char *long_kernel
>  	struct bo_dict_entry bo_dict_short[ARRAY_SIZE(bo_dict_long)];
>  	struct bo_execenv execenv_short, execenv_long;
>  	float *input_short, *output_short, *input_long;
> +	uint64_t *post_data;
>  	unsigned int long_kernel_loop_count = 0;
>  	int64_t timeout_one_ns = 1;
>  	bool use_loop_kernel = loop_kernel && !threadgroup_preemption;
> @@ -2165,6 +2168,7 @@ static void xe2lpg_compute_preempt_exec(int fd, const unsigned char *long_kernel
>  	input_long = (float *) bo_dict_long[4].data;
>  	input_short = (float *) bo_dict_short[4].data;
>  	output_short = (float *) bo_dict_short[5].data;
> +	post_data = (uint64_t *) bo_dict_long[8].data;
>  
>  	bo_randomize(input_short, SIZE_DATA);
>  
> @@ -2195,6 +2199,12 @@ static void xe2lpg_compute_preempt_exec(int fd, const unsigned char *long_kernel
>  	bo_execenv_exec(&execenv_short, ADDR_BATCH);
>  	bo_check_square(input_short, output_short, SIZE_DATA);
>  
> +	/*
> +	 * Catch command level preemption instead TG preemption. For TG and WMTP
> +	 * post sync can't be visible at this point yet.
> +	 */
> +	igt_assert_neq_u64(POST_SYNC_VALUE, *post_data);
> +
>  	/* Check that the long kernel has not completed yet */
>  	igt_assert_neq(0, __xe_wait_ufence(fd, &execenv_long.bo_sync->sync, USER_FENCE_VALUE,
>  					   execenv_long.exec_queue, &timeout_one_ns));
> @@ -2205,6 +2215,7 @@ static void xe2lpg_compute_preempt_exec(int fd, const unsigned char *long_kernel
>  	((int *)input_long)[0] = MAGIC_LOOP_STOP;
>  
>  	bo_execenv_sync(&execenv_long);
> +	igt_assert_eq_u64(POST_SYNC_VALUE, *post_data);
>  
>  	bo_execenv_unbind(&execenv_short, bo_dict_short, entries);
>  	bo_execenv_unbind(&execenv_long, bo_dict_long, entries);
> -- 
> 2.43.0
> 

  reply	other threads:[~2025-07-04  8:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03  6:30 [PATCH i-g-t 0/3] TG preemption detection improvements Zbigniew Kempczyński
2025-07-03  6:30 ` [PATCH i-g-t 1/3] lib/intel_mocs: fix wb mocs entry for MTL Zbigniew Kempczyński
2025-07-03  8:41   ` Matthew Auld
2025-07-03  6:30 ` [PATCH i-g-t 2/3] lib/intel_compute: use macros instead of binary data in post-sync op Zbigniew Kempczyński
2025-07-04  8:01   ` Francois Dugast
2025-07-03  6:30 ` [PATCH i-g-t 3/3] lib/intel_compute: use post-sync write to detect command level preemption Zbigniew Kempczyński
2025-07-04  8:02   ` Francois Dugast [this message]
2025-07-04  8:05     ` Zbigniew Kempczyński
2025-07-03  8:02 ` ✗ Xe.CI.BAT: failure for TG preemption detection improvements Patchwork
2025-07-03 10:41   ` Zbigniew Kempczyński
2025-07-03  8:05 ` ✓ i915.CI.BAT: success " Patchwork
2025-07-03 11:48 ` ✓ Xe.CI.BAT: " Patchwork
2025-07-03 15:38 ` ✗ i915.CI.Full: failure " Patchwork
2025-07-04 21:12 ` ✗ 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=aGeKjDZeLvwxOTFA@fdugast-desk \
    --to=francois.dugast@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=zbigniew.kempczynski@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.