i40e: avoid overflow in i40e_ptp_adjfreq()
authorJacob Keller <jacob.e.keller@intel.com>
Fri, 20 Apr 2018 08:41:38 +0000 (01:41 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Mon, 30 Apr 2018 16:23:39 +0000 (09:23 -0700)
commit830e0dd9996c4644e42412aa6c46ed8f8eab0cca
tree3e767d60b62e1da2b10ed9812b1bf01c2e1d1141
parent5305d0fe2f22ec42b19f5ed205faad9b26955e5c
i40e: avoid overflow in i40e_ptp_adjfreq()

When operating at 1GbE, the base incval for the PTP clock is so large
that multiplying it by numbers close to the max_adj can overflow the
u64.

Rather than attempting to limit the max_adj to a value small enough to
avoid overflow, instead calculate the incvalue adjustment based on the
40GbE incvalue, and then multiply that by the scaling factor for the
link speed.

This sacrifices a small amount of precision in the adjustment but we
avoid erratic behavior of the clock due to the overflow caused if ppb is
very near the maximum adjustment.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e.h
drivers/net/ethernet/intel/i40e/i40e_ptp.c