• Jacob Keller's avatar
    e1000e: don't modify SYSTIM registers during SIOCSHWTSTAMP ioctl · aa524b66
    Jacob Keller authored
    The e1000e_config_hwtstamp function was incorrectly resetting the SYSTIM
    registers every time the ioctl was being run. If you happened to be
    running ptp4l and lost the PTP connect (removing cable, or blocking the
    UDP traffic for example), then ptp4l will eventually perform a restart
    which involves re-requesting timestamp settings. In e1000e this has the
    unfortunate and incorrect result of resetting SYSTIME to the kernel
    time. Since kernel time is usually in UTC, and PTP time is in TAI, this
    results in the leap second being re-applied.
    
    Fix this by extracting the SYSTIME reset out into its own function,
    e1000e_ptp_reset, which we call during reset to restore the hardware
    registers. This function will (a) restart the timecounter based on the
    new system time, (b) restore the previous PPB setting, and (c) restore
    the previous hwtstamp settings.
    
    In order to perform (b), I had to modify the adjfreq ptp function
    pointer to store the old delta each time it is called. This also has the
    side effect of restoring the correct base timinca register correctly.
    The driver does not need to explicitly zero the ptp_delta variable since
    the entire adapter structure comes zero-initialized.
    Reported-by: default avatarBrian Walsh <brian@walsh.ws>
    Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
    Tested-by: default avatarBrian Walsh <brian@walsh.ws>
    Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
    Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
    aa524b66
e1000.h 17.6 KB