linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/tsc: Unset TSC_KNOWN_FREQ and TSC_RELIABLE flags on Intel Bay Trail SoC
@ 2019-12-18 15:30 Vipul Kumar
  2019-12-18 16:26 ` Greg KH
  2020-01-16 22:04 ` Thomas Gleixner
  0 siblings, 2 replies; 4+ messages in thread
From: Vipul Kumar @ 2019-12-18 15:30 UTC (permalink / raw)
  To: Daniel Lezcano, Thomas Gleixner
  Cc: linux-kernel, Stable, Srikanth Krishnakar, Cedric Hombourger,
	Vipul Kumar, Vipul Kumar

From: Vipul Kumar <vipul_kumar@mentor.com>

'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.

Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
---
 arch/x86/kernel/tsc_msr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/tsc_msr.c b/arch/x86/kernel/tsc_msr.c
index e0cbe4f2af49..1ca27c28db98 100644
--- a/arch/x86/kernel/tsc_msr.c
+++ b/arch/x86/kernel/tsc_msr.c
@@ -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.
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/tsc: Unset TSC_KNOWN_FREQ and TSC_RELIABLE flags on Intel Bay Trail SoC
  2019-12-18 15:30 [PATCH] x86/tsc: Unset TSC_KNOWN_FREQ and TSC_RELIABLE flags on Intel Bay Trail SoC Vipul Kumar
@ 2019-12-18 16:26 ` Greg KH
  2020-01-16 22:04 ` Thomas Gleixner
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2019-12-18 16:26 UTC (permalink / raw)
  To: Vipul Kumar
  Cc: Daniel Lezcano, Thomas Gleixner, linux-kernel, Stable,
	Srikanth Krishnakar, Cedric Hombourger, Vipul Kumar

On Wed, Dec 18, 2019 at 09:00:39PM +0530, Vipul Kumar wrote:
> From: Vipul Kumar <vipul_kumar@mentor.com>
> 
> '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.
> 
> Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
> ---
>  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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/tsc: Unset TSC_KNOWN_FREQ and TSC_RELIABLE flags on Intel Bay Trail SoC
  2019-12-18 15:30 [PATCH] x86/tsc: Unset TSC_KNOWN_FREQ and TSC_RELIABLE flags on Intel Bay Trail SoC Vipul Kumar
  2019-12-18 16:26 ` Greg KH
@ 2020-01-16 22:04 ` Thomas Gleixner
       [not found]   ` <CADdC98RwESeK_nNXfiF00vdUdQSwN08sM+zt8-se6OdrhA_h2w@mail.gmail.com>
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2020-01-16 22:04 UTC (permalink / raw)
  To: Vipul Kumar
  Cc: linux-kernel, Srikanth Krishnakar, Cedric Hombourger,
	Vipul Kumar, x86, Bin Gao, Andy Shevchenko, Len Brown

Vipul,

please always CC the relevant maintainers. Aside of that it's good
practice to CC the author of a particular commit you identified.

Vipul Kumar <vipulk0511@gmail.com> writes:

> From: Vipul Kumar <vipul_kumar@mentor.com>
>
> '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.

Which is completely irrelevant. These CPUs read their frequency from
MSRs not from CPUID.

> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/tsc: Unset TSC_KNOWN_FREQ and TSC_RELIABLE flags on Intel Bay Trail SoC
       [not found]   ` <CADdC98RwESeK_nNXfiF00vdUdQSwN08sM+zt8-se6OdrhA_h2w@mail.gmail.com>
@ 2020-01-17  9:36     ` Thomas Gleixner
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2020-01-17  9:36 UTC (permalink / raw)
  To: vipul kumar
  Cc: linux-kernel, Srikanth Krishnakar, Cedric Hombourger,
	Vipul Kumar, x86, Andy Shevchenko, Len Brown

Vipul,

vipul kumar <vipulk0511@gmail.com> writes:
> On Fri, Jan 17, 2020 at 3:34 AM Thomas Gleixner <tglx@linutronix.de> wrote:
>> Vipul Kumar <vipulk0511@gmail.com> writes:
>> Can you please provide detailed data about the problem you are trying to
>> solve? 'time drift' is pretty unspecific.
>
> 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 minutes
>
> This 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.

> To fix this drift issue, disable X86_FEATURE_TSC_KNOWN_FREQ flag for Soc's
> having  cpuid_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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-17  9:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18 15:30 [PATCH] x86/tsc: Unset TSC_KNOWN_FREQ and TSC_RELIABLE flags on Intel Bay Trail SoC Vipul Kumar
2019-12-18 16:26 ` Greg KH
2020-01-16 22:04 ` Thomas Gleixner
     [not found]   ` <CADdC98RwESeK_nNXfiF00vdUdQSwN08sM+zt8-se6OdrhA_h2w@mail.gmail.com>
2020-01-17  9:36     ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).