svn commit: r304708 - in projects/powernv/powerpc: aim mpc85xx powermac powerpc
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Tue Aug 23 22:04:27 UTC 2016
Author: nwhitehorn
Date: Tue Aug 23 22:04:25 2016
New Revision: 304708
URL: https://svnweb.freebsd.org/changeset/base/304708
Log:
Setting the timebase on PowerNV is toxic to OPAL, as well as unnecessary,
since firmware takes of this (better) for us. On CHRP and on any platform
with a hypervisor, firmware also takes care of it for us and, on hypervisors,
trying to set it will trigger a fault. Make it per-platform instead of
expanding the list of conditions in the generic code.
Modified:
projects/powernv/powerpc/aim/aim_machdep.c
projects/powernv/powerpc/aim/mp_cpudep.c
projects/powernv/powerpc/mpc85xx/platform_mpc85xx.c
projects/powernv/powerpc/powermac/platform_powermac.c
projects/powernv/powerpc/powerpc/mp_machdep.c
projects/powernv/powerpc/powerpc/platform.c
projects/powernv/powerpc/powerpc/platform_if.m
Modified: projects/powernv/powerpc/aim/aim_machdep.c
==============================================================================
--- projects/powernv/powerpc/aim/aim_machdep.c Tue Aug 23 21:41:27 2016 (r304707)
+++ projects/powernv/powerpc/aim/aim_machdep.c Tue Aug 23 22:04:25 2016 (r304708)
@@ -595,7 +595,7 @@ cpu_sleep()
while (1)
mtmsr(msr);
}
- mttb(timebase);
+ platform_smp_timebase_sync(timebase, 0);
PCPU_SET(curthread, curthread);
PCPU_SET(curpcb, curthread->td_pcb);
pmap_activate(curthread);
Modified: projects/powernv/powerpc/aim/mp_cpudep.c
==============================================================================
--- projects/powernv/powerpc/aim/mp_cpudep.c Tue Aug 23 21:41:27 2016 (r304707)
+++ projects/powernv/powerpc/aim/mp_cpudep.c Tue Aug 23 22:04:25 2016 (r304708)
@@ -281,13 +281,8 @@ cpudep_ap_setup()
vers = mfpvr() >> 16;
/* The following is needed for restoring from sleep. */
-#ifdef __powerpc64__
- /* Writing to the time base register is hypervisor-privileged */
- if (mfmsr() & PSL_HV)
- mttb(0);
-#else
- mttb(0);
-#endif
+ platform_smp_timebase_sync(0, 1);
+
switch(vers) {
case IBM970:
case IBM970FX:
Modified: projects/powernv/powerpc/mpc85xx/platform_mpc85xx.c
==============================================================================
--- projects/powernv/powerpc/mpc85xx/platform_mpc85xx.c Tue Aug 23 21:41:27 2016 (r304707)
+++ projects/powernv/powerpc/mpc85xx/platform_mpc85xx.c Tue Aug 23 22:04:25 2016 (r304708)
@@ -90,6 +90,7 @@ static int mpc85xx_smp_first_cpu(platfor
static int mpc85xx_smp_next_cpu(platform_t, struct cpuref *cpuref);
static int mpc85xx_smp_get_bsp(platform_t, struct cpuref *cpuref);
static int mpc85xx_smp_start_cpu(platform_t, struct pcpu *cpu);
+static void mpc85xx_smp_timebase_sync(platform_t, u_long tb, int ap);
static void mpc85xx_idle(platform_t, int cpu);
static int mpc85xx_idle_wakeup(platform_t plat, int cpu);
@@ -105,6 +106,7 @@ static platform_method_t mpc85xx_methods
PLATFORMMETHOD(platform_smp_next_cpu, mpc85xx_smp_next_cpu),
PLATFORMMETHOD(platform_smp_get_bsp, mpc85xx_smp_get_bsp),
PLATFORMMETHOD(platform_smp_start_cpu, mpc85xx_smp_start_cpu),
+ PLATFORMMETHOD(platform_smp_timebase_sync, mpc85xx_smp_timebase_sync),
PLATFORMMETHOD(platform_reset, mpc85xx_reset),
PLATFORMMETHOD(platform_idle, mpc85xx_idle),
@@ -536,6 +538,13 @@ mpc85xx_reset(platform_t plat)
}
static void
+mpc85xx_smp_timebase_sync(platform_t plat, u_long tb, int ap)
+{
+
+ mttb(tb);
+}
+
+static void
mpc85xx_idle(platform_t plat, int cpu)
{
uint32_t reg;
Modified: projects/powernv/powerpc/powermac/platform_powermac.c
==============================================================================
--- projects/powernv/powerpc/powermac/platform_powermac.c Tue Aug 23 21:41:27 2016 (r304707)
+++ projects/powernv/powerpc/powermac/platform_powermac.c Tue Aug 23 22:04:25 2016 (r304708)
@@ -64,6 +64,7 @@ static int powermac_smp_first_cpu(platfo
static int powermac_smp_next_cpu(platform_t, struct cpuref *cpuref);
static int powermac_smp_get_bsp(platform_t, struct cpuref *cpuref);
static int powermac_smp_start_cpu(platform_t, struct pcpu *cpu);
+static void powermac_smp_timebase_sync(platform_t, u_long tb, int ap);
static void powermac_reset(platform_t);
static void powermac_sleep(platform_t);
@@ -77,6 +78,7 @@ static platform_method_t powermac_method
PLATFORMMETHOD(platform_smp_next_cpu, powermac_smp_next_cpu),
PLATFORMMETHOD(platform_smp_get_bsp, powermac_smp_get_bsp),
PLATFORMMETHOD(platform_smp_start_cpu, powermac_smp_start_cpu),
+ PLATFORMMETHOD(platform_smp_timebase_sync, powermac_smp_timebase_sync),
PLATFORMMETHOD(platform_reset, powermac_reset),
PLATFORMMETHOD(platform_sleep, powermac_sleep),
@@ -390,6 +392,13 @@ powermac_smp_start_cpu(platform_t plat,
}
static void
+powermac_smp_timebase_sync(platform_t plat, u_long tb, int ap)
+{
+
+ mttb(tb);
+}
+
+static void
powermac_reset(platform_t platform)
{
OF_reboot();
Modified: projects/powernv/powerpc/powerpc/mp_machdep.c
==============================================================================
--- projects/powernv/powerpc/powerpc/mp_machdep.c Tue Aug 23 21:41:27 2016 (r304707)
+++ projects/powernv/powerpc/powerpc/mp_machdep.c Tue Aug 23 22:04:25 2016 (r304708)
@@ -81,13 +81,7 @@ machdep_ap_bootstrap(void)
;
/* Initialize DEC and TB, sync with the BSP values */
-#ifdef __powerpc64__
- /* Writing to the time base register is hypervisor-privileged */
- if (mfmsr() & PSL_HV)
- mttb(ap_timebase);
-#else
- mttb(ap_timebase);
-#endif
+ platform_smp_timebase_sync(ap_timebase, 1);
decr_ap_init();
/* Give platform code a chance to do anything necessary */
@@ -248,13 +242,7 @@ cpu_mp_unleash(void *dummy)
/* Let APs continue */
atomic_store_rel_int(&ap_letgo, 1);
-#ifdef __powerpc64__
- /* Writing to the time base register is hypervisor-privileged */
- if (mfmsr() & PSL_HV)
- mttb(ap_timebase);
-#else
- mttb(ap_timebase);
-#endif
+ platform_smp_timebase_sync(ap_timebase, 0);
while (ap_awake < smp_cpus)
;
Modified: projects/powernv/powerpc/powerpc/platform.c
==============================================================================
--- projects/powernv/powerpc/powerpc/platform.c Tue Aug 23 21:41:27 2016 (r304707)
+++ projects/powernv/powerpc/powerpc/platform.c Tue Aug 23 22:04:25 2016 (r304708)
@@ -266,6 +266,12 @@ platform_cpu_idle(int cpu)
PLATFORM_IDLE(plat_obj, cpu);
}
+void platform_smp_timebase_sync(u_long tb, int ap)
+{
+
+ PLATFORM_SMP_TIMEBASE_SYNC(plat_obj, tb, ap);
+}
+
/*
* Platform install routines. Highest priority wins, using the same
* algorithm as bus attachment.
Modified: projects/powernv/powerpc/powerpc/platform_if.m
==============================================================================
--- projects/powernv/powerpc/powerpc/platform_if.m Tue Aug 23 21:41:27 2016 (r304707)
+++ projects/powernv/powerpc/powerpc/platform_if.m Tue Aug 23 22:04:25 2016 (r304708)
@@ -241,3 +241,14 @@ METHOD void sleep {
platform_t _plat;
};
+/**
+ * @brief Attempt to synchronize timebase of current CPU with others.
+ * Entered (approximately) simultaneously on all CPUs, including the BSP.
+ * Passed the timebase value on the BSP as of shortly before the call.
+ */
+METHOD void smp_timebase_sync {
+ platform_t _plat;
+ u_long _tb;
+ int _ap;
+};
+
More information about the svn-src-projects
mailing list