summaryrefslogtreecommitdiff
path: root/usr/src/uts/i86pc/os/mp_machdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/i86pc/os/mp_machdep.c')
-rw-r--r--usr/src/uts/i86pc/os/mp_machdep.c90
1 files changed, 23 insertions, 67 deletions
diff --git a/usr/src/uts/i86pc/os/mp_machdep.c b/usr/src/uts/i86pc/os/mp_machdep.c
index f36f5f052d..865fa049fd 100644
--- a/usr/src/uts/i86pc/os/mp_machdep.c
+++ b/usr/src/uts/i86pc/os/mp_machdep.c
@@ -25,7 +25,8 @@
/*
* Copyright (c) 2009-2010, Intel Corporation.
* All rights reserved.
- * Copyright 2018 Joyent, Inc.
+ * Copyright 2020 Joyent, Inc.
+ * Copyright 2020 Oxide Computer Company
*/
#define PSMI_1_7
@@ -63,6 +64,9 @@
#include <sys/sunddi.h>
#include <sys/sunndi.h>
#include <sys/cpc_pcbe.h>
+#include <sys/prom_debug.h>
+#include <sys/tsc.h>
+
#define OFFSETOF(s, m) (size_t)(&(((s *)0)->m))
@@ -100,10 +104,6 @@ static int mach_cpu_create_devinfo(cpu_t *cp, dev_info_t **dipp);
* External reference functions
*/
extern void return_instr();
-extern uint64_t freq_tsc(uint32_t *);
-#if defined(__i386)
-extern uint64_t freq_notsc(uint32_t *);
-#endif
extern void pc_gethrestime(timestruc_t *);
extern int cpuid_get_coreid(cpu_t *);
extern int cpuid_get_chipid(cpu_t *);
@@ -978,6 +978,7 @@ mach_init()
{
struct psm_ops *pops;
+ PRM_POINT("mach_construct_info()");
mach_construct_info();
pops = mach_set[0];
@@ -1017,6 +1018,7 @@ mach_init()
notify_error = pops->psm_notify_error;
}
+ PRM_POINT("psm_softinit()");
(*pops->psm_softinit)();
/*
@@ -1034,6 +1036,7 @@ mach_init()
#ifndef __xpv
non_deep_idle_disp_enq_thread = disp_enq_thread;
#endif
+ PRM_DEBUG(idle_cpu_use_hlt);
if (idle_cpu_use_hlt) {
idle_cpu = cpu_idle_adaptive;
CPU->cpu_m.mcpu_idle_cpu = cpu_idle;
@@ -1068,6 +1071,7 @@ mach_init()
#endif
}
+ PRM_POINT("mach_smpinit()");
mach_smpinit();
}
@@ -1209,28 +1213,14 @@ uint64_t cpu_freq_hz; /* measured (in hertz) */
int xpv_cpufreq_workaround = 1;
int xpv_cpufreq_verbose = 0;
-#else /* __xpv */
-
-static uint64_t
-mach_calchz(uint32_t pit_counter, uint64_t *processor_clks)
-{
- uint64_t cpu_hz;
-
- if ((pit_counter == 0) || (*processor_clks == 0) ||
- (*processor_clks > (((uint64_t)-1) / PIT_HZ)))
- return (0);
-
- cpu_hz = ((uint64_t)PIT_HZ * *processor_clks) / pit_counter;
-
- return (cpu_hz);
-}
-
#endif /* __xpv */
static uint64_t
mach_getcpufreq(void)
{
-#if defined(__xpv)
+#ifndef __xpv
+ return (tsc_get_freq());
+#else
vcpu_time_info_t *vti = &CPU->cpu_m.mcpu_vcpu_info->time;
uint64_t cpu_hz;
@@ -1269,37 +1259,6 @@ mach_getcpufreq(void)
vti->tsc_to_system_mul, vti->tsc_shift, cpu_hz);
return (cpu_hz);
-#else /* __xpv */
- uint32_t pit_counter;
- uint64_t processor_clks;
-
- if (is_x86_feature(x86_featureset, X86FSET_TSC)) {
- /*
- * We have a TSC. freq_tsc() knows how to measure the number
- * of clock cycles sampled against the PIT.
- */
- ulong_t flags = clear_int_flag();
- processor_clks = freq_tsc(&pit_counter);
- restore_int_flag(flags);
- return (mach_calchz(pit_counter, &processor_clks));
- } else if (x86_vendor == X86_VENDOR_Cyrix || x86_type == X86_TYPE_P5) {
-#if defined(__amd64)
- panic("mach_getcpufreq: no TSC!");
-#elif defined(__i386)
- /*
- * We are a Cyrix based on a 6x86 core or an Intel Pentium
- * for which freq_notsc() knows how to measure the number of
- * elapsed clock cycles sampled against the PIT
- */
- ulong_t flags = clear_int_flag();
- processor_clks = freq_notsc(&pit_counter);
- restore_int_flag(flags);
- return (mach_calchz(pit_counter, &processor_clks));
-#endif /* __i386 */
- }
-
- /* We do not know how to calculate cpu frequency for this cpu. */
- return (0);
#endif /* __xpv */
}
@@ -1445,21 +1404,18 @@ mach_clkinit(int preferred_mode, int *set_mode)
cpu_freq = machhztomhz(cpu_freq_hz);
- if (!is_x86_feature(x86_featureset, X86FSET_TSC) || (cpu_freq == 0))
- tsc_gethrtime_enable = 0;
+ /*
+ * For most systems, we retain the default TSC-based gethrtime()
+ * implementation that was initialized early in the boot process.
+ */
+#ifdef __xpv
+ if (pops->psm_hrtimeinit)
+ (*pops->psm_hrtimeinit)();
+ gethrtimef = pops->psm_gethrtime;
+ gethrtimeunscaledf = gethrtimef;
+ /* scalehrtimef will remain dummy */
-#ifndef __xpv
- if (tsc_gethrtime_enable) {
- tsc_hrtimeinit(cpu_freq_hz);
- } else
-#endif
- {
- if (pops->psm_hrtimeinit)
- (*pops->psm_hrtimeinit)();
- gethrtimef = pops->psm_gethrtime;
- gethrtimeunscaledf = gethrtimef;
- /* scalehrtimef will remain dummy */
- }
+#endif /* __xpv */
mach_fixcpufreq();