From patchwork Thu Feb 5 08:41:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 436689 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 019191401DE for ; Thu, 5 Feb 2015 19:42:25 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id E5D491A1098 for ; Thu, 5 Feb 2015 19:42:24 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp03.au.ibm.com (e23smtp03.au.ibm.com [202.81.31.145]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id EE3491A1032 for ; Thu, 5 Feb 2015 19:42:17 +1100 (AEDT) Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Feb 2015 18:42:17 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Feb 2015 18:42:15 +1000 Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id CE6C93578048 for ; Thu, 5 Feb 2015 19:42:14 +1100 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t158g62S45482180 for ; Thu, 5 Feb 2015 19:42:14 +1100 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t158ffbq023916 for ; Thu, 5 Feb 2015 19:41:41 +1100 Received: from localhost.localdomain ([9.124.35.64]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t158feE1023575 for ; Thu, 5 Feb 2015 19:41:41 +1100 From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 05 Feb 2015 14:11:25 +0530 Message-ID: <20150205084125.12859.86781.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-0009-0000-0000-000000E66297 Subject: [Skiboot] [PATCH 16/22] 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 strucutre (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 --- hw/fsp/fsp-leds.c | 42 +++++++++++++++++++++++++----------------- hw/fsp/fsp-leds.h | 2 +- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c index 16c9b68..335a967 100644 --- a/hw/fsp/fsp-leds.c +++ b/hw/fsp/fsp-leds.c @@ -244,14 +244,21 @@ enclosure: encl_led->excl_bit = encl_cec_led->excl_bit; } +/* Free SPCN command */ +static inline void free_spcn_cmd(struct led_set_cmd *spcn_cmd) +{ + lock(&spcn_cmd_lock); + free(spcn_cmd); + unlock(&spcn_cmd_lock); +} + 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 +273,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,6 +287,8 @@ static void fsp_spcn_set_led_completion(struct fsp_msg *msg) } } + free_spcn_cmd(spcn_cmd); + /* free msg */ fsp_freemsg(msg); @@ -349,6 +350,7 @@ static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd) "|FSP_STATUS_INVALID_LC\n"); } } + free_spcn_cmd(spcn_cmd); return rc; } @@ -356,7 +358,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 +402,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(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(spcn_cmd); + } + return rc; } @@ -449,7 +457,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; };