Skip to contentSkip to conversation

sep: limit time to wait for reconfig shared area complete

PATCH In review Mark Allyn 1 participant 1 message Dec 9, 2010 Staging

lore
Share & tools
lore

Mark Allyn

author
#0 lore raw

PATCH 8/11 sep: limit time to wait for reconfig shared area complete

---
 drivers/staging/sep/sep_driver.c        |    9 ++++++++-
 drivers/staging/sep/sep_driver_config.h |    2 ++
 2 files changed, 10 insertions(+), 1 deletions(-)
drivers/staging/sep/sep_driver.c +8 -1
index 5a54f98..83475eb 100644
@@ -53,6 +53,7 @@
 #include <asm/cacheflush.h>
 #include <linux/sched.h>
 #include <linux/delay.h>
+#include <linux/jiffies.h>
 #include <linux/rar_register.h>
 
 #include "../memrar/memrar.h"
@@ -3244,6 +3245,9 @@ static int sep_reconfig_shared_area(struct sep_device *sep)
 {
 	int ret_val;
 
+	/* use to limit waiting for SEP */
+	unsigned long end_time;
+
 	dev_dbg(&sep->pdev->dev, "reconfig shared area start\n");
 
 	/* Send the new SHARED MESSAGE AREA to the SEP */
@@ -3255,7 +3259,10 @@ static int sep_reconfig_shared_area(struct sep_device *sep)
 	/* Poll for SEP response */
 	ret_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR1_REG_ADDR);
 
-	while (ret_val != 0xffffffff && ret_val != sep->shared_bus)
+	end_time = jiffies + (WAIT_TIME * HZ);
+
+	while ((time_before(jiffies, end_time)) && (ret_val != 0xffffffff) &&
+		(ret_val != sep->shared_bus))
 		ret_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR1_REG_ADDR);
 
 	/* Check the return value (register) */
drivers/staging/sep/sep_driver_config.h +2 -0
index b96045f..92338c0 100644
@@ -230,5 +230,7 @@ held by the proccess (struct file) */
 /* the token that defines the data pool pointers address */
 #define SEP_EXT_CACHE_ADDR_VAL_TOKEN                          0xBABABABA
 
+/* Time limit for SEP to finish */
+#define WAIT_TIME 10
 
 #endif /* SEP DRIVER CONFIG */
Signature · 1 line
1.6.3.3