Author: nwhitehorn
Date: Fri Feb  9 20:09:32 2018
New Revision: 329080

  Fix PowerMac G5 thermal management, plus likely other bugs, introduced in
  r328113 and affecting SMP systems.
  The way the time is set on PowerMacs is racy and relies on all the
  CPUs in the system setting a register simultaneously in a rendezvous. A
  few-cycle delay can result in out-of-sync times, which can break the
  scheduler and result in calls like mtx_sleep() and pause() never timing out
  if the thread is migrated while sleeping. r328113 added a call to a no-op
  function between the beginning of the rendezvous and setting the time that
  was only called on APs and added enough cycles to cause a problematic offset.
  For some reason, the fan-management code was the first place this appeared.
  Clue from:    andreast
  Reported by:  many


Modified: head/sys/powerpc/powerpc/mp_machdep.c
--- head/sys/powerpc/powerpc/mp_machdep.c       Fri Feb  9 20:00:51 2018        
+++ head/sys/powerpc/powerpc/mp_machdep.c       Fri Feb  9 20:09:32 2018        
@@ -81,11 +81,20 @@ machdep_ap_bootstrap(void)
                __asm __volatile("or 27,27,27");
        __asm __volatile("or 6,6,6");
-       /* Give platform code a chance to do anything necessary */
+       /*
+        * Set timebase as soon as possible to meet an implicit rendezvous
+        * from cpu_mp_unleash(), which sets ap_letgo and then immediately
+        * sets timebase.
+        *
+        * Note that this is instrinsically racy and is only relevant on
+        * platforms that do not support better mechanisms.
+        */
+       platform_smp_timebase_sync(ap_timebase, 1);
+       /* Give platform code a chance to do anything else necessary */
-       /* Initialize DEC and TB, sync with the BSP values */
-       platform_smp_timebase_sync(ap_timebase, 1);
+       /* Initialize decrementer */
        /* Serialize console output and AP count increment */
_______________________________________________ mailing list
To unsubscribe, send any mail to ""

Reply via email to