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
This commit is contained in:
Nathan Whitehorn 2018-02-09 20:09:32 +00:00
parent 51adff9318
commit 778c8dac96
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329080

View file

@ -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 */
platform_smp_ap_init();
/* Initialize DEC and TB, sync with the BSP values */
platform_smp_timebase_sync(ap_timebase, 1);
/* Initialize decrementer */
decr_ap_init();
/* Serialize console output and AP count increment */