[igt-dev] [PATCH i-g-t 1/3] lib/intel_batchbuffer: Use safe alignment for intel-bb

Kamil Konieczny kamil.konieczny at linux.intel.com
Fri Mar 4 09:37:07 UTC 2022


Dnia 2022-03-04 at 10:02:00 +0100, Zbigniew Kempczyński napisał(a):
> Discrete cards can have different memory alignment requirements
> when objects used in execbuffer comes from different memory regions.
> Lets use safe alignment which should be fine regardless objects
> location.
> 
> v2: ensure passed alignment is power of two (Kamil)
> 
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Cc: Ashutosh Dixit <ashutosh.dixit at intel.com>
> Cc: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> ---
>  lib/intel_batchbuffer.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
> index ddb8d8c1fd..460f5f2bb3 100644
> --- a/lib/intel_batchbuffer.c
> +++ b/lib/intel_batchbuffer.c
> @@ -1370,7 +1370,7 @@ __intel_bb_create(int i915, uint32_t ctx, uint32_t size, bool do_relocs,
>  	ibb->enforce_relocs = do_relocs;
>  	ibb->handle = gem_create(i915, size);
>  	ibb->size = size;
> -	ibb->alignment = 4096;
> +	ibb->alignment = gem_detect_safe_alignment(i915);
>  	ibb->ctx = ctx;
>  	ibb->vm_id = 0;
>  	ibb->batch = calloc(1, size);
> @@ -1925,9 +1925,10 @@ intel_bb_add_object(struct intel_bb *ibb, uint32_t handle, uint64_t size,
>  
>  	igt_assert(INVALID_ADDR(offset) || alignment == 0
>  		   || ALIGN(offset, alignment) == offset);
> +	igt_assert(is_power_of_two(alignment));
>  
>  	object = __add_to_cache(ibb, handle);
> -	alignment = alignment ?: 4096;
> +	alignment = max_t(uint64_t, alignment, gem_detect_safe_alignment(ibb->i915));
>  	__add_to_objects(ibb, object);
>  
>  	/*
> -- 
> 2.32.0
> 
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>

--
Kamil



More information about the igt-dev mailing list