[Skiboot] [PATCH] fast-reboot: move pci_reset error handling into fast-reboot code

Nicholas Piggin npiggin at gmail.com
Fri Feb 2 16:46:24 AEDT 2018


pci_reset() currently does a platform reboot if it fails. It
should not know about fast-reboot at this level, so instead have
it return an error, and the fast reboot caller will do the
platform reboot.

The code essentially does the same thing, but flexibility is
improved. Ideally the fast reboot code should perform pci_reset
and all such fail-able operations before the CPU resets itself
and destroys its own stack. That's not the case now, but that
should be the goal.

Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
 core/fast-reboot.c | 13 ++++++++++++-
 core/pci.c         | 11 +++++------
 include/pci.h      |  2 +-
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/core/fast-reboot.c b/core/fast-reboot.c
index 1c76c0891..382e781ae 100644
--- a/core/fast-reboot.c
+++ b/core/fast-reboot.c
@@ -348,7 +348,18 @@ void __noreturn fast_reboot_entry(void)
 	}
 
 	/* Remove all PCI devices */
-	pci_reset();
+	if (pci_reset()) {
+		prlog(PR_NOTICE, "RESET: Fast reboot failed to reset PCI\n");
+
+		/*
+		 * Can't return to caller here because we're past no-return.
+		 * Attempt an IPL here which is what the caller would do.
+		 */
+		if (platform.cec_reboot)
+			platform.cec_reboot();
+		for (;;)
+			;
+	}
 
 	ipmi_set_fw_progress_sensor(IPMI_FW_PCI_INIT);
 
diff --git a/core/pci.c b/core/pci.c
index 0809521f8..494a33a45 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -1668,7 +1668,7 @@ static void __pci_reset(struct list_head *list)
 	}
 }
 
-void pci_reset(void)
+int64_t pci_reset(void)
 {
 	unsigned int i;
 	struct pci_slot *slot;
@@ -1695,11 +1695,9 @@ void pci_reset(void)
 				rc = slot->ops.run_sm(slot);
 			}
 			if (rc < 0) {
-				PCIERR(phb, 0, "Complete reset failed, aborting"
-				               "fast reboot (rc=%lld)\n", rc);
-				if (platform.cec_reboot)
-					platform.cec_reboot();
-				while (true) {}
+				PCIERR(phb, 0, "Complete reset failed "
+				               "(rc=%lld)\n", rc);
+				return rc;
 			}
 		}
 
@@ -1710,6 +1708,7 @@ void pci_reset(void)
 	/* Re-Initialize all discovered PCI slots */
 	pci_init_slots();
 
+	return 0;
 }
 
 static void pci_do_jobs(void (*fn)(void *))
diff --git a/include/pci.h b/include/pci.h
index c085b6b86..508ebf45f 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -475,7 +475,7 @@ extern void pci_std_swizzle_irq_map(struct dt_node *dt_node,
 
 /* Initialize all PCI slots */
 extern void pci_init_slots(void);
-extern void pci_reset(void);
+extern int64_t pci_reset(void);
 
 extern void opal_pci_eeh_set_evt(uint64_t phb_id);
 extern void opal_pci_eeh_clear_evt(uint64_t phb_id);
-- 
2.15.1



More information about the Skiboot mailing list