From owner-svn-src-head@freebsd.org Sun Nov 8 14:26:52 2015 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 BAC08A29359; Sun, 8 Nov 2015 14:26:52 +0000 (UTC) (envelope-from tijl@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 787B01825; Sun, 8 Nov 2015 14:26:52 +0000 (UTC) (envelope-from tijl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tA8EQpci086559; Sun, 8 Nov 2015 14:26:51 GMT (envelope-from tijl@FreeBSD.org) Received: (from tijl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tA8EQopT086552; Sun, 8 Nov 2015 14:26:50 GMT (envelope-from tijl@FreeBSD.org) Message-Id: <201511081426.tA8EQopT086552@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tijl set sender to tijl@FreeBSD.org using -f From: Tijl Coosemans Date: Sun, 8 Nov 2015 14:26:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r290547 - in head/sys: arm/annapurna/alpine arm/mv/armadaxp arm/qemu arm/ti/omap4 arm/xilinx kern x86/x86 X-SVN-Group: head 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.20 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: Sun, 08 Nov 2015 14:26:52 -0000 Author: tijl Date: Sun Nov 8 14:26:50 2015 New Revision: 290547 URL: https://svnweb.freebsd.org/changeset/base/290547 Log: Since r289279 bufinit() uses mp_ncpus, but some architectures set this variable during mp_start() which is too late. Move this to mp_setmaxid() where other architectures set it and move x86 assertions to MI code. Reviewed by: kib (x86 part) Modified: head/sys/arm/annapurna/alpine/alpine_machdep_mp.c head/sys/arm/mv/armadaxp/armadaxp_mp.c head/sys/arm/qemu/virt_mp.c head/sys/arm/ti/omap4/omap4_mp.c head/sys/arm/xilinx/zy7_mp.c head/sys/kern/subr_smp.c head/sys/x86/x86/mp_x86.c Modified: head/sys/arm/annapurna/alpine/alpine_machdep_mp.c ============================================================================== --- head/sys/arm/annapurna/alpine/alpine_machdep_mp.c Sun Nov 8 14:22:57 2015 (r290546) +++ head/sys/arm/annapurna/alpine/alpine_machdep_mp.c Sun Nov 8 14:26:50 2015 (r290547) @@ -128,16 +128,14 @@ platform_mp_init_secondary(void) void platform_mp_setmaxid(void) { - int core_cnt; - core_cnt = platform_mp_get_core_cnt(); - mp_maxid = core_cnt - 1; + mp_ncpus = platform_mp_get_core_cnt(); + mp_maxid = mp_ncpus - 1; } int platform_mp_probe(void) { - mp_ncpus = platform_mp_get_core_cnt(); return (1); } Modified: head/sys/arm/mv/armadaxp/armadaxp_mp.c ============================================================================== --- head/sys/arm/mv/armadaxp/armadaxp_mp.c Sun Nov 8 14:22:57 2015 (r290546) +++ head/sys/arm/mv/armadaxp/armadaxp_mp.c Sun Nov 8 14:26:50 2015 (r290547) @@ -82,15 +82,14 @@ void platform_mp_setmaxid(void) { - mp_maxid = 3; + mp_ncpus = platform_get_ncpus(); + mp_maxid = mp_ncpus - 1; } int platform_mp_probe(void) { - mp_ncpus = platform_get_ncpus(); - return (mp_ncpus > 1); } Modified: head/sys/arm/qemu/virt_mp.c ============================================================================== --- head/sys/arm/qemu/virt_mp.c Sun Nov 8 14:22:57 2015 (r290546) +++ head/sys/arm/qemu/virt_mp.c Sun Nov 8 14:26:50 2015 (r290547) @@ -49,17 +49,8 @@ static int running_cpus; int platform_mp_probe(void) { - int ncpus; - ncpus = ofw_cpu_early_foreach(NULL, true); - if (ncpus <= 1) { - mp_ncpus = 1; - return (0); - } - - mp_ncpus = MIN(ncpus, MAXCPU); - - return (1); + return (mp_ncpus > 1); } static boolean_t @@ -77,7 +68,10 @@ platform_mp_setmaxid(void) { mp_maxid = PCPU_GET(cpuid); - ofw_cpu_early_foreach(virt_maxid, true); + mp_ncpus = ofw_cpu_early_foreach(virt_maxid, true); + if (mp_ncpus < 1) + mp_ncpus = 1; + mp_ncpus = MIN(ncpus, MAXCPU); } static boolean_t Modified: head/sys/arm/ti/omap4/omap4_mp.c ============================================================================== --- head/sys/arm/ti/omap4/omap4_mp.c Sun Nov 8 14:22:57 2015 (r290546) +++ head/sys/arm/ti/omap4/omap4_mp.c Sun Nov 8 14:26:50 2015 (r290547) @@ -51,14 +51,14 @@ void platform_mp_setmaxid(void) { - mp_maxid = 1; + mp_maxid = 1; + mp_ncpus = 2; } int platform_mp_probe(void) { - mp_ncpus = 2; return (1); } Modified: head/sys/arm/xilinx/zy7_mp.c ============================================================================== --- head/sys/arm/xilinx/zy7_mp.c Sun Nov 8 14:22:57 2015 (r290546) +++ head/sys/arm/xilinx/zy7_mp.c Sun Nov 8 14:26:50 2015 (r290547) @@ -57,13 +57,13 @@ platform_mp_setmaxid(void) { mp_maxid = 1; + mp_ncpus = 2; } int platform_mp_probe(void) { - mp_ncpus = 2; return (1); } Modified: head/sys/kern/subr_smp.c ============================================================================== --- head/sys/kern/subr_smp.c Sun Nov 8 14:22:57 2015 (r290546) +++ head/sys/kern/subr_smp.c Sun Nov 8 14:26:50 2015 (r290547) @@ -125,7 +125,15 @@ struct mtx smp_ipi_mtx; static void mp_setmaxid(void *dummy) { + cpu_mp_setmaxid(); + + KASSERT(mp_ncpus >= 1, ("%s: CPU count < 1", __func__)); + KASSERT(mp_ncpus > 1 || mp_maxid == 0, + ("%s: one CPU but mp_maxid is not zero", __func__)); + KASSERT(mp_maxid >= mp_ncpus - 1, + ("%s: counters out of sync: max %d, count %d", __func__, + mp_maxid, mp_ncpus)); } SYSINIT(cpu_mp_setmaxid, SI_SUB_TUNABLES, SI_ORDER_FIRST, mp_setmaxid, NULL); Modified: head/sys/x86/x86/mp_x86.c ============================================================================== --- head/sys/x86/x86/mp_x86.c Sun Nov 8 14:22:57 2015 (r290546) +++ head/sys/x86/x86/mp_x86.c Sun Nov 8 14:26:50 2015 (r290547) @@ -425,18 +425,11 @@ cpu_mp_setmaxid(void) { /* - * mp_maxid should be already set by calls to cpu_add(). - * Just sanity check its value here. + * mp_ncpus and mp_maxid should be already set by calls to cpu_add(). + * If there were no calls to cpu_add() assume this is a UP system. */ if (mp_ncpus == 0) - KASSERT(mp_maxid == 0, - ("%s: mp_ncpus is zero, but mp_maxid is not", __func__)); - else if (mp_ncpus == 1) - mp_maxid = 0; - else - KASSERT(mp_maxid >= mp_ncpus - 1, - ("%s: counters out of sync: max %d, count %d", __func__, - mp_maxid, mp_ncpus)); + mp_ncpus = 1; } int @@ -448,28 +441,7 @@ cpu_mp_probe(void) * correctly. */ CPU_SETOF(0, &all_cpus); - if (mp_ncpus == 0) { - /* - * No CPUs were found, so this must be a UP system. Setup - * the variables to represent a system with a single CPU - * with an id of 0. - */ - mp_ncpus = 1; - return (0); - } - - /* At least one CPU was found. */ - if (mp_ncpus == 1) { - /* - * One CPU was found, so this must be a UP system with - * an I/O APIC. - */ - mp_maxid = 0; - return (0); - } - - /* At least two CPUs were found. */ - return (1); + return (mp_ncpus > 1); } /*