[Skiboot] [PATCH 05/18] fast-reboot: clean up some common cpu iteration processes with macros
Nicholas Piggin
npiggin at gmail.com
Sun Nov 19 20:14:55 AEDT 2017
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
core/fast-reboot.c | 67 +++++++++++++++++-------------------------------------
1 file changed, 21 insertions(+), 46 deletions(-)
diff --git a/core/fast-reboot.c b/core/fast-reboot.c
index 45c8d2a4..81d9fe4d 100644
--- a/core/fast-reboot.c
+++ b/core/fast-reboot.c
@@ -28,6 +28,16 @@
#include <chiptod.h>
#include <ipmi.h>
+#define for_each_ungarded_primary(cpu) \
+ for_each_cpu(cpu) \
+ if ((cpu->state != cpu_state_unavailable) && \
+ (cpu->primary == cpu))
+
+#define for_each_ungarded_cpu(cpu) \
+ for_each_cpu(cpu) \
+ if (cpu->state != cpu_state_unavailable)
+
+
#define P8_EX_TCTL_DIRECT_CONTROLS(t) (0x10013000 + (t) * 0x10)
#define P8_DIRECT_CTL_STOP PPC_BIT(63)
#define P8_DIRECT_CTL_PRENAP PPC_BIT(47)
@@ -233,24 +243,15 @@ static int sreset_all_prepare(void)
this_cpu()->pir, pir_to_core_id(this_cpu()->pir));
/* Assert special wakup on all cores. Only on operational cores. */
- for_each_cpu(cpu) {
- /* GARDed CPUs are marked unavailable. Skip them. */
- if (cpu->state == cpu_state_unavailable)
- continue;
-
- if (cpu->primary == cpu)
- if (set_special_wakeup(cpu) != OPAL_SUCCESS)
- return false;
+ for_each_ungarded_primary(cpu) {
+ if (set_special_wakeup(cpu) != OPAL_SUCCESS)
+ return false;
}
prlog(PR_DEBUG, "RESET: Stopping the world...\n");
/* Put everybody in stop except myself */
- for_each_cpu(cpu) {
- /* GARDed CPUs are marked unavailable. Skip them. */
- if (cpu->state == cpu_state_unavailable)
- continue;
-
+ for_each_ungarded_cpu(cpu) {
if (cpu != this_cpu())
set_direct_ctl(cpu, P8_DIRECT_CTL_STOP);
}
@@ -262,14 +263,8 @@ static void sreset_all_finish(void)
{
struct cpu_thread *cpu;
- for_each_cpu(cpu) {
- /* GARDed CPUs are marked unavailable. Skip them. */
- if (cpu->state == cpu_state_unavailable)
- continue;
-
- if (cpu->primary == cpu)
- clr_special_wakeup(cpu);
- }
+ for_each_ungarded_primary(cpu)
+ clr_special_wakeup(cpu);
}
static void sreset_all_others(void)
@@ -279,11 +274,7 @@ static void sreset_all_others(void)
prlog(PR_DEBUG, "RESET: Pre-napping all threads but one...\n");
/* Put everybody in pre-nap except myself */
- for_each_cpu(cpu) {
- /* GARDed CPUs are marked unavailable. Skip them. */
- if (cpu->state == cpu_state_unavailable)
- continue;
-
+ for_each_ungarded_cpu(cpu) {
if (cpu != this_cpu())
set_direct_ctl(cpu, P8_DIRECT_CTL_PRENAP);
}
@@ -291,11 +282,7 @@ static void sreset_all_others(void)
prlog(PR_DEBUG, "RESET: Resetting all threads but one...\n");
/* Reset everybody except my own core threads */
- for_each_cpu(cpu) {
- /* GARDed CPUs are marked unavailable. Skip them. */
- if (cpu->state == cpu_state_unavailable)
- continue;
-
+ for_each_ungarded_cpu(cpu) {
if (cpu != this_cpu())
set_direct_ctl(cpu, P8_DIRECT_CTL_SRESET);
}
@@ -309,11 +296,7 @@ static bool fast_reset_p8(void)
return false;
/* Put everybody in stop except myself */
- for_each_cpu(cpu) {
- /* GARDed CPUs are marked unavailable. Skip them. */
- if (cpu->state == cpu_state_unavailable)
- continue;
-
+ for_each_ungarded_cpu(cpu) {
/* Also make sure that saved_r1 is 0 ! That's what will
* make our reset vector jump to fast_reboot_entry
*/
@@ -525,14 +508,10 @@ void __noreturn fast_reboot_entry(void)
/* We are the original boot CPU, wait for secondaries to
* be captured.
*/
- for_each_cpu(cpu) {
+ for_each_ungarded_cpu(cpu) {
if (cpu == this_cpu())
continue;
- /* GARDed CPUs are marked unavailable. Skip them. */
- if (cpu->state == cpu_state_unavailable)
- continue;
-
/* XXX Add a callin timeout ? */
while (cpu->state != cpu_state_present) {
smt_lowest();
@@ -548,14 +527,10 @@ void __noreturn fast_reboot_entry(void)
sync();
/* Wait for them to respond */
- for_each_cpu(cpu) {
+ for_each_ungarded_cpu(cpu) {
if (cpu == this_cpu())
continue;
- /* GARDed CPUs are marked unavailable. Skip them. */
- if (cpu->state == cpu_state_unavailable)
- continue;
-
/* XXX Add a callin timeout ? */
while (cpu->state == cpu_state_present) {
smt_lowest();
--
2.15.0
More information about the Skiboot
mailing list