[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.21.1904182359360.3174@nanos.tec.linutronix.de>
Date: Fri, 19 Apr 2019 00:30:02 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: Daniel Drake <drake@...lessm.com>
cc: Len Brown <lenb@...nel.org>, x86@...nel.org,
LKML <linux-kernel@...r.kernel.org>, linux@...lessm.com,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>
Subject: Re: Detecting x86 LAPIC timer frequency from CPUID data
On Thu, 18 Apr 2019, Thomas Gleixner wrote:
> On Wed, 17 Apr 2019, Daniel Drake wrote:
>
> > The CPUID.0x16 leaf provides "Bus (Reference) Frequency (in MHz)".
> >
> > In the thread "No 8254 PIT & no HPET on new Intel N3350 platforms
> > causes kernel panic during early boot" we are exploring ways to have
> > the kernel avoid using the PIT/HPET IRQ0 timer in more cases, and
> > Thomas Gleixner suggested that we could use this CPUID data to set
> > lapic_timer_frequency, avoiding the need for calibrate_APIC_clock()
> > to measure the APIC clock against the IRQ0 timer.
> >
> > I'm thinking of the the following code change, however I get
> > unexpected results on Intel i7-8565U (Whiskey Lake). When
> > booting without this change, and with apic=notscdeadline (so that
> > APIC clock gets calibrated and used), the bus speed is detected as
> > 23MHz:
> >
> > ... lapic delta = 149994
> > ... PM-Timer delta = 357939
> > ... PM-Timer result ok
> > ..... delta 149994
> > ..... mult: 6442193
> > ..... calibration result: 23999
That's 24MHZ which is the nominal clock for these machines.
> > ..... CPU clock speed is 1991.0916 MHz.
> > ..... host bus clock speed is 23.0999 MHz.
I think that printout is wrong in two aspects. First it should be
23.9999Mhz, second it should be 100MHz. This stuff comes from old systems
which had completely different clock setups.
> > However the CPUID.0x16 ECX reports a 100MHz bus speed on this device,
> > so this code change would produce a significantly different calibration.
Yes.
> > Am I doing anything obviously wrong?
>
> It's probably just my fault sending you down the wrong path. What's the
> content of CPUUD.0x15 on that box?
I bet that CPUID.0x15 ECX says 24Mhz or it just says 0 like on my
machine. But then interestingly enough on that box I see:
Time Stamp Counter/Core Crystal Clock Information (0x15):
TSC/clock ratio = 168/2
nominal core crystal clock = 0 Hz
Processor Frequency Information (0x16):
Core Base Frequency (MHz) = 0x834 (2100)
Core Maximum Frequency (MHz) = 0xed8 (3800)
Bus (Reference) Frequency (MHz) = 0x64 (100)
Assuming that TSC and local APIC timer run from the same frequency on these
modern machines.
2100MHz * 2 / 168 = 25MHz
and disabling the tsc deadline timer tells me:
..... calibration result: 24999
Close enough. Thinking about it - that makes a lot of sense. With TSC
deadline timer available it would be pretty silly if there is yet another
clock feeding into local APIC.
And the 0x15 -> 0x16 correlation is clear as well. The TSC runs at the
nominal CPU frequency, in this case 2100MHz. So the nominator/denominator
pair from 0x15 allows to deduce the nominal core crystal clock which seems
to be exactly the clock which is fed into the local APIC timer.
If someone from Intel could confirm that, then we could make that work for
any modern system.
Thanks,
tglx
Powered by blists - more mailing lists