diff mbox

[22/22] FSP/LEDS: Roll back exclusive bit in case FSP command queuing fails

Message ID 20150205084323.12859.40309.stgit@localhost.localdomain
State Changes Requested
Headers show

Commit Message

Vasant Hegde Feb. 5, 2015, 8:43 a.m. UTC
Presently we update enclosure exclusive bit before making LED update
SPCN passthrough command and not reverting if this command fails. So
we endup having wrong state if SPCN passthrough command fails.

This patch fixes above described issue.

Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
---
 hw/fsp/fsp-leds.c |   40 ++++++++++++++++++++++------------------
 hw/fsp/fsp-leds.h |    1 +
 2 files changed, 23 insertions(+), 18 deletions(-)
diff mbox

Patch

diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c
index 1353b78..10e8229 100644
--- a/hw/fsp/fsp-leds.c
+++ b/hw/fsp/fsp-leds.c
@@ -200,25 +200,11 @@  static inline void opal_led_update_complete(u64 async_token, u64 result)
  * occured with the recent SPCN command. Subsequent LED requests will
  * be served with these updates changed to the list.
  */
-static void update_led_list(char *loc_code, u32 led_state)
+static void update_led_list(char *loc_code, u32 led_state, u32 excl_bit)
 {
 	struct fsp_led_data *led = NULL, *encl_led = NULL, *encl_cec_led = NULL;
 	bool is_encl_led = is_enclosure_led(loc_code);
 
-	if (is_encl_led)
-		goto enclosure;
-
-	/* Descendant LED in CEC list */
-	led = fsp_find_cec_led(loc_code);
-	if (!led) {
-		log_simple_error(&e_info(OPAL_RC_LED_LC),
-			PREFIX "Could not find descendent LED in CEC LC=%s\n",
-			loc_code);
-		return;
-	}
-	led->status = led_state;
-
-enclosure:
 	/* Enclosure LED in CEC list */
 	encl_cec_led = fsp_find_encl_cec_led(loc_code);
 	if (!encl_cec_led) {
@@ -228,6 +214,21 @@  enclosure:
 		return;
 	}
 
+	/* Update state */
+	if (is_encl_led) {
+		/* Enclosure exclusive bit */
+		encl_cec_led->excl_bit = excl_bit;
+	} else {	/* Descendant LED in CEC list */
+		led = fsp_find_cec_led(loc_code);
+		if (!led) {
+			log_simple_error(&e_info(OPAL_RC_LED_LC), PREFIX
+					 "Could not find descendent LED in \
+					 CEC LC=%s\n", loc_code);
+			return;
+		}
+		led->status = led_state;
+	}
+
 	/* Enclosure LED in ENCL list */
 	encl_led = fsp_find_encl_encl_led(loc_code);
 	if (!encl_led) {
@@ -303,7 +304,8 @@  static void fsp_spcn_set_led_completion(struct fsp_msg *msg)
 		cmd |= FSP_STATUS_GENERIC_ERROR;
 
 		/* Rollback the changes */
-		update_led_list(spcn_cmd->loc_code, spcn_cmd->ckpt_status);
+		update_led_list(spcn_cmd->loc_code,
+				spcn_cmd->ckpt_status, spcn_cmd->ckpt_excl_bit);
 	}
 
 	/* FSP initiated SPCN command */
@@ -390,6 +392,7 @@  static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd)
 	 * command eventually fails.
 	 */
 	spcn_cmd->ckpt_status = led->status;
+	spcn_cmd->ckpt_excl_bit = led->excl_bit;
 	sled.state = led->status;
 
 	/* Update the exclussive LED bits  */
@@ -444,7 +447,7 @@  static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd)
 	 * Update the local lists based on the attempted SPCN command to
 	 * set/reset an individual led (CEC or ENCL).
 	 */
-	update_led_list(spcn_cmd->loc_code, sled.state);
+	update_led_list(spcn_cmd->loc_code, sled.state, led->excl_bit);
 	msg->user_data = spcn_cmd;
 
 	rc = fsp_queue_msg(msg, fsp_spcn_set_led_completion);
@@ -453,7 +456,8 @@  static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd)
 		fsp_freemsg(msg);
 		free_spcn_cmd(spcn_cmd);
 		/* Revert LED state update */
-		update_led_list(spcn_cmd->loc_code, spcn_cmd->ckpt_status);
+		update_led_list(spcn_cmd->loc_code, spcn_cmd->ckpt_status,
+				spcn_cmd->ckpt_excl_bit);
 	}
 
 update_fail:
diff --git a/hw/fsp/fsp-leds.h b/hw/fsp/fsp-leds.h
index 8837104..a411636 100644
--- a/hw/fsp/fsp-leds.h
+++ b/hw/fsp/fsp-leds.h
@@ -120,6 +120,7 @@  struct led_set_cmd {
 	u8	command;
 	u8	state;
 	u16	ckpt_status;		/* Checkpointed status */
+	u16	ckpt_excl_bit;		/* Checkpointed exclusive status */
 	u64	async_token;		/* OPAL async token */
 	enum	spcn_cmd_src cmd_src;	/* OPAL or FSP based */
 	struct	list_node link;