[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
Thu Mar 3 19:32:18 UTC 2022


Dnia 2022-03-02 at 13:12:51 +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.
> 
> 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 | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
> index ddb8d8c1fd..e50ab9055e 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);
> @@ -1927,7 +1927,7 @@ intel_bb_add_object(struct intel_bb *ibb, uint32_t handle, uint64_t size,
>  		   || ALIGN(offset, alignment) == offset);
>  
>  	object = __add_to_cache(ibb, handle);
> -	alignment = alignment ?: 4096;
> +	alignment = max_t(uint64_t, alignment, gem_detect_safe_alignment(ibb->i915));

Maybe there should be check if alignment is power of 2 ?
For example both offset and alignment can be -1 or 2^32 + 1
we do not catch error then.
 
>  	__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