[Bug 240475] [PATCH]: Add support for CPUID 0x16 in tsc_freq_cpuid() (TSC clock)

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Sep 12 23:38:54 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240475

--- Comment #7 from Neel Chauhan <neel at neelc.org> ---
It's true that Linux does this (lines 660-661):

    crystal_khz = eax_base_mhz * 1000 *
        eax_denominator / ebx_numerator;

But in the same function, Linux returns this (line 674):

    return crystal_khz * ebx_numerator / eax_denominator;

So the numerator and denominator in crystal_khz effectively cancels out on
CPUID 0x16.

>From what I understand, Linux expects the value in kilohertz, so a multiplier
of 1000 works on Linux. I believe FreeBSD expects hertz, so a multiplier of
1000000 is needed.

For unit conversion of megahertz to hertz, 1000 Hz = 1 KHz and 1000 KHz = 1
MHz, so 1 MHz = 1000 KHz * 1000 Hz.

Also, using the numerator and denominator wouldn't work (I've tried that, I got
a kernel panic).

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list