aboutsummaryrefslogtreecommitdiff
path: root/hw/chiptod.c
diff options
context:
space:
mode:
authorMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>2015-06-05 23:40:15 +0530
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-07-09 16:27:32 +1000
commit8c6d7e5aa922c580ebea630a0dec492aee25e6ee (patch)
tree3b6fed858ef0ece5cb6a539a0577e25d7e15ed57 /hw/chiptod.c
parent939ac40f8010210078a04a4d35f5dbfd780603e1 (diff)
downloadskiboot-8c6d7e5aa922c580ebea630a0dec492aee25e6ee.zip
skiboot-8c6d7e5aa922c580ebea630a0dec492aee25e6ee.tar.gz
skiboot-8c6d7e5aa922c580ebea630a0dec492aee25e6ee.tar.bz2
opal: Enable backup topology.
Whenever FSP makes any changes to backup topology as part of either routine hardware maintenance or fixing failed backup topology configuration, it sends out mailbox command xE6, s/c 0x06, mod 0, to enable/disable the backup topology. OPAL layer should keep itself up-to-date with accurate details of current topology configurations. This will help OPAL layer to successfully handle any TOD failover in future. The FSP can only request that the currently inactive (backup) topology be disabled or enabled. If the requested topology is currently the active topology, then fail this request with a 0xB8 (TOD topology in use) status as return code. For disable request, set the backup topology status as disabled. For enable request, scan all the available chips and find the new backup master chip by looking at TOD status register of each chip. Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw/chiptod.c')
-rw-r--r--hw/chiptod.c70
1 files changed, 64 insertions, 6 deletions
diff --git a/hw/chiptod.c b/hw/chiptod.c
index 061ecf9..4f770cf 100644
--- a/hw/chiptod.c
+++ b/hw/chiptod.c
@@ -120,12 +120,6 @@ static enum chiptod_type {
chiptod_p8
} chiptod_type;
-enum chiptod_topology {
- chiptod_topo_unknown = -1,
- chiptod_topo_primary = 0,
- chiptod_topo_secondary = 1,
-};
-
enum chiptod_chip_role {
chiptod_chip_role_UNKNOWN = -1,
chiptod_chip_role_MDMT = 0, /* Master Drawer Master TOD */
@@ -1492,6 +1486,70 @@ static bool chiptod_probe(void)
return true;
}
+static void chiptod_discover_new_backup(enum chiptod_topology topo)
+{
+ struct proc_chip *chip = NULL;
+
+ /* Scan through available chips to find new backup master chip */
+ for_each_chip(chip) {
+ if (_chiptod_get_chip_status(chip->id) == chiptod_backup_master)
+ break;
+ }
+
+ /* Found new backup master chip. Update the topology info */
+ if (chip) {
+ prlog(PR_DEBUG, "CHIPTOD: New backup master: CHIP [%d]\n",
+ chip->id);
+
+ if (topo == chiptod_topo_primary)
+ chiptod_primary = chip->id;
+ else
+ chiptod_secondary = chip->id;
+ chiptod_topology_info[topo].id = chip->id;
+ chiptod_update_topology(topo);
+
+ prlog(PR_DEBUG,
+ "CHIPTOD: Backup topology configuration changed.\n");
+ print_topology_info();
+ }
+}
+
+/*
+ * Enable/disable backup topology.
+ * If request is to enable topology, then discover new backup master
+ * chip and update the topology configuration info. If the request is
+ * to disable topology, then mark the current backup topology as disabled.
+ * Return error (-1) if the action is requested on currenlty active
+ * topology.
+ *
+ * Return values:
+ * 0 <= Success
+ * -1 <= Topology is active and in use.
+ */
+int chiptod_adjust_topology(enum chiptod_topology topo, bool enable)
+{
+ uint8_t rc = 0;
+ /*
+ * The FSP can only request that the currently inactive topology
+ * be disabled or enabled. If the requested topology is currently
+ * the active topology, then fail this request with a -1 (TOD
+ * topology in use) status as return code.
+ */
+ lock(&chiptod_lock);
+ if (topo == current_topology) {
+ rc = -1;
+ goto out;
+ }
+
+ if (enable)
+ chiptod_discover_new_backup(topo);
+ else
+ chiptod_topology_info[topo].status = chiptod_backup_disabled;
+out:
+ unlock(&chiptod_lock);
+ return rc;
+}
+
static void chiptod_init_topology_info(void)
{
/* Find and update current topology in use. */