[Skiboot] [PATCH] fsp/dpo: DPO driver code improvements
Vipin K Parashar
vipin at linux.vnet.ibm.com
Fri Sep 4 01:23:15 AEST 2015
This patch makes below code improvements in DPO driver
for FSP based systems:
1. Improves code logic at few places.
2. Improves logging by changing PR_TRACE severity to
PR_INFO for log messages and adding new log messages.
3. Removes unused header files.
4. Replaces Sapphire word with OPAL in comments.
Signed-off-by: Vipin K Parashar <vipin at linux.vnet.ibm.com>
---
hw/fsp/fsp-dpo.c | 62 ++++++++++++++++++++++++++++----------------------------
1 file changed, 31 insertions(+), 31 deletions(-)
diff --git a/hw/fsp/fsp-dpo.c b/hw/fsp/fsp-dpo.c
index 51c4824..8c7c296 100644
--- a/hw/fsp/fsp-dpo.c
+++ b/hw/fsp/fsp-dpo.c
@@ -13,14 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * Handle FSP DPO (Delayed Power Off) event notification
- */
-#define pr_fmt(fmt) "FSPDPO: " fmt
+
+/* FSP DPO (Delayed Power Off) event support */
+
+#define pr_fmt(fmt) "FSP-DPO: " fmt
+
#include <skiboot.h>
-#include <console.h>
#include <fsp.h>
-#include <device.h>
#include <stdio.h>
#include <timebase.h>
#include <opal.h>
@@ -30,8 +29,8 @@
#define DPO_CMD_SGN_BYTE1 0x20 /* Byte[1] signature */
#define DPO_TIMEOUT 2700 /* 45 minutes in seconds */
-static bool fsp_dpo_pending = false;
-static unsigned long fsp_dpo_init_tb = 0;
+static bool fsp_dpo_pending;
+static unsigned long fsp_dpo_init_tb;
/*
* OPAL DPO interface
@@ -42,13 +41,13 @@ static unsigned long fsp_dpo_init_tb = 0;
*/
static int64_t fsp_opal_get_dpo_status(int64_t *dpo_timeout)
{
- if (fsp_dpo_init_tb && fsp_dpo_pending) {
- *dpo_timeout = DPO_TIMEOUT - tb_to_secs(mftb() - fsp_dpo_init_tb);
- return OPAL_SUCCESS;
- } else {
+ if (!fsp_dpo_pending) {
*dpo_timeout = 0;
return OPAL_WRONG_STATE;
}
+
+ *dpo_timeout = DPO_TIMEOUT - tb_to_secs(mftb() - fsp_dpo_init_tb);
+ return OPAL_SUCCESS;
}
/* Process FSP DPO init message */
@@ -61,7 +60,7 @@ static void fsp_process_dpo(struct fsp_msg *msg)
/* DPO message does not have the correct signatures */
if ((msg->data.bytes[0] != DPO_CMD_SGN_BYTE0)
|| (msg->data.bytes[1] != DPO_CMD_SGN_BYTE1)) {
- prlog(PR_ERR, "Message signatures did not match\n");
+ prerror("Message signatures did not match\n");
cmd |= FSP_STATUS_INVALID_CMD;
resp = fsp_mkmsg(cmd, 0);
if (resp == NULL) {
@@ -76,14 +75,13 @@ static void fsp_process_dpo(struct fsp_msg *msg)
return;
}
- /* Sapphire is already in "DPO pending" state */
+ /* OPAL is already in "DPO pending" state */
if (fsp_dpo_pending) {
- prlog(PR_ERR, "OPAL is already in DPO pending state\n");
+ prlog(PR_INFO, "OPAL already in DPO pending state\n");
cmd |= FSP_STATUS_INVALID_DPOSTATE;
resp = fsp_mkmsg(cmd, 0);
if (resp == NULL) {
- prerror("%s : Message allocation failed\n",
- __func__);
+ prerror("%s : Message allocation failed\n", __func__);
return;
}
if (fsp_queue_msg(resp, fsp_freemsg)) {
@@ -94,18 +92,15 @@ 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) {
- prlog(PR_ERR, "OPAL message queuing failed\n");
+ prerror("OPAL message queuing failed\n");
cmd |= FSP_STATUS_GENERIC_ERROR;
resp = fsp_mkmsg(cmd, 0);
if (resp == NULL) {
- prerror("%s : Message allocation failed\n",
- __func__);
+ prerror("%s : Message allocation failed\n", __func__);
return;
}
if (fsp_queue_msg(resp, fsp_freemsg)) {
@@ -114,7 +109,8 @@ static void fsp_process_dpo(struct fsp_msg *msg)
"message\n", __func__);
}
return;
- }
+ } else
+ prlog(PR_INFO, "Notified host about DPO event\n");
/* Acknowledge the FSP on DPO */
resp = fsp_mkmsg(cmd, 0);
@@ -124,21 +120,23 @@ static void fsp_process_dpo(struct fsp_msg *msg)
}
if (fsp_queue_msg(resp, fsp_freemsg)) {
fsp_freemsg(resp);
- prerror("%s : Failed to queue response message\n",
- __func__);
+ prerror("%s : Failed to queue response message\n", __func__);
+ return;
}
+ /* Record DPO init time and set DPO pending flag */
+ fsp_dpo_init_tb = mftb();
fsp_dpo_pending = true;
/*
- * Sapphire is now in DPO pending state. After first detecting DPO
- * condition from Sapphire, the host will have 45 minutes to prepare
+ * OPAL is now in DPO pending state. After first detecting DPO
+ * condition from OPAL, the host will have 45 minutes to prepare
* the system for shutdown. The host must take all necessary actions
* required in that regard and at the end shutdown itself. The host
* shutdown sequence eventually will make the call OPAL_CEC_POWER_DOWN
* which in turn ask the FSP to shutdown the CEC. If the FSP does not
- * receive the cec power down command from Sapphire within 45 minutes,
- * it will assume that the host and the Sapphire has processed the DPO
+ * receive the cec power down command from OPAL within 45 minutes,
+ * it will assume that the host and the OPAL has processed the DPO
* sequence successfully and hence force power off the system.
*/
}
@@ -147,10 +145,12 @@ static void fsp_process_dpo(struct fsp_msg *msg)
static bool fsp_dpo_message(u32 cmd_sub_mod, struct fsp_msg *msg)
{
if (cmd_sub_mod == FSP_CMD_INIT_DPO) {
- prlog(PR_TRACE, "SP initiated Delayed Power Off (DPO)\n");
+ prlog(PR_INFO, "Delayed Power Off (DPO) notification received\n");
fsp_process_dpo(msg);
return true;
}
+
+ prerror("Unknown command 0x%x\n", cmd_sub_mod);
return false;
}
@@ -162,5 +162,5 @@ 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);
- prlog(PR_TRACE, "FSP DPO support initialized\n");
+ prlog(PR_INFO, "FSP DPO support initialized\n");
}
--
1.9.3
More information about the Skiboot
mailing list