x86/tsc: Add tsc_early_khz command line parameter
authorKrzysztof Piecuch <piecuch@protonmail.com>
Thu, 23 Jan 2020 16:09:26 +0000 (16:09 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 21 May 2020 21:07:00 +0000 (23:07 +0200)
commitbd35c77e32e4359580207891c0f7a438ad4b42df
treef611ea73fa8e5eb892d7b87e34fb295d494a19bd
parentcec5f268cd02d25d2d74807843d8ae0292fe0fb7
x86/tsc: Add tsc_early_khz command line parameter

Changing base clock frequency directly impacts TSC Hz but not CPUID.16h
value. An overclocked CPU supporting CPUID.16h and with partial CPUID.15h
support will set TSC KHZ according to "best guess" given by CPUID.16h
relying on tsc_refine_calibration_work to give better numbers later.
tsc_refine_calibration_work will refuse to do its work when the outcome is
off the early TSC KHZ value by more than 1% which is certain to happen on
an overclocked system.

Fix this by adding a tsc_early_khz command line parameter that makes the
kernel skip early TSC calibration and use the given value instead.

This allows the user to provide the expected TSC frequency that is closer
to reality than the one reported by the hardware, enabling
tsc_refine_calibration_work to do meaningful error checking.

[ tglx: Made the variable __initdata as it's only used on init and
        removed the error checking in the argument parser because
kstrto*() only stores to the variable if the string is valid ]

Signed-off-by: Krzysztof Piecuch <piecuch@protonmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/O2CpIOrqLZHgNRkfjRpz_LGqnc1ix_seNIiOCvHY4RHoulOVRo6kMXKuLOfBVTi0SMMevg6Go1uZ_cL9fLYtYdTRNH78ChaFaZyG3VAyYz8=@protonmail.com
Documentation/admin-guide/kernel-parameters.txt
arch/x86/kernel/tsc.c