[Skiboot] [PATCH 18/22] FSP/LEDS: Serialize the entire LED state change code and it's callback

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Thu Feb 5 19:42:10 AEDT 2015


From: Anshuman Khandual <khandual at linux.vnet.ibm.com>

This patch increase the scope of the lock to cover all data structure
manipulation and SPCN command queuing to change the LED state. It also
locks the corresponding sections in the function callback.

Signed-off-by: Anshuman Khandual <khandual at linux.vnet.ibm.com>
Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 hw/fsp/fsp-leds.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c
index 7c8bc8b..ecdc3a9 100644
--- a/hw/fsp/fsp-leds.c
+++ b/hw/fsp/fsp-leds.c
@@ -260,6 +260,8 @@ static void fsp_spcn_set_led_completion(struct fsp_msg *msg)
 	u8 status = resp->word1 & 0xff00;
 	struct led_set_cmd *spcn_cmd = (struct led_set_cmd *)msg->user_data;
 
+	lock(&led_lock);
+
 	/*
 	 * LED state update request came as part of FSP async message
 	 * FSP_CMD_SET_LED_STATE, hence need to send response message.
@@ -292,6 +294,8 @@ static void fsp_spcn_set_led_completion(struct fsp_msg *msg)
 		}
 	}
 
+	unlock(&led_lock);
+
 	free_spcn_cmd(spcn_cmd);
 
 	/* free msg */
@@ -328,6 +332,8 @@ static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd)
 	sled.lc_len = strlen(spcn_cmd->loc_code);
 	strncpy(sled.lc_code, spcn_cmd->loc_code, sled.lc_len);
 
+	lock(&led_lock);
+
 	/* Location code length + Location code + LED control */
 	data_len = LOC_CODE_LEN + sled.lc_len + LED_CONTROL_LEN;
 	cmd_hdr =  SPCN_MOD_SET_LED_CTL_LOC_CODE << 24 | SPCN_CMD_SET << 16 |
@@ -355,6 +361,8 @@ static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd)
 					"|FSP_STATUS_INVALID_LC\n");
 			}
 		}
+
+		unlock(&led_lock);
 		free_spcn_cmd(spcn_cmd);
 		return rc;
 	}
@@ -408,6 +416,7 @@ 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;
 	}
@@ -416,10 +425,8 @@ 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).
 	 */
-	lock(&led_lock);
 	update_led_list(spcn_cmd->loc_code, sled.state);
 	msg->user_data = spcn_cmd;
-	unlock(&led_lock);
 
 	rc = fsp_queue_msg(msg, fsp_spcn_set_led_completion);
 	if (rc != OPAL_SUCCESS) {
@@ -427,6 +434,7 @@ static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd)
 		free_spcn_cmd(spcn_cmd);
 	}
 
+	unlock(&led_lock);
 	return rc;
 }
 



More information about the Skiboot mailing list