x86/tsc: Unset TSC_KNOWN_FREQ and TSC_RELIABLE flags on Intel Bay Trail SoC
Subsystems (2)
PATCH 1/1 x86/tsc: Unset TSC_KNOWN_FREQ and TSC_RELIABLE flags on Intel Bay Trail SoC
From: Vipul Kumar <[email protected]>
'commit f3a02ecebed7 ("x86/tsc: Set TSC_KNOWN_FREQ and TSC_RELIABLE flags on Intel Atom SoCs")', causing time drift for Bay trail SoC. These flags are set for SoCs having cpuid_level 0x15 or more. Bay trail is having cpuid_level 0xb.
So, unset both flags to make sure the clocksource calibration can be done.
--- arch/x86/kernel/tsc_msr.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kernel/tsc_msr.c +3 -0
@@ -112,6 +112,9 @@ unsigned long cpu_khz_from_msr(void) lapic_timer_period = (freq *1000 ) /HZ ;#endif +if (boot_cpu_data.cpuid_level <0x15 ) +return res; +/* * TSC frequency determined by MSR is always considered "known" * because it is reported by HW.
Signature · 1 line
2.20.1
Greg KH
maintainerQuoted 7 lines · Vipul Kumar
From: Vipul Kumar <[email protected]>
'commit
f3a02ecebed7("x86/tsc: SetTSC_KNOWN_FREQandTSC_RELIABLEflags on Intel Atom SoCs")', causing time drift for Bay trail SoC. These flags are set for SoCs havingcpuid_level0x15or more. Bay trail is havingcpuid_level0xb.
Quoted 7 lines
So, unset both flags to make sure the clocksource calibration can be done.
Signed-off-by Vipul Kumar <[email protected]>--- arch/x86/kernel/tsc_msr.c | 3 +++ 1 file changed, 3 insertions(+)
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
Vipul,
please always CC the relevant maintainers. Aside of that it's good practice to CC the author of a particular commit you identified.
Quoted 6 lines · Vipul Kumar
From: Vipul Kumar <[email protected]>
'commit
f3a02ecebed7("x86/tsc: SetTSC_KNOWN_FREQandTSC_RELIABLEflags on Intel Atom SoCs")', causing time drift for Bay trail SoC. These flags are set for SoCs havingcpuid_level0x15or more. Bay trail is havingcpuid_level0xb.
Which is completely irrelevant. These CPUs read their frequency from MSRs not from CPUID.
Quoted 2 lines
So, unset both flags to make sure the clocksource calibration can be done.
That's going to break tons of ATOM SoC based systems which have neither HPET not PIT.
Aside of that on some systems HPET/PIT based calibration is not really more accurate than the MSR based frequency, quite the contrary.
Can you please provide detailed data about the problem you are trying to solve? 'time drift' is pretty unspecific.
Thanks,
tglx
Vipul,
Quoted 5 lines · vipul kumar
Quoted 3 lines · Thomas Gleixner
Vipul Kumar <[email protected]> writes:
Can you please provide detailed data about the problem you are trying to solve? 'time drift' is pretty unspecific.
Quoted 7 lines
After running board for some days without rebooting it, time drift is observed between system time and RTC time.
SystemTime: 2019-11-08T15:48:46+00:00 RTC Time: 2019-11-08
15:44:35.976137+0000 Uptime: up 7 days 5 hours, 33 minutesThis sample shows a difference of 4 minutes after 7 days.
Of course you fail to provide the data for the case where the frequency is recalibrated, i.e. with your patch applied.
Quoted 2 lines
To fix this drift issue, disable
X86_FEATURE_TSC_KNOWN_FREQflag for Soc's havingcpuid_level<0x15.
Again, I explained you already that this does not work on SoCs which do not expose HPET or PIT.
And again, it has absolutely nothing to do with the CPUID level because these chips are not using CPUID to retrieve the frequency information. They use cpu_khz_from_msr() which only depends on the CPU model/family.
So if you want to enforce refined calibration on such systems, then you need to do it in a way which does not break the world.
Thanks,
tglx