[PATCH i-g-t 1/2] tests/intel/xe_copy_basic: account for prefetch

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Wed Jan 24 04:48:45 UTC 2024


On Tue, Jan 23, 2024 at 06:33:22PM +0000, Matthew Auld wrote:
> Xe2 expects an extra page after the batch to avoid prefetch hitting an
> invalid page. Not doing so can result in CAT errors.
> 
> Signed-off-by: Matthew Auld <matthew.auld at intel.com>
> Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> ---
>  tests/intel/xe_copy_basic.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/intel/xe_copy_basic.c b/tests/intel/xe_copy_basic.c
> index 1bde876cd..3ae5a7291 100644
> --- a/tests/intel/xe_copy_basic.c
> +++ b/tests/intel/xe_copy_basic.c
> @@ -44,7 +44,7 @@ mem_copy(int fd, uint32_t src_handle, uint32_t dst_handle, const intel_ctx_t *ct
>  	 uint32_t size, uint32_t width, uint32_t height, uint32_t region)
>  {
>  	struct blt_mem_data mem = {};
> -	uint64_t bb_size = xe_get_default_alignment(fd);
> +	uint64_t bb_size;
>  	uint64_t ahnd = intel_allocator_open_full(fd, ctx->vm, 0, 0,
>  						  INTEL_ALLOCATOR_SIMPLE,
>  						  ALLOC_STRATEGY_LOW_TO_HIGH, 0);
> @@ -53,6 +53,8 @@ mem_copy(int fd, uint32_t src_handle, uint32_t dst_handle, const intel_ctx_t *ct
>  	uint32_t bb;
>  	int result;
>  
> +	bb_size = ALIGN(SZ_4K + xe_cs_prefetch_size(fd),
> +			xe_get_default_alignment(fd));
>  	bb = xe_bo_create(fd, 0, bb_size, region, 0);
>  
>  	blt_mem_init(fd, &mem);
> @@ -97,7 +99,7 @@ mem_set(int fd, uint32_t dst_handle, const intel_ctx_t *ctx, uint32_t size,
>  	uint32_t width, uint32_t height, uint8_t fill_data, uint32_t region)
>  {
>  	struct blt_mem_data mem = {};
> -	uint64_t bb_size = xe_get_default_alignment(fd);
> +	uint64_t bb_size;
>  	uint64_t ahnd = intel_allocator_open_full(fd, ctx->vm, 0, 0,
>  						  INTEL_ALLOCATOR_SIMPLE,
>  						  ALLOC_STRATEGY_LOW_TO_HIGH, 0);
> @@ -105,6 +107,8 @@ mem_set(int fd, uint32_t dst_handle, const intel_ctx_t *ctx, uint32_t size,
>  	uint32_t bb;
>  	uint8_t *result;
>  
> +	bb_size = ALIGN(SZ_4K + xe_cs_prefetch_size(fd),
> +			xe_get_default_alignment(fd));
>  	bb = xe_bo_create(fd, 0, bb_size, region, 0);
>  	blt_mem_init(fd, &mem);
>  	blt_set_mem_object(&mem.dst, dst_handle, size, 0, width, height, region,
> -- 
> 2.43.0
> 

Maybe we should create helper like:

uint64_t xe_bb_size(int fd, uint64_t reqsize)
{
	return ALIGN(reqsize + xe_cs_prefetch_size(fd),
	             xe_get_default_alignment(fd));
}

as adding prefetch size will likely stay with us forever.

Anyway, green light from me for the above change:

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


More information about the igt-dev mailing list