Skip to content

Commit c4ae36f

Browse files
authored
Merge pull request #3869 from Zzzoom/find_freq_bogomips
opal: Get x86 TSC frequency from bogomips
2 parents b0c8273 + b5883a3 commit c4ae36f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

opal/mca/timer/linux/timer_linux_component.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@ static int opal_timer_linux_find_freq(void)
134134
}
135135
}
136136

137+
#if ((OPAL_ASSEMBLY_ARCH == OPAL_IA32) || (OPAL_ASSEMBLY_ARCH == OPAL_X86_64))
138+
if (0 == opal_timer_linux_freq && opal_sys_timer_is_monotonic()) {
139+
/* tsc is exposed through bogomips ~> loops_per_jiffy ~> tsc_khz */
140+
loc = find_info(fp, "bogomips", buf, 1024);
141+
if (NULL != loc) {
142+
ret = sscanf(loc, "%f", &cpu_f);
143+
if (1 == ret) {
144+
/* number is in MHz * 2 and has 2 decimal digits
145+
convert to Hz and make an integer */
146+
opal_timer_linux_freq = (opal_timer_t) (cpu_f * 100.0f) * 5000;
147+
}
148+
}
149+
}
150+
#endif
151+
137152
if (0 == opal_timer_linux_freq) {
138153
/* find the CPU speed - most timers are 1:1 with CPU speed */
139154
loc = find_info(fp, "cpu MHz", buf, 1024);

0 commit comments

Comments
 (0)