From: kettenis Date: Fri, 23 Feb 2018 19:08:56 +0000 (+0000) Subject: Get rid of the cpu_on_fn hook and call the psci(4) functions directly instead X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=45584b64b56a7a79f7810b5769d32515e13929a2;p=openbsd Get rid of the cpu_on_fn hook and call the psci(4) functions directly instead like we already do in the code that flushes the BTB. ok jsg@ --- diff --git a/sys/arch/arm/arm/cpu.c b/sys/arch/arm/arm/cpu.c index 6a23a685288..573aea7ec9b 100644 --- a/sys/arch/arm/arm/cpu.c +++ b/sys/arch/arm/arm/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.45 2018/01/26 16:22:19 kettenis Exp $ */ +/* $OpenBSD: cpu.c,v 1.46 2018/02/23 19:08:56 kettenis Exp $ */ /* $NetBSD: cpu.c,v 1.56 2004/04/14 04:01:49 bsh Exp $ */ @@ -384,5 +384,3 @@ intr_barrier(void *ih) { sched_barrier(NULL); } - -int (*cpu_on_fn)(register_t, register_t); diff --git a/sys/arch/arm64/arm64/cpu.c b/sys/arch/arm64/arm64/cpu.c index 360c2a430f2..de474b7cec9 100644 --- a/sys/arch/arm64/arm64/cpu.c +++ b/sys/arch/arm64/arm64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.14 2018/02/20 23:46:48 kettenis Exp $ */ +/* $OpenBSD: cpu.c,v 1.15 2018/02/23 19:08:56 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -323,8 +323,6 @@ cpu_clockspeed(int *freq) return 0; } -int (*cpu_on_fn)(register_t, register_t); - #ifdef MULTIPROCESSOR void cpu_boot_secondary(struct cpu_info *ci); @@ -391,8 +389,9 @@ cpu_hatch_secondary(struct cpu_info *ci, int method, uint64_t data) switch (method) { case 1: /* psci */ - if (cpu_on_fn != 0) - rc = !cpu_on_fn(ci->ci_mpidr, startaddr); +#if NPSCI > 0 + rc = (psci_cpu_on(ci->ci_mpidr, startaddr, 0) == PSCI_SUCCESS); +#endif break; case 2: /* spin-table */ diff --git a/sys/dev/fdt/psci.c b/sys/dev/fdt/psci.c index 0dec743dc81..774b15ff89f 100644 --- a/sys/dev/fdt/psci.c +++ b/sys/dev/fdt/psci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: psci.c,v 1.5 2018/01/28 12:48:20 jsg Exp $ */ +/* $OpenBSD: psci.c,v 1.6 2018/02/23 19:08:56 kettenis Exp $ */ /* * Copyright (c) 2016 Jonathan Gray @@ -30,7 +30,6 @@ extern void (*cpuresetfn)(void); extern void (*powerdownfn)(void); -extern int (*cpu_on_fn)(register_t, register_t); #define PSCI_VERSION 0x84000000 #define SYSTEM_OFF 0x84000008 @@ -57,7 +56,6 @@ int psci_match(struct device *, void *, void *); void psci_attach(struct device *, struct device *, void *); void psci_reset(void); void psci_powerdown(void); -int psci_cpu_on(register_t, register_t); extern register_t hvc_call(register_t, register_t, register_t, register_t); extern register_t smc_call(register_t, register_t, register_t, register_t); @@ -123,8 +121,6 @@ psci_attach(struct device *parent, struct device *self, void *aux) powerdownfn = psci_powerdown; if (sc->sc_system_reset != 0) cpuresetfn = psci_reset; - if (sc->sc_cpu_on != 0) - cpu_on_fn = psci_cpu_on; } uint32_t @@ -155,11 +151,15 @@ psci_powerdown(void) (*sc->sc_callfn)(sc->sc_system_off, 0, 0, 0); } -int -psci_cpu_on(register_t mpidr, register_t pc) +int32_t +psci_cpu_on(register_t target_cpu, register_t entry_point_address, + register_t context_id) { struct psci_softc *sc = psci_sc; - if (sc->sc_callfn) - return (*sc->sc_callfn)(sc->sc_cpu_on, mpidr, pc, 0); - return -1; + + if (sc && sc->sc_callfn && sc->sc_cpu_on != 0) + return (*sc->sc_callfn)(sc->sc_cpu_on, target_cpu, + entry_point_address, context_id); + + return PSCI_NOT_SUPPORTED; } diff --git a/sys/dev/fdt/pscivar.h b/sys/dev/fdt/pscivar.h index 77551db3d2a..59d3702670e 100644 --- a/sys/dev/fdt/pscivar.h +++ b/sys/dev/fdt/pscivar.h @@ -3,6 +3,10 @@ #ifndef _SYS_DEV_FDT_PSCIVAR_H_ #define _SYS_DEV_FDT_PSCIVAR_H_ +#define PSCI_SUCCESS 0 +#define PSCI_NOT_SUPPORTED -1 + uint32_t psci_version(void); +int32_t psci_cpu_on(register_t, register_t, register_t); #endif /* _SYS_DEV_FDT_PSCIVAR_H_ */