From owner-freebsd-arm@freebsd.org Mon Oct 23 04:27:13 2017 Return-Path: Delivered-To: freebsd-arm@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 0D0B2E3FF95 for ; Mon, 23 Oct 2017 04:27:13 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: from asp.reflexion.net (outbound-mail-211-161.reflexion.net [208.70.211.161]) (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 ACE3C15D2 for ; Mon, 23 Oct 2017 04:27:12 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: (qmail 4271 invoked from network); 23 Oct 2017 04:27:10 -0000 Received: from unknown (HELO mail-cs-02.app.dca.reflexion.local) (10.81.19.2) by 0 (rfx-qmail) with SMTP; 23 Oct 2017 04:27:10 -0000 Received: by mail-cs-02.app.dca.reflexion.local (Reflexion email security v8.40.3) with SMTP; Mon, 23 Oct 2017 00:27:10 -0400 (EDT) Received: (qmail 14420 invoked from network); 23 Oct 2017 04:27:10 -0000 Received: from unknown (HELO iron2.pdx.net) (69.64.224.71) by 0 (rfx-qmail) with (AES256-SHA encrypted) SMTP; 23 Oct 2017 04:27:10 -0000 Received: from [192.168.1.25] (c-76-115-7-162.hsd1.or.comcast.net [76.115.7.162]) by iron2.pdx.net (Postfix) with ESMTPSA id C683FEC8683; Sun, 22 Oct 2017 21:27:09 -0700 (PDT) From: Mark Millard Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Why/how I get the panic for mp_ncpu <= cpuid in pcpu_find on the BPI-M3 in my modern code Date: Sun, 22 Oct 2017 21:27:08 -0700 References: <3AD6B1F8-512C-43BB-AC76-7721454AD02F@dsl-only.net> <20171021195812.5bdb902401b8e756b6abfe40@bidouilliste.com> <20171021204356.47e3cd6066144bcd07f46699@bidouilliste.com> <50728566-11C2-45EB-8367-00CAF38D4548@dsl-only.net> <8696CCFA-AE7D-4324-90A8-BB73402FA124@dsl-only.net> To: Emmanuel Vadot , freebsd-arm In-Reply-To: Message-Id: <06B9A4AD-EA28-41A8-91B9-FE368EF622FE@dsl-only.net> X-Mailer: Apple Mail (2.3273) X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2017 04:27:13 -0000 [Some detail for the "cpuid too large" issue is added: It is my own check that is reporting the panic but what it reports might be a valid problem for all I know.] On 2017-Oct-22, at 2:35 PM, Mark Millard wrote: > . . . >=20 > Mostly this is usb stuff but pcpu_find also > reported "cpuid too large". (BPI-M3's have > 8 cores, 2 clusters of 4, but FreeBSD only > classically enabled/used 4 of the 8: one > cluster.) Not stopping at 4 lead to a panic > via ofw_cpu_attach and dpcpu_alloc. >=20 > . . . . . . 512KB/64B 8-way unified cache WB Read-Alloc Write-Alloc real memory =3D 2147483648 (2048 MB) avail memory =3D 2089463808 (1992 MB) FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs . . . This is from /usr/src/sys/kern/subr_smp.c: printf("FreeBSD/SMP: Multiprocessor System Detected: %d CPUs\n", mp_ncpus); and: /usr/src/sys/arm/include/armreg.h:#define CPUV7_L2CTLR_NPROC(r) = ((((r) >> CPUV7_L2CTLR_NPROC_SHIFT) & 3) + 1) being used in sys/arm/allwinner/aw_mp.c code: void aw_mp_setmaxid(platform_t plat) { int ncpu; uint32_t reg; if (mp_ncpus !=3D 0) return; reg =3D cp15_l2ctlr_get(); ncpu =3D CPUV7_L2CTLR_NPROC(reg); mp_ncpus =3D ncpu; . . . But pcpu_find is being given larger cpuid values (from the unused cores as far as I can tell). [Turns out that I have some code in place for trying to help catch at an earlier stage an intermittent error that I've seen rarely (on powerpc) and that extra code is what is reporting the panic for mp_ncpu <=3D cpuid .] struct pcpu * pcpu_find(u_int cpuid) { if (mp_ncpus =3D=3D 0 && cpuid =3D=3D 0) {} // HACK: This combination is = used in the late bootstrap else if (mp_ncpus <=3D cpuid) { panic("pcpu_find: cpuid too large"); } = // HACK return (cpuid_to_pcpu[cpuid]); } If mp_ncpus <=3D cpuid is supposed to be valid when there are ignored cores/cpus then my hack is reporting a false positive for the BPI-M3 context. But I do not know if mp_ncpus <=3D cpuid is supposed to be valid for such contexts. FYI: /usr/src/sys/kern/subr_pcpu.c:struct pcpu *cpuid_to_pcpu[MAXCPU]; =3D=3D=3D Mark Millard markmi at dsl-only.net