Date: Sun, 22 Oct 2017 21:27:08 -0700 From: Mark Millard <markmi@dsl-only.net> To: Emmanuel Vadot <manu@bidouilliste.com>, freebsd-arm <freebsd-arm@freebsd.org> Subject: Why/how I get the panic for mp_ncpu <= cpuid in pcpu_find on the BPI-M3 in my modern code Message-ID: <06B9A4AD-EA28-41A8-91B9-FE368EF622FE@dsl-only.net> In-Reply-To: <BF09EA6D-6DE8-4138-AD92-8836DFF28620@dsl-only.net> References: <3AD6B1F8-512C-43BB-AC76-7721454AD02F@dsl-only.net> <20171021195812.5bdb902401b8e756b6abfe40@bidouilliste.com> <C9F6BF5E-28DB-4569-B71E-EDE2A042FC78@dsl-only.net> <20171021204356.47e3cd6066144bcd07f46699@bidouilliste.com> <50728566-11C2-45EB-8367-00CAF38D4548@dsl-only.net> <B3F39A7C-339B-4072-9E41-A3F9DA1F590B@dsl-only.net> <8696CCFA-AE7D-4324-90A8-BB73402FA124@dsl-only.net> <BF09EA6D-6DE8-4138-AD92-8836DFF28620@dsl-only.net>
next in thread | previous in thread | raw e-mail | index | archive | help
[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 <markmi at dsl-only.net> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?06B9A4AD-EA28-41A8-91B9-FE368EF622FE>