From owner-svn-src-all@freebsd.org Sun Dec 27 14:39:49 2015 Return-Path: Delivered-To: svn-src-all@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 02406A4DFBC; Sun, 27 Dec 2015 14:39:49 +0000 (UTC) (envelope-from marius@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 B84EA1E2A; Sun, 27 Dec 2015 14:39:48 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tBREdl0P076817; Sun, 27 Dec 2015 14:39:47 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tBREdlhl076813; Sun, 27 Dec 2015 14:39:47 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201512271439.tBREdlhl076813@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Sun, 27 Dec 2015 14:39:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r292771 - in stable/10/sys/sparc64: include sparc64 X-SVN-Group: stable-10 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.20 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: Sun, 27 Dec 2015 14:39:49 -0000 Author: marius Date: Sun Dec 27 14:39:47 2015 New Revision: 292771 URL: https://svnweb.freebsd.org/changeset/base/292771 Log: MFC: r291121 Merge from r290547: Since r289279 bufinit() uses mp_ncpus so adapt to what x86 does and set this variable already in cpu_mp_setmaxid(). While at it, rename cpu_cpuid_prop() to cpu_portid_prop() as well as the MD cpuid variable to portid to avoid confusion with the MI use of "cpuid" and make some variable static/global in order to reduce stack usage. PR: 204685 Modified: stable/10/sys/sparc64/include/md_var.h stable/10/sys/sparc64/sparc64/machdep.c stable/10/sys/sparc64/sparc64/mp_machdep.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/sparc64/include/md_var.h ============================================================================== --- stable/10/sys/sparc64/include/md_var.h Sun Dec 27 13:37:14 2015 (r292770) +++ stable/10/sys/sparc64/include/md_var.h Sun Dec 27 14:39:47 2015 (r292771) @@ -47,9 +47,9 @@ extern vm_paddr_t kstack0_phys; struct pcpu; struct md_utrap; -const char *cpu_cpuid_prop(u_int cpu_impl); uint32_t cpu_get_mid(u_int cpu_impl); void cpu_identify(u_long vers, u_int clock, u_int id); +const char *cpu_portid_prop(u_int cpu_impl); void cpu_setregs(struct pcpu *pc); int is_physical_memory(vm_paddr_t addr); struct md_utrap *utrap_alloc(void); Modified: stable/10/sys/sparc64/sparc64/machdep.c ============================================================================== --- stable/10/sys/sparc64/sparc64/machdep.c Sun Dec 27 13:37:14 2015 (r292770) +++ stable/10/sys/sparc64/sparc64/machdep.c Sun Dec 27 14:39:47 2015 (r292771) @@ -249,7 +249,7 @@ find_bsp(phandle_t node, uint32_t bspid, { char type[sizeof("cpu")]; phandle_t child; - uint32_t cpuid; + uint32_t portid; for (; node != 0; node = OF_peer(node)) { child = OF_child(node); @@ -263,10 +263,10 @@ find_bsp(phandle_t node, uint32_t bspid, continue; if (strcmp(type, "cpu") != 0) continue; - if (OF_getprop(node, cpu_cpuid_prop(cpu_impl), &cpuid, - sizeof(cpuid)) <= 0) + if (OF_getprop(node, cpu_portid_prop(cpu_impl), + &portid, sizeof(portid)) <= 0) continue; - if (cpuid == bspid) + if (portid == bspid) return (node); } } @@ -274,7 +274,7 @@ find_bsp(phandle_t node, uint32_t bspid, } const char * -cpu_cpuid_prop(u_int cpu_impl) +cpu_portid_prop(u_int cpu_impl) { switch (cpu_impl) { Modified: stable/10/sys/sparc64/sparc64/mp_machdep.c ============================================================================== --- stable/10/sys/sparc64/sparc64/mp_machdep.c Sun Dec 27 13:37:14 2015 (r292770) +++ stable/10/sys/sparc64/sparc64/mp_machdep.c Sun Dec 27 14:39:47 2015 (r292771) @@ -119,9 +119,11 @@ struct mtx ipi_mtx; cpu_ipi_selected_t *cpu_ipi_selected; cpu_ipi_single_t *cpu_ipi_single; -static vm_offset_t mp_tramp; static u_int cpuid_to_mid[MAXCPU]; +static u_int cpuids = 1; static volatile cpuset_t shutdown_cpus; +static char ipi_pbuf[CPUSETBUFSIZ]; +static vm_offset_t mp_tramp; static void ap_count(phandle_t node, u_int mid, u_int cpu_impl); static void ap_start(phandle_t node, u_int mid, u_int cpu_impl); @@ -165,13 +167,12 @@ static void foreach_ap(phandle_t node, void (*func)(phandle_t node, u_int mid, u_int cpu_impl)) { - char type[sizeof("cpu")]; + static char type[sizeof("cpu")]; phandle_t child; - u_int cpuid; - uint32_t cpu_impl; + uint32_t cpu_impl, portid; /* There's no need to traverse the whole OFW tree twice. */ - if (mp_maxid > 0 && mp_ncpus >= mp_maxid + 1) + if (mp_maxid > 0 && cpuids > mp_maxid) return; for (; node != 0; node = OF_peer(node)) { @@ -188,13 +189,13 @@ foreach_ap(phandle_t node, void (*func)( sizeof(cpu_impl)) <= 0) panic("%s: couldn't determine CPU " "implementation", __func__); - if (OF_getprop(node, cpu_cpuid_prop(cpu_impl), &cpuid, - sizeof(cpuid)) <= 0) - panic("%s: couldn't determine CPU module ID", + if (OF_getprop(node, cpu_portid_prop(cpu_impl), + &portid, sizeof(portid)) <= 0) + panic("%s: couldn't determine CPU port ID", __func__); - if (cpuid == PCPU_GET(mid)) + if (portid == PCPU_GET(mid)) continue; - (*func)(node, cpuid, cpu_impl); + (*func)(node, portid, cpu_impl); } } } @@ -208,16 +209,17 @@ cpu_mp_setmaxid(void) CPU_SETOF(curcpu, &all_cpus); mp_ncpus = 1; - mp_maxid = 0; foreach_ap(OF_child(OF_peer(0)), ap_count); + mp_ncpus = MIN(mp_ncpus, MAXCPU); + mp_maxid = mp_ncpus - 1; } static void ap_count(phandle_t node __unused, u_int mid __unused, u_int cpu_impl __unused) { - mp_maxid++; + mp_ncpus++; } int @@ -306,7 +308,7 @@ ap_start(phandle_t node, u_int mid, u_in u_int cpuid; uint32_t clock; - if (mp_ncpus > MAXCPU) + if (cpuids > mp_maxid) return; if (OF_getprop(node, "clock-frequency", &clock, sizeof(clock)) <= 0) @@ -334,7 +336,7 @@ ap_start(phandle_t node, u_int mid, u_in csa->csa_tick = csa->csa_stick = 0; intr_restore(s); - cpuid = mp_ncpus++; + cpuid = cpuids++; cpuid_to_mid[cpuid] = mid; cpu_identify(csa->csa_ver, clock, cpuid); @@ -659,7 +661,6 @@ cheetah_ipi_single(u_int cpu, u_long d0, static void cheetah_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2) { - char pbuf[CPUSETBUFSIZ]; register_t s; u_long ids; u_int bnp; @@ -675,14 +676,14 @@ cheetah_ipi_selected(cpuset_t cpus, u_lo ("%s: outstanding dispatch", __func__)); ids = 0; - for (i = 0; i < IPI_RETRIES * mp_ncpus; i++) { + for (i = 0; i < IPI_RETRIES * smp_cpus; i++) { s = intr_disable(); stxa(AA_SDB_INTR_D0, ASI_SDB_INTR_W, d0); stxa(AA_SDB_INTR_D1, ASI_SDB_INTR_W, d1); stxa(AA_SDB_INTR_D2, ASI_SDB_INTR_W, d2); membar(Sync); bnp = 0; - for (cpu = 0; cpu < mp_ncpus; cpu++) { + for (cpu = 0; cpu < smp_cpus; cpu++) { if (CPU_ISSET(cpu, &cpus)) { stxa(AA_INTR_SEND | (cpuid_to_mid[cpu] << IDC_ITID_SHIFT) | bnp << IDC_BN_SHIFT, @@ -698,7 +699,7 @@ cheetah_ipi_selected(cpuset_t cpus, u_lo ; intr_restore(s); bnp = 0; - for (cpu = 0; cpu < mp_ncpus; cpu++) { + for (cpu = 0; cpu < smp_cpus; cpu++) { if (CPU_ISSET(cpu, &cpus)) { if ((ids & (IDR_NACK << (2 * bnp))) == 0) CPU_CLR(cpu, &cpus); @@ -710,10 +711,10 @@ cheetah_ipi_selected(cpuset_t cpus, u_lo } if (kdb_active != 0 || panicstr != NULL) printf("%s: couldn't send IPI (cpus=%s ids=0x%lu)\n", - __func__, cpusetobj_strprint(pbuf, &cpus), ids); + __func__, cpusetobj_strprint(ipi_pbuf, &cpus), ids); else panic("%s: couldn't send IPI (cpus=%s ids=0x%lu)", - __func__, cpusetobj_strprint(pbuf, &cpus), ids); + __func__, cpusetobj_strprint(ipi_pbuf, &cpus), ids); } static void @@ -760,7 +761,6 @@ jalapeno_ipi_single(u_int cpu, u_long d0 static void jalapeno_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2) { - char pbuf[CPUSETBUFSIZ]; register_t s; u_long ids; u_int cpu; @@ -775,13 +775,13 @@ jalapeno_ipi_selected(cpuset_t cpus, u_l ("%s: outstanding dispatch", __func__)); ids = 0; - for (i = 0; i < IPI_RETRIES * mp_ncpus; i++) { + for (i = 0; i < IPI_RETRIES * smp_cpus; i++) { s = intr_disable(); stxa(AA_SDB_INTR_D0, ASI_SDB_INTR_W, d0); stxa(AA_SDB_INTR_D1, ASI_SDB_INTR_W, d1); stxa(AA_SDB_INTR_D2, ASI_SDB_INTR_W, d2); membar(Sync); - for (cpu = 0; cpu < mp_ncpus; cpu++) { + for (cpu = 0; cpu < smp_cpus; cpu++) { if (CPU_ISSET(cpu, &cpus)) { stxa(AA_INTR_SEND | (cpuid_to_mid[cpu] << IDC_ITID_SHIFT), ASI_SDB_INTR_W, 0); @@ -795,7 +795,7 @@ jalapeno_ipi_selected(cpuset_t cpus, u_l if ((ids & (IDR_CHEETAH_ALL_BUSY | IDR_CHEETAH_ALL_NACK)) == 0) return; - for (cpu = 0; cpu < mp_ncpus; cpu++) + for (cpu = 0; cpu < smp_cpus; cpu++) if (CPU_ISSET(cpu, &cpus)) if ((ids & (IDR_NACK << (2 * cpuid_to_mid[cpu]))) == 0) @@ -803,8 +803,8 @@ jalapeno_ipi_selected(cpuset_t cpus, u_l } if (kdb_active != 0 || panicstr != NULL) printf("%s: couldn't send IPI (cpus=%s ids=0x%lu)\n", - __func__, cpusetobj_strprint(pbuf, &cpus), ids); + __func__, cpusetobj_strprint(ipi_pbuf, &cpus), ids); else panic("%s: couldn't send IPI (cpus=%s ids=0x%lu)", - __func__, cpusetobj_strprint(pbuf, &cpus), ids); + __func__, cpusetobj_strprint(ipi_pbuf, &cpus), ids); }