From owner-svn-src-all@freebsd.org Fri Feb 9 20:09:33 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7B5B0F205A4; Fri, 9 Feb 2018 20:09:33 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2F4C076A62; Fri, 9 Feb 2018 20:09:33 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2A4AD1777; Fri, 9 Feb 2018 20:09:33 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w19K9Xsk049277; Fri, 9 Feb 2018 20:09:33 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w19K9Xxa049276; Fri, 9 Feb 2018 20:09:33 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201802092009.w19K9Xxa049276@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Fri, 9 Feb 2018 20:09:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329080 - head/sys/powerpc/powerpc X-SVN-Group: head X-SVN-Commit-Author: nwhitehorn X-SVN-Commit-Paths: head/sys/powerpc/powerpc X-SVN-Commit-Revision: 329080 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Feb 2018 20:09:33 -0000 Author: nwhitehorn Date: Fri Feb 9 20:09:32 2018 New Revision: 329080 URL: https://svnweb.freebsd.org/changeset/base/329080 Log: 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 Modified: head/sys/powerpc/powerpc/mp_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/mp_machdep.c Fri Feb 9 20:00:51 2018 (r329079) +++ head/sys/powerpc/powerpc/mp_machdep.c Fri Feb 9 20:09:32 2018 (r329080) @@ -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 */