The branch stable/12 has been updated by kevans:

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

commit 354d310fe9871df0cbc3edfd5c3ef61ad39acfbf
Author:     Kyle Evans <[email protected]>
AuthorDate: 2022-03-19 03:03:44 +0000
Commit:     Kyle Evans <[email protected]>
CommitDate: 2022-09-17 19:29:35 +0000

    arm64: gic: disable the ITS if it's enabled prior to configuration
    
    The ITS is defined to be disabled on a warm reset, but we may be coming
    in via another kernel/hypervisor type setup where the ITS has been
    previously configured then relinquished to the next kernel in the chain.
    
    If it's enabled, the later configuration of GITS_BASER will almost
    certainly fail -- clear it to prevent that.
    
    Reviewed by:    andrew
    Sponsored by:   Ampere Computing
    Submitted by:   Klara, Inc.
    
    (cherry picked from commit 1236b04bb7045e541b2343543e356273db20ee56)
---
 sys/arm64/arm64/gicv3_its.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c
index 6521752b5a62..465d01558ae2 100644
--- a/sys/arm64/arm64/gicv3_its.c
+++ b/sys/arm64/arm64/gicv3_its.c
@@ -784,7 +784,7 @@ gicv3_its_attach(device_t dev)
 {
        struct gicv3_its_softc *sc;
        const char *name;
-       uint32_t iidr;
+       uint32_t ctlr, iidr;
        int domain, err, i, rid;
 
        sc = device_get_softc(dev);
@@ -813,6 +813,18 @@ gicv3_its_attach(device_t dev)
                }
        }
 
+       /*
+        * GIT_CTLR_EN is mandated to reset to 0 on a Warm reset, but we may be
+        * coming in via, for instance, a kexec/kboot style setup where a
+        * previous kernel has configured then relinquished control.  Clear it
+        * so that we can reconfigure GITS_BASER*.
+        */
+       ctlr = gic_its_read_4(sc, GITS_CTLR);
+       if ((ctlr & GITS_CTLR_EN) != 0) {
+               ctlr &= ~GITS_CTLR_EN;
+               gic_its_write_4(sc, GITS_CTLR, ctlr);
+       }
+
        /* Allocate the private tables */
        err = gicv3_its_table_init(dev, sc);
        if (err != 0)
@@ -845,8 +857,7 @@ gicv3_its_attach(device_t dev)
                        sc->sc_its_cols[cpu] = NULL;
 
        /* Enable the ITS */
-       gic_its_write_4(sc, GITS_CTLR,
-           gic_its_read_4(sc, GITS_CTLR) | GITS_CTLR_EN);
+       gic_its_write_4(sc, GITS_CTLR, ctlr | GITS_CTLR_EN);
 
        /* Create the LPI configuration table */
        gicv3_its_conftable_init(sc);

Reply via email to