Re: bcmintc(4) diff for raspberry pi3

2021-05-22 Thread Stuart Henderson
On 2021/05/22 12:06, Mark Kettenis wrote:
> Can't find my raspberry pi3 right now.  But here is a diff that avoids
> spinning with interrupts disabled while trying to grab the kernel lock
> for it.  I'd appreciate it if somebody could give this a spin for me.
> Just checking whether it works normally for a bit would be fine.

Seems OK so far.

booting sd0a:/bsd: 8935756+1804632+570032+831592 
[648870+109+1086336+636102]=0xf99638
type 0x0 pa 0x0 va 0x0 pages 0x1 attr 0x8
type 0x7 pa 0x1000 va 0x1000 pages 0x1ff attr 0x8
type 0x2 pa 0x20 va 0x20 pages 0x4000 attr 0x8
type 0x7 pa 0x420 va 0x420 pages 0x3cf5 attr 0x8
type 0x9 pa 0x7ef5000 va 0x7ef5000 pages 0x16 attr 0x8
type 0x7 pa 0x7f0b000 va 0x7f0b000 pages 0x3119d attr 0x8
type 0x2 pa 0x390a8000 va 0x390a8000 pages 0xd5b attr 0x8
type 0x4 pa 0x39e03000 va 0x39e03000 pages 0x1 attr 0x8
type 0x2 pa 0x39e04000 va 0x39e04000 pages 0x3 attr 0x8
type 0x7 pa 0x39e07000 va 0x39e07000 pages 0x1 attr 0x8
type 0x2 pa 0x39e08000 va 0x39e08000 pages 0x100 attr 0x8
type 0x1 pa 0x39f08000 va 0x39f08000 pages 0x2a attr 0x8
type 0x0 pa 0x39f32000 va 0x39f32000 pages 0x7 attr 0x8
type 0x4 pa 0x39f39000 va 0x39f39000 pages 0x1 attr 0x8
type 0x6 pa 0x39f3a000 va 0x5144e2a000 pages 0x1 attr 0x8008
type 0x4 pa 0x39f3b000 va 0x39f3b000 pages 0x2 attr 0x8
type 0x0 pa 0x39f3d000 va 0x39f3d000 pages 0x1 attr 0x8
type 0x6 pa 0x39f3e000 va 0x5144e2e000 pages 0x3 attr 0x8008
type 0x4 pa 0x39f41000 va 0x39f41000 pages 0x1 attr 0x8
type 0x6 pa 0x39f42000 va 0x5144e32000 pages 0x4 attr 0x8008
type 0x0 pa 0x39f46000 va 0x39f46000 pages 0x1 attr 0x8
type 0x4 pa 0x39f47000 va 0x39f47000 pages 0x1 attr 0x8
type 0x0 pa 0x39f48000 va 0x39f48000 pages 0x1 attr 0x8
type 0x4 pa 0x39f49000 va 0x39f49000 pages 0x2 attr 0x8
type 0x0 pa 0x39f4b000 va 0x39f4b000 pages 0x1 attr 0x8
type 0x4 pa 0x39f4c000 va 0x39f4c000 pages 0x2 attr 0x8
type 0x2 pa 0x39f4e000 va 0x39f4e000 pages 0x1402 attr 0x8
type 0x5 pa 0x3b35 va 0x514624 pages 0x10 attr 0x8008
type 0x2 pa 0x3b36 va 0x3b36 pages 0xa0 attr 0x8
type 0xb pa 0x3f10 va 0x514625 pages 0x1 attr 0x8000
[ using 2372384 bytes of bsd ELF symbol table ]
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2021 OpenBSD. All rights reserved.  https://www.OpenBSD.org

