|
| 1 | +From bd975fbcff8886b3d3ed3268d7b6fa41bd7fba2d Mon Sep 17 00:00:00 2001 |
| 2 | +From: Harsimran Singh Tungal <harsimransingh.tungal@arm.com> |
| 3 | +Date: Thu, 9 May 2024 16:59:34 +0000 |
| 4 | +Subject: [PATCH] feat(corstone1000): add multicore support for fvp |
| 5 | + |
| 6 | +This changeset adds the multicore support for the Corstone-1000 FVP. |
| 7 | +It adds the PSCI CPU_ON and CPU_ON_FINISH power domain functionalities |
| 8 | +for the secondary cores. |
| 9 | + |
| 10 | +Upstream-Status: Backport [https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/29176] |
| 11 | +Signed-off-by: Harsimran Singh Tungal <harsimransingh.tungal@arm.com> |
| 12 | +--- |
| 13 | + .../common/corstone1000_helpers.S | 26 +++++++++++ |
| 14 | + .../corstone1000/common/corstone1000_pm.c | 43 ++++++++++++++++++- |
| 15 | + .../common/include/platform_def.h | 15 ++++++- |
| 16 | + plat/arm/board/corstone1000/platform.mk | 8 ++++ |
| 17 | + 4 files changed, 90 insertions(+), 2 deletions(-) |
| 18 | + |
| 19 | +diff --git a/plat/arm/board/corstone1000/common/corstone1000_helpers.S b/plat/arm/board/corstone1000/common/corstone1000_helpers.S |
| 20 | +index cbe27c3b5..90dc4fee6 100644 |
| 21 | +--- a/plat/arm/board/corstone1000/common/corstone1000_helpers.S |
| 22 | ++++ b/plat/arm/board/corstone1000/common/corstone1000_helpers.S |
| 23 | +@@ -21,8 +21,34 @@ |
| 24 | + * -------------------------------------------------------------------- |
| 25 | + */ |
| 26 | + func plat_secondary_cold_boot_setup |
| 27 | ++#if defined(CORSTONE1000_FVP_MULTICORE) |
| 28 | ++ |
| 29 | ++ /* Calculate the address of our hold entry */ |
| 30 | ++ bl plat_my_core_pos |
| 31 | ++ lsl x0, x0, #CORSTONE1000_SECONDARY_CORE_HOLD_SHIFT |
| 32 | ++ mov_imm x2, CORSTONE1000_SECONDARY_CORE_HOLD_BASE |
| 33 | ++ |
| 34 | ++ /* Set the wait state for the secondary core */ |
| 35 | ++ mov_imm x3, CORSTONE1000_SECONDARY_CORE_STATE_WAIT |
| 36 | ++ str x3, [x2, x0] |
| 37 | ++ dmb ish |
| 38 | ++ |
| 39 | ++ /* Poll until the primary core signals to go */ |
| 40 | ++poll_mailbox: |
| 41 | ++ ldr x1, [x2, x0] |
| 42 | ++ cmp x1, #CORSTONE1000_SECONDARY_CORE_STATE_WAIT |
| 43 | ++ beq 1f |
| 44 | ++ mov_imm x0, PLAT_ARM_TRUSTED_MAILBOX_BASE |
| 45 | ++ ldr x1, [x0] |
| 46 | ++ br x1 |
| 47 | ++1: |
| 48 | ++ wfe |
| 49 | ++ b poll_mailbox |
| 50 | ++#else |
| 51 | + cb_panic: |
| 52 | + b cb_panic |
| 53 | ++#endif |
| 54 | ++ |
| 55 | + endfunc plat_secondary_cold_boot_setup |
| 56 | + |
| 57 | + /* --------------------------------------------------------------------- |
| 58 | +diff --git a/plat/arm/board/corstone1000/common/corstone1000_pm.c b/plat/arm/board/corstone1000/common/corstone1000_pm.c |
| 59 | +index 4b0a791e7..9cd384e18 100644 |
| 60 | +--- a/plat/arm/board/corstone1000/common/corstone1000_pm.c |
| 61 | ++++ b/plat/arm/board/corstone1000/common/corstone1000_pm.c |
| 62 | +@@ -24,10 +24,51 @@ static void __dead2 corstone1000_system_reset(void) |
| 63 | + wfi(); |
| 64 | + } |
| 65 | + } |
| 66 | ++#if defined(CORSTONE1000_FVP_MULTICORE) |
| 67 | ++int corstone1000_validate_ns_entrypoint(uintptr_t entrypoint) |
| 68 | ++{ |
| 69 | ++ /* |
| 70 | ++ * Check if the non secure entrypoint lies within the non |
| 71 | ++ * secure DRAM. |
| 72 | ++ */ |
| 73 | ++ if ((entrypoint >= ARM_NS_DRAM1_BASE) && (entrypoint < (ARM_NS_DRAM1_BASE + ARM_NS_DRAM1_SIZE))) { |
| 74 | ++ return PSCI_E_SUCCESS; |
| 75 | ++ } |
| 76 | ++ return PSCI_E_INVALID_ADDRESS; |
| 77 | ++} |
| 78 | ++ |
| 79 | ++int corstone1000_pwr_domain_on(u_register_t mpidr) |
| 80 | ++{ |
| 81 | ++ int core_index = plat_core_pos_by_mpidr(mpidr); |
| 82 | ++ uint64_t *secondary_core_hold_base = (uint64_t *)CORSTONE1000_SECONDARY_CORE_HOLD_BASE; |
| 83 | ++ |
| 84 | ++ /* Validate the core index */ |
| 85 | ++ if ((core_index < 0) || (core_index > PLATFORM_CORE_COUNT)) { |
| 86 | ++ return PSCI_E_INVALID_PARAMS; |
| 87 | ++ } |
| 88 | ++ secondary_core_hold_base[core_index] = CORSTONE1000_SECONDARY_CORE_STATE_GO; |
| 89 | ++ dsbish(); |
| 90 | ++ sev(); |
| 91 | ++ |
| 92 | ++ return PSCI_E_SUCCESS; |
| 93 | ++} |
| 94 | + |
| 95 | ++void corstone1000_pwr_domain_on_finish(const psci_power_state_t *target_state) |
| 96 | ++{ |
| 97 | ++ (void)target_state; |
| 98 | ++ plat_arm_gic_init(); |
| 99 | ++} |
| 100 | ++#endif |
| 101 | + plat_psci_ops_t plat_arm_psci_pm_ops = { |
| 102 | ++#if defined(CORSTONE1000_FVP_MULTICORE) |
| 103 | ++ .pwr_domain_on = corstone1000_pwr_domain_on, |
| 104 | ++ .pwr_domain_on_finish = corstone1000_pwr_domain_on_finish, |
| 105 | ++ .validate_ns_entrypoint = corstone1000_validate_ns_entrypoint, |
| 106 | ++ .system_reset = corstone1000_system_reset, |
| 107 | ++#else |
| 108 | ++ .validate_ns_entrypoint = NULL, |
| 109 | + .system_reset = corstone1000_system_reset, |
| 110 | +- .validate_ns_entrypoint = NULL |
| 111 | ++#endif |
| 112 | + }; |
| 113 | + |
| 114 | + const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops) |
| 115 | +diff --git a/plat/arm/board/corstone1000/common/include/platform_def.h b/plat/arm/board/corstone1000/common/include/platform_def.h |
| 116 | +index 35bb6ad5c..56e124f96 100644 |
| 117 | +--- a/plat/arm/board/corstone1000/common/include/platform_def.h |
| 118 | ++++ b/plat/arm/board/corstone1000/common/include/platform_def.h |
| 119 | +@@ -251,7 +251,20 @@ |
| 120 | + */ |
| 121 | + #define ARM_LOCAL_STATE_OFF U(2) |
| 122 | + |
| 123 | +-#define PLAT_ARM_TRUSTED_MAILBOX_BASE ARM_TRUSTED_SRAM_BASE |
| 124 | ++#define PLAT_ARM_TRUSTED_MAILBOX_BASE ARM_TRUSTED_SRAM_BASE |
| 125 | ++ |
| 126 | ++#if defined(CORSTONE1000_FVP_MULTICORE) |
| 127 | ++/* The secondary core entrypoint address points to bl31_warm_entrypoint |
| 128 | ++ * and the address size is 8 bytes */ |
| 129 | ++#define CORSTONE1000_SECONDARY_CORE_ENTRYPOINT_ADDRESS_SIZE UL(0x8) |
| 130 | ++ |
| 131 | ++#define CORSTONE1000_SECONDARY_CORE_HOLD_BASE (PLAT_ARM_TRUSTED_MAILBOX_BASE + \ |
| 132 | ++ CORSTONE1000_SECONDARY_CORE_ENTRYPOINT_ADDRESS_SIZE) |
| 133 | ++#define CORSTONE1000_SECONDARY_CORE_STATE_WAIT ULL(0) |
| 134 | ++#define CORSTONE1000_SECONDARY_CORE_STATE_GO ULL(1) |
| 135 | ++#define CORSTONE1000_SECONDARY_CORE_HOLD_SHIFT ULL(3) |
| 136 | ++#endif |
| 137 | ++ |
| 138 | + #define PLAT_ARM_NSTIMER_FRAME_ID U(1) |
| 139 | + |
| 140 | + #define PLAT_ARM_NS_IMAGE_BASE (BL33_BASE) |
| 141 | +diff --git a/plat/arm/board/corstone1000/platform.mk b/plat/arm/board/corstone1000/platform.mk |
| 142 | +index dcd0df844..71b7f324c 100644 |
| 143 | +--- a/plat/arm/board/corstone1000/platform.mk |
| 144 | ++++ b/plat/arm/board/corstone1000/platform.mk |
| 145 | +@@ -31,6 +31,14 @@ override NEED_BL31 := yes |
| 146 | + NEED_BL32 := yes |
| 147 | + override NEED_BL33 := yes |
| 148 | + |
| 149 | ++ENABLE_MULTICORE := 0 |
| 150 | ++ifneq ($(filter ${TARGET_PLATFORM}, fvp),) |
| 151 | ++ifeq (${ENABLE_MULTICORE},1) |
| 152 | ++$(eval $(call add_define,CORSTONE1000_FVP_MULTICORE)) |
| 153 | ++endif |
| 154 | ++endif |
| 155 | ++ |
| 156 | ++ |
| 157 | + # Include GICv2 driver files |
| 158 | + include drivers/arm/gic/v2/gicv2.mk |
| 159 | + |
| 160 | +-- |
| 161 | +2.34.1 |
| 162 | + |
0 commit comments