From patchwork Thu Sep 3 15:23:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vipin K Parashar X-Patchwork-Id: 514131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C35DF1402C2 for ; Fri, 4 Sep 2015 01:23:32 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id A729E1A275A for ; Fri, 4 Sep 2015 01:23:32 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e28smtp06.in.ibm.com (e28smtp06.in.ibm.com [122.248.162.6]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id E5F991A240C for ; Fri, 4 Sep 2015 01:23:26 +1000 (AEST) Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 3 Sep 2015 20:53:21 +0530 Received: from d28dlp03.in.ibm.com (9.184.220.128) by e28smtp06.in.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 3 Sep 2015 20:53:20 +0530 X-Helo: d28dlp03.in.ibm.com X-MailFrom: vipin@linux.vnet.ibm.com X-RcptTo: skiboot@lists.ozlabs.org Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id 964FB1258019 for ; Thu, 3 Sep 2015 20:52:37 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay01.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t83FNJS555115780 for ; Thu, 3 Sep 2015 20:53:19 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t83FNIa7016430 for ; Thu, 3 Sep 2015 20:53:18 +0530 Received: from localhost.in.ibm.com ([9.124.35.71]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t83FNISi016421; Thu, 3 Sep 2015 20:53:18 +0530 From: Vipin K Parashar To: skiboot@lists.ozlabs.org Date: Thu, 3 Sep 2015 20:53:15 +0530 Message-Id: <1441293795-3872-1-git-send-email-vipin@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.3 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15090315-0021-0000-0000-0000072E2D44 Subject: [Skiboot] [PATCH] fsp/dpo: DPO driver code improvements X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" 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 --- 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 -#include #include -#include #include #include #include @@ -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"); }