git: 4a7fe8305e77 - stable/13 - psci: set psci_present as early as possible

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Wed, 02 Nov 2022 04:11:48 UTC
The branch stable/13 has been updated by kevans:

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

commit 4a7fe8305e7729d8dd77de8517bf31f8f2fcb9a5
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2022-10-27 03:46:45 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2022-11-02 04:11:09 +0000

    psci: set psci_present as early as possible
    
    psci_attach is way too late to provide the intended semantics for
    psci_present.  psci calls can be made immediately after psci_init(),
    called way earlier at SI_SUB_CPU + SI_ORDER_FIRST, and we need it to
    be valid as early as we can possibly call a psci function.
    
    This fixes booting RPi3+4 with the in-review spintable patch;
    rpi3-psci-monitor patches the FDT to add a PSCI node, but it doesn't
    patch each cpus' enable-method.  Because of this, we would stall the
    boot while enabling CPU 1 as we saw a valid looking enable-method and
    "no" functional PSCI and attempted to use the spintable rather than
    simply not starting secondary APs.
    
    Fixes:  2218070b2c3c32 ("psci: finish psci_present implementation")
    Reported by:    karels
    
    (cherry picked from commit 866beaa0aa95deeba467db3dcb605ba3a5048a5b)
---
 sys/dev/psci/psci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/psci/psci.c b/sys/dev/psci/psci.c
index dd760d8e221a..d54ee62fb328 100644
--- a/sys/dev/psci/psci.c
+++ b/sys/dev/psci/psci.c
@@ -146,6 +146,7 @@ psci_init(void *dummy)
 	}
 
 	psci_callfn = new_callfn;
+	psci_present = true;
 }
 /* This needs to be before cpu_mp at SI_SUB_CPU, SI_ORDER_THIRD */
 SYSINIT(psci_start, SI_SUB_CPU, SI_ORDER_FIRST, psci_init, NULL);
@@ -348,7 +349,6 @@ psci_attach(device_t dev, psci_initfn_t psci_init, int default_version)
 		return (ENXIO);
 
 	psci_softc = sc;
-	psci_present = true;
 
 	return (0);
 }