On Wed, Dec 23, 2020 at 12:31:10PM +1100, Jonathan Gray wrote:
> On Tue, Dec 22, 2020 at 06:30:48PM +0000, James Cook wrote:
> > > +                 case 0xa6: /* Coffeelake mobile */
> > 
> > The laptop's CPU is an i7-10710U, which I think is in the Comet Lake
> > series, not Coffee Lake.
> 
> Yes 0xa6 is comet lake.
> 
> But we should really do what FreeBSD and Linux do and fallback to
> cpuid 0x16 as Intel keeps creating new skylake variants.
> 
> The frequency from cpuid 0x15 is Hz, from 0x16 it is MHz.
> 
> Untested as I don't have any >= skylake machines.
> If you can add a printf to check the value is sane that would
> be helpful.

As noticed by tb@ the last diff wasn't quite right:

Index: sys/arch/amd64/amd64/tsc.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/tsc.c,v
retrieving revision 1.21
diff -u -p -r1.21 tsc.c
--- sys/arch/amd64/amd64/tsc.c  6 Sep 2020 20:50:00 -0000       1.21
+++ sys/arch/amd64/amd64/tsc.c  23 Dec 2020 12:25:32 -0000
@@ -66,14 +66,16 @@ tsc_freq_cpuid(struct cpu_info *ci)
                eax = ebx = khz = dummy = 0;
                CPUID(0x15, eax, ebx, khz, dummy);
                khz /= 1000;
-               if (khz == 0) {
+               /*
+                * Fallback to 'Processor Base Frequency' from cpuid 0x16 when
+                * 'nominal frequency of the core crystal clock' from cpuid 0x15
+                * is 0 on >= Skylake
+                */
+               if (khz == 0 && cpuid_level >= 0x16) {
+                       CPUID(0x16, khz, dummy, dummy, dummy);
+                       khz = khz * 1000 * eax / ebx;
+               } else if (khz == 0) {
                        switch (ci->ci_model) {
-                       case 0x4e: /* Skylake mobile */
-                       case 0x5e: /* Skylake desktop */
-                       case 0x8e: /* Kabylake mobile */
-                       case 0x9e: /* Kabylake desktop */
-                               khz = 24000; /* 24.0 MHz */
-                               break;
                        case 0x5f: /* Atom Denverton */
                                khz = 25000; /* 25.0 MHz */
                                break;

Reply via email to