On Wed, Dec 23, 2020 at 11:47:05PM +1100, Jonathan Gray wrote: > 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;
The patch works (I tested bsd.rd; sleep and date both behave right). Based on added printfs, it ends up with a khz of 23880, computed as 1600 * 1000 * 2 / 134. For reference, I've attached dmesg, and the diff (applied on top of your diff) with the relevant printfs. I notice the upper 16 bits of EAX for leaf 0x16 are described as "Reserved=0" in the intel manual. Should they be masked out? diff --git a/sys/arch/amd64/amd64/tsc.c b/sys/arch/amd64/amd64/tsc.c index a96ccaaca63..89229c0b322 100644 --- a/sys/arch/amd64/amd64/tsc.c +++ b/sys/arch/amd64/amd64/tsc.c @@ -65,6 +65,7 @@ tsc_freq_cpuid(struct cpu_info *ci) cpuid_level >= 0x15) { eax = ebx = khz = dummy = 0; CPUID(0x15, eax, ebx, khz, dummy); + printf("YYY leaf 0x15: %u, %u, %u, %u\n", eax, ebx, khz, dummy); khz /= 1000; /* * Fallback to 'Processor Base Frequency' from cpuid 0x16 when @@ -73,7 +74,9 @@ tsc_freq_cpuid(struct cpu_info *ci) */ if (khz == 0 && cpuid_level >= 0x16) { CPUID(0x16, khz, dummy, dummy, dummy); + printf("YYY leaf 0x16: %u\n", khz); khz = khz * 1000 * eax / ebx; + printf("YYY computed khz to be %u\n", khz); } else if (khz == 0) { switch (ci->ci_model) { case 0x5f: /* Atom Denverton */ @@ -93,6 +96,7 @@ tsc_freq_cpuid(struct cpu_info *ci) return (count * 1000); } } + printf("YYY tsc_freq_cpuid: final khz is %u\n", khz); return (0); } -- James
OpenBSD 6.8-current (RAMDISK_CD) #7: Wed Dec 23 20:21:34 UTC 2020 falsif...@cur.angel.falsifian.org:/usr/src/sys/arch/amd64/compile/RAMDISK_CD real mem = 16837365760 (16057MB) avail mem = 16323051520 (15566MB) random: boothowto does not indicate good seed mainbus0 at root bios0 at mainbus0: SMBIOS rev. 3.2 @ 0x5e6c6000 (94 entries) bios0: vendor Dell Inc. version "1.7.0" date 10/22/2020 bios0: Dell Inc. XPS 13 7390 acpi0 at bios0: ACPI 6.1 acpi0: tables DSDT FACP SSDT SSDT HPET APIC MCFG SSDT SSDT NHLT SSDT SSDT TPM2 LPIT SSDT DBGP DBG2 BOOT SSDT DMAR SSDT BGRT FPDT acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat cpu0 at mainbus0: apid 0 (boot processor) cpu0: Intel(R) Core(TM) i7-10710U CPU @ 1.10GHz, 16266.89 MHz, 06-a6-00 cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,MD_CLEAR,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES cpu0: 256KB 64b/line 8-way L2 cache YYY leaf 0x15: 2, 134, 0, 0 YYY leaf 0x16: 1600 YYY computed khz to be 23880 cpu0: apic clock running at 23MHz cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4.1.1.1, IBE cpu at mainbus0: not configured cpu at mainbus0: not configured cpu at mainbus0: not configured cpu at mainbus0: not configured cpu at mainbus0: not configured cpu at mainbus0: not configured cpu at mainbus0: not configured cpu at mainbus0: not configured cpu at mainbus0: not configured cpu at mainbus0: not configured cpu at mainbus0: not configured ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 20, 120 pins acpiprt0 at acpi0: bus 0 (PCI0) acpiprt1 at acpi0: bus -1 (RP01) acpiprt2 at acpi0: bus -1 (RP02) acpiprt3 at acpi0: bus -1 (RP03) acpiprt4 at acpi0: bus -1 (RP04) acpiprt5 at acpi0: bus 1 (RP05) acpiprt6 at acpi0: bus -1 (RP06) acpiprt7 at acpi0: bus 2 (RP07) acpiprt8 at acpi0: bus -1 (RP08) acpiprt9 at acpi0: bus 3 (RP09) acpiprt10 at acpi0: bus -1 (RP10) acpiprt11 at acpi0: bus -1 (RP11) acpiprt12 at acpi0: bus -1 (RP12) acpiprt13 at acpi0: bus 113 (RP13) acpiprt14 at acpi0: bus -1 (RP14) acpiprt15 at acpi0: bus -1 (RP15) acpiprt16 at acpi0: bus -1 (RP16) acpiprt17 at acpi0: bus -1 (RP17) acpiprt18 at acpi0: bus -1 (RP18) acpiprt19 at acpi0: bus -1 (RP19) acpiprt20 at acpi0: bus -1 (RP20) acpiprt21 at acpi0: bus -1 (RP21) acpiprt22 at acpi0: bus -1 (RP22) acpiprt23 at acpi0: bus -1 (RP23) acpiprt24 at acpi0: bus -1 (RP24) acpiec0 at acpi0 acpipci0 at acpi0 PCI0: 0x00000000 0x00000011 0x00000001 acpicmos0 at acpi0 "INT3403" at acpi0 not configured "INT3403" at acpi0 not configured "INT3403" at acpi0 not configured "INT3403" at acpi0 not configured "INT3403" at acpi0 not configured "INT3403" at acpi0 not configured "INT34BB" at acpi0 not configured "CUST0001" at acpi0 not configured "ELAN2097" at acpi0 not configured "ABCD0000" at acpi0 not configured "ACPI000E" at acpi0 not configured "PNP0C14" at acpi0 not configured "INT0E0C" at acpi0 not configured "PNP0C14" at acpi0 not configured "PNP0C14" at acpi0 not configured "INT33A1" at acpi0 not configured "PNP0C14" at acpi0 not configured "PNP0C14" at acpi0 not configured "PNP0C14" at acpi0 not configured "PNP0C14" at acpi0 not configured "PNP0C0D" at acpi0 not configured "PNP0C0C" at acpi0 not configured "PNP0C0E" at acpi0 not configured "ACPI0003" at acpi0 not configured "PNP0C0A" at acpi0 not configured "INT33D5" at acpi0 not configured "INT3400" at acpi0 not configured "USBC000" at acpi0 not configured "NTC0702" at acpi0 not configured acpipwrres at acpi0 not configured acpipwrres at acpi0 not configured acpipwrres at acpi0 not configured acpipwrres at acpi0 not configured acpipwrres at acpi0 not configured acpipwrres at acpi0 not configured acpicpu at acpi0 not configured acpipwrres at acpi0 not configured pci0 at mainbus0 bus 0 pchb0 at pci0 dev 0 function 0 vendor "Intel", unknown product 0x9b51 rev 0x00 "Intel UHD Graphics" rev 0x04 at pci0 dev 2 function 0 not configured "Intel Core 6G Thermal" rev 0x00 at pci0 dev 4 function 0 not configured "Intel Core GMM" rev 0x00 at pci0 dev 8 function 0 not configured "Intel 400 Series Thermal" rev 0x00 at pci0 dev 18 function 0 not configured xhci0 at pci0 dev 20 function 0 "Intel 400 Series xHCI" rev 0x00: msi, xHCI 1.10 usb0 at xhci0: USB revision 3.0 uhub0 at usb0 configuration 1 interface 0 "Intel xHCI root hub" rev 3.00/1.00 addr 1 "Intel 400 Series Shared SRAM" rev 0x00 at pci0 dev 20 function 2 not configured dwiic0 at pci0 dev 21 function 0 "Intel 400 Series I2C" rev 0x00: apic 2 int 16 iic0 at dwiic0 dwiic1 at pci0 dev 21 function 1 "Intel 400 Series I2C" rev 0x00: apic 2 int 17 iic1 at dwiic1 ihidev0 at iic1 addr 0x2c irq 51, vendor 0x6cb product 0x76af, CUST0001 ihidev0: 14 report ids hid at ihidev0 reportid 2 not configured hid at ihidev0 reportid 3 not configured hid at ihidev0 reportid 4 not configured hid at ihidev0 reportid 6 not configured hid at ihidev0 reportid 7 not configured hid at ihidev0 reportid 8 not configured hid at ihidev0 reportid 9 not configured hid at ihidev0 reportid 10 not configured hid at ihidev0 reportid 11 not configured hid at ihidev0 reportid 12 not configured hid at ihidev0 reportid 13 not configured hid at ihidev0 reportid 14 not configured "Intel 400 Series MEI" rev 0x00 at pci0 dev 22 function 0 not configured ppb0 at pci0 dev 28 function 0 "Intel 400 Series PCIE" rev 0xf0: msi pci1 at ppb0 bus 1 rtsx0 at pci1 dev 0 function 0 "Realtek RTS525A Card Reader" rev 0x01: msi sdmmc0 at rtsx0: 4-bit, dma ppb1 at pci0 dev 28 function 6 "Intel 400 Series PCIE" rev 0xf0: msi pci2 at ppb1 bus 2 iwx0 at pci2 dev 0 function 0 "Intel Wi-Fi 6 AX200" rev 0x1a, msix ppb2 at pci0 dev 29 function 0 "Intel 400 Series PCIE" rev 0xf0: msi pci3 at ppb2 bus 3 ppb3 at pci3 dev 0 function 0 "Intel JHL6540 Thunderbolt" rev 0x02 pci4 at ppb3 bus 4 ppb4 at pci4 dev 0 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi pci5 at ppb4 bus 5 "Intel JHL6540 Thunderbolt" rev 0x02 at pci5 dev 0 function 0 not configured ppb5 at pci4 dev 1 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi pci6 at ppb5 bus 6 ppb6 at pci4 dev 2 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi pci7 at ppb6 bus 59 xhci1 at pci7 dev 0 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi, xHCI 1.10 usb1 at xhci1: USB revision 3.0 uhub1 at usb1 configuration 1 interface 0 "Intel xHCI root hub" rev 3.00/1.00 addr 1 ppb7 at pci4 dev 4 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi pci8 at ppb7 bus 60 ppb8 at pci0 dev 29 function 4 "Intel 400 Series PCIE" rev 0xf0: msi pci9 at ppb8 bus 113 nvme0 at pci9 dev 0 function 0 vendor "SanDisk", unknown product 0x5004 rev 0x01: msix, NVMe 1.3 nvme0: PC SN520 NVMe WDC 256GB, firmware 20220012, serial 1937B4803998 scsibus0 at nvme0: 2 targets, initiator 0 sd0 at scsibus0 targ 1 lun 0: <NVMe, PC SN520 NVMe WD, 2022> sd0: 244198MB, 512 bytes/sector, 500118192 sectors "Intel 400 Series LPC" rev 0x00 at pci0 dev 31 function 0 not configured "Intel 400 Series HD Audio" rev 0x00 at pci0 dev 31 function 3 not configured "Intel 400 Series SMBus" rev 0x00 at pci0 dev 31 function 4 not configured "Intel 400 Series SPI" rev 0x00 at pci0 dev 31 function 5 not configured isa0 at mainbus0 pckbc0 at isa0 port 0x60/5 irq 1 irq 12 pckbd0 at pckbc0 (kbd slot) wskbd0 at pckbd0: console keyboard efifb0 at mainbus0: 1920x1080, 32bpp wsdisplay0 at efifb0 mux 1: console (std, vt100 emulation), using wskbd0 YYY start_init: waiting... umass0 at uhub0 port 1 configuration 1 interface 0 " USB DISK 2.0" rev 2.00/1.00 addr 2 umass0: using SCSI over Bulk-Only scsibus1 at umass0: 2 targets, initiator 0 sd1 at scsibus1 targ 1 lun 0: <, USB DISK 2.0, PMAP> removable serial.13fe4100332B9C23F773 sd1: 60960MB, 512 bytes/sector, 124846080 sectors "CN09357G8LG0098MAFA2A01 Integrated_Webcam_HD" rev 2.01/80.08 addr 3 at uhub0 port 5 not configured "vendor 0x8087 product 0x0029" rev 2.01/0.01 addr 4 at uhub0 port 7 not configured softraid0 at root scsibus2 at softraid0: 256 targets root on rd0a swap on rd0b dump on rd0b WARNING: CHECK AND RESET THE DATE! YYY mountroot done. iwx0: could not read firmware iwx-cc-a0-48 (error 2) iwx0: failed to load init firmware YYY waking up init YYY woke up init YYY start_init: done waiting YYY start_init: okay, here we go: calling sys_execve... YYY sys_nanosleep: start is 3s + 90276400ns YYY sys_nanosleep: calling tsleep_nsec with nsecs = 2000000000d YYY sys_nanosleep: finished tsleep_nsec; stop is 5s + 100279344ns YYY sys_nanosleep: finished loop