git: 1d13cc200820 - main - gicv3: In its_init_cpu_lpi record each cpu's PENDBASER

From: Warner Losh <imp_at_FreeBSD.org>
Date: Wed, 28 Feb 2024 14:10:47 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=1d13cc200820a020d7875563b036b5f43800ef38

commit 1d13cc200820a020d7875563b036b5f43800ef38
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-02-28 14:09:10 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-02-28 14:09:42 +0000

    gicv3: In its_init_cpu_lpi record each cpu's PENDBASER
    
    When we're using the preallocated memory for gicv3, record each cpu's
    PENDBASER where we'd normally allocate memory for it. Make sure that
    memory is in the excluded list and map the PA to VA and store that, to
    mimic what we do with the allocation case.
    
    Sponsored by:           Netflix
    Reviewed by:            andrew
    Differential Revision:  https://reviews.freebsd.org/D44037
---
 sys/arm64/arm64/gicv3_its.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c
index fa172c871150..71620eec8fce 100644
--- a/sys/arm64/arm64/gicv3_its.c
+++ b/sys/arm64/arm64/gicv3_its.c
@@ -45,6 +45,7 @@
 #include <sys/malloc.h>
 #include <sys/module.h>
 #include <sys/mutex.h>
+#include <sys/physmem.h>
 #include <sys/proc.h>
 #include <sys/taskqueue.h>
 #include <sys/tree.h>
@@ -827,8 +828,18 @@ its_init_cpu_lpi(device_t dev, struct gicv3_its_softc *sc)
 
 		/* Make sure the GIC has seen everything */
 		dsb(sy);
+	} else {
+		KASSERT(sc->sc_pend_base[cpuid] == 0,
+		    ("PREALLOC too soon cpuid %d", cpuid));
+		tmp = gic_r_read_8(gicv3, GICR_PENDBASER);
+		tmp &= GICR_PENDBASER_PA_MASK;
+		if (!physmem_excluded(tmp, LPI_PENDTAB_SIZE))
+			panic("gicv3 PENDBASER on cpu %d needs to reuse 0x%#lx, but not reserved\n",
+			    cpuid, tmp);
+		sc->sc_pend_base[cpuid] = PHYS_TO_DMAP(tmp);
 	}
 
+
 	if (bootverbose)
 		device_printf(gicv3, "using %sPENDBASE of %#lx on cpu %d\n",
 		    (sc->sc_its_flags & ITS_FLAGS_LPI_PREALLOC) ? "pre-existing " : "",