summaryrefslogtreecommitdiffstats
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
parent939ac40f8010210078a04a4d35f5dbfd780603e1 (diff)
downloadtalos-skiboot-8c6d7e5aa922c580ebea630a0dec492aee25e6ee.tar.gz
talos-skiboot-8c6d7e5aa922c580ebea630a0dec492aee25e6ee.zip
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>
-rw-r--r--hw/chiptod.c70
-rw-r--r--hw/fsp/Makefile.inc2
-rw-r--r--hw/fsp/fsp-chiptod.c74
-rw-r--r--include/chiptod.h7
-rw-r--r--include/fsp.h9
-rw-r--r--platforms/ibm-fsp/common.c3
6 files changed, 158 insertions, 7 deletions
diff --git a/hw/chiptod.c b/hw/chiptod.c
index 061ecf9b..4f770cf9 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. */
diff --git a/hw/fsp/Makefile.inc b/hw/fsp/Makefile.inc
index d4654d5f..2fe4f0dd 100644
--- a/hw/fsp/Makefile.inc
+++ b/hw/fsp/Makefile.inc
@@ -4,7 +4,7 @@ FSP_OBJS = fsp.o fsp-console.o fsp-rtc.o fsp-nvram.o fsp-sysparam.o
FSP_OBJS += fsp-surveillance.o fsp-codeupdate.o fsp-sensor.o
FSP_OBJS += fsp-diag.o fsp-leds.o fsp-mem-err.o fsp-op-panel.o
FSP_OBJS += fsp-elog-read.o fsp-elog-write.o fsp-epow.o fsp-dpo.o
-FSP_OBJS += fsp-dump.o fsp-mdst-table.o
+FSP_OBJS += fsp-dump.o fsp-mdst-table.o fsp-chiptod.o
FSP_OBJS += fsp-attn.o
FSP = hw/fsp/built-in.o
$(FSP): $(FSP_OBJS:%=hw/fsp/%)
diff --git a/hw/fsp/fsp-chiptod.c b/hw/fsp/fsp-chiptod.c
new file mode 100644
index 00000000..69c59c66
--- /dev/null
+++ b/hw/fsp/fsp-chiptod.c
@@ -0,0 +1,74 @@
+/* Copyright 2013-2014 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <skiboot.h>
+#include <chiptod.h>
+#include <fsp.h>
+
+/* Response status for fsp command 0xE6, s/c 0x06 (Enable/Disable Topology) */
+#define FSP_STATUS_TOPO_IN_USE 0xb8 /* topology is in use */
+
+static bool fsp_chiptod_update_topology(uint32_t cmd_sub_mod,
+ struct fsp_msg *msg __unused)
+{
+ struct fsp_msg *resp;
+ enum chiptod_topology topo;
+ bool action;
+ uint8_t rc;
+
+ switch (cmd_sub_mod) {
+ case FSP_CMD_TOPO_ENABLE_DISABLE:
+ /*
+ * Action Values: 0x00 = Disable, 0x01 = Enable
+ * Topology Values: 0x00 = Primary, 0x01 = Secondary
+ */
+ action = !!msg->data.bytes[2];
+ topo = msg->data.bytes[3];
+ prlog(PR_DEBUG, "CHIPTOD: Topology update event\n");
+ prlog(PR_DEBUG, "CHIPTOD: Action = %s, Topology = %s\n",
+ action ? "Enable" : "Disable",
+ topo ? "Secondary" : "Primary");
+
+ if (chiptod_adjust_topology(topo, action) < 0)
+ rc = FSP_STATUS_TOPO_IN_USE;
+
+ resp = fsp_mkmsg(FSP_RSP_TOPO_ENABLE_DISABLE | rc, 0);
+ if (!resp) {
+ prerror("CHIPTOD: Response allocation failed\n");
+ return false;
+ }
+ if (fsp_queue_msg(resp, fsp_freemsg)) {
+ fsp_freemsg(resp);
+ prerror("CHIPTOD: Failed to queue response msg\n");
+ }
+ return true;
+ default:
+ prlog(PR_DEBUG,
+ "CHIPTOD: Unhandled sub cmd: %06x\n", cmd_sub_mod);
+ break;
+ }
+ return false;
+}
+
+static struct fsp_client fsp_chiptod_client = {
+ .message = fsp_chiptod_update_topology,
+};
+
+void fsp_chiptod_init(void)
+{
+ /* Register for Class E6 (HW maintanance) */
+ fsp_register_client(&fsp_chiptod_client, FSP_MCLASS_HW_MAINT);
+}
diff --git a/include/chiptod.h b/include/chiptod.h
index 43f1d3dd..07e3115b 100644
--- a/include/chiptod.h
+++ b/include/chiptod.h
@@ -21,9 +21,16 @@
* time base across the fabric.
*/
+enum chiptod_topology {
+ chiptod_topo_unknown = -1,
+ chiptod_topo_primary = 0,
+ chiptod_topo_secondary = 1,
+};
+
extern void chiptod_init(void);
extern bool chiptod_wakeup_resync(void);
extern int chiptod_recover_tb_errors(void);
extern void chiptod_reset_tb(void);
+extern int chiptod_adjust_topology(enum chiptod_topology topo, bool enable);
#endif /* __CHIPTOD_H */
diff --git a/include/fsp.h b/include/fsp.h
index 56897982..3df78a17 100644
--- a/include/fsp.h
+++ b/include/fsp.h
@@ -520,6 +520,12 @@
#define FSP_CMD_VSERIAL_OUT 0x0e10200 /* HV->FSP */
/*
+ * Class E6
+ */
+#define FSP_CMD_TOPO_ENABLE_DISABLE 0x0e60600 /* FSP->HV */
+#define FSP_RSP_TOPO_ENABLE_DISABLE 0x0e68600 /* HV->FSP */
+
+/*
* Class E8
*/
#define FSP_CMD_READ_SRC 0x1e84a40 /* HV->FSP */
@@ -812,4 +818,7 @@ extern void fsp_epow_init(void);
/* DPO */
extern void fsp_dpo_init(void);
+/* Chiptod */
+extern void fsp_chiptod_init(void);
+
#endif /* __FSP_H */
diff --git a/platforms/ibm-fsp/common.c b/platforms/ibm-fsp/common.c
index d993b95b..12536bd4 100644
--- a/platforms/ibm-fsp/common.c
+++ b/platforms/ibm-fsp/common.c
@@ -110,6 +110,9 @@ void ibm_fsp_init(void)
/* Initialize SP attention area */
fsp_attn_init();
+ /* Initialize monitoring of TOD topology change event notification */
+ fsp_chiptod_init();
+
/* Send MDST table notification to FSP */
op_display(OP_LOG, OP_MOD_INIT, 0x0000);
fsp_mdst_table_init();
OpenPOWER on IntegriCloud