git: b53202779c2e - stable/14 - gicv3: In its_init_cpu_lpi record each cpu's PENDBASER

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 16 Apr 2024 21:42:51 UTC
The branch stable/14 has been updated by imp:

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

commit b53202779c2e39c3ecdcd6bbc86a23f0bdc485aa
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-02-28 14:09:10 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-04-16 21:28:41 +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
    
    (cherry picked from commit 1d13cc200820a020d7875563b036b5f43800ef38)
---
 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 2ab77e1e9966..49d9c08a4ffd 100644
--- a/sys/arm64/arm64/gicv3_its.c
+++ b/sys/arm64/arm64/gicv3_its.c
@@ -46,6 +46,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>
@@ -828,8 +829,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 " : "",