diff mbox

[05/13] fsp: Audit callers of opal_run_pollers

Message ID 1424231849-17973-5-git-send-email-benh@kernel.crashing.org
State Accepted
Headers show

Commit Message

Benjamin Herrenschmidt Feb. 18, 2015, 3:57 a.m. UTC
Use cpu_relax() and don't call it with a lock held

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 hw/fsp/fsp-codeupdate.c | 17 +++++++++--------
 hw/fsp/fsp.c            | 20 +++++++++++++++-----
 2 files changed, 24 insertions(+), 13 deletions(-)
diff mbox

Patch

diff --git a/hw/fsp/fsp-codeupdate.c b/hw/fsp/fsp-codeupdate.c
index b5e2622..33fd9e6 100644
--- a/hw/fsp/fsp-codeupdate.c
+++ b/hw/fsp/fsp-codeupdate.c
@@ -23,6 +23,8 @@ 
 #include <ccan/endian/endian.h>
 #include <errorlog.h>
 #include <opal-api.h>
+#include <fsp-elog.h>
+#include <timebase.h>
 
 #include "fsp-codeupdate.h"
 
@@ -455,14 +457,13 @@  void fsp_code_update_wait_vpd(bool is_boot)
 	if (!fsp_present())
 		return;
 
-	prlog(PR_NOTICE, "CUPD: Waiting read marker LID completion...\n");
-
-	while(flash_state == FLASH_STATE_READING)
-		opal_run_pollers();
-
-	prlog(PR_NOTICE, "CUPD: Waiting in flight params completion...\n");
-	while(in_flight_params)
-		opal_run_pollers();
+	prlog(PR_NOTICE, "CUPD: Waiting read marker LID"
+	      " and in flight parsm completion...\n");
+	while (flash_state == FLASH_STATE_READING || in_flight_params) {
+		unlock(&flash_lock);
+		time_wait_ms(100);
+		lock(&flash_lock);
+	}
 
 	if (is_boot)
 		add_opal_firmware_version();
diff --git a/hw/fsp/fsp.c b/hw/fsp/fsp.c
index da68eef..21926b6 100644
--- a/hw/fsp/fsp.c
+++ b/hw/fsp/fsp.c
@@ -1643,8 +1643,10 @@  int fsp_sync_msg(struct fsp_msg *msg, bool autofree)
 	if (rc)
 		goto bail;
 
-	while(fsp_msg_busy(msg))
+	while(fsp_msg_busy(msg)) {
+		cpu_relax();
 		opal_run_pollers();
+	}
 
 	switch(msg->state) {
 	case fsp_msg_done:
@@ -2064,19 +2066,25 @@  void fsp_opl(void)
 	/* Send OPL */
 	ipl_state |= ipl_opl_sent;
 	fsp_sync_msg(fsp_mkmsg(FSP_CMD_OPL, 0), true);
-	while(!(ipl_state & ipl_got_continue))
+	while(!(ipl_state & ipl_got_continue)) {
 		opal_run_pollers();
+		cpu_relax();
+	}
 
 	/* Send continue ACK */
 	fsp_sync_msg(fsp_mkmsg(FSP_CMD_CONTINUE_ACK, 0), true);
 
 	/* Wait for various FSP messages */
 	prlog(PR_INFO, "INIT: Waiting for FSP to advertize new role...\n");
-	while(!(ipl_state & ipl_got_new_role))
+	while(!(ipl_state & ipl_got_new_role)) {
+		cpu_relax();
 		opal_run_pollers();
+	}
 	prlog(PR_INFO, "INIT: Waiting for FSP to request capabilities...\n");
-	while(!(ipl_state & ipl_got_caps))
+	while(!(ipl_state & ipl_got_caps)) {
+		cpu_relax();
 		opal_run_pollers();
+	}
 
 	/* Initiate the timeout poller */
 	opal_add_poller(fsp_timeout_poll, NULL);
@@ -2087,8 +2095,10 @@  void fsp_opl(void)
 
 	/* Wait for FSP functional */
 	prlog(PR_INFO, "INIT: Waiting for FSP functional\n");
-	while(!(ipl_state & ipl_got_fsp_functional))
+	while(!(ipl_state & ipl_got_fsp_functional)) {
+		cpu_relax();
 		opal_run_pollers();
+	}
 
 	/* Tell FSP we are in running state */
 	prlog(PR_INFO, "INIT: Sending HV Functional: Runtime...\n");