Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

e1000e: convert .adjfreq to .adjfine

The PTP implementation for the e1000e driver uses the older .adjfreq
method. This method takes an adjustment in parts per billion. The newer
.adjfine implementation uses scaled_ppm. The use of scaled_ppm allows for
finer grained adjustments and is preferred over using the older
implementation.

Make use of mul_u64_u64_div_u64 in order to handle possible overflow of the
multiplication used to calculate the desired adjustment to the hardware
increment value.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Naama Meir <naamax.meir@linux.intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>

authored by

Jacob Keller and committed by
Tony Nguyen
abab010f ab8e8db2

+11 -10
+1 -1
drivers/net/ethernet/intel/e1000e/e1000.h
··· 329 329 struct ptp_clock *ptp_clock; 330 330 struct ptp_clock_info ptp_clock_info; 331 331 struct pm_qos_request pm_qos_req; 332 - s32 ptp_delta; 332 + long ptp_delta; 333 333 334 334 u16 eee_advert; 335 335 };
+2 -2
drivers/net/ethernet/intel/e1000e/netdev.c
··· 3922 3922 if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP)) 3923 3923 return; 3924 3924 3925 - if (info->adjfreq) { 3925 + if (info->adjfine) { 3926 3926 /* restore the previous ptp frequency delta */ 3927 - ret_val = info->adjfreq(info, adapter->ptp_delta); 3927 + ret_val = info->adjfine(info, adapter->ptp_delta); 3928 3928 } else { 3929 3929 /* set the default base frequency if no adjustment possible */ 3930 3930 ret_val = e1000e_get_base_timinca(adapter, &timinca);
+8 -7
drivers/net/ethernet/intel/e1000e/ptp.c
··· 15 15 #endif 16 16 17 17 /** 18 - * e1000e_phc_adjfreq - adjust the frequency of the hardware clock 18 + * e1000e_phc_adjfine - adjust the frequency of the hardware clock 19 19 * @ptp: ptp clock structure 20 - * @delta: Desired frequency change in parts per billion 20 + * @delta: Desired frequency chance in scaled parts per million 21 21 * 22 22 * Adjust the frequency of the PHC cycle counter by the indicated delta from 23 23 * the base frequency. 24 + * 25 + * Scaled parts per million is ppm but with a 16 bit binary fractional field. 24 26 **/ 25 - static int e1000e_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta) 27 + static int e1000e_phc_adjfine(struct ptp_clock_info *ptp, long delta) 26 28 { 27 29 struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter, 28 30 ptp_clock_info); ··· 49 47 50 48 incvalue = timinca & E1000_TIMINCA_INCVALUE_MASK; 51 49 52 - adjustment = incvalue; 53 - adjustment *= delta; 54 - adjustment = div_u64(adjustment, 1000000000); 50 + adjustment = mul_u64_u64_div_u64(incvalue, (u64)delta, 51 + 1000000ULL << 16); 55 52 56 53 incvalue = neg_adj ? (incvalue - adjustment) : (incvalue + adjustment); 57 54 ··· 258 257 .n_per_out = 0, 259 258 .n_pins = 0, 260 259 .pps = 0, 261 - .adjfreq = e1000e_phc_adjfreq, 260 + .adjfine = e1000e_phc_adjfine, 262 261 .adjtime = e1000e_phc_adjtime, 263 262 .gettimex64 = e1000e_phc_gettimex, 264 263 .settime64 = e1000e_phc_settime,