From patchwork Sun Mar 8 10:43:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 447737 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 22D261401DC for ; Sun, 8 Mar 2015 21:43:32 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 05F2B1A056E for ; Sun, 8 Mar 2015 21:43:32 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e28smtp07.in.ibm.com (e28smtp07.in.ibm.com [122.248.162.7]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id F2E681A04D7 for ; Sun, 8 Mar 2015 21:43:22 +1100 (AEDT) Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 8 Mar 2015 16:13:20 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 8 Mar 2015 16:13:18 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 69EE9E0044 for ; Sun, 8 Mar 2015 16:15:15 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay04.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t28AhHbn066022 for ; Sun, 8 Mar 2015 16:13:17 +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 t28AhHxn021471 for ; Sun, 8 Mar 2015 16:13:17 +0530 Received: from localhost.localdomain ([9.124.88.34]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t28AhE2G021387; Sun, 8 Mar 2015 16:13:15 +0530 From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Sun, 08 Mar 2015 16:13:12 +0530 Message-ID: <20150308104257.724.61941.stgit@localhost.localdomain> In-Reply-To: <20150308103924.724.66871.stgit@localhost.localdomain> References: <20150308103924.724.66871.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: 15030810-0025-0000-0000-000003AE4A92 Cc: khandual@linux.vnet.ibm.com Subject: [Skiboot] [PATCH v2 2/8] FSP/LEDS: Move checkpoint status variable to led_set_cmd structure 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" "fsp_led_data" structure contains ckpt_status variable which keeps current LED state before updating and if LED update fails then we use this to revert the LED state. We have introduced new structure (led_set_cmd) to queue up LED update requests. It make sense to move checkpoint status variable to this new structure. Signed-off-by: Vasant Hegde --- Changes in v2: - Removed redundant lock in free path hw/fsp/fsp-leds.c | 35 +++++++++++++++++------------------ hw/fsp/fsp-leds.h | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c index 911f853..f3da941 100644 --- a/hw/fsp/fsp-leds.c +++ b/hw/fsp/fsp-leds.c @@ -246,12 +246,11 @@ enclosure: static void fsp_spcn_set_led_completion(struct fsp_msg *msg) { - u16 ckpt_status; - char loc_code[LOC_CODE_SIZE + 1]; - struct fsp_msg *resp = msg->resp; struct fsp_msg *smsg = NULL; + struct fsp_msg *resp = msg->resp; u32 cmd = FSP_RSP_SET_LED_STATE; u8 status = resp->word1 & 0xff00; + struct led_set_cmd *spcn_cmd = (struct led_set_cmd *)msg->user_data; /* * LED state update request came as part of FSP async message @@ -266,16 +265,8 @@ static void fsp_spcn_set_led_completion(struct fsp_msg *msg) status); cmd |= FSP_STATUS_GENERIC_ERROR; - /* Identify the failed command */ - memset(loc_code, 0, sizeof(loc_code)); - strncpy(loc_code, - ((struct fsp_led_data *)(msg->user_data))->loc_code, - LOC_CODE_SIZE); - ckpt_status = ((struct fsp_led_data *)(msg->user_data)) - ->ckpt_status; - /* Rollback the changes */ - update_led_list(loc_code, ckpt_status); + update_led_list(spcn_cmd->loc_code, spcn_cmd->ckpt_status); } smsg = fsp_mkmsg(cmd, 0); @@ -288,7 +279,8 @@ static void fsp_spcn_set_led_completion(struct fsp_msg *msg) } } - /* free msg */ + /* free msg and spcn command */ + free(spcn_cmd); fsp_freemsg(msg); /* Process pending LED update request */ @@ -349,6 +341,7 @@ static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd) "|FSP_STATUS_INVALID_LC\n"); } } + free(spcn_cmd); return rc; } @@ -356,7 +349,7 @@ static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd) * Checkpoint the status here, will use it if the SPCN * command eventually fails. */ - led->ckpt_status = led->status; + spcn_cmd->ckpt_status = led->status; sled.state = led->status; /* Update the exclussive LED bits */ @@ -400,20 +393,26 @@ 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) + if (!msg) { + free(spcn_cmd); return rc; + } + /* * Update the local lists based on the attempted SPCN command to * set/reset an individual led (CEC or ENCL). */ lock(&led_lock); update_led_list(spcn_cmd->loc_code, sled.state); - msg->user_data = led; + msg->user_data = spcn_cmd; unlock(&led_lock); rc = fsp_queue_msg(msg, fsp_spcn_set_led_completion); - if (rc != OPAL_SUCCESS) + if (rc != OPAL_SUCCESS) { fsp_freemsg(msg); + free(spcn_cmd); + } + return rc; } @@ -449,7 +448,7 @@ static int process_led_state_change(void) log_simple_error(&e_info(OPAL_RC_LED_STATE), PREFIX "Set led state failed at LC=%s\n", spcn_cmd->loc_code); - free(spcn_cmd); + return rc; } diff --git a/hw/fsp/fsp-leds.h b/hw/fsp/fsp-leds.h index a09a27e..de750ad 100644 --- a/hw/fsp/fsp-leds.h +++ b/hw/fsp/fsp-leds.h @@ -54,7 +54,6 @@ struct fsp_led_data { char loc_code[LOC_CODE_SIZE]; u16 parms; /* Parameters */ u16 status; /* Status */ - u16 ckpt_status; /* Checkpointed status */ u16 excl_bit; /* Exclussive LED bit */ struct list_node link; }; @@ -113,6 +112,7 @@ struct led_set_cmd { char loc_code[LOC_CODE_SIZE]; u8 command; u8 state; + u16 ckpt_status; /* Checkpointed status */ struct list_node link; };