[PATCH i-g-t] tests/intel/xe_exec_system_allocator: Fix 32-bit compilation

Matthew Brost matthew.brost at intel.com
Wed Apr 30 04:28:08 UTC 2025


On Tue, Apr 29, 2025 at 04:30:51PM +0200, Kamil Konieczny wrote:
> There is one more place which needs fixing of Xe test
> compilation for 32-bit platforms, reported errors are:
> 
> ../tests/intel/xe_exec_system_allocator.c:382:41: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>   aligned_alloc_type.ptr = (void *)ALIGN((uint64_t)aligned_alloc_type.__ptr, alignment);
>                                          ^
> ../tests/intel/xe_exec_system_allocator.c:382:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>   aligned_alloc_type.ptr = (void *)ALIGN((uint64_t)aligned_alloc_type.__ptr, alignment);
>                            ^
> cc1: some warnings being treated as errors
> 
> Fixes: 9eda33fedff7 ("tests/xe: Add system_allocator test")
> Cc: Matthew Brost <matthew.brost at intel.com>

Sorry for the trouble and thanks for the fix:

Reviewed-by: Matthew Brost <matthew.brost at intel.com>

> Cc: Jonathan Cavitt <jonathan.cavitt at intel.com>
> Cc: Francois Dugast <francois.dugast at intel.com>
> Signed-off-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> ---
>  tests/intel/xe_exec_system_allocator.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/intel/xe_exec_system_allocator.c b/tests/intel/xe_exec_system_allocator.c
> index e1121a862..30b99f3ed 100644
> --- a/tests/intel/xe_exec_system_allocator.c
> +++ b/tests/intel/xe_exec_system_allocator.c
> @@ -374,12 +374,15 @@ struct aligned_alloc_type {
>  static struct aligned_alloc_type __aligned_alloc(size_t alignment, size_t size)
>  {
>  	struct aligned_alloc_type aligned_alloc_type;
> +	uint64_t addr;
>  
>  	aligned_alloc_type.__ptr = mmap(NULL, alignment + size, PROT_NONE, MAP_PRIVATE |
>  					MAP_ANONYMOUS, -1, 0);
>  	igt_assert(aligned_alloc_type.__ptr != MAP_FAILED);
>  
> -	aligned_alloc_type.ptr = (void *)ALIGN((uint64_t)aligned_alloc_type.__ptr, alignment);
> +	addr = to_user_pointer(aligned_alloc_type.__ptr);
> +	addr = ALIGN(addr, (uint64_t)alignment);
> +	aligned_alloc_type.ptr = from_user_pointer(addr);
>  	aligned_alloc_type.size = size;
>  	aligned_alloc_type.__size = size + alignment;
>  
> -- 
> 2.49.0
> 


More information about the igt-dev mailing list