Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/broadcom PR port-arm/56264



details:   https://anonhg.NetBSD.org/src/rev/c66cc325a206
branches:  trunk
changeset: 1023284:c66cc325a206
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Sep 01 03:08:08 2021 +0000

description:
PR port-arm/56264

Register all PICs when bcmicu1 is attached, in order to avoid calling
pic_add() from cpu_hatch(), which blocks for aarch64 kernel on RPI3.
This prevented MP kernel to boot due to KASSERT failure as described
in the PR.

This is a kind of a workaround; the real fix should be to

(a) reorganize cpu_hatch() for aarch64 and arm:
http://mail-index.netbsd.org/port-arm/2021/06/21/msg007320.html

(b) or change MI abstraction of ``MP ready'':
http://mail-index.netbsd.org/port-arm/2021/06/22/msg007327.html

However, still, this fix does not bring about any penalty, and it is
not good to leave RPI3 broken for months...

Tested on RPI3 (aarch64 MP, armv7hf MP) as well as RPI1 (armv6hf UP).

diffstat:

 sys/arch/arm/broadcom/bcm2835_intr.c |  46 +++++++++++++++++++++++------------
 1 files changed, 30 insertions(+), 16 deletions(-)

diffs (78 lines):

diff -r 3e87d9b1037e -r c66cc325a206 sys/arch/arm/broadcom/bcm2835_intr.c
--- a/sys/arch/arm/broadcom/bcm2835_intr.c      Tue Aug 31 23:49:21 2021 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_intr.c      Wed Sep 01 03:08:08 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm2835_intr.c,v 1.38 2021/03/08 14:22:42 mlelstv Exp $        */
+/*     $NetBSD: bcm2835_intr.c,v 1.39 2021/09/01 03:08:08 rin Exp $    */
 
 /*-
  * Copyright (c) 2012, 2015, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.38 2021/03/08 14:22:42 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.39 2021/09/01 03:08:08 rin Exp $");
 
 #define _INTR_PRIVATE
 
@@ -359,6 +359,34 @@
 
                ifuncs = &bcm2836mpicu_fdt_funcs;
 
+               /*
+                * XXX
+                * Register all PICs here in order to avoid pic_add() from
+                * cpu_hatch(). See port-arm/56264.
+                */
+               CPU_INFO_ITERATOR cii;
+               struct cpu_info *ci;
+               for (CPU_INFO_FOREACH(cii, ci)) {
+                       const cpuid_t cpuid = ci->ci_core_id;
+                       struct pic_softc * const pic = &bcm2836mp_pic[cpuid];
+
+                       KASSERT(cpuid < BCM2836_NCPUS);
+
+#if defined(MULTIPROCESSOR)
+                       pic->pic_cpus = ci->ci_kcpuset;
+                       /*
+                        * Append "#n" to avoid duplication of .pic_name[]
+                        * It should be a unique id for intr_get_source()
+                        */
+                       char suffix[sizeof("#00000")];
+                       snprintf(suffix, sizeof(suffix), "#%lu", cpuid);
+                       strlcat(pic->pic_name, suffix, sizeof(pic->pic_name));
+#endif
+
+                       bcm2836mp_int_base[cpuid] =
+                           pic_add(pic, PIC_IRQBASE_ALLOC);
+               }
+
                bcm2836mp_intr_init(self, curcpu());
                arm_fdt_cpu_hatch_register(self, bcm2836mp_intr_init);
        } else {
@@ -865,24 +893,10 @@
 bcm2836mp_intr_init(void *priv, struct cpu_info *ci)
 {
        const cpuid_t cpuid = ci->ci_core_id;
-       struct pic_softc * const pic = &bcm2836mp_pic[cpuid];
 
        KASSERT(cpuid < BCM2836_NCPUS);
 
 #if defined(MULTIPROCESSOR)
-       pic->pic_cpus = ci->ci_kcpuset;
-
-       /*
-        * Append "#n" to avoid duplication of .pic_name[]
-        * It should be a unique id for intr_get_source()
-        */
-       char suffix[sizeof("#00000")];
-       snprintf(suffix, sizeof(suffix), "#%lu", cpuid);
-       strlcat(pic->pic_name, suffix, sizeof(pic->pic_name));
-#endif
-       bcm2836mp_int_base[cpuid] = pic_add(pic, PIC_IRQBASE_ALLOC);
-
-#if defined(MULTIPROCESSOR)
        intr_establish(BCM2836_INT_MAILBOX0_CPUN(cpuid), IPL_HIGH,
            IST_LEVEL | IST_MPSAFE, bcm2836mp_ipi_handler, NULL);
 



Home | Main Index | Thread Index | Old Index