]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
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)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 1 Mar 2019 13:21:06 +0000 (14:21 +0100)
commitc86caa5b5cd86343e88e3b96ac0000e6d4b8636b
treeda81c7314b3138ec5093fb58c84b34fb6b32286b
parent49e052f4cd0001f614cc3a7b7329a27bbc570f1a
i40e: avoid overflow in i40e_ptp_adjfreq()

BugLink: http://bugs.launchpad.net/bugs/1815234
[ Upstream commit 830e0dd9996c4644e42412aa6c46ed8f8eab0cca ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/ethernet/intel/i40e/i40e.h
drivers/net/ethernet/intel/i40e/i40e_ptp.c