From owner-svn-src-head@freebsd.org Mon Jan 29 08:10:04 2018 Return-Path: Delivered-To: svn-src-head@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 E3A72EDC660; Mon, 29 Jan 2018 08:10:03 +0000 (UTC) (envelope-from wma@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 9659084459; Mon, 29 Jan 2018 08:10:03 +0000 (UTC) (envelope-from wma@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 8CF222572E; Mon, 29 Jan 2018 08:10:03 +0000 (UTC) (envelope-from wma@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0T8A38s068115; Mon, 29 Jan 2018 08:10:03 GMT (envelope-from wma@FreeBSD.org) Received: (from wma@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0T8A3fm068113; Mon, 29 Jan 2018 08:10:03 GMT (envelope-from wma@FreeBSD.org) Message-Id: <201801290810.w0T8A3fm068113@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wma set sender to wma@FreeBSD.org using -f From: Wojciech Macek Date: Mon, 29 Jan 2018 08:10:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328533 - in head/sys/powerpc: powernv powerpc X-SVN-Group: head X-SVN-Commit-Author: wma X-SVN-Commit-Paths: in head/sys/powerpc: powernv powerpc X-SVN-Commit-Revision: 328533 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jan 2018 08:10:04 -0000 Author: wma Date: Mon Jan 29 08:10:03 2018 New Revision: 328533 URL: https://svnweb.freebsd.org/changeset/base/328533 Log: PPC64: cleanup APs startup routines Cleaning up AP startup routines. This is a mix of changes required to make PowerNV running and to modify the code to be more robust. Previously, some races were seen if more than 90CPUs were online. Authored by: Patryk Duda Submitted by: Wojciech Macek Obtained from: Semihalf Sponsored by: IBM, QCM Technologies Differential revision: https://reviews.freebsd.org/D14026 Modified: head/sys/powerpc/powernv/platform_powernv.c head/sys/powerpc/powerpc/mp_machdep.c Modified: head/sys/powerpc/powernv/platform_powernv.c ============================================================================== --- head/sys/powerpc/powernv/platform_powernv.c Mon Jan 29 05:29:28 2018 (r328532) +++ head/sys/powerpc/powernv/platform_powernv.c Mon Jan 29 08:10:03 2018 (r328533) @@ -425,9 +425,21 @@ powernv_reset(platform_t platform) static void powernv_smp_ap_init(platform_t platform) { + register_t msr; + /* LPID must not be altered when PSL_DR or PSL_IR is set */ + msr = mfmsr(); + mtmsr(msr & ~(PSL_DR | PSL_IR)); + + isync(); /* Direct interrupts to SRR instead of HSRR and reset LPCR otherwise */ + mtspr(SPR_LPID, 0); + isync(); + + mtmsr(msr); + mtspr(SPR_LPCR, LPCR_LPES); + isync(); } static void Modified: head/sys/powerpc/powerpc/mp_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/mp_machdep.c Mon Jan 29 05:29:28 2018 (r328532) +++ head/sys/powerpc/powerpc/mp_machdep.c Mon Jan 29 08:10:03 2018 (r328533) @@ -94,6 +94,9 @@ machdep_ap_bootstrap(void) printf("SMP: AP CPU #%d launched\n", PCPU_GET(cpuid)); mtx_unlock_spin(&ap_boot_mtx); + while(smp_started == 0) + ; + /* Start per-CPU event timers. */ cpu_initclocks_ap(); @@ -197,6 +200,7 @@ cpu_mp_unleash(void *dummy) { struct pcpu *pc; int cpus, timeout; + int ret; if (mp_ncpus <= 1) return; @@ -215,12 +219,12 @@ cpu_mp_unleash(void *dummy) printf("Waking up CPU %d (dev=%x)\n", pc->pc_cpuid, (int)pc->pc_hwref); - platform_smp_start_cpu(pc); - - timeout = 2000; /* wait 2sec for the AP */ - while (!pc->pc_awake && --timeout > 0) - DELAY(1000); - + ret = platform_smp_start_cpu(pc); + if (ret == 0) { + timeout = 2000; /* wait 2sec for the AP */ + while (!pc->pc_awake && --timeout > 0) + DELAY(1000); + } } else { pc->pc_awake = 1; } @@ -253,11 +257,12 @@ cpu_mp_unleash(void *dummy) mp_ncpus, cpus, smp_cpus); } + if (smp_cpus > 1) + atomic_store_rel_int(&smp_started, 1); + /* Let the APs get into the scheduler */ DELAY(10000); - /* XXX Atomic set operation? */ - smp_started = 1; } SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, cpu_mp_unleash, NULL);