Re: [PATCH wireless-next] wifi: iwlwifi: mvm: Avoid 64-bit division in iwl_mvm_get_crosstimestamp_fw()
From: Johannes Berg
Date: Wed Mar 29 2023 - 15:01:03 EST
On Wed, 2023-03-29 at 10:30 -0700, Nick Desaulniers wrote:
> >
> > > Nick pointed out that the result of this division is being
> > > stored to a 32-bit type anyways, so truncate gp2_10ns first then do the
> > > division, which elides the need for libcalls.
> >
> > That loses ~7 top bits though, no? I'd be more worried about that, than
> > the time div_u64() takes.
>
> The result is still stored in a u32; there is a loss of precision
> regardless of use of div_u64 or open coded binary operator /.
>
Right, obviously.
> So is
> the loss of precision before the division as tolerable as after the
> division?
For all I can tell this is meant to be 'gp2' with an additional lower
bits to reach a unit/granularity of 10ns, basically in FW something like
gp2_10ns = gp2 * 100 + subsampling_10ns_unit
(and gp2 in FW is a 32-bit value, so it rolls over eventually).
But I _think_ we want to make a proper division by 100 to obtain back
the original 'gp2' value here.
johannes