Subject: Re: [PATCH net 5/6] igc: Fix launchtime before start of cycle

From: Jakub Kicinski <[email-masked]>
Date: Tue, 11 Jul 2023 17:54:54 -0700

On Tue, 11 Jul 2023 13:12:33 +0300 Leon Romanovsky wrote:
> > If I understand correctly, ktime_sub_ns(txtime, baset_est) will only return
> > something larger than s32 max if cycle_time is larger than s32 max and if that
> > is the case everything will be broken anyway since the corresponding hardware
> > register only holds 30 bits.  
> 
> I suggest you to use proper variable types, what about the following
> snippet?
> 
> ktime_t launchtime;
> 
> launchtime = ktime_sub_ns(txtime, baset_est);
> WARN_ON(upper_32_bits(launchtime));
> div_s64_rem(launchtime, cycle_time, &launchtime);
> 
> return cpu_to_le32(lower_32_bits(launchtime));

That needs to be coupled with some control path checks on cycle_time?
Seems like a separate fix TBH.