Commit 56378aa6 authored by Andrew Thoelke's avatar Andrew Thoelke
Browse files

Remove current CPU mpidr from PSCI common code

Many of the interfaces internal to PSCI pass the current CPU
MPIDR_EL1 value from function to function. This is not required,
and with inline access to the system registers is less efficient
than requiring the code to read that register whenever required.

This patch remove the mpidr parameter from the affected interfaces
and reduces code in FVP BL3-1 size by 160 bytes.

Change-Id: I16120a7c6944de37232016d7e109976540775602
parent e73af8ac
...@@ -34,13 +34,13 @@ ...@@ -34,13 +34,13 @@
#include <string.h> #include <string.h>
#include "psci_private.h" #include "psci_private.h"
typedef int (*afflvl_off_handler_t)(unsigned long, aff_map_node_t *); typedef int (*afflvl_off_handler_t)(aff_map_node_t *);
/******************************************************************************* /*******************************************************************************
* The next three functions implement a handler for each supported affinity * The next three functions implement a handler for each supported affinity
* level which is called when that affinity level is turned off. * level which is called when that affinity level is turned off.
******************************************************************************/ ******************************************************************************/
static int psci_afflvl0_off(unsigned long mpidr, aff_map_node_t *cpu_node) static int psci_afflvl0_off(aff_map_node_t *cpu_node)
{ {
unsigned int plat_state; unsigned int plat_state;
int rc; int rc;
...@@ -98,7 +98,7 @@ static int psci_afflvl0_off(unsigned long mpidr, aff_map_node_t *cpu_node) ...@@ -98,7 +98,7 @@ static int psci_afflvl0_off(unsigned long mpidr, aff_map_node_t *cpu_node)
/* Get the current physical state of this cpu */ /* Get the current physical state of this cpu */
plat_state = psci_get_phys_state(cpu_node); plat_state = psci_get_phys_state(cpu_node);
rc = psci_plat_pm_ops->affinst_off(mpidr, rc = psci_plat_pm_ops->affinst_off(read_mpidr_el1(),
cpu_node->level, cpu_node->level,
plat_state); plat_state);
} }
...@@ -106,7 +106,7 @@ static int psci_afflvl0_off(unsigned long mpidr, aff_map_node_t *cpu_node) ...@@ -106,7 +106,7 @@ static int psci_afflvl0_off(unsigned long mpidr, aff_map_node_t *cpu_node)
return rc; return rc;
} }
static int psci_afflvl1_off(unsigned long mpidr, aff_map_node_t *cluster_node) static int psci_afflvl1_off(aff_map_node_t *cluster_node)
{ {
int rc = PSCI_E_SUCCESS; int rc = PSCI_E_SUCCESS;
unsigned int plat_state; unsigned int plat_state;
...@@ -136,14 +136,14 @@ static int psci_afflvl1_off(unsigned long mpidr, aff_map_node_t *cluster_node) ...@@ -136,14 +136,14 @@ static int psci_afflvl1_off(unsigned long mpidr, aff_map_node_t *cluster_node)
* program the power controller etc. * program the power controller etc.
*/ */
if (psci_plat_pm_ops->affinst_off) if (psci_plat_pm_ops->affinst_off)
rc = psci_plat_pm_ops->affinst_off(mpidr, rc = psci_plat_pm_ops->affinst_off(read_mpidr_el1(),
cluster_node->level, cluster_node->level,
plat_state); plat_state);
return rc; return rc;
} }
static int psci_afflvl2_off(unsigned long mpidr, aff_map_node_t *system_node) static int psci_afflvl2_off(aff_map_node_t *system_node)
{ {
int rc = PSCI_E_SUCCESS; int rc = PSCI_E_SUCCESS;
unsigned int plat_state; unsigned int plat_state;
...@@ -167,7 +167,7 @@ static int psci_afflvl2_off(unsigned long mpidr, aff_map_node_t *system_node) ...@@ -167,7 +167,7 @@ static int psci_afflvl2_off(unsigned long mpidr, aff_map_node_t *system_node)
* at this affinity level * at this affinity level
*/ */
if (psci_plat_pm_ops->affinst_off) if (psci_plat_pm_ops->affinst_off)
rc = psci_plat_pm_ops->affinst_off(mpidr, rc = psci_plat_pm_ops->affinst_off(read_mpidr_el1(),
system_node->level, system_node->level,
plat_state); plat_state);
return rc; return rc;
...@@ -186,8 +186,7 @@ static const afflvl_off_handler_t psci_afflvl_off_handlers[] = { ...@@ -186,8 +186,7 @@ static const afflvl_off_handler_t psci_afflvl_off_handlers[] = {
******************************************************************************/ ******************************************************************************/
static int psci_call_off_handlers(mpidr_aff_map_nodes_t mpidr_nodes, static int psci_call_off_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
int start_afflvl, int start_afflvl,
int end_afflvl, int end_afflvl)
unsigned long mpidr)
{ {
int rc = PSCI_E_INVALID_PARAMS, level; int rc = PSCI_E_INVALID_PARAMS, level;
aff_map_node_t *node; aff_map_node_t *node;
...@@ -202,7 +201,7 @@ static int psci_call_off_handlers(mpidr_aff_map_nodes_t mpidr_nodes, ...@@ -202,7 +201,7 @@ static int psci_call_off_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
* of restoring what we might have torn down at * of restoring what we might have torn down at
* lower affinity levels. * lower affinity levels.
*/ */
rc = psci_afflvl_off_handlers[level](mpidr, node); rc = psci_afflvl_off_handlers[level](node);
if (rc != PSCI_E_SUCCESS) if (rc != PSCI_E_SUCCESS)
break; break;
} }
...@@ -232,14 +231,12 @@ static int psci_call_off_handlers(mpidr_aff_map_nodes_t mpidr_nodes, ...@@ -232,14 +231,12 @@ static int psci_call_off_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
* CAUTION: This function is called with coherent stacks so that coherency can * CAUTION: This function is called with coherent stacks so that coherency can
* be turned off and caches can be flushed safely. * be turned off and caches can be flushed safely.
******************************************************************************/ ******************************************************************************/
int psci_afflvl_off(unsigned long mpidr, int psci_afflvl_off(int start_afflvl,
int start_afflvl,
int end_afflvl) int end_afflvl)
{ {
int rc = PSCI_E_SUCCESS; int rc = PSCI_E_SUCCESS;
mpidr_aff_map_nodes_t mpidr_nodes; mpidr_aff_map_nodes_t mpidr_nodes;
mpidr &= MPIDR_AFFINITY_MASK;;
/* /*
* Collect the pointers to the nodes in the topology tree for * Collect the pointers to the nodes in the topology tree for
...@@ -248,7 +245,7 @@ int psci_afflvl_off(unsigned long mpidr, ...@@ -248,7 +245,7 @@ int psci_afflvl_off(unsigned long mpidr,
* levels are incorrect. In either case, we cannot return back * levels are incorrect. In either case, we cannot return back
* to the caller as it would not know what to do. * to the caller as it would not know what to do.
*/ */
rc = psci_get_aff_map_nodes(mpidr, rc = psci_get_aff_map_nodes(read_mpidr_el1() & MPIDR_AFFINITY_MASK,
start_afflvl, start_afflvl,
end_afflvl, end_afflvl,
mpidr_nodes); mpidr_nodes);
...@@ -259,23 +256,20 @@ int psci_afflvl_off(unsigned long mpidr, ...@@ -259,23 +256,20 @@ int psci_afflvl_off(unsigned long mpidr,
* level so that by the time all locks are taken, the system topology * level so that by the time all locks are taken, the system topology
* is snapshot and state management can be done safely. * is snapshot and state management can be done safely.
*/ */
psci_acquire_afflvl_locks(mpidr, psci_acquire_afflvl_locks(start_afflvl,
start_afflvl,
end_afflvl, end_afflvl,
mpidr_nodes); mpidr_nodes);
/* Perform generic, architecture and platform specific handling */ /* Perform generic, architecture and platform specific handling */
rc = psci_call_off_handlers(mpidr_nodes, rc = psci_call_off_handlers(mpidr_nodes,
start_afflvl, start_afflvl,
end_afflvl, end_afflvl);
mpidr);
/* /*
* Release the locks corresponding to each affinity level in the * Release the locks corresponding to each affinity level in the
* reverse order to which they were acquired. * reverse order to which they were acquired.
*/ */
psci_release_afflvl_locks(mpidr, psci_release_afflvl_locks(start_afflvl,
start_afflvl,
end_afflvl, end_afflvl,
mpidr_nodes); mpidr_nodes);
......
...@@ -285,7 +285,6 @@ int psci_afflvl_on(unsigned long target_cpu, ...@@ -285,7 +285,6 @@ int psci_afflvl_on(unsigned long target_cpu,
{ {
int rc = PSCI_E_SUCCESS; int rc = PSCI_E_SUCCESS;
mpidr_aff_map_nodes_t target_cpu_nodes; mpidr_aff_map_nodes_t target_cpu_nodes;
unsigned long mpidr = read_mpidr() & MPIDR_AFFINITY_MASK;
/* /*
* Collect the pointers to the nodes in the topology tree for * Collect the pointers to the nodes in the topology tree for
...@@ -306,8 +305,7 @@ int psci_afflvl_on(unsigned long target_cpu, ...@@ -306,8 +305,7 @@ int psci_afflvl_on(unsigned long target_cpu,
* level so that by the time all locks are taken, the system topology * level so that by the time all locks are taken, the system topology
* is snapshot and state management can be done safely. * is snapshot and state management can be done safely.
*/ */
psci_acquire_afflvl_locks(mpidr, psci_acquire_afflvl_locks(start_afflvl,
start_afflvl,
end_afflvl, end_afflvl,
target_cpu_nodes); target_cpu_nodes);
...@@ -323,8 +321,7 @@ int psci_afflvl_on(unsigned long target_cpu, ...@@ -323,8 +321,7 @@ int psci_afflvl_on(unsigned long target_cpu,
* This loop releases the lock corresponding to each affinity level * This loop releases the lock corresponding to each affinity level
* in the reverse order to which they were acquired. * in the reverse order to which they were acquired.
*/ */
psci_release_afflvl_locks(mpidr, psci_release_afflvl_locks(start_afflvl,
start_afflvl,
end_afflvl, end_afflvl,
target_cpu_nodes); target_cpu_nodes);
...@@ -335,8 +332,7 @@ int psci_afflvl_on(unsigned long target_cpu, ...@@ -335,8 +332,7 @@ int psci_afflvl_on(unsigned long target_cpu,
* The following functions finish an earlier affinity power on request. They * The following functions finish an earlier affinity power on request. They
* are called by the common finisher routine in psci_common.c. * are called by the common finisher routine in psci_common.c.
******************************************************************************/ ******************************************************************************/
static unsigned int psci_afflvl0_on_finish(unsigned long mpidr, static unsigned int psci_afflvl0_on_finish(aff_map_node_t *cpu_node)
aff_map_node_t *cpu_node)
{ {
unsigned int plat_state, state, rc; unsigned int plat_state, state, rc;
...@@ -356,7 +352,7 @@ static unsigned int psci_afflvl0_on_finish(unsigned long mpidr, ...@@ -356,7 +352,7 @@ static unsigned int psci_afflvl0_on_finish(unsigned long mpidr,
/* Get the physical state of this cpu */ /* Get the physical state of this cpu */
plat_state = get_phys_state(state); plat_state = get_phys_state(state);
rc = psci_plat_pm_ops->affinst_on_finish(mpidr, rc = psci_plat_pm_ops->affinst_on_finish(read_mpidr_el1(),
cpu_node->level, cpu_node->level,
plat_state); plat_state);
assert(rc == PSCI_E_SUCCESS); assert(rc == PSCI_E_SUCCESS);
...@@ -399,8 +395,7 @@ static unsigned int psci_afflvl0_on_finish(unsigned long mpidr, ...@@ -399,8 +395,7 @@ static unsigned int psci_afflvl0_on_finish(unsigned long mpidr,
return rc; return rc;
} }
static unsigned int psci_afflvl1_on_finish(unsigned long mpidr, static unsigned int psci_afflvl1_on_finish(aff_map_node_t *cluster_node)
aff_map_node_t *cluster_node)
{ {
unsigned int plat_state, rc = PSCI_E_SUCCESS; unsigned int plat_state, rc = PSCI_E_SUCCESS;
...@@ -418,7 +413,7 @@ static unsigned int psci_afflvl1_on_finish(unsigned long mpidr, ...@@ -418,7 +413,7 @@ static unsigned int psci_afflvl1_on_finish(unsigned long mpidr,
/* Get the physical state of this cluster */ /* Get the physical state of this cluster */
plat_state = psci_get_phys_state(cluster_node); plat_state = psci_get_phys_state(cluster_node);
rc = psci_plat_pm_ops->affinst_on_finish(mpidr, rc = psci_plat_pm_ops->affinst_on_finish(read_mpidr_el1(),
cluster_node->level, cluster_node->level,
plat_state); plat_state);
assert(rc == PSCI_E_SUCCESS); assert(rc == PSCI_E_SUCCESS);
...@@ -431,8 +426,7 @@ static unsigned int psci_afflvl1_on_finish(unsigned long mpidr, ...@@ -431,8 +426,7 @@ static unsigned int psci_afflvl1_on_finish(unsigned long mpidr,
} }
static unsigned int psci_afflvl2_on_finish(unsigned long mpidr, static unsigned int psci_afflvl2_on_finish(aff_map_node_t *system_node)
aff_map_node_t *system_node)
{ {
unsigned int plat_state, rc = PSCI_E_SUCCESS; unsigned int plat_state, rc = PSCI_E_SUCCESS;
...@@ -456,7 +450,7 @@ static unsigned int psci_afflvl2_on_finish(unsigned long mpidr, ...@@ -456,7 +450,7 @@ static unsigned int psci_afflvl2_on_finish(unsigned long mpidr,
/* Get the physical state of the system */ /* Get the physical state of the system */
plat_state = psci_get_phys_state(system_node); plat_state = psci_get_phys_state(system_node);
rc = psci_plat_pm_ops->affinst_on_finish(mpidr, rc = psci_plat_pm_ops->affinst_on_finish(read_mpidr_el1(),
system_node->level, system_node->level,
plat_state); plat_state);
assert(rc == PSCI_E_SUCCESS); assert(rc == PSCI_E_SUCCESS);
......
...@@ -38,8 +38,7 @@ ...@@ -38,8 +38,7 @@
#include <stddef.h> #include <stddef.h>
#include "psci_private.h" #include "psci_private.h"
typedef int (*afflvl_suspend_handler_t)(unsigned long, typedef int (*afflvl_suspend_handler_t)(aff_map_node_t *,
aff_map_node_t *,
unsigned long, unsigned long,
unsigned long, unsigned long,
unsigned int); unsigned int);
...@@ -121,8 +120,7 @@ int psci_get_suspend_stateid(unsigned long mpidr) ...@@ -121,8 +120,7 @@ int psci_get_suspend_stateid(unsigned long mpidr)
* The next three functions implement a handler for each supported affinity * The next three functions implement a handler for each supported affinity
* level which is called when that affinity level is about to be suspended. * level which is called when that affinity level is about to be suspended.
******************************************************************************/ ******************************************************************************/
static int psci_afflvl0_suspend(unsigned long mpidr, static int psci_afflvl0_suspend(aff_map_node_t *cpu_node,
aff_map_node_t *cpu_node,
unsigned long ns_entrypoint, unsigned long ns_entrypoint,
unsigned long context_id, unsigned long context_id,
unsigned int power_state) unsigned int power_state)
...@@ -214,7 +212,7 @@ static int psci_afflvl0_suspend(unsigned long mpidr, ...@@ -214,7 +212,7 @@ static int psci_afflvl0_suspend(unsigned long mpidr,
if (psci_plat_pm_ops->affinst_suspend) { if (psci_plat_pm_ops->affinst_suspend) {
plat_state = psci_get_phys_state(cpu_node); plat_state = psci_get_phys_state(cpu_node);
rc = psci_plat_pm_ops->affinst_suspend(mpidr, rc = psci_plat_pm_ops->affinst_suspend(read_mpidr_el1(),
psci_entrypoint, psci_entrypoint,
ns_entrypoint, ns_entrypoint,
cpu_node->level, cpu_node->level,
...@@ -224,8 +222,7 @@ static int psci_afflvl0_suspend(unsigned long mpidr, ...@@ -224,8 +222,7 @@ static int psci_afflvl0_suspend(unsigned long mpidr,
return rc; return rc;
} }
static int psci_afflvl1_suspend(unsigned long mpidr, static int psci_afflvl1_suspend(aff_map_node_t *cluster_node,
aff_map_node_t *cluster_node,
unsigned long ns_entrypoint, unsigned long ns_entrypoint,
unsigned long context_id, unsigned long context_id,
unsigned int power_state) unsigned int power_state)
...@@ -267,7 +264,7 @@ static int psci_afflvl1_suspend(unsigned long mpidr, ...@@ -267,7 +264,7 @@ static int psci_afflvl1_suspend(unsigned long mpidr,
* platform handler prototype the same. * platform handler prototype the same.
*/ */
psci_entrypoint = (unsigned long) psci_aff_suspend_finish_entry; psci_entrypoint = (unsigned long) psci_aff_suspend_finish_entry;
rc = psci_plat_pm_ops->affinst_suspend(mpidr, rc = psci_plat_pm_ops->affinst_suspend(read_mpidr_el1(),
psci_entrypoint, psci_entrypoint,
ns_entrypoint, ns_entrypoint,
cluster_node->level, cluster_node->level,
...@@ -278,8 +275,7 @@ static int psci_afflvl1_suspend(unsigned long mpidr, ...@@ -278,8 +275,7 @@ static int psci_afflvl1_suspend(unsigned long mpidr,
} }
static int psci_afflvl2_suspend(unsigned long mpidr, static int psci_afflvl2_suspend(aff_map_node_t *system_node,
aff_map_node_t *system_node,
unsigned long ns_entrypoint, unsigned long ns_entrypoint,
unsigned long context_id, unsigned long context_id,
unsigned int power_state) unsigned int power_state)
...@@ -313,7 +309,7 @@ static int psci_afflvl2_suspend(unsigned long mpidr, ...@@ -313,7 +309,7 @@ static int psci_afflvl2_suspend(unsigned long mpidr,
* platform handler prototype the same. * platform handler prototype the same.
*/ */
psci_entrypoint = (unsigned long) psci_aff_suspend_finish_entry; psci_entrypoint = (unsigned long) psci_aff_suspend_finish_entry;
rc = psci_plat_pm_ops->affinst_suspend(mpidr, rc = psci_plat_pm_ops->affinst_suspend(read_mpidr_el1(),
psci_entrypoint, psci_entrypoint,
ns_entrypoint, ns_entrypoint,
system_node->level, system_node->level,
...@@ -337,7 +333,6 @@ static const afflvl_suspend_handler_t psci_afflvl_suspend_handlers[] = { ...@@ -337,7 +333,6 @@ static const afflvl_suspend_handler_t psci_afflvl_suspend_handlers[] = {
static int psci_call_suspend_handlers(mpidr_aff_map_nodes_t mpidr_nodes, static int psci_call_suspend_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
int start_afflvl, int start_afflvl,
int end_afflvl, int end_afflvl,
unsigned long mpidr,
unsigned long entrypoint, unsigned long entrypoint,
unsigned long context_id, unsigned long context_id,
unsigned int power_state) unsigned int power_state)
...@@ -355,8 +350,7 @@ static int psci_call_suspend_handlers(mpidr_aff_map_nodes_t mpidr_nodes, ...@@ -355,8 +350,7 @@ static int psci_call_suspend_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
* of restoring what we might have torn down at * of restoring what we might have torn down at
* lower affinity levels. * lower affinity levels.
*/ */
rc = psci_afflvl_suspend_handlers[level](mpidr, rc = psci_afflvl_suspend_handlers[level](node,
node,
entrypoint, entrypoint,
context_id, context_id,
power_state); power_state);
...@@ -389,8 +383,7 @@ static int psci_call_suspend_handlers(mpidr_aff_map_nodes_t mpidr_nodes, ...@@ -389,8 +383,7 @@ static int psci_call_suspend_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
* CAUTION: This function is called with coherent stacks so that coherency can * CAUTION: This function is called with coherent stacks so that coherency can
* be turned off and caches can be flushed safely. * be turned off and caches can be flushed safely.
******************************************************************************/ ******************************************************************************/
int psci_afflvl_suspend(unsigned long mpidr, int psci_afflvl_suspend(unsigned long entrypoint,
unsigned long entrypoint,
unsigned long context_id, unsigned long context_id,
unsigned int power_state, unsigned int power_state,
int start_afflvl, int start_afflvl,
...@@ -399,15 +392,13 @@ int psci_afflvl_suspend(unsigned long mpidr, ...@@ -399,15 +392,13 @@ int psci_afflvl_suspend(unsigned long mpidr,
int rc = PSCI_E_SUCCESS; int rc = PSCI_E_SUCCESS;
mpidr_aff_map_nodes_t mpidr_nodes; mpidr_aff_map_nodes_t mpidr_nodes;
mpidr &= MPIDR_AFFINITY_MASK;
/* /*
* Collect the pointers to the nodes in the topology tree for * Collect the pointers to the nodes in the topology tree for
* each affinity instance in the mpidr. If this function does * each affinity instance in the mpidr. If this function does
* not return successfully then either the mpidr or the affinity * not return successfully then either the mpidr or the affinity
* levels are incorrect. * levels are incorrect.
*/ */
rc = psci_get_aff_map_nodes(mpidr, rc = psci_get_aff_map_nodes(read_mpidr_el1() & MPIDR_AFFINITY_MASK,
start_afflvl, start_afflvl,
end_afflvl, end_afflvl,
mpidr_nodes); mpidr_nodes);
...@@ -419,8 +410,7 @@ int psci_afflvl_suspend(unsigned long mpidr, ...@@ -419,8 +410,7 @@ int psci_afflvl_suspend(unsigned long mpidr,
* level so that by the time all locks are taken, the system topology * level so that by the time all locks are taken, the system topology
* is snapshot and state management can be done safely. * is snapshot and state management can be done safely.
*/ */
psci_acquire_afflvl_locks(mpidr, psci_acquire_afflvl_locks(start_afflvl,
start_afflvl,
end_afflvl, end_afflvl,
mpidr_nodes); mpidr_nodes);
...@@ -428,7 +418,6 @@ int psci_afflvl_suspend(unsigned long mpidr, ...@@ -428,7 +418,6 @@ int psci_afflvl_suspend(unsigned long mpidr,
rc = psci_call_suspend_handlers(mpidr_nodes, rc = psci_call_suspend_handlers(mpidr_nodes,
start_afflvl, start_afflvl,
end_afflvl, end_afflvl,
mpidr,
entrypoint, entrypoint,
context_id, context_id,
power_state); power_state);
...@@ -437,8 +426,7 @@ int psci_afflvl_suspend(unsigned long mpidr, ...@@ -437,8 +426,7 @@ int psci_afflvl_suspend(unsigned long mpidr,
* Release the locks corresponding to each affinity level in the * Release the locks corresponding to each affinity level in the
* reverse order to which they were acquired. * reverse order to which they were acquired.
*/ */
psci_release_afflvl_locks(mpidr, psci_release_afflvl_locks(start_afflvl,
start_afflvl,
end_afflvl, end_afflvl,
mpidr_nodes); mpidr_nodes);
...@@ -449,8 +437,7 @@ int psci_afflvl_suspend(unsigned long mpidr, ...@@ -449,8 +437,7 @@ int psci_afflvl_suspend(unsigned long mpidr,
* The following functions finish an earlier affinity suspend request. They * The following functions finish an earlier affinity suspend request. They
* are called by the common finisher routine in psci_common.c. * are called by the common finisher routine in psci_common.c.
******************************************************************************/ ******************************************************************************/
static unsigned int psci_afflvl0_suspend_finish(unsigned long mpidr, static unsigned int psci_afflvl0_suspend_finish(aff_map_node_t *cpu_node)
aff_map_node_t *cpu_node)
{ {
unsigned int plat_state, state, rc; unsigned int plat_state, state, rc;
int32_t suspend_level; int32_t suspend_level;
...@@ -472,7 +459,7 @@ static unsigned int psci_afflvl0_suspend_finish(unsigned long mpidr, ...@@ -472,7 +459,7 @@ static unsigned int psci_afflvl0_suspend_finish(unsigned long mpidr,
/* Get the physical state of this cpu */ /* Get the physical state of this cpu */
plat_state = get_phys_state(state); plat_state = get_phys_state(state);
rc = psci_plat_pm_ops->affinst_suspend_finish(mpidr, rc = psci_plat_pm_ops->affinst_suspend_finish(read_mpidr_el1(),
cpu_node->level, cpu_node->level,
plat_state); plat_state);
assert(rc == PSCI_E_SUCCESS); assert(rc == PSCI_E_SUCCESS);
...@@ -516,8 +503,7 @@ static unsigned int psci_afflvl0_suspend_finish(unsigned long mpidr, ...@@ -516,8 +503,7 @@ static unsigned int psci_afflvl0_suspend_finish(unsigned long mpidr,
return rc; return rc;
} }
static unsigned int psci_afflvl1_suspend_finish(unsigned long mpidr, static unsigned int psci_afflvl1_suspend_finish(aff_map_node_t *cluster_node)
aff_map_node_t *cluster_node)
{ {
unsigned int plat_state, rc = PSCI_E_SUCCESS; unsigned int plat_state, rc = PSCI_E_SUCCESS;
...@@ -535,7 +521,7 @@ static unsigned int psci_afflvl1_suspend_finish(unsigned long mpidr, ...@@ -535,7 +521,7 @@ static unsigned int psci_afflvl1_suspend_finish(unsigned long mpidr,
/* Get the physical state of this cpu */ /* Get the physical state of this cpu */
plat_state = psci_get_phys_state(cluster_node); plat_state = psci_get_phys_state(cluster_node);
rc = psci_plat_pm_ops->affinst_suspend_finish(mpidr, rc = psci_plat_pm_ops->affinst_suspend_finish(read_mpidr_el1(),
cluster_node->level, cluster_node->level,
plat_state); plat_state);
assert(rc == PSCI_E_SUCCESS); assert(rc == PSCI_E_SUCCESS);
...@@ -548,8 +534,7 @@ static unsigned int psci_afflvl1_suspend_finish(unsigned long mpidr, ...@@ -548,8 +534,7 @@ static unsigned int psci_afflvl1_suspend_finish(unsigned long mpidr,
} }
static unsigned int psci_afflvl2_suspend_finish(unsigned long mpidr, static unsigned int psci_afflvl2_suspend_finish(aff_map_node_t *system_node)
aff_map_node_t *system_node)
{ {
unsigned int plat_state, rc = PSCI_E_SUCCESS;; unsigned int plat_state, rc = PSCI_E_SUCCESS;;
...@@ -573,7 +558,7 @@ static unsigned int psci_afflvl2_suspend_finish(unsigned long mpidr, ...@@ -573,7 +558,7 @@ static unsigned int psci_afflvl2_suspend_finish(unsigned long mpidr,
/* Get the physical state of the system */ /* Get the physical state of the system */
plat_state = psci_get_phys_state(system_node); plat_state = psci_get_phys_state(system_node);
rc = psci_plat_pm_ops->affinst_suspend_finish(mpidr, rc = psci_plat_pm_ops->affinst_suspend_finish(read_mpidr_el1(),
system_node->level, system_node->level,
plat_state); plat_state);
assert(rc == PSCI_E_SUCCESS); assert(rc == PSCI_E_SUCCESS);
......
...@@ -156,8 +156,7 @@ int psci_check_afflvl_range(int start_afflvl, int end_afflvl) ...@@ -156,8 +156,7 @@ int psci_check_afflvl_range(int start_afflvl, int end_afflvl)
* topology tree for an mpidr. It picks up locks for each affinity level bottom * topology tree for an mpidr. It picks up locks for each affinity level bottom
* up in the range specified. * up in the range specified.
******************************************************************************/ ******************************************************************************/
void psci_acquire_afflvl_locks(unsigned long mpidr, void psci_acquire_afflvl_locks(int start_afflvl,
int start_afflvl,
int end_afflvl, int end_afflvl,
mpidr_aff_map_nodes_t mpidr_nodes) mpidr_aff_map_nodes_t mpidr_nodes)
{ {
...@@ -175,8 +174,7 @@ void psci_acquire_afflvl_locks(unsigned long mpidr, ...@@ -175,8 +174,7 @@ void psci_acquire_afflvl_locks(unsigned long mpidr,
* topology tree for an mpidr. It releases the lock for each affinity level top * topology tree for an mpidr. It releases the lock for each affinity level top
* down in the range specified. * down in the range specified.
******************************************************************************/ ******************************************************************************/
void psci_release_afflvl_locks(unsigned long mpidr, void psci_release_afflvl_locks(int start_afflvl,
int start_afflvl,
int end_afflvl, int end_afflvl,
mpidr_aff_map_nodes_t mpidr_nodes) mpidr_aff_map_nodes_t mpidr_nodes)
{ {
...@@ -353,8 +351,7 @@ unsigned short psci_get_phys_state(aff_map_node_t *node) ...@@ -353,8 +351,7 @@ unsigned short psci_get_phys_state(aff_map_node_t *node)
static int psci_call_power_on_handlers(mpidr_aff_map_nodes_t mpidr_nodes, static int psci_call_power_on_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
int start_afflvl, int start_afflvl,
int end_afflvl, int end_afflvl,
afflvl_power_on_finisher_t *pon_handlers, afflvl_power_on_finisher_t *pon_handlers)
unsigned long mpidr)
{ {
int rc = PSCI_E_INVALID_PARAMS, level; int rc = PSCI_E_INVALID_PARAMS, level;
aff_map_node_t *node; aff_map_node_t *node;
...@@ -370,7 +367,7 @@ static int psci_call_power_on_handlers(mpidr_aff_map_nodes_t mpidr_nodes, ...@@ -370,7 +367,7 @@ static int psci_call_power_on_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
* so simply return an error and let the caller take * so simply return an error and let the caller take
* care of the situation. * care of the situation.
*/ */
rc = pon_handlers[level](mpidr, node); rc = pon_handlers[level](node);
if (rc != PSCI_E_SUCCESS) if (rc != PSCI_E_SUCCESS)
break; break;
} }
...@@ -397,23 +394,20 @@ static int psci_call_power_on_handlers(mpidr_aff_map_nodes_t mpidr_nodes, ...@@ -397,23 +394,20 @@ static int psci_call_power_on_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
* CAUTION: This function is called with coherent stacks so that coherency and * CAUTION: This function is called with coherent stacks so that coherency and
* the mmu can be turned on safely. * the mmu can be turned on safely.
******************************************************************************/ ******************************************************************************/
void psci_afflvl_power_on_finish(unsigned long mpidr, void psci_afflvl_power_on_finish(int start_afflvl,
int start_afflvl,
int end_afflvl, int end_afflvl,
afflvl_power_on_finisher_t *pon_handlers) afflvl_power_on_finisher_t *pon_handlers)
{ {
mpidr_aff_map_nodes_t mpidr_nodes; mpidr_aff_map_nodes_t mpidr_nodes;
int rc; int rc;
mpidr &= MPIDR_AFFINITY_MASK;
/* /*
* Collect the pointers to the nodes in the topology tree for * Collect the pointers to the nodes in the topology tree for
* each affinity instance in the mpidr. If this function does * each affinity instance in the mpidr. If this function does
* not return successfully then either the mpidr or the affinity * not return successfully then either the mpidr or the affinity
* levels are incorrect. Either case is an irrecoverable error. * levels are incorrect. Either case is an irrecoverable error.
*/ */
rc = psci_get_aff_map_nodes(mpidr, rc = psci_get_aff_map_nodes(read_mpidr_el1() & MPIDR_AFFINITY_MASK,
start_afflvl, start_afflvl,
end_afflvl, end_afflvl,
mpidr_nodes); mpidr_nodes);
...@@ -425,8 +419,7 @@ void psci_afflvl_power_on_finish(unsigned long mpidr, ...@@ -425,8 +419,7 @@ void psci_afflvl_power_on_finish(unsigned long mpidr,
* level so that by the time all locks are taken, the system topology * level so that by the time all locks are taken, the system topology
* is snapshot and state management can be done safely. * is snapshot and state management can be done safely.
*/ */
psci_acquire_afflvl_locks(mpidr, psci_acquire_afflvl_locks(start_afflvl,
start_afflvl,
end_afflvl, end_afflvl,
mpidr_nodes); mpidr_nodes);
...@@ -434,8 +427,7 @@ void psci_afflvl_power_on_finish(unsigned long mpidr, ...@@ -434,8 +427,7 @@ void psci_afflvl_power_on_finish(unsigned long mpidr,
rc = psci_call_power_on_handlers(mpidr_nodes, rc = psci_call_power_on_handlers(mpidr_nodes,
start_afflvl, start_afflvl,
end_afflvl, end_afflvl,
pon_handlers, pon_handlers);
mpidr);
if (rc != PSCI_E_SUCCESS) if (rc != PSCI_E_SUCCESS)
panic(); panic();
...@@ -443,8 +435,7 @@ void psci_afflvl_power_on_finish(unsigned long mpidr, ...@@ -443,8 +435,7 @@ void psci_afflvl_power_on_finish(unsigned long mpidr,
* This loop releases the lock corresponding to each affinity level * This loop releases the lock corresponding to each affinity level
* in the reverse order to which they were acquired. * in the reverse order to which they were acquired.
*/ */
psci_release_afflvl_locks(mpidr, psci_release_afflvl_locks(start_afflvl,
start_afflvl,
end_afflvl, end_afflvl,
mpidr_nodes); mpidr_nodes);
} }
......
...@@ -58,8 +58,6 @@ psci_aff_suspend_finish_entry: ...@@ -58,8 +58,6 @@ psci_aff_suspend_finish_entry:
adr x23, psci_afflvl_suspend_finishers adr x23, psci_afflvl_suspend_finishers
psci_aff_common_finish_entry: psci_aff_common_finish_entry:
adr x22, psci_afflvl_power_on_finish
/* --------------------------------------------- /* ---------------------------------------------
* Initialise the pcpu cache pointer for the CPU * Initialise the pcpu cache pointer for the CPU
* --------------------------------------------- * ---------------------------------------------
...@@ -92,11 +90,10 @@ psci_aff_common_finish_entry: ...@@ -92,11 +90,10 @@ psci_aff_common_finish_entry:
bl get_power_on_target_afflvl bl get_power_on_target_afflvl
cmp x0, xzr cmp x0, xzr
b.lt _panic b.lt _panic
mov x3, x23 mov x2, x23
mov x2, x0 mov x1, x0
mov x1, #MPIDR_AFFLVL0 mov x0, #MPIDR_AFFLVL0
mrs x0, mpidr_el1 bl psci_afflvl_power_on_finish
blr x22
/* -------------------------------------------- /* --------------------------------------------
* Give ourselves a stack allocated in Normal * Give ourselves a stack allocated in Normal
......
...@@ -78,7 +78,6 @@ int psci_cpu_suspend(unsigned int power_state, ...@@ -78,7 +78,6 @@ int psci_cpu_suspend(unsigned int power_state,
unsigned long context_id) unsigned long context_id)
{ {
int rc; int rc;
unsigned long mpidr;
unsigned int target_afflvl, pstate_type; unsigned int target_afflvl, pstate_type;
/* Check SBZ bits in power state are zero */ /* Check SBZ bits in power state are zero */
...@@ -111,9 +110,7 @@ int psci_cpu_suspend(unsigned int power_state, ...@@ -111,9 +110,7 @@ int psci_cpu_suspend(unsigned int power_state,
* enter the final wfi which will power down this cpu else return * enter the final wfi which will power down this cpu else return
* an error. * an error.
*/ */
mpidr = read_mpidr(); rc = psci_afflvl_suspend(entrypoint,
rc = psci_afflvl_suspend(mpidr,
entrypoint,
context_id, context_id,
power_state, power_state,
MPIDR_AFFLVL0, MPIDR_AFFLVL0,
...@@ -127,18 +124,15 @@ int psci_cpu_suspend(unsigned int power_state, ...@@ -127,18 +124,15 @@ int psci_cpu_suspend(unsigned int power_state,
int psci_cpu_off(void) int psci_cpu_off(void)
{ {
int rc; int rc;
unsigned long mpidr;
int target_afflvl = get_max_afflvl(); int target_afflvl = get_max_afflvl();
mpidr = read_mpidr();
/* /*
* Traverse from the highest to the lowest affinity level. When the * Traverse from the highest to the lowest affinity level. When the
* lowest affinity level is hit, all the locks are acquired. State * lowest affinity level is hit, all the locks are acquired. State
* management is done immediately followed by cpu, cluster ... * management is done immediately followed by cpu, cluster ...
* ..target_afflvl specific actions as this function unwinds back. * ..target_afflvl specific actions as this function unwinds back.
*/ */
rc = psci_afflvl_off(mpidr, MPIDR_AFFLVL0, target_afflvl); rc = psci_afflvl_off(MPIDR_AFFLVL0, target_afflvl);
/* /*
* Check if all actions needed to safely power down this cpu have * Check if all actions needed to safely power down this cpu have
......
...@@ -62,8 +62,7 @@ typedef struct aff_limits_node { ...@@ -62,8 +62,7 @@ typedef struct aff_limits_node {
} aff_limits_node_t; } aff_limits_node_t;
typedef aff_map_node_t (*mpidr_aff_map_nodes_t[MPIDR_MAX_AFFLVL]); typedef aff_map_node_t (*mpidr_aff_map_nodes_t[MPIDR_MAX_AFFLVL]);
typedef unsigned int (*afflvl_power_on_finisher_t)(unsigned long, typedef unsigned int (*afflvl_power_on_finisher_t)(aff_map_node_t *);
aff_map_node_t *);
/******************************************************************************* /*******************************************************************************
* Data prototypes * Data prototypes
...@@ -87,20 +86,17 @@ void psci_set_state(aff_map_node_t *node, unsigned short state); ...@@ -87,20 +86,17 @@ void psci_set_state(aff_map_node_t *node, unsigned short state);
unsigned long mpidr_set_aff_inst(unsigned long, unsigned char, int); unsigned long mpidr_set_aff_inst(unsigned long, unsigned char, int);
int psci_validate_mpidr(unsigned long, int); int psci_validate_mpidr(unsigned long, int);
int get_power_on_target_afflvl(unsigned long mpidr); int get_power_on_target_afflvl(unsigned long mpidr);
void psci_afflvl_power_on_finish(unsigned long, void psci_afflvl_power_on_finish(int,
int,
int, int,
afflvl_power_on_finisher_t *); afflvl_power_on_finisher_t *);
int psci_save_ns_entry(uint64_t mpidr, int psci_save_ns_entry(uint64_t mpidr,
uint64_t entrypoint, uint64_t context_id, uint64_t entrypoint, uint64_t context_id,
uint32_t caller_scr_el3, uint32_t caller_sctlr_el1); uint32_t caller_scr_el3, uint32_t caller_sctlr_el1);
int psci_check_afflvl_range(int start_afflvl, int end_afflvl); int psci_check_afflvl_range(int start_afflvl, int end_afflvl);
void psci_acquire_afflvl_locks(unsigned long mpidr, void psci_acquire_afflvl_locks(int start_afflvl,
int start_afflvl,
int end_afflvl, int end_afflvl,
mpidr_aff_map_nodes_t mpidr_nodes); mpidr_aff_map_nodes_t mpidr_nodes);
void psci_release_afflvl_locks(unsigned long mpidr, void psci_release_afflvl_locks(int start_afflvl,
int start_afflvl,
int end_afflvl, int end_afflvl,
mpidr_aff_map_nodes_t mpidr_nodes); mpidr_aff_map_nodes_t mpidr_nodes);
...@@ -119,19 +115,18 @@ int psci_afflvl_on(unsigned long, ...@@ -119,19 +115,18 @@ int psci_afflvl_on(unsigned long,
int); int);
/* Private exported functions from psci_affinity_off.c */ /* Private exported functions from psci_affinity_off.c */
int psci_afflvl_off(unsigned long, int, int); int psci_afflvl_off(int, int);
/* Private exported functions from psci_affinity_suspend.c */ /* Private exported functions from psci_affinity_suspend.c */
void psci_set_suspend_power_state(aff_map_node_t *node, void psci_set_suspend_power_state(aff_map_node_t *node,
unsigned int power_state); unsigned int power_state);
int psci_get_aff_map_node_suspend_afflvl(aff_map_node_t *node); int psci_get_aff_map_node_suspend_afflvl(aff_map_node_t *node);
int psci_afflvl_suspend(unsigned long, int psci_afflvl_suspend(unsigned long,
unsigned long,
unsigned long, unsigned long,
unsigned int, unsigned int,
int, int,
int); int);
unsigned int psci_afflvl_suspend_finish(unsigned long, int, int); unsigned int psci_afflvl_suspend_finish(int, int);
#endif /* __PSCI_PRIVATE_H__ */ #endif /* __PSCI_PRIVATE_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment