[Skiboot] [PATCH 08/12] opal: Check if backup master is valid before topology switch.

Mahesh J Salgaonkar mahesh at linux.vnet.ibm.com
Sat Mar 28 20:36:15 AEDT 2015


From: Mahesh Salgaonkar <mahesh at linux.vnet.ibm.com>

Check if backup chip TOD is valid and enabled before we trigger
topology switch.

Signed-off-by: Mahesh Salgaonkar <mahesh at linux.vnet.ibm.com>
---
 hw/chiptod.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/hw/chiptod.c b/hw/chiptod.c
index 9564276..1f6e2f1 100644
--- a/hw/chiptod.c
+++ b/hw/chiptod.c
@@ -984,6 +984,24 @@ static bool is_topology_switch_required(void)
 	return false;
 }
 
+static bool chiptod_backup_valid(void)
+{
+	enum chiptod_topology backup_topo;
+
+	if (current_topology < 0)
+		return false;
+
+	if (current_topology == chiptod_topo_primary)
+		backup_topo = chiptod_topo_secondary;
+	else
+		backup_topo = chiptod_topo_primary;
+
+	if (chiptod_topology_info[backup_topo].status == chiptod_backup_master)
+		return chiptod_sync_step_check_running(backup_topo);
+
+	return false;
+}
+
 /*
  * Sync up TOD with other chips and get TOD in running state.
  * Check if current topology is active and running. If not, then
@@ -1008,7 +1026,16 @@ static int chiptod_start_tod(void)
 		 * topology we can then request TOD value from new active
 		 * master. But make sure we move local chiptod to Not Set
 		 * before requesting TOD value.
+		 *
+		 * Before triggering a topology switch, check if backup
+		 * is valid.
 		 */
+		if (!chiptod_backup_valid()) {
+			prerror("CHIPTOD: Backup master is not enabled.\n");
+			prerror("CHIPTOD: Can not do a topology switch.\n");
+			return 0;
+		}
+
 		if (xscom_write(mchip, TOD_TTYPE_1, (1UL << 63)) != 0) {
 			prerror("CHIPTOD: XSCOM error switching primary/secondary\n");
 			return 0;



More information about the Skiboot mailing list