aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAnshuman Khandual <khandual@linux.vnet.ibm.com>2014-08-13 14:27:45 +0530
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-08-13 19:01:36 +1000
commit087e04598ed74146c2f2eab5666cd4d4b53b6974 (patch)
treed0d4c15c2f4fae090f05cda1a2df20d51baf7d46 /hw
parent0a22f85f524f366a3e2ef2af4a3faa0e9cef26ca (diff)
downloadskiboot-087e04598ed74146c2f2eab5666cd4d4b53b6974.zip
skiboot-087e04598ed74146c2f2eab5666cd4d4b53b6974.tar.gz
skiboot-087e04598ed74146c2f2eab5666cd4d4b53b6974.tar.bz2
dpo: Add OPAL interface to access the DPO timeout
This patch adds a OPAL interface to fetch the DPO timeout. This functionality is required to synchronously query Sapphire about how much seconds are remaining for a forced system shutdown which is useful in cases where the host has missed the OPAL_MSG_DPO for some reason like system boot, reboot or kexec operations. This ensures host can still query about the DPO timeout status and act. This patch also adds helper routine to convert time base into seconds. Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'hw')
-rw-r--r--hw/fsp/fsp-dpo.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/hw/fsp/fsp-dpo.c b/hw/fsp/fsp-dpo.c
index 23ab1ba..94a705e 100644
--- a/hw/fsp/fsp-dpo.c
+++ b/hw/fsp/fsp-dpo.c
@@ -21,12 +21,33 @@
#include <fsp.h>
#include <device.h>
#include <stdio.h>
+#include <timebase.h>
#include <opal.h>
#include <opal-msg.h>
#define PREFIX "FSPDPO: "
+#define DPO_TIMEOUT 2700 /* 45 minutes in seconds */
static bool fsp_dpo_pending = false;
+unsigned long fsp_dpo_init_tb = 0;
+
+/*
+ * OPAL DPO interface
+ *
+ * Returns zero if DPO is not active, positive value indicating number
+ * of seconds remaining for a forced system shutdown. This will enable
+ * the host to schedule for shutdown voluntarily before timeout occurs.
+ */
+static int64_t fsp_opal_get_dpo_status(int64_t *dpo_timeout)
+{
+ int64_t timeout = 0;
+
+ if (fsp_dpo_init_tb && fsp_dpo_pending)
+ timeout = DPO_TIMEOUT - tb_to_secs(mftb() - fsp_dpo_init_tb);
+
+ *dpo_timeout = timeout;
+ return OPAL_SUCCESS;
+}
/* Process FSP DPO init message */
static void fsp_process_dpo(struct fsp_msg *msg)
@@ -50,6 +71,9 @@ static void fsp_process_dpo(struct fsp_msg *msg)
return;
}
+ /* Record the DPO init time */
+ fsp_dpo_init_tb = mftb();
+
/* Inform the host about DPO */
rc = opal_queue_msg(OPAL_MSG_DPO, NULL, NULL);
if (rc) {
@@ -90,5 +114,6 @@ static struct fsp_client fsp_dpo_client = {
void fsp_dpo_init(void)
{
fsp_register_client(&fsp_dpo_client, FSP_MCLASS_SERVICE);
+ opal_register(OPAL_GET_DPO_STATUS, fsp_opal_get_dpo_status, 1);
printf(PREFIX "FSP DPO support initialized\n");
}