From patchwork Thu Feb 5 08:42:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 436693 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 E219D1401DE for ; Thu, 5 Feb 2015 19:43:31 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id C41A71A0EE9 for ; Thu, 5 Feb 2015 19:43:31 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp05.au.ibm.com (e23smtp05.au.ibm.com [202.81.31.147]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 862A01A0E6C for ; Thu, 5 Feb 2015 19:43:29 +1100 (AEDT) Received: from /spool/local by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Feb 2015 18:43:28 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp05.au.ibm.com (202.81.31.211) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Feb 2015 18:43:27 +1000 Received: from d23relay08.au.ibm.com (d23relay08.au.ibm.com [9.185.71.33]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 21FD62CE8040 for ; Thu, 5 Feb 2015 19:43:27 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t158hIdB27918394 for ; Thu, 5 Feb 2015 19:43:27 +1100 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t158grhd023847 for ; Thu, 5 Feb 2015 19:42:53 +1100 Received: from localhost.localdomain ([9.124.35.64]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t158gqqs023296 for ; Thu, 5 Feb 2015 19:42:53 +1100 From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 05 Feb 2015 14:12:37 +0530 Message-ID: <20150205084237.12859.4674.stgit@localhost.localdomain> In-Reply-To: <20150205083611.12859.41225.stgit@localhost.localdomain> References: <20150205083611.12859.41225.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15020508-0017-0000-0000-000000C39830 Subject: [Skiboot] [PATCH 20/22] FSP/LEDS: Handle failure cases in set LED MBOX command X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" If set LED mbox command fails then we have to respond to FSP with apropriate status code. Moved MBOX response code to separate function so that we can just call that with different status code. Signed-off-by: Vasant Hegde --- hw/fsp/fsp-leds.c | 127 ++++++++++++++++++++++++----------------------------- include/fsp.h | 4 ++ 2 files changed, 62 insertions(+), 69 deletions(-) diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c index 814459e..ba9e3bf 100644 --- a/hw/fsp/fsp-leds.c +++ b/hw/fsp/fsp-leds.c @@ -252,9 +252,29 @@ static inline void free_spcn_cmd(struct led_set_cmd *spcn_cmd) unlock(&spcn_cmd_lock); } +static int fsp_set_led_response(uint32_t cmd) +{ + struct fsp_msg *msg; + int rc = -1; + + msg = fsp_mkmsg(cmd, 0); + if (!msg) { + prerror(PREFIX + "Failed to allocate FSP_RSP_SET_LED_STATE [cmd=%x])\n", + cmd); + } else { + rc = fsp_queue_msg(msg, fsp_freemsg); + if (rc != OPAL_SUCCESS) { + fsp_freemsg(msg); + prerror(PREFIX "Failed to queue " + "FSP_RSP_SET_LED_STATE [cmd=%x]\n", cmd); + } + } + return rc; +} + static void fsp_spcn_set_led_completion(struct fsp_msg *msg) { - struct fsp_msg *smsg = NULL; struct fsp_msg *resp = msg->resp; u32 cmd = FSP_RSP_SET_LED_STATE; u8 status = resp->word1 & 0xff00; @@ -280,19 +300,8 @@ static void fsp_spcn_set_led_completion(struct fsp_msg *msg) } /* FSP initiated SPCN command */ - if (spcn_cmd->cmd_src == SPCN_SRC_FSP) { - smsg = fsp_mkmsg(cmd, 0); - if (!smsg) { - prerror(PREFIX - "Failed to allocate FSP_RSP_SET_LED_STATE\n"); - } else { - if (fsp_queue_msg(smsg, fsp_freemsg)) { - fsp_freemsg(smsg); - prerror(PREFIX "Failed to queue " - "FSP_RSP_SET_LED_STATE\n"); - } - } - } + if (spcn_cmd->cmd_src == SPCN_SRC_FSP) + fsp_set_led_response(cmd); unlock(&led_lock); @@ -327,6 +336,7 @@ static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd) void *buf = led_buffer; u16 data_len = 0; u32 cmd_hdr = 0; + u32 cmd = FSP_RSP_SET_LED_STATE; int rc = -1; sled.lc_len = strlen(spcn_cmd->loc_code); @@ -344,22 +354,9 @@ static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd) /* LED not present */ if (led == NULL) { - u32 cmd = 0; - struct fsp_msg *msg = NULL; - - cmd = FSP_RSP_SET_LED_STATE | FSP_STATUS_INVALID_LC; - msg = fsp_mkmsg(cmd, 0); - if (!msg) { - prerror(PREFIX "Could not allocate " - "FSP_RSP_SET_LED_STATE | " - "FSP_STATUS_INVALID_LC\n"); - } else { - if (fsp_queue_msg(msg, fsp_freemsg)) { - fsp_freemsg(msg); - prerror(PREFIX "Couldn't queue " - "FSP_RSP_SET_LED_STATE" - "|FSP_STATUS_INVALID_LC\n"); - } + if (spcn_cmd->cmd_src == SPCN_SRC_FSP) { + cmd |= FSP_STATUS_INVALID_LC; + fsp_set_led_response(cmd); } unlock(&led_lock); @@ -416,9 +413,10 @@ static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd) msg = fsp_mkmsg(FSP_CMD_SPCN_PASSTHRU, 4, SPCN_ADDR_MODE_CEC_NODE, cmd_hdr, 0, PSI_DMA_LED_BUF); if (!msg) { - unlock(&led_lock); free_spcn_cmd(spcn_cmd); - return rc; + cmd |= FSP_STATUS_GENERIC_ERROR; + rc = -1; + goto update_fail; } /* @@ -430,12 +428,23 @@ static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd) rc = fsp_queue_msg(msg, fsp_spcn_set_led_completion); if (rc != OPAL_SUCCESS) { + cmd |= FSP_STATUS_GENERIC_ERROR; fsp_freemsg(msg); free_spcn_cmd(spcn_cmd); /* Revert LED state update */ update_led_list(spcn_cmd->loc_code, spcn_cmd->ckpt_status); } +update_fail: + if (rc) { + log_simple_error(&e_info(OPAL_RC_LED_STATE), + PREFIX "Set led state failed at LC=%s\n", + spcn_cmd->loc_code); + + if (spcn_cmd->cmd_src == SPCN_SRC_FSP) + fsp_set_led_response(cmd); + } + unlock(&led_lock); return rc; } @@ -467,12 +476,7 @@ static int process_led_state_change(void) spcn_cmd = list_pop(&spcn_cmdq, struct led_set_cmd, link); unlock(&spcn_cmd_lock); - rc = fsp_msg_set_led_state(spcn_cmd); - if (rc) - log_simple_error(&e_info(OPAL_RC_LED_STATE), - PREFIX "Set led state failed at LC=%s\n", - spcn_cmd->loc_code); - + fsp_msg_set_led_state(spcn_cmd); return rc; } @@ -878,25 +882,13 @@ static void fsp_set_led_state(struct fsp_msg *msg) u32 tce_token = msg->data.words[1]; bool command, state; void *buf; - struct fsp_msg *resp; + int rc; /* Parse the inbound buffer */ buf = fsp_inbound_buf_from_tce(tce_token); if (!buf) { - struct fsp_msg *msg; - msg = fsp_mkmsg(FSP_RSP_SET_LED_STATE | - FSP_STATUS_INVALID_DATA, - 0); - if (!msg) { - prerror(PREFIX "Couldn't allocate FSP_RSP_SET_LED_STATE |" - " FSP_STATUS_INVALID_DATA\n"); - return; - } - if (fsp_queue_msg(msg, fsp_freemsg)) { - fsp_freemsg(msg); - prerror(PREFIX "Couldn't queue FSP_RSP_SET_LED_STATE |" - " FSP_STATUS_INVALID_DATA\n"); - } + fsp_set_led_response(FSP_RSP_SET_LED_STATE | + FSP_STATUS_INVALID_DATA); return; } memcpy(&req, buf, sizeof(req)); @@ -936,28 +928,25 @@ static void fsp_set_led_state(struct fsp_msg *msg) if (!strcmp(led->loc_code, req.loc_code)) continue; - queue_led_state_change(led->loc_code, - command, state, SPCN_SRC_FSP); + rc = queue_led_state_change(led->loc_code, command, + state, SPCN_SRC_FSP); + if (rc != 0) + fsp_set_led_response(FSP_RSP_SET_LED_STATE | + FSP_STATUS_GENERIC_ERROR); } break; case SET_IND_SINGLE_LOC_CODE: /* Set led state for single descendent led */ - queue_led_state_change(req.loc_code, - command, state, SPCN_SRC_FSP); + rc = queue_led_state_change(req.loc_code, + command, state, SPCN_SRC_FSP); + if (rc != 0) + fsp_set_led_response(FSP_RSP_SET_LED_STATE | + FSP_STATUS_GENERIC_ERROR); break; default: - resp = fsp_mkmsg(FSP_RSP_SET_LED_STATE | - FSP_STATUS_NOT_SUPPORTED, 0); - if (!resp) { - prerror(PREFIX "Unable to alloc FSP_RSP_SET_LED_STATE |" - " FSP_STATUS_NOT_SUPPORTED\n"); - break; - } - if (fsp_queue_msg(resp, fsp_freemsg)) { - fsp_freemsg(resp); - prerror(PREFIX "Failed to queue FSP_RSP_SET_LED_STATE |" - " FSP_STATUS_NOT_SUPPORTED\n"); - } + fsp_set_led_response(FSP_RSP_SET_LED_STATE | + FSP_STATUS_NOT_SUPPORTED); + break; } } diff --git a/include/fsp.h b/include/fsp.h index c2c586d..60e9ed1 100644 --- a/include/fsp.h +++ b/include/fsp.h @@ -69,8 +69,12 @@ #define FSP_STAUS_INVALID_HMC_ID 0x51 #define FSP_STATUS_SPCN_ERROR 0xA8 /* SPCN error */ #define FSP_STATUS_INVALID_LC 0xC0 /* Invalid location code */ +#define FSP_STATUS_ENCL_IND_RESET 0xC2 /* Enclosure Indicator cannot be reset */ #define FSP_STATUS_TOD_RESET 0xA9 /* TOD reset due to invalid state at POR */ #define FSP_STATUS_TOD_PERMANENT_ERROR 0xAF /* Permanent error in TOD */ +#define FSP_STATUS_I2C_TRANS_ERROR 0xE4 /* I2C device / transmission error */ +#define FSP_STATUS_IND_PARTIAL_SUCCESS 0xE5 /* Indicator partial success */ +#define FSP_STATUS_GENERIC_FAILURE 0xEF /* Generic Failure in execution */ /* * FSP registers