From: Jan Kiszka <[email protected]> This will be the key to enable PSCI-based CPU hotplugging on the RPi4: Include ATF into the boot process and patch it to provide also the CPU_OFF functionality. The patch is pending for ATF upstream.
Signed-off-by: Jan Kiszka <[email protected]> --- .../arm-trusted-firmware-rpi4_2.2.bb | 28 +++++++++++++ .../arm-trusted-firmware_2.2.inc | 1 + ...001-rpi3-4-Add-support-for-offlining-CPUs.patch | 46 ++++++++++++++++++++++ recipes-bsp/arm-trusted-firmware/files/rpi-rules | 23 +++++++++++ 4 files changed, 98 insertions(+) create mode 100644 recipes-bsp/arm-trusted-firmware/arm-trusted-firmware-rpi4_2.2.bb create mode 100644 recipes-bsp/arm-trusted-firmware/files/0001-rpi3-4-Add-support-for-offlining-CPUs.patch create mode 100644 recipes-bsp/arm-trusted-firmware/files/rpi-rules diff --git a/recipes-bsp/arm-trusted-firmware/arm-trusted-firmware-rpi4_2.2.bb b/recipes-bsp/arm-trusted-firmware/arm-trusted-firmware-rpi4_2.2.bb new file mode 100644 index 0000000..2dd180a --- /dev/null +++ b/recipes-bsp/arm-trusted-firmware/arm-trusted-firmware-rpi4_2.2.bb @@ -0,0 +1,28 @@ +# +# Jailhouse, a Linux-based partitioning hypervisor +# +# Copyright (c) Siemens AG, 2019 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +inherit dpkg + +ATF_PV = "${PV}" + +require arm-trusted-firmware_${PV}.inc + +SRC_URI += "file://rpi-rules" + +S = "${WORKDIR}/arm-trusted-firmware-${PV}" + +do_prepare_build[cleandirs] += "${S}/debian" +do_prepare_build() { + cp ${WORKDIR}/rpi-rules ${WORKDIR}/rules + deb_debianize + + echo "build/rpi4/release/bl31.bin /usr/lib/arm-trusted-firmware/rpi4/" > ${S}/debian/install +} diff --git a/recipes-bsp/arm-trusted-firmware/arm-trusted-firmware_2.2.inc b/recipes-bsp/arm-trusted-firmware/arm-trusted-firmware_2.2.inc index 2281d72..dbf3d8f 100644 --- a/recipes-bsp/arm-trusted-firmware/arm-trusted-firmware_2.2.inc +++ b/recipes-bsp/arm-trusted-firmware/arm-trusted-firmware_2.2.inc @@ -13,5 +13,6 @@ FILESPATH =. "${LAYERDIR_jailhouse}/recipes-bsp/arm-trusted-firmware/files:" SRC_URI += " \ https://github.com/ARM-software/arm-trusted-firmware/archive/v${ATF_PV}.tar.gz;name=atf \ + file://0001-rpi3-4-Add-support-for-offlining-CPUs.patch;patchdir=${WORKDIR}/arm-trusted-firmware-${ATF_PV} \ " SRC_URI[atf.sha256sum] = "07e3c058ae2d95c7d516a46fc93565b797e912c3271ddbf29df523b1ab1ee911" diff --git a/recipes-bsp/arm-trusted-firmware/files/0001-rpi3-4-Add-support-for-offlining-CPUs.patch b/recipes-bsp/arm-trusted-firmware/files/0001-rpi3-4-Add-support-for-offlining-CPUs.patch new file mode 100644 index 0000000..33d288b --- /dev/null +++ b/recipes-bsp/arm-trusted-firmware/files/0001-rpi3-4-Add-support-for-offlining-CPUs.patch @@ -0,0 +1,46 @@ +From 92ff7ed78f8600adc9733663380706a1bdb3e4a9 Mon Sep 17 00:00:00 2001 +From: Jan Kiszka <[email protected]> +Date: Sun, 8 Dec 2019 20:48:46 +0100 +Subject: [PATCH] rpi3/4: Add support for offlining CPUs + +The hooks were populated but the power down left the CPU in limbo-land. +What we need to do - until there is a way to actually power off - is to +turn off the MMU and enter the spinning loop as if we were cold-booted. +This allows the on-call to pick up the CPU again. + +Signed-off-by: Jan Kiszka <[email protected]> +--- + plat/rpi/common/rpi3_pm.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/plat/rpi/common/rpi3_pm.c b/plat/rpi/common/rpi3_pm.c +index 8c2d070c4..2a6bf076b 100644 +--- a/plat/rpi/common/rpi3_pm.c ++++ b/plat/rpi/common/rpi3_pm.c +@@ -123,6 +123,15 @@ static void rpi3_pwr_domain_off(const psci_power_state_t *target_state) + #endif + } + ++void __dead2 plat_secondary_cold_boot_setup(void); ++ ++static void __dead2 ++rpi3_pwr_domain_pwr_down_wfi(const psci_power_state_t *target_state) ++{ ++ disable_mmu_el3(); ++ plat_secondary_cold_boot_setup(); ++} ++ + /******************************************************************************* + * Platform handler called when a power domain is about to be turned on. The + * mpidr determines the CPU to be turned on. +@@ -224,6 +233,7 @@ static void __dead2 rpi3_system_off(void) + static const plat_psci_ops_t plat_rpi3_psci_pm_ops = { + .cpu_standby = rpi3_cpu_standby, + .pwr_domain_off = rpi3_pwr_domain_off, ++ .pwr_domain_pwr_down_wfi = rpi3_pwr_domain_pwr_down_wfi, + .pwr_domain_on = rpi3_pwr_domain_on, + .pwr_domain_on_finish = rpi3_pwr_domain_on_finish, + .system_off = rpi3_system_off, +-- +2.16.4 + diff --git a/recipes-bsp/arm-trusted-firmware/files/rpi-rules b/recipes-bsp/arm-trusted-firmware/files/rpi-rules new file mode 100644 index 0000000..abb65be --- /dev/null +++ b/recipes-bsp/arm-trusted-firmware/files/rpi-rules @@ -0,0 +1,23 @@ +#!/usr/bin/make -f +# +# Jailhouse, a Linux-based partitioning hypervisor +# +# Copyright (c) Siemens AG, 2019 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) +export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)- +endif + +PARALLEL_BUILD=-j $(shell echo $$(($$(nproc) * 2))) + +override_dh_auto_build: + CFLAGS= LDFLAGS= $(MAKE) $(PARALLEL_BUILD) PLAT=rpi4 + +%: + dh $@ -- 2.16.4 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/cdb73c8bfafc1c97fecdbceac8a9c5ee59eeb28b.1579170887.git.jan.kiszka%40siemens.com.