OpenBSD 6.9-current (GENERIC.MP) #3: Sat May 22 14:49:21 BST 2021
st...@mala.spacehopper.org:/sys/arch/arm64/compile/GENERIC.MP
real mem  = 956895232 (912MB)
avail mem = 895025152 (853MB)
random: good seed from bootblocks
mainbus0 at root: Raspberry Pi 3 Model B Rev 1.2
cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4
cpu0: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
cpu0: 512KB 64b/line 16-way L2 cache
cpu0: CRC32,ASID16
cpu1 at mainbus0 mpidr 1: ARM Cortex-A53 r0p4
cpu1: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
cpu1: 512KB 64b/line 16-way L2 cache
cpu1: CRC32,ASID16
cpu2 at mainbus0 mpidr 2: ARM Cortex-A53 r0p4
cpu2: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
cpu2: 512KB 64b/line 16-way L2 cache
cpu2: CRC32,ASID16
cpu3 at mainbus0 mpidr 3: ARM Cortex-A53 r0p4
cpu3: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
cpu3: 512KB 64b/line 16-way L2 cache
cpu3: CRC32,ASID16
efi0 at mainbus0: UEFI 2.8
efi0: Das U-Boot rev 0x20210400
apm0 at mainbus0
simplefb0 at mainbus0: 656x416, 32bpp
wsdisplay0 at simplefb0 mux 1
wsdisplay0: screen 0-5 added (std, vt100 emulation)
"system" at mainbus0 not configured
"axi" at mainbus0 not configured
simplebus0 at mainbus0: "soc"
bcmclock0 at simplebus0
bcmmbox0 at simplebus0
bcmgpio0 at simplebus0
bcmaux0 at simplebus0
bcmdmac0 at simplebus0: DMA0 DMA2 DMA4 DMA5 DMA8 DMA9 DMA10
bcmintc0 at simplebus0
pluart0 at simplebus0: console
bcmsdhost0 at simplebus0: 250 MHz base clock
sdmmc0 at bcmsdhost0: 4-bit, sd high-speed, mmc high-speed, dma
dwctwo0 at simplebus0
bcmdog0 at simplebus0
bcmrng0 at simplebus0
bcmtemp0 at simplebus0
"local_intc" at simplebus0 not configured
sdhc0 at simplebus0
sdhc0: SDHC 3.0, 200 MHz base clock
sdmmc1 at sdhc0: 4-bit, sd high-speed, mmc high-speed
"firmware" at simplebus0 not configured
"power" at simplebus0 not configured
"mailbox" at simplebus0 not configured
"gpiomem" at simplebus0 not configured
"fb" at simplebus0 not configured
"vcsm" at simplebus0 not configured
"virtgpio" at simplebus0 not configured
"clocks" at mainbus0 not configured
"phy" at mainbus0 not configured
"arm-pmu" at mainbus0 not configured
agtimer0 at mainbus0: 19200 kHz
"leds" at mainbus0 not configured
"fixedregulator_3v3" at mainbus0 not configured
"fixedregulator_5v0" at mainbus0 not configured
"bootloader" at mainbus0 not configured
dt: 443 probes
usb0 at dwctwo0: USB revision 2.0
sdmmc0: can't enable card
uhub0 at usb0 configuration 1 interface 0 "Broadcom DWC2 root hub" rev 
2.00/1.00 

bcmintc(4) diff for raspberry pi3

2021-05-22 Thread Mark Kettenis
Can't find my raspberry pi3 right now.  But here is a diff that avoids
spinning with interrupts disabled while trying to grab the kernel lock
for it.  I'd appreciate it if somebody could give this a spin for me.
Just checking whether it works normally for a bit would be fine.

Thanks,

Mark


Index: arch/arm64/dev/bcm2836_intr.c
===
RCS file: /cvs/src/sys/arch/arm64/dev/bcm2836_intr.c,v
retrieving revision 1.11
diff -u -p -r1.11 bcm2836_intr.c
--- arch/arm64/dev/bcm2836_intr.c   15 May 2021 11:30:27 -  1.11
+++ arch/arm64/dev/bcm2836_intr.c   22 May 2021 10:03:37 -
@@ -96,8 +96,8 @@ struct intrsource {
 
 struct bcm_intc_softc {
struct devicesc_dev;
-   struct intrsourcesc_bcm_intc_handler[INTC_NIRQ];
-   uint32_t sc_bcm_intc_imask[INTC_NBANK][NIPL];
+   struct intrsourcesc_handler[INTC_NIRQ];
+   uint32_t sc_imask[INTC_NBANK][NIPL];
int32_t  sc_localcoremask[MAXCPUS];
bus_space_tag_t  sc_iot;
bus_space_handle_t   sc_ioh;
@@ -115,11 +115,11 @@ intbcm_intc_splraise(int new);
 voidbcm_intc_setipl(int new);
 voidbcm_intc_calc_mask(void);
 void   *bcm_intc_intr_establish(int, int, struct cpu_info *,
-int (*)(void *), void *, char *);
+   int (*)(void *), void *, char *);
 void   *bcm_intc_intr_establish_fdt(void *, int *, int, struct cpu_info *,
-int (*)(void *), void *, char *);
+   int (*)(void *), void *, char *);
 void   *l1_intc_intr_establish_fdt(void *, int *, int, struct cpu_info *,
-int (*)(void *), void *, char *);
+   int (*)(void *), void *, char *);
 voidbcm_intc_intr_disestablish(void *);
 voidbcm_intc_irq_handler(void *);
 voidbcm_intc_intr_route(void *, int , struct cpu_info *);
