From: Achin Gupta Date: Thu, 26 Jun 2014 10:12:37 +0000 (+0100) Subject: Remove the concept of coherent stacks X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=539a7b383d52493a94df4f5da8f74aa102429fa0;p=project%2Fbcm63xx%2Fatf.git Remove the concept of coherent stacks This patch removes the allocation of memory for coherent stacks, associated accessor function and some dead code which called the accessor function. It also updates the porting guide to remove the concept and the motivation behind using stacks allocated in coherent memory. Fixes ARM-software/tf-issues#198 Change-Id: I00ff9a04f693a03df3627ba39727e3497263fc38 --- diff --git a/docs/porting-guide.md b/docs/porting-guide.md index 813d0be6..2bd1b561 100644 --- a/docs/porting-guide.md +++ b/docs/porting-guide.md @@ -104,12 +104,6 @@ file is found in [plat/fvp/include/platform_def.h]. by [plat/common/aarch64/platform_mp_stack.S] and [plat/common/aarch64/platform_up_stack.S]. -* **#define : PCPU_DV_MEM_STACK_SIZE** - - Defines the coherent stack memory available to each CPU. This constant is used - by [plat/common/aarch64/platform_mp_stack.S] and - [plat/common/aarch64/platform_up_stack.S]. - * **#define : FIRMWARE_WELCOME_STR** Defines the character string printed by BL1 upon entry into the `bl1_main()` @@ -395,31 +389,6 @@ maximum of 4 CPUs: cluster_id = 8-bit value in MPIDR at affinity level 1 -### Function : platform_set_coherent_stack() - - Argument : unsigned long - Return : void - -A platform may need stack memory that is coherent with main memory to perform -certain operations like: - -* Turning the MMU on, or -* Flushing caches prior to powering down a CPU or cluster. - -Each BL stage allocates this coherent stack memory for each CPU in the -`tzfw_coherent_mem` section. - -This function sets the current stack pointer to the coherent stack that -has been allocated for the CPU specified by MPIDR. For BL images that only -require a stack for the primary CPU the parameter is ignored. The size of -the stack allocated to each CPU is specified by the platform defined constant -`PCPU_DV_MEM_STACK_SIZE`. - -Common implementations of this function for the UP and MP BL images are -provided in [plat/common/aarch64/platform_up_stack.S] and -[plat/common/aarch64/platform_mp_stack.S] - - ### Function : platform_is_primary_cpu() Argument : unsigned long @@ -1116,11 +1085,6 @@ the calling CPU is the last powered on CPU in the cluster, after powering down affinity level 0 (CPU), the platform port should power down affinity level 1 (the cluster) as well. -This function is called with coherent stacks. This allows the PSCI -implementation to flush caches at a given affinity level without running into -stale stack state after turning off the caches. On ARMv8-A cache hits do not -occur after the cache has been turned off. - #### plat_pm_ops.affinst_suspend() Perform the platform specific setup to power off an affinity instance in the @@ -1143,11 +1107,6 @@ case, the affinity instance is expected to save enough state so that it can resume execution by restoring this state when its powered on (see `affinst_suspend_finish()`). -This function is called with coherent stacks. This allows the PSCI -implementation to flush caches at a given affinity level without running into -stale stack state after turning off the caches. On ARMv8-A cache hits do not -occur after the cache has been turned off. - #### plat_pm_ops.affinst_on_finish() This function is called by the PSCI implementation after the calling CPU is @@ -1159,11 +1118,6 @@ services. The `MPIDR` (first argument), `affinity level` (second argument) and `state` (third argument) have a similar meaning as described in the previous operations. -This function is called with coherent stacks. This allows the PSCI -implementation to flush caches at a given affinity level without running into -stale stack state after turning off the caches. On ARMv8-A cache hits do not -occur after the cache has been turned off. - #### plat_pm_ops.affinst_on_suspend() This function is called by the PSCI implementation after the calling CPU is @@ -1176,11 +1130,6 @@ and also provide secure runtime firmware services. The `MPIDR` (first argument), `affinity level` (second argument) and `state` (third argument) have a similar meaning as described in the previous operations. -This function is called with coherent stacks. This allows the PSCI -implementation to flush caches at a given affinity level without running into -stale stack state after turning off the caches. On ARMv8-A cache hits do not -occur after the cache has been turned off. - BL3-1 platform initialization code must also detect the system topology and the state of each affinity instance in the topology. This information is critical for the PSCI runtime service to function correctly. More details are diff --git a/plat/common/aarch64/platform_mp_stack.S b/plat/common/aarch64/platform_mp_stack.S index 801ec7fa..8eb1aa68 100644 --- a/plat/common/aarch64/platform_mp_stack.S +++ b/plat/common/aarch64/platform_mp_stack.S @@ -33,28 +33,11 @@ #include - .local pcpu_dv_mem_stack .local platform_normal_stacks .weak platform_set_stack .weak platform_get_stack - .weak platform_set_coherent_stack - /* ----------------------------------------------------- - * void platform_set_coherent_stack (unsigned long mpidr) - * - * For a given CPU, this function sets the stack pointer - * to a stack allocated in device memory. This stack can - * be used by C code which enables/disables the SCTLR.M - * SCTLR.C bit e.g. while powering down a cpu - * ----------------------------------------------------- - */ -func platform_set_coherent_stack - mov x5, x30 // lr - get_mp_stack pcpu_dv_mem_stack, PCPU_DV_MEM_STACK_SIZE - mov sp, x0 - ret x5 - /* ----------------------------------------------------- * unsigned long platform_get_stack (unsigned long mpidr) * @@ -81,22 +64,9 @@ func platform_set_stack ret x9 /* ----------------------------------------------------- - * Per-cpu stacks in normal memory. - * Used for C code during runtime execution (when coherent - * stacks are not required). - * Each cpu gets a stack of PLATFORM_STACK_SIZE bytes. + * Per-cpu stacks in normal memory. Each cpu gets a + * stack of PLATFORM_STACK_SIZE bytes. * ----------------------------------------------------- */ declare_stack platform_normal_stacks, tzfw_normal_stacks, \ PLATFORM_STACK_SIZE, PLATFORM_CORE_COUNT - - /* ----------------------------------------------------- - * Per-cpu stacks in device memory. - * Used for C code just before power down or right after - * power up when the MMU or caches need to be turned on - * or off. - * Each cpu gets a stack of PCPU_DV_MEM_STACK_SIZE bytes. - * ----------------------------------------------------- - */ -declare_stack pcpu_dv_mem_stack, tzfw_coherent_mem, \ - PCPU_DV_MEM_STACK_SIZE, PLATFORM_CORE_COUNT diff --git a/plat/common/aarch64/platform_up_stack.S b/plat/common/aarch64/platform_up_stack.S index 45a96a64..73b74b2e 100644 --- a/plat/common/aarch64/platform_up_stack.S +++ b/plat/common/aarch64/platform_up_stack.S @@ -33,26 +33,9 @@ #include - .local pcpu_dv_mem_stack .local platform_normal_stacks .globl platform_set_stack .globl platform_get_stack - .globl platform_set_coherent_stack - - - /* ----------------------------------------------------- - * void platform_set_coherent_stack (unsigned long) - * - * For cold-boot BL images, only the primary CPU needs a - * stack. This function sets the stack pointer to a stack - * allocated in device memory. - * ----------------------------------------------------- - */ -func platform_set_coherent_stack - get_up_stack pcpu_dv_mem_stack, PCPU_DV_MEM_STACK_SIZE - mov sp, x0 - ret - /* ----------------------------------------------------- * unsigned long platform_get_stack (unsigned long) @@ -87,11 +70,3 @@ func platform_set_stack */ declare_stack platform_normal_stacks, tzfw_normal_stacks, \ PLATFORM_STACK_SIZE, 1 - - /* ----------------------------------------------------- - * Single cpu stack in device/coherent memory. - * PCPU_DV_MEM_STACK_SIZE bytes are allocated. - * ----------------------------------------------------- - */ -declare_stack pcpu_dv_mem_stack, tzfw_coherent_mem, \ - PCPU_DV_MEM_STACK_SIZE, 1 diff --git a/plat/fvp/fvp_pm.c b/plat/fvp/fvp_pm.c index 55f465ba..22e53e12 100644 --- a/plat/fvp/fvp_pm.c +++ b/plat/fvp/fvp_pm.c @@ -120,11 +120,10 @@ exit: * platform to decide whether the cluster is being turned off and take apt * actions. * - * CAUTION: This function is called with coherent stacks so that caches can be - * turned off, flushed and coherency disabled. There is no guarantee that caches - * will remain turned on across calls to this function as each affinity level is - * dealt with. So do not write & read global variables across calls. It will be - * wise to do flush a write to the global to prevent unpredictable results. + * CAUTION: There is no guarantee that caches will remain turned on across calls + * to this function as each affinity level is dealt with. So do not write & read + * global variables across calls. It will be wise to do flush a write to the + * global to prevent unpredictable results. ******************************************************************************/ int fvp_affinst_off(unsigned long mpidr, unsigned int afflvl, @@ -192,11 +191,10 @@ int fvp_affinst_off(unsigned long mpidr, * platform to decide whether the cluster is being turned off and take apt * actions. * - * CAUTION: This function is called with coherent stacks so that caches can be - * turned off, flushed and coherency disabled. There is no guarantee that caches - * will remain turned on across calls to this function as each affinity level is - * dealt with. So do not write & read global variables across calls. It will be - * wise to do flush a write to the global to prevent unpredictable results. + * CAUTION: There is no guarantee that caches will remain turned on across calls + * to this function as each affinity level is dealt with. So do not write & read + * global variables across calls. It will be wise to do flush a write to the + * global to prevent unpredictable results. ******************************************************************************/ int fvp_affinst_suspend(unsigned long mpidr, unsigned long sec_entrypoint, diff --git a/plat/fvp/include/platform_def.h b/plat/fvp/include/platform_def.h index ec4cf525..99832663 100644 --- a/plat/fvp/include/platform_def.h +++ b/plat/fvp/include/platform_def.h @@ -47,13 +47,6 @@ /* Size of cacheable stacks */ #define PLATFORM_STACK_SIZE 0x800 -/* Size of coherent stacks for debug and release builds */ -#if DEBUG -#define PCPU_DV_MEM_STACK_SIZE 0x400 -#else -#define PCPU_DV_MEM_STACK_SIZE 0x300 -#endif - #define FIRMWARE_WELCOME_STR "Booting trusted firmware boot loader stage 1\n\r" /* Trusted Boot Firmware BL2 */ diff --git a/services/std_svc/psci/psci_afflvl_off.c b/services/std_svc/psci/psci_afflvl_off.c index a1f729bc..83d19d3e 100644 --- a/services/std_svc/psci/psci_afflvl_off.c +++ b/services/std_svc/psci/psci_afflvl_off.c @@ -210,9 +210,6 @@ static int psci_call_off_handlers(mpidr_aff_map_nodes_t mpidr_nodes, * the lowest to the highest affinity level implemented by the platform because * to turn off affinity level X it is neccesary to turn off affinity level X - 1 * first. - * - * CAUTION: This function is called with coherent stacks so that coherency can - * be turned off and caches can be flushed safely. ******************************************************************************/ int psci_afflvl_off(int start_afflvl, int end_afflvl) diff --git a/services/std_svc/psci/psci_afflvl_suspend.c b/services/std_svc/psci/psci_afflvl_suspend.c index ab731fb6..1e60276c 100644 --- a/services/std_svc/psci/psci_afflvl_suspend.c +++ b/services/std_svc/psci/psci_afflvl_suspend.c @@ -355,9 +355,6 @@ static int psci_call_suspend_handlers(mpidr_aff_map_nodes_t mpidr_nodes, * the lowest to the highest affinity level implemented by the platform because * to turn off affinity level X it is neccesary to turn off affinity level X - 1 * first. - * - * CAUTION: This function is called with coherent stacks so that coherency can - * be turned off and caches can be flushed safely. ******************************************************************************/ int psci_afflvl_suspend(unsigned long entrypoint, unsigned long context_id, diff --git a/services/std_svc/psci/psci_common.c b/services/std_svc/psci/psci_common.c index 3c79a5e7..56f3daf2 100644 --- a/services/std_svc/psci/psci_common.c +++ b/services/std_svc/psci/psci_common.c @@ -390,9 +390,6 @@ static int psci_call_power_on_handlers(mpidr_aff_map_nodes_t mpidr_nodes, * the highest to the lowest affinity level implemented by the platform because * to turn on affinity level X it is neccesary to turn on affinity level X + 1 * first. - * - * CAUTION: This function is called with coherent stacks so that coherency and - * the mmu can be turned on safely. ******************************************************************************/ void psci_afflvl_power_on_finish(int start_afflvl, int end_afflvl, diff --git a/services/std_svc/psci/psci_entry.S b/services/std_svc/psci/psci_entry.S index e77d0e63..192b638c 100644 --- a/services/std_svc/psci/psci_entry.S +++ b/services/std_svc/psci/psci_entry.S @@ -44,11 +44,6 @@ * upon whether it was resumed from suspend or simply * turned on, call the common power on finisher with * the handlers (chosen depending upon original state). - * For ease, the finisher is called with coherent - * stacks. This allows the cluster/cpu finishers to - * enter coherency and enable the mmu without running - * into issues. We switch back to normal stacks once - * all this is done. * ----------------------------------------------------- */ func psci_aff_on_finish_entry