From owner-svn-src-head@freebsd.org Sat Dec 30 20:24:34 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE1FEEAAB48; Sat, 30 Dec 2017 20:24:34 +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 mx1.freebsd.org (Postfix) with ESMTPS id B81216B165; Sat, 30 Dec 2017 20:24:34 +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 vBUKOX9p016237; Sat, 30 Dec 2017 20:24:33 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBUKOX5U016236; Sat, 30 Dec 2017 20:24:33 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201712302024.vBUKOX5U016236@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Sat, 30 Dec 2017 20:24:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327388 - head/sys/powerpc/ps3 X-SVN-Group: head X-SVN-Commit-Author: nwhitehorn X-SVN-Commit-Paths: head/sys/powerpc/ps3 X-SVN-Commit-Revision: 327388 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: Sat, 30 Dec 2017 20:24:35 -0000 Author: nwhitehorn Date: Sat Dec 30 20:24:33 2017 New Revision: 327388 URL: https://svnweb.freebsd.org/changeset/base/327388 Log: Change the way SMP startup works to match the new multi-AP features in locore64.S introduced in r327358. MFC after: 3 weeks Modified: head/sys/powerpc/ps3/platform_ps3.c Modified: head/sys/powerpc/ps3/platform_ps3.c ============================================================================== --- head/sys/powerpc/ps3/platform_ps3.c Sat Dec 30 20:23:14 2017 (r327387) +++ head/sys/powerpc/ps3/platform_ps3.c Sat Dec 30 20:24:33 2017 (r327388) @@ -103,6 +103,8 @@ static platform_def_t ps3_platform = { PLATFORM_DEF(ps3_platform); +static int ps3_boot_pir = 0; + static int ps3_probe(platform_t plat) { @@ -129,6 +131,9 @@ ps3_attach(platform_t plat) /* Set a breakpoint to make NULL an invalid address */ lv1_set_dabr(0x7 /* read and write, MMU on */, 2 /* kernel accesses */); + /* Record our PIR at boot for later */ + ps3_boot_pir = mfspr(SPR_PIR); + return (0); } @@ -189,7 +194,7 @@ ps3_smp_first_cpu(platform_t plat, struct cpuref *cpur { cpuref->cr_cpuid = 0; - cpuref->cr_hwref = cpuref->cr_cpuid; + cpuref->cr_hwref = ps3_boot_pir; return (0); } @@ -202,7 +207,7 @@ ps3_smp_next_cpu(platform_t plat, struct cpuref *cpure return (ENOENT); cpuref->cr_cpuid++; - cpuref->cr_hwref = cpuref->cr_cpuid; + cpuref->cr_hwref = !ps3_boot_pir; return (0); } @@ -212,7 +217,7 @@ ps3_smp_get_bsp(platform_t plat, struct cpuref *cpuref { cpuref->cr_cpuid = 0; - cpuref->cr_hwref = cpuref->cr_cpuid; + cpuref->cr_hwref = ps3_boot_pir; return (0); } @@ -220,21 +225,21 @@ ps3_smp_get_bsp(platform_t plat, struct cpuref *cpuref static int ps3_smp_start_cpu(platform_t plat, struct pcpu *pc) { - /* loader(8) is spinning on 0x40 == 0 right now */ - uint32_t *secondary_spin_sem = (uint32_t *)(0x40); + /* kernel is spinning on 0x40 == -1 right now */ + volatile uint32_t *secondary_spin_sem = (uint32_t *)(0x40); + int remote_pir = pc->pc_hwref; int timeout; - if (pc->pc_hwref != 1) - return (ENXIO); - ap_pcpu = pc; - *secondary_spin_sem = 1; - powerpc_sync(); - DELAY(1); + /* Try both PIR values, looping a few times: the HV likes moving us */ timeout = 10000; - while (!pc->pc_awake && timeout--) + while (!pc->pc_awake && timeout--) { + *secondary_spin_sem = remote_pir; + powerpc_sync(); DELAY(100); + remote_pir = !remote_pir; + } return ((pc->pc_awake) ? 0 : EBUSY); }