[Skiboot] [PATCH v3 29/29] direct-controls: enable fast reboot direct controls for mambo

Nicholas Piggin npiggin at gmail.com
Wed Nov 29 16:37:07 AEDT 2017


Add mambo direct controls to stop threads, which is required for
reliable fast-reboot. Enable direct controls by default on mambo.

Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
 core/chip.c            |  2 +-
 core/direct-controls.c | 20 ++++++++++++++++++--
 hw/xive.c              |  7 ++++++-
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/core/chip.c b/core/chip.c
index 7de00e2f2..d2ff3f41c 100644
--- a/core/chip.c
+++ b/core/chip.c
@@ -109,7 +109,7 @@ void init_chips(void)
 	if (dt_find_by_path(dt_root, "/mambo")) {
 		proc_chip_quirks |= QUIRK_NO_CHIPTOD | QUIRK_MAMBO_CALLOUTS
 			| QUIRK_NO_F000F | QUIRK_NO_PBA | QUIRK_NO_OCC_IRQ
-			| QUIRK_NO_DIRECT_CTL | QUIRK_NO_RNG;
+			| QUIRK_NO_RNG;
 
 		enable_mambo_console();
 
diff --git a/core/direct-controls.c b/core/direct-controls.c
index 486d2e8ca..ba3e4d1d3 100644
--- a/core/direct-controls.c
+++ b/core/direct-controls.c
@@ -33,7 +33,17 @@ static void mambo_sreset_cpu(struct cpu_thread *cpu)
 	uint32_t thread_id = pir_to_thread_id(cpu->pir);
 	char tcl_cmd[50];
 
-	snprintf(tcl_cmd, sizeof(tcl_cmd), "mysim cpu %i:%i set spr pc 0x100", core_id, thread_id);
+	snprintf(tcl_cmd, sizeof(tcl_cmd), "mysim cpu 0:%i:%i start_thread 0x100", core_id, thread_id);
+	callthru_tcl(tcl_cmd, strlen(tcl_cmd));
+}
+
+static void mambo_stop_cpu(struct cpu_thread *cpu)
+{
+	uint32_t core_id = pir_to_core_id(cpu->pir);
+	uint32_t thread_id = pir_to_thread_id(cpu->pir);
+	char tcl_cmd[50];
+
+	snprintf(tcl_cmd, sizeof(tcl_cmd), "mysim cpu 0:%i:%i stop_thread", core_id, thread_id);
 	callthru_tcl(tcl_cmd, strlen(tcl_cmd));
 }
 
@@ -629,8 +639,14 @@ int sreset_all_prepare(void)
 	prlog(PR_DEBUG, "RESET: Resetting from cpu: 0x%x (core 0x%x)\n",
 	      this_cpu()->pir, pir_to_core_id(this_cpu()->pir));
 
-	if (chip_quirk(QUIRK_MAMBO_CALLOUTS))
+	if (chip_quirk(QUIRK_MAMBO_CALLOUTS)) {
+		for_each_ungarded_cpu(cpu) {
+			if (cpu == this_cpu())
+				continue;
+			mambo_stop_cpu(cpu);
+		}
 		return OPAL_SUCCESS;
+	}
 
 	/* Assert special wakup on all cores. Only on operational cores. */
 	for_each_ungarded_primary(cpu) {
diff --git a/hw/xive.c b/hw/xive.c
index db9797cae..b13112898 100644
--- a/hw/xive.c
+++ b/hw/xive.c
@@ -239,7 +239,8 @@
 static enum {
 	XIVE_MODE_EMU	= OPAL_XIVE_MODE_EMU,
 	XIVE_MODE_EXPL	= OPAL_XIVE_MODE_EXPL,
-} xive_mode;
+	XIVE_MODE_NONE,
+} xive_mode = XIVE_MODE_NONE;
 
 
 /* Each source controller has one of these. There's one embedded
@@ -4483,6 +4484,8 @@ static int64_t __xive_reset(uint64_t version)
 /* Called by fast reboot */
 int64_t xive_reset(void)
 {
+	if (xive_mode == XIVE_MODE_NONE)
+		return OPAL_SUCCESS;
 	return __xive_reset(XIVE_MODE_EMU);
 }
 
@@ -5004,6 +5007,8 @@ void init_xive(void)
 	if (first)
 		return;
 
+	xive_mode = XIVE_MODE_EMU;
+
 	/* Init VP allocator */
 	xive_init_vp_allocator();
 
-- 
2.15.0



More information about the Skiboot mailing list