@@ -204,7 +204,7 @@ bcm_intc_attach(struct device *parent, s
ARM_LOCAL_INT_MAILBOX(i), 0);
 
for (i = 0; i < INTC_NIRQ; i++) {
-   TAILQ_INIT(>sc_bcm_intc_handler[i].is_list);
+   TAILQ_INIT(>sc_handler[i].is_list);
}
 
bcm_intc_calc_mask();
@@ -239,13 +239,13 @@ bcm_intc_intr_enable(int irq, int ipl)
struct bcm_intc_softc   *sc = bcm_intc;
 
if (IS_IRQ_BANK0(irq))
-   sc->sc_bcm_intc_imask[0][ipl] |= (1 << IRQ_BANK0(irq));
+   sc->sc_imask[0][ipl] |= (1 << IRQ_BANK0(irq));
else if (IS_IRQ_BANK1(irq))
-   sc->sc_bcm_intc_imask[1][ipl] |= (1 << IRQ_BANK1(irq));
+   sc->sc_imask[1][ipl] |= (1 << IRQ_BANK1(irq));
else if (IS_IRQ_BANK2(irq))
-   sc->sc_bcm_intc_imask[2][ipl] |= (1 << IRQ_BANK2(irq));
+   sc->sc_imask[2][ipl] |= (1 << IRQ_BANK2(irq));
else if (IS_IRQ_LOCAL(irq))
-   sc->sc_bcm_intc_imask[3][ipl] |= (1 << IRQ_LOCAL(irq));
+   sc->sc_imask[3][ipl] |= (1 << IRQ_LOCAL(irq));
else
printf("%s: invalid irq number: %d\n", __func__, irq);
 }
@@ -256,13 +256,13 @@ bcm_intc_intr_disable(int irq, int ipl)
struct bcm_intc_softc   *sc = bcm_intc;
 
if (IS_IRQ_BANK0(irq))
-   sc->sc_bcm_intc_imask[0][ipl] &= ~(1 << IRQ_BANK0(irq));
+   sc->sc_imask[0][ipl] &= ~(1 << IRQ_BANK0(irq));
else if (IS_IRQ_BANK1(irq))
-   sc->sc_bcm_intc_imask[1][ipl] &= ~(1 << IRQ_BANK1(irq));
+   sc->sc_imask[1][ipl] &= ~(1 << IRQ_BANK1(irq));
else if (IS_IRQ_BANK2(irq))
-   sc->sc_bcm_intc_imask[2][ipl] &= ~(1 << IRQ_BANK2(irq));
+   sc->sc_imask[2][ipl] &= ~(1 << IRQ_BANK2(irq));
else if (IS_IRQ_LOCAL(irq))
-   sc->sc_bcm_intc_imask[3][ipl] &= ~(1 << IRQ_LOCAL(irq));
+   sc->sc_imask[3][ipl] &= ~(1 << IRQ_LOCAL(irq));
else
printf("%s: invalid irq number: %d\n", __func__, irq);
 }
@@ -279,8 +279,7 @@ bcm_intc_calc_mask(void)
for (irq = 0; irq < INTC_NIRQ; irq++) {
int max = IPL_NONE;
int min = IPL_HIGH;
-   TAILQ_FOREACH(ih, >sc_bcm_intc_handler[irq].is_list,
-   ih_list) {
+   TAILQ_FOREACH(ih, >sc_handler[irq].is_list, ih_list) {
if (ih->ih_ipl > max)
max = ih->ih_ipl;
 
@@ -288,7 +287,7 @@ bcm_intc_calc_mask(void)
min = ih->ih_ipl;
}
 
-   sc->sc_bcm_intc_handler[irq].is_irq = max;
+   sc->sc_handler[irq].is_irq = max;
 
if (max == IPL_NONE)
min = IPL_NONE;
@@ -369,16 +368,16 @@ bcm_intc_setipl(int new)
bus_space_write_4(sc->sc_iot, sc->sc_ioh, INTC_DISABLE_BANK2,
0x);
bus_space_write_4(sc->sc_iot, sc->sc_ioh, INTC_ENABLE_BANK0,
-   sc->sc_bcm_intc_imask[0][new]);