> Date: Wed, 22 Jan 2025 14:36:04 +0900
> From: FUKAUMI Naoki <na...@radxa.com>
> 
> On 1/22/25 11:49, FUKAUMI Naoki wrote:
> > I found the key to enable the SPCR table in EDK2. I rebuilt the UEFI and 
> > the SPCR table started to appear. But on OpenBSD things got worse, I 
> > lost output on both serial and HDMI...
> 
> ^It was wrong. SPCR is working!

Cool.  I'm still going to look at DBG2 support though.  But
meanwhile...

> 
> [ using 3054328 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-2025 OpenBSD. All rights reserved. 
> https://www.OpenBSD.org
> 
> OpenBSD 7.6-current (GENERIC) #282: Fri Jan 17 13:42:14 MST 2025
>      dera...@arm64.openbsd.org:/usr/src/sys/arch/arm64/compile/GENERIC
> real mem  = 16952713216 (16167MB)
> avail mem = 16293494784 (15538MB)
> random: boothowto does not indicate good seed
> mainbus0 at root: ACPI
> psci0 at mainbus0: PSCI 1.1, SMCCC 1.2, SYSTEM_SUSPEND
> efi0 at mainbus0: UEFI 2.7
> efi0: EDK II rev 0x10000
> smbios0 at efi0: SMBIOS 3.0.0
> smbios0: vendor Radxa Computer (Shenzhen) Co., Ltd. version "1.0" date 
> Jan  1 1980
> smbios0: Radxa Computer (Shenzhen) Co., Ltd. Radxa Orion O6
> cpu0 at mainbus0 mpidr a00: ARM Cortex-A720 r0p1
> cpu0: 64KB 64b/line 4-way L1 PIPT I-cache, 64KB 64b/line 4-way L1 D-cache
> cpu0: 512KB 64b/line 8-way L2 cache
> cpu0: 12288KB 64b/line 12-way L3 cache
> cpu0: 
> TLBIOS+IRANGE,TS+AXFLAG,FHM,DP,SM4,SM3,SHA3,RDM,Atomic,CRC32,SHA2+SHA512,SHA1,AES+PMULL,XS,I8MM,DGH,BF16,SPECRES,SB,FRINTTS,LRCPC+LDAPUR,FCMA,JSCVT,DPB+DCCVADP,WFXT,ECV+CNTHCTL,ASID16,AFP,PAN+ATS1E1+EPAN,LO,HPDS,VH,HAFDBS,ECBHB,IDS,AT,CSV3,CSV2+SCXT,DIT,AdvSIMD+HP,FP+HP,BT,SSBS+MSR,MTE
> apm0 at mainbus0
> agintc0 at mainbus0 shift 4:4 nirq 544 nredist 12: "interrupt-controller"
> agintcmsi0 at agintc0
> agtimer0 at mainbus0: 1000000 kHz
> acpi0 at mainbus0: ACPI 5.1
> acpi0: sleep states
> acpi0: tables DSDT FACP SSDT CSRT DBG2 GTDT IORT SDEI SPCR APIC SSDT MCFG
> acpi0: wakeup devices
> acpiiort0 at acpi0
> acpimcfg0 at acpi0
> acpimcfg0: addr 0x20000000, bus 96-127
> acpimcfg0: addr 0x20000000, bus 48-79
> acpimcfg0: addr 0x20000000, bus 0-31
> "CIXHA016" at acpi0 not configured
> "CIXHA017" at acpi0 not configured
> "CIXHA018" at acpi0 not configured
> pluart0 at acpi0 COM0 addr 0x40b0000/0x10000 irq 328
> pluart1 at acpi0 COM1 addr 0x40c0000/0x10000 irq 329
> pluart2 at acpi0 COM2 addr 0x40d0000/0x10000 irq 330
> "PRP0001" at acpi0 not configured
> "PRP0001" at acpi0 not configured
> "PRP0001" at acpi0 not configured
> "CIXHA019" at acpi0 not configured
> "CIXHA001" at acpi0 not configured
> "CIXHA001" at acpi0 not configured
> "CIXHA001" at acpi0 not configured
> "CIXHA001" at acpi0 not configured
> "CIXHA010" at acpi0 not configured
> "CIXA1019" at acpi0 not configured
> "CIXHA020" at acpi0 not configured
> "CIXHA021" at acpi0 not configured
> "CIXHA018" at acpi0 not configured
> "CIXHA018" at acpi0 not configured
> "CIXH7020" at acpi0 not configured
> "CIXHA004" at acpi0 not configured
> "CIXHA005" at acpi0 not configured
> "CIXHA006" at acpi0 not configured
> "CIXHA008" at acpi0 not configured
> "CIXHA009" at acpi0 not configured
> "CIXHA000" at acpi0 not configured
> "CIXHA007" at acpi0 not configured
> "CIXH6060" at acpi0 not configured
> "CIXH6061" at acpi0 not configured
> "CIXH6062" at acpi0 not configured
> "CIXHA018" at acpi0 not configured
> "CIXH1002" at acpi0 not configured
> "CIXH1003" at acpi0 not configured
> "CIXH1003" at acpi0 not configured
> "CIXH1003" at acpi0 not configured
> "CIXH1003" at acpi0 not configured
> "CIXH1003" at acpi0 not configured
> "CIXH2011" at acpi0 not configured
> "CIXH1007" at acpi0 not configured
> "CIXH6020" at acpi0 not configured
> "CIXHA018" at acpi0 not configured
> "CIXH6000" at acpi0 not configured
> "CIXHA014" at acpi0 not configured
> "CIXH1006" at acpi0 not configured
> "CIXH302C" at acpi0 not configured
> "CIXH3024" at acpi0 not configured
> "CIXH3023" at acpi0 not configured
> "CIXH200B" at acpi0 not configured
> "CIXH200D" at acpi0 not configured
> "CIXH200D" at acpi0 not configured
> "RTL5682" at acpi0 not configured
> "CIXHA011" at acpi0 not configured
> "CIXH200B" at acpi0 not configured
> "RX8900" at acpi0 not configured
> "CIXH3024" at acpi0 not configured
> "CIXH200B" at acpi0 not configured
> "CIXH3024" at acpi0 not configured
> "CIXH200B" at acpi0 not configured
> "CIXH200B" at acpi0 not configured
> "CIXH200D" at acpi0 not configured
> "CIXH200D" at acpi0 not configured
> "CIXH2001" at acpi0 not configured
> "SPT0001" at acpi0 not configured
> "CIXH2001" at acpi0 not configured
> "SPT0002" at acpi0 not configured
> acpipci0 at acpi0 PCI2
> pci0 at acpipci0
> acpipci1 at acpi0 PCI3
> panic: kernel diagnostic assertion "sc->sc_pc->pc_intr_v == NULL" 
> failed: file "
> /usr/src/sys/arch/arm64/dev/acpipci.c", line 203
> Stopped at      panic+0x140:    cmp     w21, #0x0
>      TID    PID    UID     PRFLAGS     PFLAGS  CPU  COMMAND
> *     0      0      0     0x10000      0x200    0  swapper
> db_enter() at panic+0x13c
> panic() at __assert+0x28
> panic() at acpipci_attach+0x3c8
> acpipci_parse_resources() at config_attach+0x210
> config_attach() at acpi_foundhid+0x290
> acpi_foundhid() at aml_find_node+0x7c
> aml_find_node() at aml_find_node+0xa0
> https://www.openbsd.org/ddb.html describes the minimum info required in bug
> reports.  Insufficient info makes it difficult to find and fix bugs.
> ddb>

I think I figured out what went wrong here.  If you know how to apply
patches and build your own kernel the diff below will probably fix the
issue.

If not, this will probably be committed soon and should be included in
the snapshots we build.

P.S. I think you mentioned GENERIC.MP being unstable on your RK3588
     board.  Not sure what board you're using, but the ROCK 5B board
     that I have works quite well with the right power supply.  But
     with other power supplies it doesn't.  I believe that's because
     upstream U-Boot didn't do USB-C PD negotiation.  But it does
     implement that now and I need to look into updating the U-Boot
     version that we build for OpenBSD.


Index: arch/amd64/include/pci_machdep.h
===================================================================
RCS file: /cvs/src/sys/arch/amd64/include/pci_machdep.h,v
diff -u -p -r1.31 pci_machdep.h
--- arch/amd64/include/pci_machdep.h    19 Jan 2024 18:38:16 -0000      1.31
+++ arch/amd64/include/pci_machdep.h    22 Jan 2025 12:51:09 -0000
@@ -103,7 +103,7 @@ pcireg_t    pci_min_powerstate(pci_chipset_
 void           pci_set_powerstate_md(pci_chipset_tag_t, pcitag_t, int, int);
 
 void           pci_mcfg_init(bus_space_tag_t, bus_addr_t, int, int, int);
-pci_chipset_tag_t pci_lookup_segment(int);
+pci_chipset_tag_t pci_lookup_segment(int, int);
 
 #define __HAVE_PCI_MSIX
 
Index: arch/amd64/pci/pci_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/pci/pci_machdep.c,v
diff -u -p -r1.80 pci_machdep.c
--- arch/amd64/pci/pci_machdep.c        13 May 2024 10:01:53 -0000      1.80
+++ arch/amd64/pci/pci_machdep.c        22 Jan 2025 12:51:09 -0000
@@ -160,7 +160,7 @@ pci_mcfg_init(bus_space_tag_t iot, bus_a
 }
 
 pci_chipset_tag_t
-pci_lookup_segment(int segment)
+pci_lookup_segment(int segment, int bus)
 {
        KASSERT(segment == 0);
        return NULL;
Index: arch/arm64/dev/acpipci.c
===================================================================
RCS file: /cvs/src/sys/arch/arm64/dev/acpipci.c,v
diff -u -p -r1.42 acpipci.c
--- arch/arm64/dev/acpipci.c    3 Feb 2024 10:37:25 -0000       1.42
+++ arch/arm64/dev/acpipci.c    22 Jan 2025 12:51:09 -0000
@@ -199,7 +199,7 @@ acpipci_attach(struct device *parent, st
        }
        sc->sc_msi_ic = ic;
 
-       sc->sc_pc = pci_lookup_segment(seg);
+       sc->sc_pc = pci_lookup_segment(sc->sc_seg, sc->sc_bus);
        KASSERT(sc->sc_pc->pc_intr_v == NULL);
 
        sc->sc_pc->pc_probe_device_hook = acpipci_probe_device_hook;
@@ -784,12 +784,13 @@ struct machine_pci_chipset acpipci_dummy
 };
 
 pci_chipset_tag_t
-pci_lookup_segment(int segment)
+pci_lookup_segment(int segment, int bus)
 {
        struct acpipci_mcfg *am;
 
        SLIST_FOREACH(am, &acpipci_mcfgs, am_list) {
-               if (am->am_segment == segment)
+               if (segment == am->am_segment &&
+                   bus >= am->am_min_bus && bus <= am->am_max_bus)
                        return &am->am_pc;
        }
 
Index: arch/arm64/include/pci_machdep.h
===================================================================
RCS file: /cvs/src/sys/arch/arm64/include/pci_machdep.h,v
diff -u -p -r1.12 pci_machdep.h
--- arch/arm64/include/pci_machdep.h    3 Feb 2024 10:37:26 -0000       1.12
+++ arch/arm64/include/pci_machdep.h    22 Jan 2025 12:51:09 -0000
@@ -125,7 +125,7 @@ struct machine_pci_chipset {
 #define        pci_dev_postattach(a, b)
 
 void   pci_mcfg_init(bus_space_tag_t, bus_addr_t, int, int, int);
-pci_chipset_tag_t pci_lookup_segment(int);
+pci_chipset_tag_t pci_lookup_segment(int, int);
 
 int    pci_intr_enable_msivec(struct pci_attach_args *, int);
 
Index: arch/i386/pci/pci_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/pci/pci_machdep.c,v
diff -u -p -r1.88 pci_machdep.c
--- arch/i386/pci/pci_machdep.c 10 Oct 2024 06:00:42 -0000      1.88
+++ arch/i386/pci/pci_machdep.c 22 Jan 2025 12:51:09 -0000
@@ -204,7 +204,7 @@ pci_mcfg_init(bus_space_tag_t iot, bus_a
 }
 
 pci_chipset_tag_t
-pci_lookup_segment(int segment)
+pci_lookup_segment(int segment, int bus)
 {
        KASSERT(segment == 0);
        return NULL;
Index: arch/i386/pci/pci_machdep.h
===================================================================
RCS file: /cvs/src/sys/arch/i386/pci/pci_machdep.h,v
diff -u -p -r1.32 pci_machdep.h
--- arch/i386/pci/pci_machdep.h 17 Jun 2020 06:17:19 -0000      1.32
+++ arch/i386/pci/pci_machdep.h 22 Jan 2025 12:51:09 -0000
@@ -114,7 +114,7 @@ pcireg_t    pci_min_powerstate(pci_chipset_
 void           pci_set_powerstate_md(pci_chipset_tag_t, pcitag_t, int, int);
 
 void           pci_mcfg_init(bus_space_tag_t, bus_addr_t, int, int, int);
-pci_chipset_tag_t pci_lookup_segment(int);
+pci_chipset_tag_t pci_lookup_segment(int, int);
 
 static inline int
 pci_intr_map_msix(struct pci_attach_args *pa, int vec, pci_intr_handle_t *ihp)
Index: dev/acpi/acpi.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
diff -u -p -r1.439 acpi.c
--- dev/acpi/acpi.c     4 Sep 2024 21:39:18 -0000       1.439
+++ dev/acpi/acpi.c     22 Jan 2025 12:51:10 -0000
@@ -324,7 +324,8 @@ acpi_gasio(struct acpi_softc *sc, int io
                        return (0);
                }
 
-               pc = pci_lookup_segment(ACPI_PCI_SEG(address));
+               pc = pci_lookup_segment(ACPI_PCI_SEG(address),
+                   ACPI_PCI_BUS(address));
                tag = pci_make_tag(pc,
                    ACPI_PCI_BUS(address), ACPI_PCI_DEV(address),
                    ACPI_PCI_FN(address));
@@ -642,7 +643,7 @@ acpi_getpci(struct aml_node *node, void 
                free(pci, M_DEVBUF, sizeof(*pci));
                return (1);
        }
-       pc = pci_lookup_segment(pci->seg);
+       pc = pci_lookup_segment(pci->seg, pci->bus);
        tag = pci_make_tag(pc, pci->bus, pci->dev, pci->fun);
        reg = pci_conf_read(pc, tag, PCI_ID_REG);
        if (PCI_VENDOR(reg) == PCI_VENDOR_INVALID) {
@@ -839,7 +840,7 @@ acpi_pci_notify(struct aml_node *node, i
        if (ntype != 2)
                return (0);
 
-       pc = pci_lookup_segment(pdev->seg);
+       pc = pci_lookup_segment(pdev->seg, pdev->bus);
        tag = pci_make_tag(pc, pdev->bus, pdev->dev, pdev->fun);
        if (pci_get_capability(pc, tag, PCI_CAP_PWRMGMT, &offset, 0)) {
                /* Clear the PME Status bit if it is set. */

Reply via email to