[PATCH i-g-t 2/3] lib/xe: replace div64_u64_round_up() with DIV_ROUND_UP

Kamil Konieczny kamil.konieczny at linux.intel.com
Thu Apr 24 17:39:44 UTC 2025


Hi Shuicheng,
On 2025-04-16 at 16:30:52 +0000, Shuicheng Lin wrote:
> DIV_ROUND_UP is defined in igt_aux.h with the same function as
> div64_u64_round_up().

Version in igt_aux.h is different then one below.

> 
> Cc: Matt Roper <matthew.d.roper at intel.com>
> Signed-off-by: Shuicheng Lin <shuicheng.lin at intel.com>
> ---
>  lib/xe/xe_util.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/lib/xe/xe_util.c b/lib/xe/xe_util.c
> index 06b378ce0..9907c8b16 100644
> --- a/lib/xe/xe_util.c
> +++ b/lib/xe/xe_util.c
> @@ -253,14 +253,6 @@ static uint32_t reference_clock(int fd, int gt_id)
>  	return refclock;
>  }
>  
> -static uint64_t div64_u64_round_up(const uint64_t x, const uint64_t y)
> -{
> -	igt_assert(y > 0);
> -	igt_assert_lte_u64(x, UINT64_MAX - (y - 1));

I like those two asserts here, why not moving this function to
lib igt_aux.c and creating new macro for it?

#define DIV64_ROUND_UP(n, d) div64_u64_round_up((uint64_t)(n), (uint64_t)(d))

or make it a multi-line macro with do { ... } while(0)

Regards,
Kamil

> -
> -	return (x + y - 1) / y;
> -}
> -
>  /**
>   * xe_nsec_to_ticks: convert time in nanoseconds to timestamp ticks
>   * @fd: opened device
> @@ -273,5 +265,5 @@ uint32_t xe_nsec_to_ticks(int fd, int gt_id, uint64_t nsec)
>  {
>  	uint32_t refclock = reference_clock(fd, gt_id);
>  
> -	return div64_u64_round_up(nsec * refclock, NSEC_PER_SEC);
> +	return DIV_ROUND_UP(nsec * refclock, NSEC_PER_SEC);
>  }
> -- 
> 2.25.1
> 


More information about the igt-dev mailing list