[PATCH i-g-t, v4 2/5] lib/xe/xe_spin: Add mem copy capability to spinner

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Apr 1 19:09:54 UTC 2025


On Tue, Apr 01, 2025 at 04:00:57PM +0200, Francois Dugast wrote:
> Add the option to perform a copy while spinning. The existing struct
> blt_mem_object is reused as it contains the information required for
> the copy.
> 
> Signed-off-by: Francois Dugast <francois.dugast at intel.com>
> ---
>  lib/xe/xe_spin.c | 14 ++++++++++++++
>  lib/xe/xe_spin.h | 19 +++++++++++++++++++
>  2 files changed, 33 insertions(+)
> 
> diff --git a/lib/xe/xe_spin.c b/lib/xe/xe_spin.c
> index 0de0b1f2e..5a9d51575 100644
> --- a/lib/xe/xe_spin.c
> +++ b/lib/xe/xe_spin.c
> @@ -125,6 +125,20 @@ void xe_spin_init(struct xe_spin *spin, struct xe_spin_opts *opts)
>  		spin->batch[b++] = ticks_delta_addr >> 32;
>  	}
>  
> +	if (opts->mem_copy) {
> +		spin->batch[b++] = MEM_COPY_CMD;
> +		spin->batch[b++] = opts->mem_copy->src->width - 1;
> +		spin->batch[b++] = opts->mem_copy->src->height - 1;
> +		spin->batch[b++] = opts->mem_copy->src->pitch - 1;
> +		spin->batch[b++] = opts->mem_copy->dst->pitch - 1;
> +		spin->batch[b++] = opts->mem_copy->src_offset;
> +		spin->batch[b++] = opts->mem_copy->src_offset << 32;
> +		spin->batch[b++] = opts->mem_copy->dst_offset;
> +		spin->batch[b++] = opts->mem_copy->dst_offset << 32;
> +		spin->batch[b++] = opts->mem_copy->src->mocs_index << MEM_COPY_MOCS_SHIFT |
> +				   opts->mem_copy->dst->mocs_index;
> +	}
> +
>  	spin->batch[b++] = MI_COND_BATCH_BUFFER_END | MI_DO_COMPARE | 2;
>  	spin->batch[b++] = 0;
>  	spin->batch[b++] = end_addr;
> diff --git a/lib/xe/xe_spin.h b/lib/xe/xe_spin.h
> index 7c95996c3..c4110469b 100644
> --- a/lib/xe/xe_spin.h
> +++ b/lib/xe/xe_spin.h
> @@ -14,6 +14,7 @@
>  
>  #include "xe_query.h"
>  #include "lib/igt_dummyload.h"
> +#include "lib/intel_blt.h"
>  
>  /* Wrapper to integrate with igt_dummyload, aka igt_spin */
>  igt_spin_t *xe_spin_create(int fd, const struct igt_spin_factory *opt);
> @@ -24,11 +25,28 @@ void xe_spin_free(int fd, struct igt_spin *spin);
>   * engine in which it's exec'ed
>   */
>  
> +/**
> + * struct xe_spin_mem_copy
> + * @src: source BLT object
> + * @dst: destination BLT object
> + * @src_offset: source offset
> + * @dst_offset: destination offset
> + *
> + * Used to perform memory copy with the spinner.
> + */
> +struct xe_spin_mem_copy {
> +	struct blt_mem_object *src;
> +	struct blt_mem_object *dst;
> +	uint64_t src_offset;
> +	uint64_t dst_offset;
> +};
> +
>  /**
>   * struct xe_spin_opts
>   * @addr: offset of spinner within vm
>   * @preempt: allow spinner to be preempted or not
>   * @ctx_ticks: number of ticks after which spinner is stopped, applied if > 0
> + * @mem_copy: todo

Just fill it, other things lgtm. With this field filled, the patch is:

Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>


--
Zbigniew

>   *
>   * Used to initialize struct xe_spin spinner behavior.
>   */
> @@ -37,6 +55,7 @@ struct xe_spin_opts {
>  	bool preempt;
>  	uint32_t ctx_ticks;
>  	bool write_timestamp;
> +	struct xe_spin_mem_copy *mem_copy;
>  };
>  
>  /* Mapped GPU object */
> -- 
> 2.43.0
> 


More information about the igt-dev mailing list