[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240508202201.GB2248333@kernel.org>
Date: Wed, 8 May 2024 21:22:01 +0100
From: Simon Horman <horms@...nel.org>
To: Tony Nguyen <anthony.l.nguyen@...el.com>
Cc: davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com,
edumazet@...gle.com, netdev@...r.kernel.org,
Jacob Keller <jacob.e.keller@...el.com>, richardcochran@...il.com,
peterz@...radead.org, linux-kernel@...r.kernel.org,
Arpana Arland <arpanax.arland@...el.com>
Subject: Re: [PATCH net-next] ice: add and use roundup_u64 instead of open
coding equivalent
On Tue, May 07, 2024 at 01:54:39PM -0700, Tony Nguyen wrote:
> From: Jacob Keller <jacob.e.keller@...el.com>
>
> In ice_ptp_cfg_clkout(), the ice driver needs to calculate the nearest next
> second of a current time value specified in nanoseconds. It implements this
> using div64_u64, because the time value is a u64. It could use div_u64
> since NSEC_PER_SEC is smaller than 32-bits.
>
> Ideally this would be implemented directly with roundup(), but that can't
> work on all platforms due to a division which requires using the specific
> macros and functions due to platform restrictions, and to ensure that the
> most appropriate and fast instructions are used.
>
> The kernel doesn't currently provide any 64-bit equivalents for doing
> roundup. Attempting to use roundup() on a 32-bit platform will result in a
> link failure due to not having a direct 64-bit division.
>
> The closest equivalent for this is DIV64_U64_ROUND_UP, which does a
> division always rounding up. However, this only computes the division, and
> forces use of the div64_u64 in cases where the divisor is a 32bit value and
> could make use of div_u64.
>
> Introduce DIV_U64_ROUND_UP based on div_u64, and then use it to implement
> roundup_u64 which takes a u64 input value and a u32 rounding value.
>
> The name roundup_u64 matches the naming scheme of div_u64, and future
> patches could implement roundup64_u64 if they need to round by a multiple
> that is greater than 32-bits.
>
> Replace the logic in ice_ptp.c which does this equivalent with the newly
> added roundup_u64.
>
> Signed-off-by: Jacob Keller <jacob.e.keller@...el.com>
> Tested-by: Arpana Arland <arpanax.arland@...el.com> (A Contingent worker at Intel)
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@...el.com>
Reviewed-by: Simon Horman <horms@...nel.org>
..
Powered by blists - more mailing lists